Changeset 64420 in vbox
- Timestamp:
- Oct 25, 2016 3:51:03 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 111537
- Location:
- trunk/src/VBox/Devices/Bus
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevPCI.cpp
r64419 r64420 69 69 70 70 /********************************************************************************************************************************* 71 * Structures and Typedefs *72 *********************************************************************************************************************************/73 typedef DEVPCIBUS PCIBUS;74 typedef PDEVPCIBUS PPCIBUS;75 typedef DEVPCIROOT PCIGLOBALS;76 typedef PDEVPCIROOT PPCIGLOBALS;77 78 79 /*********************************************************************************************************************************80 71 * Defined Constants And Macros * 81 72 *********************************************************************************************************************************/ 82 83 /** Converts a bus instance pointer to a device instance pointer. */84 #define PCIBUS_2_DEVINS(pPciBus) ((pPciBus)->CTX_SUFF(pDevIns))85 /** Converts a PCI bus device instance pointer to a PCIGLOBALS pointer. */86 #define DEVINS_2_PCIGLOBALS(pDevIns) ((PPCIGLOBALS)(PDMINS_2_DATA(pDevIns, PPCIGLOBALS)))87 /** Converts a PCI bus device instance pointer to a DEVPCIBUS pointer. */88 #define DEVINS_2_PCIBUS(pDevIns) ((PPCIBUS)(&PDMINS_2_DATA(pDevIns, PPCIGLOBALS)->PciBus))89 90 /** Converts a pointer to a PCI bus instance to a PCIGLOBALS pointer.91 * @note This works only if the bus number is 0!!!92 */93 #define PCIBUS_2_PCIGLOBALS(pPciBus) RT_FROM_MEMBER(pPciBus, PCIGLOBALS, PciBus)94 95 /** @def PCI_LOCK96 * Acquires the PDM lock. This is a NOP if locking is disabled. */97 /** @def PCI_UNLOCK98 * Releases the PDM lock. This is a NOP if locking is disabled. */99 #define PCI_LOCK(pDevIns, rc) \100 do { \101 int rc2 = DEVINS_2_PCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \102 if (rc2 != VINF_SUCCESS) \103 return rc2; \104 } while (0)105 #define PCI_UNLOCK(pDevIns) \106 DEVINS_2_PCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns)107 108 73 /** @def VBOX_PCI_SAVED_STATE_VERSION 109 74 * Saved state version of the PCI bus device. 110 75 */ 111 76 #define VBOX_PCI_SAVED_STATE_VERSION 3 112 113 114 #ifndef VBOX_DEVICE_STRUCT_TESTCASE115 77 116 78 … … 128 90 129 91 #ifdef IN_RING3 130 DECLINLINE(PPDMPCIDEV) pciR3FindBridge(P PCIBUS pBus, uint8_t iBus);92 DECLINLINE(PPDMPCIDEV) pciR3FindBridge(PDEVPCIBUS pBus, uint8_t iBus); 131 93 #endif 132 94 … … 151 113 static void pci_update_mappings(PDMPCIDEV *d) 152 114 { 153 P PCIBUS pBus = d->Int.s.CTX_SUFF(pBus);115 PDEVPCIBUS pBus = d->Int.s.CTX_SUFF(pBus); 154 116 PCIIORegion *r; 155 117 int cmd, i; … … 391 353 #endif /* IN_RING3 */ 392 354 393 static int pci_data_write(P PCIGLOBALSpGlobals, uint32_t addr, uint32_t val, int len)355 static int pci_data_write(PDEVPCIROOT pGlobals, uint32_t addr, uint32_t val, int len) 394 356 { 395 357 uint8_t iBus, iDevice; … … 440 402 } 441 403 442 static int pci_data_read(P PCIGLOBALSpGlobals, uint32_t addr, int len, uint32_t *pu32)404 static int pci_data_read(PDEVPCIROOT pGlobals, uint32_t addr, int len, uint32_t *pu32) 443 405 { 444 406 uint8_t iBus, iDevice; … … 507 469 } 508 470 509 static inline int get_pci_irq_apic_level(P PCIGLOBALSpGlobals, int irq_num)471 static inline int get_pci_irq_apic_level(PDEVPCIROOT pGlobals, int irq_num) 510 472 { 511 473 return (pGlobals->auPciApicIrqLevels[irq_num] != 0); 512 474 } 513 475 514 static void apic_set_irq(P PCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, int iAcpiIrq, uint32_t uTagSrc)476 static void apic_set_irq(PDEVPCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, int iAcpiIrq, uint32_t uTagSrc) 515 477 { 516 478 /* This is only allowed to be called with a pointer to the host bus. */ … … 519 481 if (iAcpiIrq == -1) { 520 482 int apic_irq, apic_level; 521 P PCIGLOBALS pGlobals = PCIBUS_2_PCIGLOBALS(pBus);483 PDEVPCIROOT pGlobals = DEVPCIBUS_2_DEVPCIROOT(pBus); 522 484 int irq_num = pci_slot_get_apic_pirq(uDevFn, irq_num1); 523 485 … … 548 510 } 549 511 550 DECLINLINE(int) get_pci_irq_level(P PCIGLOBALSpGlobals, int irq_num)512 DECLINLINE(int) get_pci_irq_level(PDEVPCIROOT pGlobals, int irq_num) 551 513 { 552 514 return (pGlobals->Piix3.auPciLegacyIrqLevels[irq_num] != 0); … … 566 528 * is needed to calculate the PIRQ value. 567 529 */ 568 static void pciSetIrqInternal(P PCIGLOBALSpGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)569 { 570 P PCIBUS pBus = &pGlobals->PciBus;530 static void pciSetIrqInternal(PDEVPCIROOT pGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 531 { 532 PDEVPCIBUS pBus = &pGlobals->PciBus; 571 533 uint8_t *pbCfg = pGlobals->Piix3.PIIX3State.dev.abConfig; 572 534 const bool fIsAcpiDevice = pPciDev->abConfig[2] == 0x13 && pPciDev->abConfig[3] == 0x71; … … 660 622 PDMBOTHCBDECL(void) pciSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 661 623 { 662 pciSetIrqInternal(PDMINS_2_DATA(pDevIns, P PCIGLOBALS), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc);624 pciSetIrqInternal(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 663 625 } 664 626 … … 673 635 * @param iBus Destination bus number. 674 636 */ 675 DECLINLINE(PPDMPCIDEV) pciR3FindBridge(P PCIBUS pBus, uint8_t iBus)637 DECLINLINE(PPDMPCIDEV) pciR3FindBridge(PDEVPCIBUS pBus, uint8_t iBus) 676 638 { 677 639 /* Search for a fitting bridge. */ … … 729 691 } 730 692 731 static void pci_config_writel(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val)693 static void pci_config_writel(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val) 732 694 { 733 695 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 736 698 } 737 699 738 static void pci_config_writew(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val)700 static void pci_config_writew(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val) 739 701 { 740 702 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 743 705 } 744 706 745 static void pci_config_writeb(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val)707 static void pci_config_writeb(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val) 746 708 { 747 709 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 750 712 } 751 713 752 static uint32_t pci_config_readl(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr)714 static uint32_t pci_config_readl(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr) 753 715 { 754 716 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 760 722 } 761 723 762 static uint32_t pci_config_readw(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr)724 static uint32_t pci_config_readw(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr) 763 725 { 764 726 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 770 732 } 771 733 772 static uint32_t pci_config_readb(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr)734 static uint32_t pci_config_readb(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr) 773 735 { 774 736 pGlobals->uConfigReg = 0x80000000 | (uBus << 16) | … … 783 745 static const uint8_t pci_irqs[4] = { 11, 9, 11, 9 }; /* bird: added const */ 784 746 785 static void pci_set_io_region_addr(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, int region_num, uint32_t addr)747 static void pci_set_io_region_addr(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, int region_num, uint32_t addr) 786 748 { 787 749 uint32_t ofs; … … 799 761 } 800 762 801 static void pci_bios_init_device(P PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint8_t cBridgeDepth, uint8_t *paBridgePositions)763 static void pci_bios_init_device(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint8_t cBridgeDepth, uint8_t *paBridgePositions) 802 764 { 803 765 uint32_t *paddr; … … 1066 1028 if (cb == 4) 1067 1029 { 1068 P PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1030 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1069 1031 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE); 1070 1032 pThis->uConfigReg = u32 & ~3; /* Bits 0-1 are reserved and we silently clear them */ … … 1085 1047 if (cb == 4) 1086 1048 { 1087 P PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1049 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1088 1050 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ); 1089 1051 *pu32 = pThis->uConfigReg; … … 1110 1072 { 1111 1073 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE); 1112 rc = pci_data_write(PDMINS_2_DATA(pDevIns, P PCIGLOBALS), Port, u32, cb);1074 rc = pci_data_write(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), Port, u32, cb); 1113 1075 PCI_UNLOCK(pDevIns); 1114 1076 } … … 1128 1090 { 1129 1091 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ); 1130 int rc = pci_data_read(PDMINS_2_DATA(pDevIns, P PCIGLOBALS), Port, cb, pu32);1092 int rc = pci_data_read(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), Port, cb, pu32); 1131 1093 PCI_UNLOCK(pDevIns); 1132 1094 Log(("pciIOPortDataRead: Port=%#x cb=%#x -> %#x (%Rrc)\n", Port, cb, *pu32, rc)); … … 1160 1122 * @param pSSM The saved state handle. 1161 1123 */ 1162 static int pciR3CommonSaveExec(P PCIBUS pBus, PSSMHANDLE pSSM)1124 static int pciR3CommonSaveExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM) 1163 1125 { 1164 1126 /* … … 1188 1150 { 1189 1151 uint32_t i; 1190 P PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1152 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1191 1153 1192 1154 /* … … 1391 1353 * @param uPass The pass. 1392 1354 */ 1393 static DECLCALLBACK(int) pciR3CommonLoadExec(P PCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)1355 static DECLCALLBACK(int) pciR3CommonLoadExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1394 1356 { 1395 1357 uint32_t u32; … … 1504 1466 static DECLCALLBACK(int) pciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1505 1467 { 1506 P PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1507 P PCIBUS pBus = &pThis->PciBus;1468 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1469 PDEVPCIBUS pBus = &pThis->PciBus; 1508 1470 uint32_t u32; 1509 1471 int rc; … … 1622 1584 unsigned i; 1623 1585 uint8_t elcr[2] = {0, 0}; 1624 P PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1586 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1625 1587 PVM pVM = PDMDevHlpGetVM(pDevIns); Assert(pVM); 1626 1588 PVMCPU pVCpu = PDMDevHlpGetVMCPU(pDevIns); Assert(pVM); … … 1682 1644 static DECLCALLBACK(void) pciR3IrqRouteInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1683 1645 { 1684 P PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1646 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1685 1647 NOREF(pszArgs); 1686 1648 … … 1704 1666 static DECLCALLBACK(void) pciR3IrqInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1705 1667 { 1706 P PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1668 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1707 1669 NOREF(pszArgs); 1708 1670 … … 1733 1695 * of each device on the bus. 1734 1696 */ 1735 static void pciR3BusInfo(P PCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bool fRegisters)1697 static void pciR3BusInfo(PDEVPCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bool fRegisters) 1736 1698 { 1737 1699 for (uint32_t iDev = 0; iDev < RT_ELEMENTS(pBus->apDevices); iDev++) … … 1834 1796 for (uint32_t iBridge = 0; iBridge < pBus->cBridges; iBridge++) 1835 1797 { 1836 P PCIBUS pBusSub = PDMINS_2_DATA(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns), PPCIBUS);1798 PDEVPCIBUS pBusSub = PDMINS_2_DATA(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 1837 1799 pciR3BusInfo(pBusSub, pHlp, iIndent + 1, fRegisters); 1838 1800 } … … 1846 1808 static DECLCALLBACK(void) pciR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1847 1809 { 1848 P PCIBUS pBus = DEVINS_2_PCIBUS(pDevIns);1810 PDEVPCIBUS pBus = DEVINS_2_DEVPCIBUS(pDevIns); 1849 1811 1850 1812 if (pszArgs == NULL || !*pszArgs || !strcmp(pszArgs, "basic")) … … 1864 1826 static DECLCALLBACK(void) pciR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 1865 1827 { 1866 P PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1867 P PCIBUS pBus = &pGlobals->PciBus;1828 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1829 PDEVPCIBUS pBus = &pGlobals->PciBus; 1868 1830 pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1869 1831 … … 1929 1891 * Init data and register the PCI bus. 1930 1892 */ 1931 P PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);1893 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1932 1894 pGlobals->uPciBiosIo = 0xc000; 1933 1895 pGlobals->uPciBiosMmio = 0xf0000000; … … 1953 1915 1954 1916 PDMPCIBUSREG PciBusReg; 1955 P PCIBUS pBus = &pGlobals->PciBus;1917 PDEVPCIBUS pBus = &pGlobals->PciBus; 1956 1918 PciBusReg.u32Version = PDM_PCIBUSREG_VERSION; 1957 1919 PciBusReg.pfnRegisterR3 = pciR3MergedRegister; … … 2073 2035 1, 2074 2036 /* cbInstance */ 2075 sizeof( PCIGLOBALS),2037 sizeof(DEVPCIROOT), 2076 2038 /* pfnConstruct */ 2077 2039 pciR3Construct, … … 2124 2086 * of our parent passing the device which asserted the interrupt instead of the device of the bridge. 2125 2087 */ 2126 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2088 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2127 2089 PPDMPCIDEV pPciDevBus = pPciDev; 2128 2090 int iIrqPinBridge = iIrq; … … 2141 2103 2142 2104 AssertMsg(pBus->iBus == 0, ("This is not the host pci bus iBus=%d\n", pBus->iBus)); 2143 pciSetIrqInternal( PCIBUS_2_PCIGLOBALS(pBus), uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc);2105 pciSetIrqInternal(DEVPCIBUS_2_DEVPCIROOT(pBus), uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc); 2144 2106 } 2145 2107 … … 2151 2113 static DECLCALLBACK(void) pcibridgeR3ConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb) 2152 2114 { 2153 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2115 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2154 2116 2155 2117 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, u32Value, cb)); … … 2183 2145 static DECLCALLBACK(uint32_t) pcibridgeR3ConfigRead(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb) 2184 2146 { 2185 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2147 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2186 2148 uint32_t u32Value = 0xffffffff; /* Return value in case there is no device. */ 2187 2149 … … 2218 2180 static DECLCALLBACK(int) pcibridgeR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 2219 2181 { 2220 P PCIBUS pThis = PDMINS_2_DATA(pDevIns, PPCIBUS);2182 PDEVPCIBUS pThis = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2221 2183 return pciR3CommonSaveExec(pThis, pSSM); 2222 2184 } … … 2228 2190 static DECLCALLBACK(int) pcibridgeR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 2229 2191 { 2230 P PCIBUS pThis = PDMINS_2_DATA(pDevIns, PPCIBUS);2192 PDEVPCIBUS pThis = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2231 2193 if (uVersion > VBOX_PCI_SAVED_STATE_VERSION) 2232 2194 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; … … 2240 2202 static DECLCALLBACK(void) pcibridgeR3Reset(PPDMDEVINS pDevIns) 2241 2203 { 2242 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2204 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2243 2205 2244 2206 /* Reset config space to default values. */ … … 2254 2216 static DECLCALLBACK(void) pcibridgeR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 2255 2217 { 2256 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2218 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2257 2219 pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 2258 2220 … … 2297 2259 * Init data and register the PCI bus. 2298 2260 */ 2299 P PCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);2261 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2300 2262 pBus->fTypePiix3 = true; 2301 2263 pBus->fTypeIch9 = false; … … 2442 2404 2443 2405 #endif /* IN_RING3 */ 2444 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 2406 -
trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
r64419 r64420 52 52 * Structures and Typedefs * 53 53 *********************************************************************************************************************************/ 54 typedef DEVPCIBUS ICH9PCIBUS;55 typedef PDEVPCIBUS PICH9PCIBUS;56 typedef DEVPCIROOT ICH9PCIGLOBALS;57 typedef PDEVPCIROOT PICH9PCIGLOBALS;58 59 60 61 62 54 /** 63 55 * PCI configuration space address. … … 70 62 } PciAddress; 71 63 72 #ifndef VBOX_DEVICE_STRUCT_TESTCASE73 74 64 75 65 /********************************************************************************************************************************* 76 66 * Defined Constants And Macros * 77 67 *********************************************************************************************************************************/ 78 79 68 /** @def VBOX_ICH9PCI_SAVED_STATE_VERSION 80 69 * Saved state version of the ICH9 PCI bus device. … … 84 73 #define VBOX_ICH9PCI_SAVED_STATE_VERSION_CURRENT VBOX_ICH9PCI_SAVED_STATE_VERSION_MSI 85 74 86 /** Converts a bus instance pointer to a device instance pointer. */ 87 #define PCIBUS_2_DEVINS(pPciBus) ((pPciBus)->CTX_SUFF(pDevIns)) 88 /** Converts a device instance pointer to a ICH9PCIGLOBALS pointer. */ 89 #define DEVINS_2_PCIGLOBALS(pDevIns) ((PICH9PCIGLOBALS)(PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS))) 90 /** Converts a device instance pointer to a PCIBUS pointer. */ 91 #define DEVINS_2_PCIBUS(pDevIns) ((PICH9PCIBUS)(&PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS)->PciBus)) 92 /** Converts a pointer to a PCI root bus instance to a PCIGLOBALS pointer. */ 93 #define PCIROOTBUS_2_PCIGLOBALS(pPciBus) ( (PICH9PCIGLOBALS)((uintptr_t)(pPciBus) - RT_OFFSETOF(ICH9PCIGLOBALS, PciBus)) ) 94 95 /** @def PCI_LOCK 96 * Acquires the PDM lock. This is a NOP if locking is disabled. */ 97 /** @def PCI_UNLOCK 98 * Releases the PDM lock. This is a NOP if locking is disabled. */ 99 #define PCI_LOCK(pDevIns, rc) \ 100 do { \ 101 int rc2 = DEVINS_2_PCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \ 102 if (rc2 != VINF_SUCCESS) \ 103 return rc2; \ 104 } while (0) 105 #define PCI_UNLOCK(pDevIns) \ 106 DEVINS_2_PCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns) 107 75 76 /********************************************************************************************************************************* 77 * Internal Functions * 78 *********************************************************************************************************************************/ 108 79 /* Prototypes */ 109 static void ich9pciSetIrqInternal(P ICH9PCIGLOBALSpGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev,80 static void ich9pciSetIrqInternal(PDEVPCIROOT pGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev, 110 81 int iIrq, int iLevel, uint32_t uTagSrc); 111 82 #ifdef IN_RING3 … … 114 85 static DECLCALLBACK(uint32_t) ich9pciConfigReadDev(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t u32Address, unsigned len); 115 86 static DECLCALLBACK(void) ich9pciConfigWriteDev(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t u32Address, uint32_t val, unsigned len); 116 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(P ICH9PCIBUS pBus, uint8_t iBus);117 static void ich9pciBiosInitDevice(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn);87 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(PDEVPCIBUS pBus, uint8_t iBus); 88 static void ich9pciBiosInitDevice(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn); 118 89 #endif 119 90 120 91 // See 7.2.2. PCI Express Enhanced Configuration Mechanism for details of address 121 92 // mapping, we take n=6 approach 122 DECLINLINE(void) ich9pciPhysToPciAddr(P ICH9PCIGLOBALSpGlobals, RTGCPHYS GCPhysAddr, PciAddress* pPciAddr)93 DECLINLINE(void) ich9pciPhysToPciAddr(PDEVPCIROOT pGlobals, RTGCPHYS GCPhysAddr, PciAddress* pPciAddr) 123 94 { 124 95 NOREF(pGlobals); … … 128 99 } 129 100 130 DECLINLINE(void) ich9pciStateToPciAddr(P ICH9PCIGLOBALSpGlobals, RTGCPHYS addr, PciAddress* pPciAddr)101 DECLINLINE(void) ich9pciStateToPciAddr(PDEVPCIROOT pGlobals, RTGCPHYS addr, PciAddress* pPciAddr) 131 102 { 132 103 pPciAddr->iBus = (pGlobals->uConfigReg >> 16) & 0xff; … … 138 109 { 139 110 LogFlowFunc(("invoked by %p/%d: iIrq=%d iLevel=%d uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, iIrq, iLevel, uTagSrc)); 140 ich9pciSetIrqInternal(PDMINS_2_DATA(pDevIns, P ICH9PCIGLOBALS), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc);111 ich9pciSetIrqInternal(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 141 112 } 142 113 … … 150 121 * of our parent passing the device which asserted the interrupt instead of the device of the bridge. 151 122 */ 152 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);123 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 153 124 PPDMPCIDEV pPciDevBus = pPciDev; 154 125 int iIrqPinBridge = iIrq; … … 167 138 168 139 AssertMsgReturnVoid(pBus->iBus == 0, ("This is not the host pci bus iBus=%d\n", pBus->iBus)); 169 ich9pciSetIrqInternal( PCIROOTBUS_2_PCIGLOBALS(pBus), uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc);140 ich9pciSetIrqInternal(DEVPCIBUS_2_DEVPCIROOT(pBus), uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc); 170 141 } 171 142 … … 191 162 if (cb == 4) 192 163 { 193 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);164 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 194 165 195 166 /* … … 227 198 if (cb == 4) 228 199 { 229 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);200 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 230 201 231 202 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ); … … 245 216 * Perform configuration space write. 246 217 */ 247 static int ich9pciDataWriteAddr(P ICH9PCIGLOBALSpGlobals, PciAddress* pAddr,218 static int ich9pciDataWriteAddr(PDEVPCIROOT pGlobals, PciAddress* pAddr, 248 219 uint32_t val, int cb, int rcReschedule) 249 220 { … … 300 271 * similarly named functions. 301 272 */ 302 static int ich9pciDataWrite(P ICH9PCIGLOBALSpGlobals, uint32_t addr, uint32_t val, int len)273 static int ich9pciDataWrite(PDEVPCIROOT pGlobals, uint32_t addr, uint32_t val, int len) 303 274 { 304 275 LogFlow(("ich9pciDataWrite: config=%08x val=%08x len=%d\n", pGlobals->uConfigReg, val, len)); … … 338 309 if (!(Port % cb)) 339 310 { 340 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);311 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 341 312 342 313 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE); … … 360 331 * Perform configuration space read. 361 332 */ 362 static int ich9pciDataReadAddr(P ICH9PCIGLOBALSpGlobals, PciAddress* pPciAddr, int cb,333 static int ich9pciDataReadAddr(PDEVPCIROOT pGlobals, PciAddress* pPciAddr, int cb, 363 334 uint32_t *pu32, int rcReschedule) 364 335 { … … 419 390 * similarly named functions. 420 391 */ 421 static int ich9pciDataRead(P ICH9PCIGLOBALSpGlobals, uint32_t addr, int cb, uint32_t *pu32)392 static int ich9pciDataRead(PDEVPCIROOT pGlobals, uint32_t addr, int cb, uint32_t *pu32) 422 393 { 423 394 LogFlow(("ich9pciDataRead: config=%x cb=%d\n", pGlobals->uConfigReg, cb)); … … 457 428 if (!(Port % cb)) 458 429 { 459 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);430 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 460 431 461 432 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ); … … 495 466 496 467 /* Add one more level up request on APIC input line */ 497 DECLINLINE(void) ich9pciApicLevelUp(P ICH9PCIGLOBALSpGlobals, int irq_num)468 DECLINLINE(void) ich9pciApicLevelUp(PDEVPCIROOT pGlobals, int irq_num) 498 469 { 499 470 ASMAtomicIncU32(&pGlobals->auPciApicIrqLevels[irq_num]); … … 501 472 502 473 /* Remove one level up request on APIC input line */ 503 DECLINLINE(void) ich9pciApicLevelDown(P ICH9PCIGLOBALSpGlobals, int irq_num)474 DECLINLINE(void) ich9pciApicLevelDown(PDEVPCIROOT pGlobals, int irq_num) 504 475 { 505 476 ASMAtomicDecU32(&pGlobals->auPciApicIrqLevels[irq_num]); 506 477 } 507 478 508 static void ich9pciApicSetIrq(P ICH9PCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel,479 static void ich9pciApicSetIrq(PDEVPCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, 509 480 uint32_t uTagSrc, int iForcedIrq) 510 481 { … … 515 486 { 516 487 int apic_irq, apic_level; 517 P ICH9PCIGLOBALS pGlobals = PCIROOTBUS_2_PCIGLOBALS(pBus);488 PDEVPCIROOT pGlobals = DEVPCIBUS_2_DEVPCIROOT(pBus); 518 489 int irq_num = ich9pciSlot2ApicIrq(uDevFn >> 3, irq_num1); 519 490 … … 549 520 } 550 521 551 static void ich9pciSetIrqInternal(P ICH9PCIGLOBALSpGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev,522 static void ich9pciSetIrqInternal(PDEVPCIROOT pGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev, 552 523 int iIrq, int iLevel, uint32_t uTagSrc) 553 524 { … … 574 545 } 575 546 576 P ICH9PCIBUS pBus = &pGlobals->PciBus;547 PDEVPCIBUS pBus = &pGlobals->PciBus; 577 548 const bool fIsAcpiDevice = PCIDevGetDeviceId(pPciDev) == 0x7113; 578 549 … … 615 586 PDMBOTHCBDECL(int) ich9pciMcfgMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 616 587 { 617 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);588 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 618 589 uint32_t u32 = 0; 619 590 NOREF(pvUser); … … 667 638 PDMBOTHCBDECL(int) ich9pciMcfgMMIORead (PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 668 639 { 669 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);640 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 670 641 uint32_t rv; 671 642 NOREF(pvUser); … … 719 690 720 691 721 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(P ICH9PCIBUS pBus, uint8_t iBus)692 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(PDEVPCIBUS pBus, uint8_t iBus) 722 693 { 723 694 /* Search for a fitting bridge. */ … … 774 745 PCIIORegion* pRegion = &pDev->Int.s.aIORegions[iRegion]; 775 746 int rc = VINF_SUCCESS; 776 P ICH9PCIBUS pBus = pDev->Int.s.CTX_SUFF(pBus);747 PDEVPCIBUS pBus = pDev->Int.s.CTX_SUFF(pBus); 777 748 778 749 Assert (pRegion->size != 0); … … 980 951 } 981 952 982 static int ich9pciR3CommonSaveExec(P ICH9PCIBUS pBus, PSSMHANDLE pSSM)953 static int ich9pciR3CommonSaveExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM) 983 954 { 984 955 /* … … 1035 1006 static DECLCALLBACK(int) ich9pciR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1036 1007 { 1037 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);1008 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1038 1009 1039 1010 /* … … 1056 1027 static DECLCALLBACK(int) ich9pcibridgeR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1057 1028 { 1058 P ICH9PCIBUS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);1029 PDEVPCIBUS pThis = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1059 1030 return ich9pciR3CommonSaveExec(pThis, pSSM); 1060 1031 } … … 1063 1034 static DECLCALLBACK(void) ich9pcibridgeConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb) 1064 1035 { 1065 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);1036 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1066 1037 1067 1038 LogFlowFunc((": pDevIns=%p iBus=%d iDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, u32Value, cb)); … … 1092 1063 static DECLCALLBACK(uint32_t) ich9pcibridgeConfigRead(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb) 1093 1064 { 1094 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);1065 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1095 1066 uint32_t u32Value; 1096 1067 … … 1303 1274 * @param uPass The pass. 1304 1275 */ 1305 static DECLCALLBACK(int) ich9pciR3CommonLoadExec(P ICH9PCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)1276 static DECLCALLBACK(int) ich9pciR3CommonLoadExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1306 1277 { 1307 1278 uint32_t u32; … … 1444 1415 static DECLCALLBACK(int) ich9pciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1445 1416 { 1446 P ICH9PCIGLOBALS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);1447 P ICH9PCIBUS pBus = &pThis->PciBus;1417 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1418 PDEVPCIBUS pBus = &pThis->PciBus; 1448 1419 uint32_t u32; 1449 1420 int rc; … … 1478 1449 static DECLCALLBACK(int) ich9pcibridgeR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1479 1450 { 1480 P ICH9PCIBUS pThis = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);1451 PDEVPCIBUS pThis = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1481 1452 if (uVersion > VBOX_ICH9PCI_SAVED_STATE_VERSION_MSI) 1482 1453 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; … … 1489 1460 * Cannot be rescheduled, as already in R3. 1490 1461 */ 1491 static uint32_t ich9pciConfigRead(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t len)1462 static uint32_t ich9pciConfigRead(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t len) 1492 1463 { 1493 1464 PciAddress aPciAddr; … … 1508 1479 * Cannot be rescheduled, as already in R3. 1509 1480 */ 1510 static void ich9pciConfigWrite(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val, uint32_t len)1481 static void ich9pciConfigWrite(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val, uint32_t len) 1511 1482 { 1512 1483 PciAddress aPciAddr; … … 1520 1491 1521 1492 1522 static void ich9pciSetRegionAddress(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn, int iRegion, uint64_t addr)1493 static void ich9pciSetRegionAddress(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, int iRegion, uint64_t addr) 1523 1494 { 1524 1495 uint32_t uReg = ich9pciGetRegionReg(iRegion); … … 1539 1510 1540 1511 1541 static void ich9pciBiosInitBridge(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn)1512 static void ich9pciBiosInitBridge(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn) 1542 1513 { 1543 1514 Log(("BIOS init bridge: %02x::%02x.%d\n", uBus, uDevFn >> 3, uDevFn & 7)); … … 1605 1576 } 1606 1577 1607 static void ich9pciBiosInitDevice(P ICH9PCIGLOBALSpGlobals, uint8_t uBus, uint8_t uDevFn)1578 static void ich9pciBiosInitDevice(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn) 1608 1579 { 1609 1580 uint16_t uDevClass, uVendor, uDevice; … … 1784 1755 { 1785 1756 /* Find bus this device attached to. */ 1786 P ICH9PCIBUS pBus = &pGlobals->PciBus;1757 PDEVPCIBUS pBus = &pGlobals->PciBus; 1787 1758 while (1) 1788 1759 { … … 1798 1769 break; 1799 1770 } 1800 pBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), P ICH9PCIBUS);1771 pBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 1801 1772 } 1802 1773 … … 1828 1799 * @param uBusSecondary The secondary bus number, i.e. the bus number behind the bridge. 1829 1800 */ 1830 static void ich9pciInitBridgeTopology(P ICH9PCIGLOBALS pGlobals, PICH9PCIBUS pBus, unsigned uBusPrimary,1801 static void ich9pciInitBridgeTopology(PDEVPCIROOT pGlobals, PDEVPCIBUS pBus, unsigned uBusPrimary, 1831 1802 unsigned uBusSecondary) 1832 1803 { … … 1845 1816 AssertMsg(pBridge && pciDevIsPci2PciBridge(pBridge), 1846 1817 ("Device is not a PCI bridge but on the list of PCI bridges\n")); 1847 P ICH9PCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PICH9PCIBUS);1818 PDEVPCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 1848 1819 pGlobals->uPciBiosBus++; 1849 1820 ich9pciInitBridgeTopology(pGlobals, pChildBus, uBusSecondary, pGlobals->uPciBiosBus); … … 1861 1832 static DECLCALLBACK(int) ich9pciFakePCIBIOS(PPDMDEVINS pDevIns) 1862 1833 { 1863 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);1834 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1864 1835 PVM pVM = PDMDevHlpGetVM(pDevIns); 1865 1836 uint32_t const cbBelow4GB = MMR3PhysGetRamSizeBelow4GB(pVM); … … 1885 1856 * Assign bridge topology, for further routing to work. 1886 1857 */ 1887 P ICH9PCIBUS pBus = &pGlobals->PciBus;1858 PDEVPCIBUS pBus = &pGlobals->PciBus; 1888 1859 ich9pciInitBridgeTopology(pGlobals, pBus, 0, 0); 1889 1860 … … 2166 2137 } 2167 2138 2168 static void ich9pciBusInfo(P ICH9PCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bool fRegisters)2139 static void ich9pciBusInfo(PDEVPCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bool fRegisters) 2169 2140 { 2170 2141 for (uint32_t iDev = 0; iDev < RT_ELEMENTS(pBus->apDevices); iDev++) … … 2284 2255 for (uint32_t iBridge = 0; iBridge < pBus->cBridges; iBridge++) 2285 2256 { 2286 P ICH9PCIBUS pBusSub = PDMINS_2_DATA(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns), PICH9PCIBUS);2257 PDEVPCIBUS pBusSub = PDMINS_2_DATA(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 2287 2258 ich9pciBusInfo(pBusSub, pHlp, iIndent + 1, fRegisters); 2288 2259 } … … 2299 2270 static DECLCALLBACK(void) ich9pciInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2300 2271 { 2301 P ICH9PCIBUS pBus = DEVINS_2_PCIBUS(pDevIns);2272 PDEVPCIBUS pBus = DEVINS_2_DEVPCIBUS(pDevIns); 2302 2273 2303 2274 if (pszArgs == NULL || !strcmp(pszArgs, "basic")) … … 2359 2330 * Init data. 2360 2331 */ 2361 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);2362 P ICH9PCIBUS pBus = &pGlobals->PciBus;2332 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 2333 PDEVPCIBUS pBus = &pGlobals->PciBus; 2363 2334 /* Zero out everything */ 2364 2335 memset(pGlobals, 0, sizeof(*pGlobals)); … … 2563 2534 static DECLCALLBACK(void) ich9pciReset(PPDMDEVINS pDevIns) 2564 2535 { 2565 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);2566 P ICH9PCIBUS pBus = &pGlobals->PciBus;2536 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 2537 PDEVPCIBUS pBus = &pGlobals->PciBus; 2567 2538 2568 2539 /* PCI-specific reset for each device. */ … … 2597 2568 static DECLCALLBACK(void) ich9pciRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 2598 2569 { 2599 P ICH9PCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PICH9PCIGLOBALS);2600 P ICH9PCIBUS pBus = &pGlobals->PciBus;2570 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 2571 PDEVPCIBUS pBus = &pGlobals->PciBus; 2601 2572 pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 2602 2573 … … 2643 2614 * Init data and register the PCI bus. 2644 2615 */ 2645 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);2616 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2646 2617 pBus->fTypePiix3 = false; 2647 2618 pBus->fTypeIch9 = true; … … 2741 2712 static void ich9pcibridgeReset(PPDMDEVINS pDevIns) 2742 2713 { 2743 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);2714 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2744 2715 2745 2716 /* Reset config space to default values. */ … … 2762 2733 static DECLCALLBACK(void) ich9pcibridgeRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 2763 2734 { 2764 P ICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);2735 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 2765 2736 pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 2766 2737 … … 2792 2763 1, 2793 2764 /* cbInstance */ 2794 sizeof( ICH9PCIGLOBALS),2765 sizeof(DEVPCIROOT), 2795 2766 /* pfnConstruct */ 2796 2767 ich9pciConstruct, … … 2882 2853 2883 2854 #endif /* IN_RING3 */ 2884 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 2855 -
trunk/src/VBox/Devices/Bus/DevPciInternal.h
r64419 r64420 162 162 163 163 164 /** Converts a PCI bus device instance pointer to a DEVPCIBUS pointer. */ 165 #define DEVINS_2_DEVPCIBUS(pDevIns) (&PDMINS_2_DATA(pDevIns, PDEVPCIROOT)->PciBus) 166 /** Converts a pointer to a PCI bus instance to a DEVPCIROOT pointer. */ 167 #define DEVPCIBUS_2_DEVPCIROOT(pPciBus) RT_FROM_MEMBER(pPciBus, DEVPCIROOT, PciBus) 168 169 /** @def PCI_LOCK 170 * Acquires the PDM lock. This is a NOP if locking is disabled. */ 171 /** @def PCI_UNLOCK 172 * Releases the PDM lock. This is a NOP if locking is disabled. */ 173 #define PCI_LOCK(pDevIns, rc) \ 174 do { \ 175 int rc2 = DEVINS_2_DEVPCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \ 176 if (rc2 != VINF_SUCCESS) \ 177 return rc2; \ 178 } while (0) 179 #define PCI_UNLOCK(pDevIns) \ 180 DEVINS_2_DEVPCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns) 181 182 164 183 #endif 165 184 -
trunk/src/VBox/Devices/Bus/DevPciMerge1.cpp.h
r64414 r64420 221 221 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName) 222 222 { 223 PDEVPCIBUS pBus = DEVINS_2_PCIBUS(pDevIns); 223 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 224 AssertCompileMemberOffset(DEVPCIROOT, PciBus, 0); 224 225 return pciR3MergedRegisterDeviceOnBus(pBus, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName, 225 226 pciR3UnmergedConfigReadDev, pciR3UnmergedConfigWriteDev);
Note:
See TracChangeset
for help on using the changeset viewer.