VirtualBox

Changeset 2538 in vbox for trunk


Ignore:
Timestamp:
May 8, 2007 3:04:53 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20977
Message:

Quick implementation of IRQ level flip-flip (pass PDM_IRQ_LEVEL_FLIP_FLOP as the level).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdm.h

    r2464 r2538  
    32193219
    32203220
     3221/** @name IRQ Level for use with the *SetIrq APIs.
     3222 * @{
     3223 */
     3224/** Assert the IRQ (can assume value 1). */
     3225#define PDM_IRQ_LEVEL_HIGH          BIT(0)
     3226/** Deassert the IRQ (can assume value 0). */
     3227#define PDM_IRQ_LEVEL_LOW           0
     3228/** flip-flop - assert and then deassert it again immediately. */
     3229#define PDM_IRQ_LEVEL_FLIP_FLOP     (BIT(1) | PDM_IRQ_LEVEL_HIGH)
     3230/** @} */
     3231
     3232
    32213233/**
    32223234 * PCI Bus registaration structure.
     
    32613273     * @param   pPciDev         The PCI device structure.
    32623274     * @param   iIrq            IRQ number to set.
    3263      * @param   iLevel          IRQ level.
     3275     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    32643276     */
    32653277    DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
     
    33213333     * @param   pDevIns         PCI device instance.
    33223334     * @param   iIrq            IRQ number to set.
    3323      * @param   iLevel          IRQ level.
     3335     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    33243336     * @thread  EMT only.
    33253337     */
     
    33313343     * @param   pDevIns         PCI device instance.
    33323344     * @param   iIrq            IRQ number to set.
    3333      * @param   iLevel          IRQ level.
     3345     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    33343346     * @thread  EMT only.
    33353347     */
     
    33793391     * @param   pDevIns         PCI device instance.
    33803392     * @param   iIrq            IRQ number to set.
    3381      * @param   iLevel          IRQ level.
     3393     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    33823394     * @thread  EMT only.
    33833395     */
     
    33893401     * @param   pDevIns         PCI device instance.
    33903402     * @param   iIrq            IRQ number to set.
    3391      * @param   iLevel          IRQ level.
     3403     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    33923404     * @thread  EMT only.
    33933405     */
     
    34373449     * @param   pDevIns         The PCI device instance.
    34383450     * @param   iIrq            IRQ number to set.
    3439      * @param   iLevel          IRQ level.
     3451     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    34403452     * @thread  EMT only.
    34413453     */
     
    34473459     * @param   pDevIns         The PCI device instance.
    34483460     * @param   iIrq            IRQ number to set.
    3449      * @param   iLevel          IRQ level.
     3461     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    34503462     * @thread  EMT only.
    34513463     */
     
    35203532     * @param   pDevIns         Device instance of the PIC.
    35213533     * @param   iIrq            IRQ number to set.
    3522      * @param   iLevel          IRQ level.
     3534     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    35233535     */
    35243536    DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
     
    40504062     * @param   pDevIns         Device instance of the I/O APIC.
    40514063     * @param   iIrq            IRQ number to set.
    4052      * @param   iLevel          IRQ level.
     4064     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    40534065     */
    40544066    DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
     
    46934705     * @param   pDevIns         Device instance.
    46944706     * @param   iIrq            IRQ number to set.
    4695      * @param   iLevel          IRQ level.
     4707     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    46964708     * @thread  Any thread, but will involve the emulation thread.
    46974709     */
     
    47144726     * @param   pDevIns         Device instance.
    47154727     * @param   iIrq            IRQ number to set.
    4716      * @param   iLevel          IRQ level.
     4728     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    47174729     * @thread  Any thread, but will involve the emulation thread.
    47184730     */
     
    47254737     * @param   pDevIns         Device instance.
    47264738     * @param   iIrq            IRQ number to set.
    4727      * @param   iLevel          IRQ level.
     4739     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    47284740     * @thread  Any thread, but will involve the emulation thread.
    47294741     */
     
    53025314     * @param   pDevIns         Device instance.
    53035315     * @param   iIrq            IRQ number to set.
    5304      * @param   iLevel          IRQ level.
     5316     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    53055317     * @thread  Any thread, but will involve the emulation thread.
    53065318     */
     
    53125324     * @param   pDevIns         Device instance.
    53135325     * @param   iIrq            IRQ number to set.
    5314      * @param   iLevel          IRQ level.
     5326     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    53155327     * @thread  Any thread, but will involve the emulation thread.
    53165328     */
     
    54065418     * @param   pDevIns         Device instance.
    54075419     * @param   iIrq            IRQ number to set.
    5408      * @param   iLevel          IRQ level.
     5420     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    54095421     * @thread  Any thread, but will involve the emulation thread.
    54105422     */
     
    54165428     * @param   pDevIns         Device instance.
    54175429     * @param   iIrq            IRQ number to set.
    5418      * @param   iLevel          IRQ level.
     5430     * @param   iLevel          IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
    54195431     * @thread  Any thread, but will involve the emulation thread.
    54205432     */
     
    64676479 * @param   pVM             VM handle.
    64686480 * @param   u8Irq           The IRQ line.
    6469  * @param   u8Level         The new level.
     6481 * @param   u8Level         The new level. See the PDM_IRQ_LEVEL_* \#defines.
    64706482 */
    64716483PDMDECL(int) PDMIsaSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
     
    64776489 * @param   pVM             VM handle.
    64786490 * @param   u8Irq           The IRQ line.
    6479  * @param   u8Level         The new level.
     6491 * @param   u8Level         The new level. See the PDM_IRQ_LEVEL_* \#defines.
    64806492 */
    64816493PDMDECL(int) PDMIoApicSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
  • trunk/src/VBox/Devices/Bus/DevPCI.cpp

    r2038 r2538  
    514514static void apic_set_irq(PPCIBUS pBus, PCIDevice *pci_dev, int irq_num1, int level, int acpi_irq)
    515515{
    516     PPCIGLOBALS pGlobals = PCIBUS2PCIGLOBALS(pBus);
    517     int shift, apic_irq, apic_level;
    518     uint32_t *p;
    519 
    520516    if (acpi_irq == -1) {
     517        int shift, apic_irq, apic_level;
     518        uint32_t *p;
     519        PPCIGLOBALS pGlobals = PCIBUS2PCIGLOBALS(pBus);
    521520        int uIrqIndex = pci_dev->Int.s.iIrq;
    522521        int irq_num = pci_slot_get_apic_pirq(pci_dev, irq_num1);
     522
    523523        p = &pGlobals->pci_apic_irq_levels[irq_num][uIrqIndex >> 5];
    524524        shift = (uIrqIndex & 0x1f);
    525         *p = (*p & ~(1 << shift)) | (level << shift);
     525        *p = (*p & ~(1 << shift)) | ((level & PDM_IRQ_LEVEL_HIGH) << shift);
    526526        apic_irq = irq_num + 0x10;
    527527        apic_level = get_pci_irq_apic_level(pGlobals, irq_num);
    528528        Log3(("apic_set_irq: %s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d\n",
    529529              HCSTRING(pci_dev->name), irq_num1, level, apic_irq, apic_level, irq_num));
     530        pBus->CTXALLSUFF(pPciHlp)->pfnIoApicSetIrq(CTXSUFF(pBus->pDevIns), apic_irq, apic_level);
     531
     532        if ((level & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) {
     533            *p = (*p & ~(1 << shift));
     534            apic_level = get_pci_irq_apic_level(pGlobals, irq_num);
     535            Log3(("apic_set_irq: %s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d (flop)\n",
     536                  HCSTRING(pci_dev->name), irq_num1, level, apic_irq, apic_level, irq_num));
     537            pBus->CTXALLSUFF(pPciHlp)->pfnIoApicSetIrq(CTXSUFF(pBus->pDevIns), apic_irq, apic_level);
     538        }
    530539    } else {
    531         apic_irq = acpi_irq;
    532         apic_level = level;
    533         Log3(("apic_set_irq: %s: irq_num1=%d level=%d apic_irq=%d apic_level=%d\n",
    534               HCSTRING(pci_dev->name), irq_num1, level, apic_irq, apic_level));
    535     }
    536 
    537     pBus->CTXALLSUFF(pPciHlp)->pfnIoApicSetIrq(CTXSUFF(pBus->pDevIns), apic_irq, apic_level);
     540        Log3(("apic_set_irq: %s: irq_num1=%d level=%d acpi_irq=%d\n",
     541              HCSTRING(pci_dev->name), irq_num1, level, acpi_irq));
     542        pBus->CTXALLSUFF(pPciHlp)->pfnIoApicSetIrq(CTXSUFF(pBus->pDevIns), acpi_irq, level);
     543    }
    538544}
    539545
     
    599605        pic_irq = pPciDev->config[0x3c];
    600606        pGlobals->acpi_irq = pic_irq;
    601         pGlobals->acpi_irq_level = iLevel;
     607        pGlobals->acpi_irq_level = iLevel & PDM_IRQ_LEVEL_HIGH;
    602608    }
    603609    else
     
    608614        p = &pGlobals->pci_irq_levels[irq_num][uIrqIndex >> 5];
    609615        shift = (uIrqIndex & 0x1f);
    610         *p = (*p & ~(1 << shift)) | (iLevel << shift);
     616        *p = (*p & ~(1 << shift)) | ((iLevel & PDM_IRQ_LEVEL_HIGH) << shift);
    611617
    612618        /* now we change the pic irq level according to the piix irq mappings */
    613619        pic_irq = pbCfg[0x60 + irq_num];
    614620        if (pic_irq >= 16)
     621        {
     622            if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP)
     623                *p = (*p & ~(1 << shift));
    615624            return;
     625        }
    616626    }
    617627
     
    632642          HCSTRING(pPciDev->name), iLevel, iIrq, pic_irq, pic_level));
    633643    pBus->CTXALLSUFF(pPciHlp)->pfnIsaSetIrq(CTXSUFF(pBus->pDevIns), pic_irq, pic_level);
     644
     645    /** @todo optimize pci irq flip-flop some rainy day. */
     646    if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP)
     647        pciSetIrq(pDevIns, pPciDev, iIrq, PDM_IRQ_LEVEL_LOW);
    634648}
    635649
  • trunk/src/VBox/Devices/PC/DevAPIC.cpp

    r2468 r2538  
    12881288                s->irr |= mask;
    12891289                ioapic_service(s);
     1290#ifdef VBOX
     1291                if ((level & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) {
     1292                    s->irr &= ~mask;
     1293                }
     1294#endif
    12901295            } else {
    12911296                s->irr &= ~mask;
  • trunk/src/VBox/Devices/PC/DevPIC.cpp

    r2269 r2538  
    353353    DumpPICState(&pData->aPics[1], "picSetIrq");
    354354    STAM_COUNTER_INC(&pData->CTXSUFF(StatSetIrq));
    355     pic_set_irq1(&pData->aPics[iIrq >> 3], iIrq & 7, iLevel);
     355    pic_set_irq1(&pData->aPics[iIrq >> 3], iIrq & 7, iLevel & PDM_IRQ_LEVEL_HIGH);
    356356    pic_update_irq(pData);
     357    if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP)
     358    {
     359        pic_set_irq1(&pData->aPics[iIrq >> 3], iIrq & 7, 0);
     360        pic_update_irq(pData);
     361    }
    357362}
    358363
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette