VirtualBox

Changeset 32280 in vbox


Ignore:
Timestamp:
Sep 7, 2010 12:01:17 PM (14 years ago)
Author:
vboxsync
Message:

PCI: BIOS init, rework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r32263 r32280  
    167167static DECLCALLBACK(uint32_t) ich9pciConfigRead(PCIDevice *aDev, uint32_t u32Address, unsigned len);
    168168DECLINLINE(PPCIDEVICE) ich9pciFindBridge(PPCIBUS pBus, uint8_t iBus);
     169static void ich9pciBiosInitDevice(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, uint8_t cBridgeDepth, uint8_t *paBridgePositions);
    169170#endif
    170171
     
    411412}
    412413
     414/* Compute mapping of PCI slot and IRQ number to APIC interrupt line */
    413415static inline int ich9pciSlot2ApicIrq(uint8_t uSlot, int irq_num)
    414416{
     
    416418}
    417419
     420/* Add one more level up request on APIC input line */
    418421static inline void ich9pciApicLevelUp(PPCIGLOBALS pGlobals, int irq_num)
    419422{
     
    421424}
    422425
     426/* Remove one level up request on APIC input line */
    423427static inline void ich9pciApicLevelDown(PPCIGLOBALS pGlobals, int irq_num)
    424428{
    425429    ASMAtomicDecU32(&pGlobals->uaPciApicIrqLevels[irq_num]);
    426430}
    427 
    428431
    429432static void ich9pciApicSetIrq(PPCIBUS pBus, uint8_t uDevFn, PCIDevice *pPciDev, int irq_num1, int iLevel, int iForcedIrq)
     
    517520}
    518521
    519 /// @todo: simplify
    520 static void ich9pciUpdateMappings(PCIDevice *d)
    521 {
    522     PPCIBUS pBus = d->Int.s.CTX_SUFF(pBus);
    523     int cmd, i;
    524     uint32_t last_addr, new_addr, config_ofs;
    525 
    526     cmd = PCIDevGetCommand(d);
    527     for (i = 0; i < PCI_NUM_REGIONS; i++) {
    528         PCIIORegion* r = &d->Int.s.aIORegions[i];
    529         if (i == PCI_ROM_SLOT) {
    530             config_ofs = 0x30;
    531         } else {
    532             config_ofs = 0x10 + i * 4;
    533         }
    534         if (r->size != 0) {
    535             if (r->type & PCI_ADDRESS_SPACE_IO) {
    536                 if (cmd & PCI_COMMAND_IOACCESS) {
    537                     new_addr = ich9pciConfigRead(d, config_ofs, 4);
    538                     new_addr = new_addr & ~(r->size - 1);
    539                     last_addr = new_addr + r->size - 1;
    540                     /* NOTE: we have only 64K ioports on PC */
    541                     if (last_addr <= new_addr || new_addr == 0 ||
    542                         last_addr >= 0x10000) {
    543                         new_addr = ~0U;
    544                     }
    545                 } else {
    546                     new_addr = ~0U;
    547                 }
    548             } else {
    549                 if (cmd & PCI_COMMAND_MEMACCESS) {
    550                     new_addr = ich9pciConfigRead(d, config_ofs, 4);
    551                     /* the ROM slot has a specific enable bit */
    552                     if (i == PCI_ROM_SLOT && !(new_addr & 1))
    553                         goto no_mem_map;
    554                     new_addr = new_addr & ~(r->size - 1);
    555                     last_addr = new_addr + r->size - 1;
     522static inline uint32_t ich9pciGetRegionReg(int iRegion)
     523{
     524    return (iRegion == PCI_ROM_SLOT) ?
     525            VBOX_PCI_ROM_ADDRESS : (VBOX_PCI_BASE_ADDRESS_0 + iRegion * 4);
     526}
     527
     528#define INVALID_PCI_ADDRESS ~0U
     529
     530static void ich9pciUpdateMappings(PCIDevice* pDev)
     531{
     532    PPCIBUS pBus = pDev->Int.s.CTX_SUFF(pBus);
     533    uint32_t uLast, uNew;
     534
     535    int iCmd = PCIDevGetCommand(pDev);
     536    for (int iRegion = 0; iRegion < PCI_NUM_REGIONS; iRegion++)
     537    {
     538        PCIIORegion* pRegion = &pDev->Int.s.aIORegions[iRegion];
     539        uint32_t uConfigReg = ich9pciGetRegionReg(iRegion);
     540        int32_t  iRegionSize =  pRegion->size;
     541        int rc;
     542
     543        if (iRegionSize == 0)
     544            continue;
     545
     546        if (pRegion->type & PCI_ADDRESS_SPACE_IO)
     547        {
     548            /* port IO region */
     549            if (iCmd & PCI_COMMAND_IOACCESS)
     550            {
     551                /* IO access allowed */
     552                uNew = ich9pciConfigRead(pDev, uConfigReg, 4);
     553                uNew &= ~(iRegionSize - 1);
     554                uLast = uNew + iRegionSize - 1;
     555                /* only 64K ioports on PC */
     556                if (uLast <= uNew || uNew == 0 || uLast >= 0x10000)
     557                    uNew = INVALID_PCI_ADDRESS;
     558            } else
     559                uNew = INVALID_PCI_ADDRESS;
     560        }
     561        else
     562        {
     563            /* MMIO region */
     564            if (iCmd & PCI_COMMAND_MEMACCESS)
     565            {
     566                uNew = ich9pciConfigRead(pDev, uConfigReg, 4);
     567                /* the ROM slot has a specific enable bit */
     568                if (iRegion == PCI_ROM_SLOT && !(uNew & 1))
     569                    uNew = INVALID_PCI_ADDRESS;
     570                else
     571                {
     572                    uNew &= ~(iRegionSize - 1);
     573                    uLast = uNew + iRegionSize - 1;
    556574                    /* NOTE: we do not support wrapping */
    557575                    /* XXX: as we cannot support really dynamic
    558576                       mappings, we handle specific values as invalid
    559577                       mappings. */
    560                     if (last_addr <= new_addr || new_addr == 0 ||
    561                         last_addr == ~0U) {
    562                         new_addr = ~0U;
     578                    if (uLast <= uNew || uNew == 0 || uLast == ~0U)
     579                        uNew = INVALID_PCI_ADDRESS;
     580                }
     581            } else
     582                uNew = INVALID_PCI_ADDRESS;
     583        }
     584        /* now do the real mapping */
     585        if (uNew != pRegion->addr)
     586        {
     587            if (pRegion->addr != INVALID_PCI_ADDRESS)
     588            {
     589                if (pRegion->type & PCI_ADDRESS_SPACE_IO)
     590                {
     591                    /* Port IO */
     592                    int devclass;
     593                    /* NOTE: specific hack for IDE in PC case:
     594                       only one byte must be mapped. */
     595                    /// @todo: do we need it?
     596                    devclass = pDev->config[0x0a] | (pDev->config[0x0b] << 8);
     597                    if (devclass == 0x0101 && iRegionSize == 4)
     598                    {
     599                        rc = PDMDevHlpIOPortDeregister(pDev->pDevIns, pRegion->addr + 2, 1);
     600                        AssertRC(rc);
    563601                    }
    564                 } else {
    565                 no_mem_map:
    566                     new_addr = ~0U;
     602                    else
     603                    {
     604                        rc = PDMDevHlpIOPortDeregister(pDev->pDevIns, pRegion->addr, pRegion->size);
     605                        AssertRC(rc);
     606                    }
     607                }
     608                else
     609                {
     610                    RTGCPHYS GCPhysBase = pRegion->addr;
     611                    if (pBus->pPciHlpR3->pfnIsMMIO2Base(pBus->pDevInsR3, pDev->pDevIns, GCPhysBase))
     612                    {
     613                        /* unmap it. */
     614                        rc = pRegion->map_func(pDev, iRegion, NIL_RTGCPHYS, pRegion->size, (PCIADDRESSSPACE)(pRegion->type));
     615                        AssertRC(rc);
     616                        rc = PDMDevHlpMMIO2Unmap(pDev->pDevIns, iRegion, GCPhysBase);
     617                    }
     618                    else
     619                        rc = PDMDevHlpMMIODeregister(pDev->pDevIns, GCPhysBase, pRegion->size);
     620                    AssertMsgRC(rc, ("rc=%Rrc d=%s i=%d GCPhysBase=%RGp size=%#x\n", rc, pDev->name, iRegion, GCPhysBase, pRegion->size));
    567621                }
    568622            }
    569             /* now do the real mapping */
    570             if (new_addr != r->addr) {
    571                 if (r->addr != ~0U) {
    572                     if (r->type & PCI_ADDRESS_SPACE_IO) {
    573                         int devclass;
    574                         /* NOTE: specific hack for IDE in PC case:
    575                            only one byte must be mapped. */
    576                         devclass = d->config[0x0a] | (d->config[0x0b] << 8);
    577                         if (devclass == 0x0101 && r->size == 4) {
    578                             int rc = PDMDevHlpIOPortDeregister(d->pDevIns, r->addr + 2, 1);
    579                             AssertRC(rc);
    580                         } else {
    581                             int rc = PDMDevHlpIOPortDeregister(d->pDevIns, r->addr, r->size);
    582                             AssertRC(rc);
    583                         }
    584                     } else {
    585                         RTGCPHYS GCPhysBase = r->addr;
    586                         int rc;
    587                         if (pBus->pPciHlpR3->pfnIsMMIO2Base(pBus->pDevInsR3, d->pDevIns, GCPhysBase))
    588                         {
    589                             /* unmap it. */
    590                             rc = r->map_func(d, i, NIL_RTGCPHYS, r->size, (PCIADDRESSSPACE)(r->type));
    591                             AssertRC(rc);
    592                             rc = PDMDevHlpMMIO2Unmap(d->pDevIns, i, GCPhysBase);
    593                         }
    594                         else
    595                             rc = PDMDevHlpMMIODeregister(d->pDevIns, GCPhysBase, r->size);
    596                         AssertMsgRC(rc, ("rc=%Rrc d=%s i=%d GCPhysBase=%RGp size=%#x\n", rc, d->name, i, GCPhysBase, r->size));
    597                     }
    598                 }
    599                 r->addr = new_addr;
    600                 if (r->addr != ~0U) {
    601                     int rc = r->map_func(d, i,
    602                                          r->addr + (r->type & PCI_ADDRESS_SPACE_IO ? 0 : 0),
    603                                          r->size, (PCIADDRESSSPACE)(r->type));
    604                     AssertRC(rc);
    605                 }
     623            pRegion->addr = uNew;
     624            if (pRegion->addr != INVALID_PCI_ADDRESS)
     625            {
     626                /* finally, map the region */
     627                rc = pRegion->map_func(pDev, iRegion,
     628                                       pRegion->addr, pRegion->size,
     629                                       (PCIADDRESSSPACE)(pRegion->type));
     630                AssertRC(rc);
    606631            }
    607632        }
     
    665690
    666691    /* Set type in the config space. */
    667     uint32_t u32Address = 0x10 + iRegion * 4;
     692    uint32_t u32Address = ich9pciGetRegionReg(iRegion);
    668693    uint32_t u32Value   =   (enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH ? (1 << 3) : 0)
    669694                          | (enmType == PCI_ADDRESS_SPACE_IO ? 1 : 0);
     
    766791}
    767792
     793static uint32_t ich9pciConfigRead(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t len)
     794{
     795    /* Set destination address */
     796    /// @todo: device locking?
     797    pGlobals->uConfigReg = 0x80000000 | (uBus << 16) |
     798                           (uDevFn << 8) | (addr & ~3);
     799    uint32_t u32Val;
     800    int rc = ich9pciDataRead(pGlobals, addr & 3, len, &u32Val);
     801    AssertRC(rc);
     802    return u32Val;
     803}
     804
     805static void ich9pciConfigWrite(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val, uint32_t len)
     806{
     807    /* Set destination address */
     808    /// @todo: device locking?
     809    pGlobals->uConfigReg = 0x80000000 | (uBus << 16) |
     810                           (uDevFn << 8) | addr;
     811    ich9pciDataWrite(pGlobals, 0, val, len);
     812}
     813
     814static void ich9pciSetRegionAddress(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, int iRegion, uint32_t addr)
     815{
     816    uint32_t uReg = ich9pciGetRegionReg(iRegion);
     817
     818    /* Read memory type first. */
     819    uint8_t uResourceType = ich9pciConfigRead(pGlobals, uBus, uDevFn, uReg, 1);
     820    /* Read command register. */
     821    uint16_t uCmd = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 2);
     822
     823    if ( iRegion == PCI_ROM_SLOT )
     824        uCmd |= PCI_COMMAND_MEMACCESS;
     825    else if ((uResourceType & PCI_ADDRESS_SPACE_IO) == PCI_ADDRESS_SPACE_IO)
     826        uCmd |= PCI_COMMAND_IOACCESS; /* Enable I/O space access. */
     827    else /* The region is MMIO. */
     828        uCmd |= PCI_COMMAND_MEMACCESS; /* Enable MMIO access. */
     829
     830    /* Write address of the device. */
     831    ich9pciConfigWrite(pGlobals, uBus, uDevFn, uReg, addr, 4);
     832
     833    /* enable memory mappings */
     834    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, uCmd, 2);
     835}
     836
     837
     838static void ich9pciBiosInitBridge(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, uint8_t cBridgeDepth, uint8_t *paBridgePositions)
     839{
     840    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_SECONDARY_BUS, pGlobals->uBus, 1);
     841    /* Temporary until we know how many other bridges are behind this one. */
     842    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_SUBORDINATE_BUS, 0xff, 1);
     843
     844    /* Add position of this bridge into the array. */
     845    paBridgePositions[cBridgeDepth+1] = (uDevFn >> 3);
     846
     847    /*
     848     * The I/O range for the bridge must be aligned to a 4KB boundary.
     849     * This does not change anything really as the access to the device is not going
     850     * through the bridge but we want to be compliant to the spec.
     851     */
     852    if ((pGlobals->uPciBiosIo % 4096) != 0)
     853    {
     854        pGlobals->uPciBiosIo = RT_ALIGN_32(pGlobals->uPciBiosIo, 4*1024);
     855        Log(("%s: Aligned I/O start address. New address %#x\n", __FUNCTION__, pGlobals->uPciBiosIo));
     856    }
     857    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_IO_BASE, (pGlobals->uPciBiosIo >> 8) & 0xf0, 1);
     858
     859    /* The MMIO range for the bridge must be aligned to a 1MB boundary. */
     860    if ((pGlobals->uPciBiosMmio % (1024 * 1024)) != 0)
     861    {
     862        pGlobals->uPciBiosMmio = RT_ALIGN_32(pGlobals->uPciBiosMmio, 1024*1024);
     863        Log(("%s: Aligned MMIO start address. New address %#x\n", __FUNCTION__, pGlobals->uPciBiosMmio));
     864    }
     865    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_BASE, (pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xffff0), 2);
     866
     867    /* Save values to compare later to. */
     868    uint32_t u32IoAddressBase = pGlobals->uPciBiosIo;
     869    uint32_t u32MMIOAddressBase = pGlobals->uPciBiosMmio;
     870
     871    /* Init devices behind the bridge and possibly other bridges as well. */
     872    for (int iDev = 0; iDev <= 255; iDev++)
     873        ich9pciBiosInitDevice(pGlobals, uBus + 1, iDev, cBridgeDepth + 1, paBridgePositions);
     874
     875    /* The number of bridges behind the this one is now available. */
     876    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uBus, 1);
     877
     878    /*
     879     * Set I/O limit register. If there is no device with I/O space behind the bridge
     880     * we set a lower value than in the base register.
     881     * The result with a real bridge is that no I/O transactions are passed to the secondary
     882     * interface. Again this doesn't really matter here but we want to be compliant to the spec.
     883     */
     884    if ((u32IoAddressBase != pGlobals->uPciBiosIo) && ((pGlobals->uPciBiosIo % 4096) != 0))
     885    {
     886        /* The upper boundary must be one byte less than a 4KB boundary. */
     887        pGlobals->uPciBiosIo = RT_ALIGN_32(pGlobals->uPciBiosIo, 4*1024);
     888    }
     889
     890    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_IO_LIMIT, ((pGlobals->uPciBiosIo >> 8) & 0xf0) - 1, 1);
     891
     892    /* Same with the MMIO limit register but with 1MB boundary here. */
     893    if ((u32MMIOAddressBase != pGlobals->uPciBiosMmio) && ((pGlobals->uPciBiosMmio % (1024 * 1024)) != 0))
     894    {
     895        /* The upper boundary must be one byte less than a 1MB boundary. */
     896        pGlobals->uPciBiosMmio = RT_ALIGN_32(pGlobals->uPciBiosMmio, 1024*1024);
     897    }
     898    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_LIMIT, ((pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xfff0)) - 1, 2);
     899
     900    /*
     901     * Set the prefetch base and limit registers. We currently have no device with a prefetchable region
     902     * which may be behind a bridge. Thatswhy it is unconditionally disabled here atm by writing a higher value into
     903     * the base register than in the limit register.
     904     */
     905    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0, 2);
     906    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0, 2);
     907    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_BASE_UPPER32, 0x00, 4);
     908    ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00, 4);
     909}
     910
    768911static void ich9pciBiosInitDevice(PPCIGLOBALS pGlobals, uint8_t uBus, uint8_t uDevFn, uint8_t cBridgeDepth, uint8_t *paBridgePositions)
    769912{
     913    uint32_t *paddr;
     914    int i, pin, pic_irq;
     915    uint16_t uDevClass, uVendor, uDevice;
     916
     917    uDevClass  = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_CLASS_DEVICE, 2);
     918    uVendor    = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_VENDOR_ID, 2);
     919    uDevice    = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_DEVICE_ID, 2);
     920
     921    /* If device is present */
     922    if (uVendor == 0xffff)
     923        return;
     924
     925    switch (uDevice)
     926    {
     927        case 0x0101:
     928            /* IDE controller */
     929            ich9pciConfigWrite(pGlobals, uBus, uDevFn, 0x40, 0x8000, 2); /* enable IDE0 */
     930            ich9pciConfigWrite(pGlobals, uBus, uDevFn, 0x42, 0x8000, 2); /* enable IDE1 */
     931            goto default_map;
     932            break;
     933        case 0x0300:
     934            /* VGA controller */
     935            if (uVendor != 0x80ee)
     936                goto default_map;
     937            /* VGA: map frame buffer to default Bochs VBE address */
     938            ich9pciSetRegionAddress(pGlobals, uBus, uDevFn, 0, 0xE0000000);
     939            /*
     940             * Legacy VGA I/O ports are implicitly decoded by a VGA class device. But
     941             * only the framebuffer (i.e., a memory region) is explicitly registered via
     942             * ich9pciSetRegionAddress, so I/O decoding must be enabled manually.
     943             */
     944            uint8_t uCmd = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 1);
     945            ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND,
     946                               /* Enable I/O space access. */
     947                               uCmd | PCI_COMMAND_IOACCESS,
     948                               1);
     949            break;
     950        case 0x0800:
     951            /* PIC */
     952            if (uVendor == 0x1014)
     953            {
     954                /* IBM */
     955                if (uDevice == 0x0046 || uDevice == 0xFFFF)
     956                    /* MPIC & MPIC2 */
     957                    ich9pciSetRegionAddress(pGlobals, uBus, uDevFn, 0, 0x80800000 + 0x00040000);
     958            }
     959            break;
     960        case 0xff00:
     961            if ((uVendor == 0x0106b)
     962                && (uDevice == 0x0017 || uDevice == 0x0022))
     963            {
     964                /* macio bridge */
     965                ich9pciSetRegionAddress(pGlobals, uBus, uDevFn, 0, 0x80800000);
     966            }
     967            break;
     968        case 0x0604:
     969            /* PCI-to-PCI bridge. */
     970            ich9pciConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PRIMARY_BUS, uBus, 1);
     971
     972            AssertMsg(pGlobals->uBus < 255, ("Too many bridges on the bus\n"));
     973            pGlobals->uBus++;
     974            ich9pciBiosInitBridge(pGlobals, uBus, uDevFn, cBridgeDepth, paBridgePositions);
     975            break;
     976        default:
     977        default_map:
     978        {
     979            /* default memory mappings */
     980            /*
     981             * We ignore ROM region here.
     982             */
     983            for (int iRegion = 0; iRegion < (PCI_NUM_REGIONS-1); iRegion++)
     984            {
     985                uint32_t u32Address = ich9pciGetRegionReg(iRegion);
     986
     987                /* Calculate size. */
     988                uint8_t u8ResourceType = ich9pciConfigRead(pGlobals, uBus, uDevFn, u32Address, 1);
     989                ich9pciConfigWrite(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0xffffffff), 4);
     990                uint32_t u32Size = ich9pciConfigRead(pGlobals, uBus, uDevFn, u32Address, 4);
     991                /* Clear resource information depending on resource type. */
     992                if ((u8ResourceType & PCI_COMMAND_IOACCESS) == PCI_COMMAND_IOACCESS) /* I/O */
     993                    u32Size &= ~(0x01);
     994                else                        /* MMIO */
     995                    u32Size &= ~(0x0f);
     996
     997                bool fIsPio = ((u8ResourceType & PCI_COMMAND_IOACCESS) == PCI_COMMAND_IOACCESS);
     998                /*
     999                 * Invert all bits and add 1 to get size of the region.
     1000                 * (From PCI implementation note)
     1001                 */
     1002                if (fIsPio && (u32Size & UINT32_C(0xffff0000)) == 0)
     1003                    u32Size = (~(u32Size | UINT32_C(0xffff0000))) + 1;
     1004                else
     1005                    u32Size = (~u32Size) + 1;
     1006
     1007                Log(("%s: Size of region %u for device %d on bus %d is %u\n", __FUNCTION__, i, uDevFn, uBus, u32Size));
     1008
     1009                if (u32Size)
     1010                {
     1011                    paddr = fIsPio ? &pGlobals->uPciBiosIo : &pGlobals->uPciBiosMmio;
     1012                    *paddr = (*paddr + u32Size - 1) & ~(u32Size - 1);
     1013                    Log(("%s: Start address of %s region %u is %#x\n", __FUNCTION__, (fIsPio ? "I/O" : "MMIO"), i, *paddr));
     1014                    ich9pciSetRegionAddress(pGlobals, uBus, uDevFn, i, *paddr);
     1015                    *paddr += u32Size;
     1016                    Log(("%s: New address is %#x\n", __FUNCTION__, *paddr));
     1017                }
     1018            }
     1019            break;
     1020        }
     1021    }
     1022
     1023    /* map the interrupt */
     1024    uint32_t uPin = ich9pciConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_INTERRUPT_PIN, 1);
     1025    if (uPin != 0)
     1026    {
     1027        uint8_t uBridgeDevFn = uDevFn;
     1028        uPin--;
     1029
     1030        /* We need to go up to the host bus to see which irq this device will assert there. */
     1031        while (cBridgeDepth != 0)
     1032        {
     1033            /* Get the pin the device would assert on the bridge. */
     1034            uPin = ((uBridgeDevFn >> 3) + uPin) & 3;
     1035            uBridgeDevFn = paBridgePositions[cBridgeDepth];
     1036            cBridgeDepth--;
     1037        }
     1038#if 0
     1039        uPin = pci_slot_get_pirq(uDevFn, pin);
     1040        pic_irq = pci_irqs[pin];
     1041        ich9pciConfigWrite(pGlobals, uBus, uDevFn, PCI_INTERRUPT_LINE, pic_irq);
     1042#endif
     1043    }
    7701044}
    7711045
     
    8541128           (u32Address >= VBOX_PCI_ROM_ADDRESS && u32Address < VBOX_PCI_ROM_ADDRESS+4))
    8551129    {
    856         PCIIORegion *region;
     1130        PCIIORegion *pRegion;
    8571131        int reg, regionSize;
    8581132
    8591133        reg = (u32Address >= VBOX_PCI_ROM_ADDRESS) ? PCI_ROM_SLOT : (u32Address - VBOX_PCI_BASE_ADDRESS_0) >> 2;
    860         region = &aDev->Int.s.aIORegions[reg];
    861         regionSize = region->size;
     1134        pRegion = &aDev->Int.s.aIORegions[reg];
     1135        regionSize = pRegion->size;
    8621136        if (regionSize == 0)
    8631137            break;
     
    8681142        } else {
    8691143            val &= ~(regionSize - 1);
    870             val |= region->type;
     1144            val |= pRegion->type;
    8711145        }
    8721146        *(uint32_t *)(aDev->config + u32Address) = RT_H2LE_U32(val);
Note: See TracChangeset for help on using the changeset viewer.

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