VirtualBox

Changeset 64450 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Oct 28, 2016 10:10:53 AM (8 years ago)
Author:
vboxsync
Message:

DevPci: Share I/O region regstration code.

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

Legend:

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

    r64424 r64450  
    15101510/* -=-=-=-=-=- PCI Bus Interface Methods (PDMPCIBUSREG) -=-=-=-=-=- */
    15111511
    1512 
    1513 /**
    1514  * @interface_method_impl{PDMPCIBUSREG,pfnIORegionRegisterR3}
    1515  */
    1516 static DECLCALLBACK(int) pciR3CommonIORegionRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
    1517                                                      PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
    1518 {
    1519     NOREF(pDevIns);
    1520 
    1521     /*
    1522      * Validate.
    1523      */
    1524     AssertMsgReturn(   enmType == PCI_ADDRESS_SPACE_MEM
    1525                     || enmType == PCI_ADDRESS_SPACE_IO
    1526                     || enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH,
    1527                     ("Invalid enmType=%#x? Or was this a bitmask after all...\n", enmType),
    1528                     VERR_INVALID_PARAMETER);
    1529     AssertMsgReturn((unsigned)iRegion < PCI_NUM_REGIONS,
    1530                     ("Invalid iRegion=%d PCI_NUM_REGIONS=%d\n", iRegion, PCI_NUM_REGIONS),
    1531                     VERR_INVALID_PARAMETER);
    1532     int iLastSet = ASMBitLastSetU64(cbRegion);
    1533     AssertMsgReturn(    iLastSet != 0
    1534                     &&  RT_BIT_64(iLastSet - 1) == cbRegion,
    1535                     ("Invalid cbRegion=%RGp iLastSet=%#x (not a power of 2 or 0)\n", cbRegion, iLastSet),
    1536                     VERR_INVALID_PARAMETER);
    1537 
    1538     /*
    1539      * Register the I/O region.
    1540      */
    1541     PPCIIOREGION pRegion = &pPciDev->Int.s.aIORegions[iRegion];
    1542     pRegion->addr        = ~0U;
    1543     pRegion->size        = cbRegion;
    1544     pRegion->type        = enmType;
    1545     pRegion->map_func    = pfnCallback;
    1546 
    1547     /* Set type in the config space. */
    1548     AssertCompile(PCI_ADDRESS_SPACE_MEM          == 0);
    1549     AssertCompile(PCI_ADDRESS_SPACE_IO           == 1);
    1550     AssertCompile(PCI_ADDRESS_SPACE_MEM_PREFETCH == RT_BIT_32(3));
    1551     PCIDevSetDWord(pPciDev, 0x10 + iRegion * 4, enmType);
    1552 
    1553     return VINF_SUCCESS;
    1554 }
    1555 
    1556 
    15571512/**
    15581513 * @interface_method_impl{PDMPCIBUSREG,pfnSetConfigCallbacksR3}
     
    17391694    PciBusReg.pfnRegisterR3           = pciR3MergedRegister;
    17401695    PciBusReg.pfnRegisterMsiR3        = NULL;
    1741     PciBusReg.pfnIORegionRegisterR3   = pciR3CommonIORegionRegister;
     1696    PciBusReg.pfnIORegionRegisterR3   = devpciR3CommonIORegionRegister;
    17421697    PciBusReg.pfnSetConfigCallbacksR3 = pciR3CommonSetConfigCallbacks;
    17431698    PciBusReg.pfnSetIrqR3             = pciSetIrq;
     
    20762031    PciBusReg.pfnRegisterR3           = pcibridgeR3MergedRegisterDevice;
    20772032    PciBusReg.pfnRegisterMsiR3        = NULL;
    2078     PciBusReg.pfnIORegionRegisterR3   = pciR3CommonIORegionRegister;
     2033    PciBusReg.pfnIORegionRegisterR3   = devpciR3CommonIORegionRegister;
    20792034    PciBusReg.pfnSetConfigCallbacksR3 = pciR3CommonSetConfigCallbacks;
    20802035    PciBusReg.pfnSetIrqR3             = pcibridgeSetIrq;
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r64424 r64450  
    782782
    783783    int iCmd = ich9pciGetWord(pDev, VBOX_PCI_COMMAND);
    784     for (int iRegion = 0; iRegion < PCI_NUM_REGIONS; iRegion++)
     784    for (int iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS; iRegion++)
    785785    {
    786786        PCIIORegion* pRegion = &pDev->Int.s.aIORegions[iRegion];
     
    862862
    863863
     864/* -=-=-=-=-=- PCI Bus Interface Methods (PDMPCIBUSREG) -=-=-=-=-=- */
     865
     866
    864867static DECLCALLBACK(int) ich9pciRegisterMsi(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
    865868{
     
    879882
    880883
    881 static DECLCALLBACK(int) ich9pciIORegionRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
     884/**
     885 * @interface_method_impl{PDMPCIBUSREG,pfnIORegionRegisterR3}
     886 */
     887DECLCALLBACK(int) devpciR3CommonIORegionRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
    882888                                                 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
    883889{
     
    895901                    ("Invalid enmType=%#x? Or was this a bitmask after all...\n", enmType),
    896902                    VERR_INVALID_PARAMETER);
    897     AssertMsgReturn((unsigned)iRegion < PCI_NUM_REGIONS,
    898                     ("Invalid iRegion=%d PCI_NUM_REGIONS=%d\n", iRegion, PCI_NUM_REGIONS),
     903    AssertMsgReturn((unsigned)iRegion < VBOX_PCI_NUM_REGIONS,
     904                    ("Invalid iRegion=%d VBOX_PCI_NUM_REGIONS=%d\n", iRegion, VBOX_PCI_NUM_REGIONS),
    899905                    VERR_INVALID_PARAMETER);
    900906    int iLastSet = ASMBitLastSetU64(cbRegion);
     
    904910                    VERR_INVALID_PARAMETER);
    905911
    906     Log(("ich9pciIORegionRegister: %s region %d size %RGp type %x\n",
     912    Log(("devpciR3CommonIORegionRegister: %s region %d size %RGp type %x\n",
    907913         pPciDev->pszNameR3, iRegion, cbRegion, enmType));
    908914
     
    922928    {
    923929        /* VBOX_PCI_BASE_ADDRESS_5 and VBOX_PCI_ROM_ADDRESS are excluded. */
    924         AssertMsgReturn(iRegion < PCI_NUM_REGIONS - 2,
     930        AssertMsgReturn(iRegion < VBOX_PCI_NUM_REGIONS - 2,
    925931                        ("Region %d cannot be 64-bit\n", iRegion),
    926932                        VERR_INVALID_PARAMETER);
     
    930936
    931937    /* Set type in the PCI config space. */
     938    AssertCompile(PCI_ADDRESS_SPACE_MEM          == 0);
     939    AssertCompile(PCI_ADDRESS_SPACE_IO           == 1);
     940    AssertCompile(PCI_ADDRESS_SPACE_BAR64        == RT_BIT_32(2));
     941    AssertCompile(PCI_ADDRESS_SPACE_MEM_PREFETCH == RT_BIT_32(3));
    932942    uint32_t u32Value   = (uint32_t)enmType & (PCI_ADDRESS_SPACE_IO | PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_MEM_PREFETCH);
    933943    PCIDevSetDWord(pPciDev, ich9pciGetRegionReg(iRegion), u32Value);
     
    16301640             * We ignore ROM region here.
    16311641             */
    1632             for (int iRegion = 0; iRegion < (PCI_NUM_REGIONS-1); iRegion++)
     1642            for (int iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS - 1; iRegion++)
    16331643            {
    16341644                uint32_t u32Address = ich9pciGetRegionReg(iRegion);
     
    21982208            if ((iCmd & (VBOX_PCI_COMMAND_IO | VBOX_PCI_COMMAND_MEMORY)) != 0)
    21992209            {
    2200                 for (unsigned iRegion = 0; iRegion < PCI_NUM_REGIONS; iRegion++)
     2210                for (unsigned iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS; iRegion++)
    22012211                {
    22022212                    PCIIORegion const *pRegion  = &pPciDev->Int.s.aIORegions[iRegion];
     
    23892399    PciBusReg.pfnRegisterR3           = pciR3MergedRegister;
    23902400    PciBusReg.pfnRegisterMsiR3        = ich9pciRegisterMsi;
    2391     PciBusReg.pfnIORegionRegisterR3   = ich9pciIORegionRegister;
     2401    PciBusReg.pfnIORegionRegisterR3   = devpciR3CommonIORegionRegister;
    23922402    PciBusReg.pfnSetConfigCallbacksR3 = ich9pciSetConfigCallbacks;
    23932403    PciBusReg.pfnSetIrqR3             = ich9pciSetIrq;
     
    25042514{
    25052515    /* Clear regions */
    2506     for (int iRegion = 0; iRegion < PCI_NUM_REGIONS; iRegion++)
     2516    for (int iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS; iRegion++)
    25072517    {
    25082518        PCIIORegion* pRegion = &pDev->Int.s.aIORegions[iRegion];
     
    26612671    PciBusReg.pfnRegisterR3           = pcibridgeR3MergedRegisterDevice;
    26622672    PciBusReg.pfnRegisterMsiR3        = ich9pciRegisterMsi;
    2663     PciBusReg.pfnIORegionRegisterR3   = ich9pciIORegionRegister;
     2673    PciBusReg.pfnIORegionRegisterR3   = devpciR3CommonIORegionRegister;
    26642674    PciBusReg.pfnSetConfigCallbacksR3 = ich9pciSetConfigCallbacks;
    26652675    PciBusReg.pfnSetIrqR3             = ich9pcibridgeSetIrq;
  • trunk/src/VBox/Devices/Bus/DevPciInternal.h

    r64424 r64450  
    185185DECLCALLBACK(void) devpciR3InfoPci(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
    186186DECLCALLBACK(void) devpciR3InfoPciIrq(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
     187DECLCALLBACK(int)  devpciR3CommonIORegionRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
     188                                                  PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback);
    187189
    188190#endif
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