VirtualBox

Changeset 36079 in vbox for trunk/src/VBox/Devices/Bus


Ignore:
Timestamp:
Feb 24, 2011 5:10:31 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70201
Message:

PCI: cleanup, todos, raw PCI regions work

Location:
trunk/src/VBox/Devices/Bus
Files:
5 edited

Legend:

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

    r35753 r36079  
    773773         */
    774774        PPCIDEVICE pBridgeTemp = pBus->papBridgesR3[iBridge];
    775         AssertMsg(pBridgeTemp && PCIIsPci2PciBridge(pBridgeTemp),
     775        AssertMsg(pBridgeTemp && pciDevIsPci2PciBridge(pBridgeTemp),
    776776                  ("Device is not a PCI bridge but on the list of PCI bridges\n"));
    777777
     
    17211721            }
    17221722        }
    1723         PCIClearRequestedDevfunc(pPciDev);
     1723        pciDevClearRequestedDevfunc(pPciDev);
    17241724    }
    17251725    else
     
    17421742            AssertReleaseMsg(!(iDev % 8), ("PCI Configuration Conflict! iDev=%d pszName=%s clashes with %s\n",
    17431743                                           iDev, pszName, pBus->devices[iDev]->name));
    1744             if (    PCIIsRequestedDevfunc(pBus->devices[iDev])
    1745                 ||  (pBus->devices[iDev + 1] && PCIIsRequestedDevfunc(pBus->devices[iDev + 1]))
    1746                 ||  (pBus->devices[iDev + 2] && PCIIsRequestedDevfunc(pBus->devices[iDev + 2]))
    1747                 ||  (pBus->devices[iDev + 3] && PCIIsRequestedDevfunc(pBus->devices[iDev + 3]))
    1748                 ||  (pBus->devices[iDev + 4] && PCIIsRequestedDevfunc(pBus->devices[iDev + 4]))
    1749                 ||  (pBus->devices[iDev + 5] && PCIIsRequestedDevfunc(pBus->devices[iDev + 5]))
    1750                 ||  (pBus->devices[iDev + 6] && PCIIsRequestedDevfunc(pBus->devices[iDev + 6]))
    1751                 ||  (pBus->devices[iDev + 7] && PCIIsRequestedDevfunc(pBus->devices[iDev + 7])))
     1744            if (    pciDevIsRequestedDevfunc(pBus->devices[iDev])
     1745                ||  (pBus->devices[iDev + 1] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 1]))
     1746                ||  (pBus->devices[iDev + 2] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 2]))
     1747                ||  (pBus->devices[iDev + 3] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 3]))
     1748                ||  (pBus->devices[iDev + 4] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 4]))
     1749                ||  (pBus->devices[iDev + 5] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 5]))
     1750                ||  (pBus->devices[iDev + 6] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 6]))
     1751                ||  (pBus->devices[iDev + 7] && pciDevIsRequestedDevfunc(pBus->devices[iDev + 7])))
    17521752            {
    17531753                AssertReleaseMsgFailed(("Configuration error:'%s' and '%s' are both configured as device %d\n",
     
    17861786            }
    17871787        } /* if conflict */
    1788         PCISetRequestedDevfunc(pPciDev);
     1788        pciDevSetRequestedDevfunc(pPciDev);
    17891789    }
    17901790
     
    17981798    pPciDev->Int.s.pfnConfigWrite   = pci_default_write_config;
    17991799    pBus->devices[iDev]             = pPciDev;
    1800     if (PCIIsPci2PciBridge(pPciDev))
     1800    if (pciDevIsPci2PciBridge(pPciDev))
    18011801    {
    18021802        AssertMsg(pBus->cBridges < RT_ELEMENTS(pBus->devices), ("Number of bridges exceeds the number of possible devices on the bus\n"));
     
    21112111
    21122112    pBus->PciDev.pDevIns              = pDevIns;
    2113     PCISetRequestedDevfunc(&pBus->PciDev);
     2113    pciDevSetRequestedDevfunc(&pBus->PciDev);
    21142114    pciRegisterInternal(pBus, 0, &pBus->PciDev, "i440FX");
    21152115
     
    21222122
    21232123    pGlobals->PIIX3State.dev.pDevIns      = pDevIns;
    2124     PCISetRequestedDevfunc(&pGlobals->PIIX3State.dev);
     2124    pciDevSetRequestedDevfunc(&pGlobals->PIIX3State.dev);
    21252125    pciRegisterInternal(pBus, 8, &pGlobals->PIIX3State.dev, "PIIX3");
    21262126    piix3_reset(&pGlobals->PIIX3State);
     
    24962496
    24972497    /* Bridge-specific data */
    2498     PCISetPci2PciBridge(&pBus->PciDev);
     2498    pciDevSetPci2PciBridge(&pBus->PciDev);
    24992499    pBus->PciDev.Int.s.pfnBridgeConfigRead  = pcibridgeConfigRead;
    25002500    pBus->PciDev.Int.s.pfnBridgeConfigWrite = pcibridgeConfigWrite;
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r35753 r36079  
    698698         */
    699699        PPCIDEVICE pBridgeTemp = pBus->papBridgesR3[iBridge];
    700         AssertMsg(pBridgeTemp && PCIIsPci2PciBridge(pBridgeTemp),
     700        AssertMsg(pBridgeTemp && pciDevIsPci2PciBridge(pBridgeTemp),
    701701                  ("Device is not a PCI bridge but on the list of PCI bridges\n"));
    702702
     
    949949static DECLCALLBACK(int) ich9pciGenericSaveExec(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSM)
    950950{
    951     Assert(!PCIIsPassthrough(pPciDev));
     951    Assert(!pciDevIsPassthrough(pPciDev));
    952952    return SSMR3PutMem(pSSM, &pPciDev->config[0], sizeof(pPciDev->config));
    953953}
     
    969969
    970970            /* Device flags */
    971             int rc = SSMR3PutU32(pSSM, pDev->Int.s.uFlags);
     971            int rc = SSMR3PutU32(pSSM, pDev->Int.s.fFlags);
    972972            if (RT_FAILURE(rc))
    973973                return rc;
     
    12021202     */
    12031203    uint8_t const fBridge = fIsBridge ? 2 : 1;
    1204     Assert(!PCIIsPassthrough(pDev));
     1204    Assert(!pciDevIsPassthrough(pDev));
    12051205    uint8_t *pbDstConfig = &pDev->config[0];
    12061206
     
    13391339
    13401340        /* get the data */
    1341         DevTmp.Int.s.uFlags = 0;
     1341        DevTmp.Int.s.fFlags = 0;
    13421342        DevTmp.Int.s.u8MsiCapOffset = 0;
    13431343        DevTmp.Int.s.u8MsiCapSize = 0;
     
    13471347        SSMR3GetMem(pSSM, DevTmp.config, sizeof(DevTmp.config));
    13481348
    1349         rc = SSMR3GetU32(pSSM, &DevTmp.Int.s.uFlags);
     1349        rc = SSMR3GetU32(pSSM, &DevTmp.Int.s.fFlags);
    13501350        if (RT_FAILURE(rc))
    13511351            goto out;
     
    13981398
    13991399        /* commit the loaded device config. */
    1400         Assert(!PCIIsPassthrough(pDev));
     1400        Assert(!pciDevIsPassthrough(pDev));
    14011401        pciR3CommonRestoreConfig(pDev, &DevTmp.config[0], false ); /** @todo fix bridge fun! */
    14021402
     
    14301430static DECLCALLBACK(int) ich9pciGenericLoadExec(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSM)
    14311431{
    1432     Assert(!PCIIsPassthrough(pPciDev));
     1432    Assert(!pciDevIsPassthrough(pPciDev));
    14331433    return SSMR3GetMem(pSSM, &pPciDev->config[0], sizeof(pPciDev->config));
    14341434}
     
    17581758    AssertMsgReturn(u32Address + len <= 256, ("Read after end of PCI config space\n"),
    17591759                    0);
    1760     if (   PCIIsMsiCapable(aDev)
     1760    if (   pciDevIsMsiCapable(aDev)
    17611761        && (u32Address >= aDev->Int.s.u8MsiCapOffset)
    17621762        && (u32Address <  aDev->Int.s.u8MsiCapOffset + aDev->Int.s.u8MsiCapSize)
     
    17661766    }
    17671767
    1768     if (   PCIIsMsixCapable(aDev)
     1768    if (   pciDevIsMsixCapable(aDev)
    17691769        && (u32Address >= aDev->Int.s.u8MsixCapOffset)
    17701770        && (u32Address <  aDev->Int.s.u8MsixCapOffset + aDev->Int.s.u8MsixCapSize)
     
    18391839    AssertMsgReturnVoid(u32Address + len <= 256, ("Write after end of PCI config space\n"));
    18401840
    1841     if (   PCIIsMsiCapable(aDev)
     1841    if (   pciDevIsMsiCapable(aDev)
    18421842        && (u32Address >= aDev->Int.s.u8MsiCapOffset)
    18431843        && (u32Address <  aDev->Int.s.u8MsiCapOffset + aDev->Int.s.u8MsiCapSize)
     
    18501850    }
    18511851
    1852     if (   PCIIsMsixCapable(aDev)
     1852    if (   pciDevIsMsixCapable(aDev)
    18531853        && (u32Address >= aDev->Int.s.u8MsixCapOffset)
    18541854        && (u32Address <  aDev->Int.s.u8MsixCapOffset + aDev->Int.s.u8MsixCapSize)
     
    20062006        if (!strcmp(pszName, PciSlotAssignments[i].pszName))
    20072007        {
    2008             PCISetRequestedDevfunc(pPciDev);
     2008            pciDevSetRequestedDevfunc(pPciDev);
    20092009            aPosition->iDeviceFunc =
    20102010                    (PciSlotAssignments[i].iSlot << 3) + PciSlotAssignments[i].iFunction;
     
    20312031                &&  !pBus->apDevices[iPos + 7])
    20322032        {
    2033             PCIClearRequestedDevfunc(pPciDev);
     2033            pciDevClearRequestedDevfunc(pPciDev);
    20342034            aPosition->iDeviceFunc = iPos;
    20352035            return true;
     
    20442044    PCIDevice** aSlot = &pBus->apDevices[iSlot << 3];
    20452045
    2046     return     (aSlot[0] && PCIIsRequestedDevfunc(aSlot[0]))
    2047             || (aSlot[1] && PCIIsRequestedDevfunc(aSlot[1]))
    2048             || (aSlot[2] && PCIIsRequestedDevfunc(aSlot[2]))
    2049             || (aSlot[3] && PCIIsRequestedDevfunc(aSlot[3]))
    2050             || (aSlot[4] && PCIIsRequestedDevfunc(aSlot[4]))
    2051             || (aSlot[5] && PCIIsRequestedDevfunc(aSlot[5]))
    2052             || (aSlot[6] && PCIIsRequestedDevfunc(aSlot[6]))
    2053             || (aSlot[7] && PCIIsRequestedDevfunc(aSlot[7]))
     2046    return     (aSlot[0] && pciDevIsRequestedDevfunc(aSlot[0]))
     2047            || (aSlot[1] && pciDevIsRequestedDevfunc(aSlot[1]))
     2048            || (aSlot[2] && pciDevIsRequestedDevfunc(aSlot[2]))
     2049            || (aSlot[3] && pciDevIsRequestedDevfunc(aSlot[3]))
     2050            || (aSlot[4] && pciDevIsRequestedDevfunc(aSlot[4]))
     2051            || (aSlot[5] && pciDevIsRequestedDevfunc(aSlot[5]))
     2052            || (aSlot[6] && pciDevIsRequestedDevfunc(aSlot[6]))
     2053            || (aSlot[7] && pciDevIsRequestedDevfunc(aSlot[7]))
    20542054           ;
    20552055}
     
    20782078     * its current habitant, if it wasn't hard assigned too.
    20792079     */
    2080     if (PCIIsRequestedDevfunc(pPciDev) &&
     2080    if (pciDevIsRequestedDevfunc(pPciDev) &&
    20812081        pBus->apDevices[iDev]          &&
    2082         PCIIsRequestedDevfunc(pBus->apDevices[iDev]))
     2082        pciDevIsRequestedDevfunc(pBus->apDevices[iDev]))
    20832083    {
    20842084        AssertReleaseMsgFailed(("Configuration error:'%s' and '%s' are both configured as device %d\n",
     
    21232123    pPciDev->Int.s.pfnConfigWrite   = ich9pciConfigWriteDev;
    21242124    pBus->apDevices[iDev]           = pPciDev;
    2125     if (PCIIsPci2PciBridge(pPciDev))
     2125    if (pciDevIsPci2PciBridge(pPciDev))
    21262126    {
    21272127        AssertMsg(pBus->cBridges < RT_ELEMENTS(pBus->apDevices), ("Number of bridges exceeds the number of possible devices on the bus\n"));
     
    21322132    }
    21332133
    2134     Log(("PCI: Registered device %d function %d (%#x) '%s'.\n",
    2135          iDev >> 3, iDev & 7, 0x80000000 | (iDev << 8), pszName));
     2134    Log(("PCI: Registered device %d function %d on bus %d (%#x) '%s'.\n",
     2135         iDev >> 3, iDev & 7, pBus->iBus, 0x80000000 | (iDev << 8), pszName));
    21362136
    21372137    return VINF_SUCCESS;
     
    21442144        pHlp->pfnPrintf(pHlp, "    ");
    21452145    }
     2146}
     2147static uint32_t ich9pciGetCfg(PCIDevice* aDev, int32_t iRegister, int cb)
     2148{
     2149    return aDev->Int.s.pfnConfigRead(aDev, iRegister, cb);
     2150}
     2151
     2152static uint8_t ich9pciGetByte(PCIDevice* aDev, int32_t iRegister)
     2153{
     2154    return (uint8_t)ich9pciGetCfg(aDev, iRegister, 1);
     2155}
     2156
     2157static uint16_t ich9pciGetWord(PCIDevice* aDev, int32_t iRegister)
     2158{
     2159    return (uint16_t)ich9pciGetCfg(aDev, iRegister, 2);
     2160}
     2161
     2162static uint32_t ich9pciGetDWord(PCIDevice* aDev, int32_t iRegister)
     2163{
     2164    return (uint32_t)ich9pciGetCfg(aDev, iRegister, 4);
    21462165}
    21472166
     
    21532172        if (pPciDev != NULL)
    21542173        {
    2155             if (PCIIsPassthrough(pPciDev))
    2156             {
    2157                 printIndent(pHlp, iIndent);
    2158                 /**
    2159                  * For passthrough devices MSI/MSI-X mostly reflects the way interrupts delivered to the guest,
    2160                  * as host driver handles real devices interrupts.
    2161                  */
    2162                 pHlp->pfnPrintf(pHlp, "%02x:%02x:%02x %s: %s%s - PASSTHROUGH\n",
    2163                                 pBus->iBus, (iDev >> 3) & 0xff, iDev & 0x7,
    2164                                 pPciDev->name,
    2165                                 PCIIsMsiCapable(pPciDev)  ? " MSI" : "",
    2166                                 PCIIsMsixCapable(pPciDev) ? " MSI-X" : ""
    2167                                 );
    2168                 continue;
    2169             }
    21702174            printIndent(pHlp, iIndent);
    2171             pHlp->pfnPrintf(pHlp, "%02x:%02x:%02x %s: %04x-%04x%s%s",
     2175
     2176            /**
     2177             * For passthrough devices MSI/MSI-X mostly reflects the way interrupts delivered to the guest,
     2178             * as host driver handles real devices interrupts.
     2179             */
     2180            pHlp->pfnPrintf(pHlp, "%02x:%02x:%02x %s%s: %04x-%04x%s%s",
    21722181                            pBus->iBus, (iDev >> 3) & 0xff, iDev & 0x7,
    21732182                            pPciDev->name,
    2174                             PCIDevGetVendorId(pPciDev), PCIDevGetDeviceId(pPciDev),
    2175                             PCIIsMsiCapable(pPciDev)  ? " MSI" : "",
    2176                             PCIIsMsixCapable(pPciDev) ? " MSI-X" : ""
     2183                            pciDevIsPassthrough(pPciDev) ? " (PASSTHROUGH)" : "",
     2184                            ich9pciGetWord(pPciDev, VBOX_PCI_VENDOR_ID), ich9pciGetWord(pPciDev, VBOX_PCI_DEVICE_ID),
     2185                            pciDevIsMsiCapable(pPciDev)  ? " MSI" : "",
     2186                            pciDevIsMsixCapable(pPciDev) ? " MSI-X" : ""
    21772187                            );
    2178             if (PCIDevGetInterruptPin(pPciDev) != 0)
     2188            if (!pciDevIsPassthrough(pPciDev) && PCIDevGetInterruptPin(pPciDev) != 0)
    21792189                pHlp->pfnPrintf(pHlp, " IRQ%d", PCIDevGetInterruptLine(pPciDev));
    21802190
    21812191            pHlp->pfnPrintf(pHlp, "\n");
    21822192
    2183             int iCmd = PCIDevGetCommand(pPciDev);
     2193            int iCmd = ich9pciGetWord(pPciDev, VBOX_PCI_COMMAND);
    21842194            if ((iCmd & (VBOX_PCI_COMMAND_IO | VBOX_PCI_COMMAND_MEMORY)) != 0)
    21852195            {
     
    21922202                        continue;
    21932203
    2194                     uint32_t u32Addr = ich9pciConfigReadDev(pPciDev, ich9pciGetRegionReg(iRegion), 4);
     2204                    uint32_t u32Addr = ich9pciGetDWord(pPciDev, ich9pciGetRegionReg(iRegion));
    21952205                    const char * szDesc;
    21962206
     
    22242234                    while (iPerLine-- > 0)
    22252235                    {
    2226                         pHlp->pfnPrintf(pHlp, "%02x ", pPciDev->config[iReg++]);
     2236                        pHlp->pfnPrintf(pHlp, "%02x ", ich9pciGetByte(pPciDev, iReg++));
    22272237                    }
    22282238                    pHlp->pfnPrintf(pHlp, "\n");
     
    25212531
    25222532    /* Bridge device reset handlers processed later */
    2523     if (!PCIIsPci2PciBridge(pDev))
     2533    if (!pciDevIsPci2PciBridge(pDev))
    25242534    {
    25252535        PCIDevSetByte(pDev, VBOX_PCI_CACHE_LINE_SIZE, 0x0);
     
    26672677
    26682678    /* Bridge-specific data */
    2669     PCISetPci2PciBridge(&pBus->aPciDev);
     2679    pciDevSetPci2PciBridge(&pBus->aPciDev);
    26702680    pBus->aPciDev.Int.s.pfnBridgeConfigRead  = ich9pcibridgeConfigRead;
    26712681    pBus->aPciDev.Int.s.pfnBridgeConfigWrite = ich9pcibridgeConfigWrite;
  • trunk/src/VBox/Devices/Bus/MsiCommon.cpp

    r35346 r36079  
    105105{
    106106    int32_t iOff = u32Address - pDev->Int.s.u8MsiCapOffset;
    107     Assert(iOff >= 0 && (PCIIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize));
     107    Assert(iOff >= 0 && (pciDevIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize));
    108108
    109109    Log2(("MsiPciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
     
    190190    int32_t iOff = u32Address - pDev->Int.s.u8MsiCapOffset;
    191191
    192     Assert(iOff >= 0 && (PCIIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize));
     192    Assert(iOff >= 0 && (pciDevIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize));
    193193    uint32_t rv = 0;
    194194
     
    255255    *msiGetPendingBits(pDev) = 0;
    256256
    257     PCISetMsiCapable(pDev);
     257    pciDevSetMsiCapable(pDev);
    258258
    259259    return VINF_SUCCESS;
     
    263263bool     MsiIsEnabled(PPCIDEVICE pDev)
    264264{
    265     return PCIIsMsiCapable(pDev) && msiIsEnabled(pDev);
     265    return pciDevIsMsiCapable(pDev) && msiIsEnabled(pDev);
    266266}
    267267
  • trunk/src/VBox/Devices/Bus/MsixCommon.cpp

    r35346 r36079  
    210210    PCIDevSetDWord(pDev,  iCapOffset + VBOX_MSIX_PBA_BIROFFSET,   offPBA   | iBar);
    211211
    212     PCISetMsixCapable(pDev);
     212    pciDevSetMsixCapable(pDev);
    213213
    214214    return VINF_SUCCESS;
     
    218218bool     MsixIsEnabled(PPCIDEVICE pDev)
    219219{
    220     return PCIIsMsixCapable(pDev) && msixIsEnabled(pDev);
     220    return pciDevIsMsixCapable(pDev) && msixIsEnabled(pDev);
    221221}
    222222
     
    267267{
    268268    int32_t iOff = u32Address - pDev->Int.s.u8MsixCapOffset;
    269     Assert(iOff >= 0 && (PCIIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize));
     269    Assert(iOff >= 0 && (pciDevIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize));
    270270
    271271    Log2(("MsixPciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
     
    312312    int32_t iOff = u32Address - pDev->Int.s.u8MsixCapOffset;
    313313
    314     Assert(iOff >= 0 && (PCIIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize));
     314    Assert(iOff >= 0 && (pciDevIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize));
    315315    uint32_t rv = 0;
    316316
  • trunk/src/VBox/Devices/Bus/PCIInternal.h

    r35738 r36079  
    125125    R3PTRTYPE(PFNPCICONFIGWRITE)    pfnConfigWrite;
    126126
    127     /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants.
    128      *  @todo s/uFlags/fFlags/g */
    129     uint32_t                        uFlags;
     127    /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants. */
     128    uint32_t                        fFlags;
    130129    /** Current state of the IRQ pin of the device. */
    131130    int32_t                         uIrqPinState;
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