Changeset 44795 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 21, 2013 7:49:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevPCI.cpp
r44508 r44795 179 179 /** Converts a bus instance pointer to a device instance pointer. */ 180 180 #define PCIBUS_2_DEVINS(pPciBus) ((pPciBus)->CTX_SUFF(pDevIns)) 181 /** Converts a device instance pointer to a PCIGLOBALS pointer. */181 /** Converts a PCI bus device instance pointer to a PCIGLOBALS pointer. */ 182 182 #define DEVINS_2_PCIGLOBALS(pDevIns) ((PPCIGLOBALS)(PDMINS_2_DATA(pDevIns, PPCIGLOBALS))) 183 /** Converts a device instance pointer to a PCIBUS pointer. */183 /** Converts a PCI bus device instance pointer to a PCIBUS pointer. */ 184 184 #define DEVINS_2_PCIBUS(pDevIns) ((PPCIBUS)(&PDMINS_2_DATA(pDevIns, PPCIGLOBALS)->PciBus)) 185 185 … … 187 187 * @note This works only if the bus number is 0!!! 188 188 */ 189 #define PCIBUS_2_PCIGLOBALS(pPciBus) ( (PPCIGLOBALS)((uintptr_t)(pPciBus) - RT_OFFSETOF(PCIGLOBALS, PciBus)))189 #define PCIBUS_2_PCIGLOBALS(pPciBus) RT_FROM_MEMBER(pPciBus, PCIGLOBALS, PciBus) 190 190 191 191 /** @def PCI_LOCK … … 743 743 } 744 744 745 /** 746 * Set the IRQ for a PCI device on the host bus. 747 * 748 * @param pDevIns Device instance of the PCI Bus. 749 * @param pPciDev The PCI device structure. 750 * @param iIrq IRQ number to set. 751 * @param iLevel IRQ level. 752 * @param uTagSrc The IRQ tag and source ID (for tracing). 745 746 /** 747 * @interface_method_impl{PDMPCIBUSREG,pfnSetIrq} 753 748 */ 754 749 PDMBOTHCBDECL(void) pciSetIrq(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) … … 1125 1120 #endif /* IN_RING3 */ 1126 1121 1127 /* -=-=-=-=-=- wrappers -=-=-=-=-=- */ 1128 1129 /** 1130 * Port I/O Handler for PCI address OUT operations. 1131 * 1132 * @returns VBox status code. 1133 * 1134 * @param pDevIns The device instance. 1135 * @param pvUser User argument - ignored. 1136 * @param uPort Port number used for the IN operation. 1137 * @param u32 The value to output. 1138 * @param cb The value size in bytes. 1122 1123 /* -=-=-=-=-=- I/O ports -=-=-=-=-=- */ 1124 1125 /** 1126 * @callback_method_impl{FNIOMIOPORTOUT, PCI address} 1139 1127 */ 1140 1128 PDMBOTHCBDECL(int) pciIOPortAddressWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) … … 1156 1144 1157 1145 /** 1158 * Port I/O Handler for PCI address IN operations. 1159 * 1160 * @returns VBox status code. 1161 * 1162 * @param pDevIns The device instance. 1163 * @param pvUser User argument - ignored. 1164 * @param uPort Port number used for the IN operation. 1165 * @param pu32 Where to store the result. 1166 * @param cb Number of bytes read. 1146 * @callback_method_impl{FNIOMIOPORTIN, PCI address} 1167 1147 */ 1168 1148 PDMBOTHCBDECL(int) pciIOPortAddressRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) … … 1186 1166 1187 1167 /** 1188 * Port I/O Handler for PCI data OUT operations. 1189 * 1190 * @returns VBox status code. 1191 * 1192 * @param pDevIns The device instance. 1193 * @param pvUser User argument - ignored. 1194 * @param uPort Port number used for the IN operation. 1195 * @param u32 The value to output. 1196 * @param cb The value size in bytes. 1168 * @callback_method_impl{FNIOMIOPORTOUT, PCI data} 1197 1169 */ 1198 1170 PDMBOTHCBDECL(int) pciIOPortDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) … … 1214 1186 1215 1187 /** 1216 * Port I/O Handler for PCI data IN operations. 1217 * 1218 * @returns VBox status code. 1219 * 1220 * @param pDevIns The device instance. 1221 * @param pvUser User argument - ignored. 1222 * @param uPort Port number used for the IN operation. 1223 * @param pu32 Where to store the result. 1224 * @param cb Number of bytes read. 1188 * @callback_method_impl{FNIOMIOPORTIN, PCI data} 1225 1189 */ 1226 1190 PDMBOTHCBDECL(int) pciIOPortDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) … … 1241 1205 #ifdef IN_RING3 1242 1206 1207 /* -=-=-=-=-=- Saved state -=-=-=-=-=- */ 1208 1243 1209 /** 1244 1210 * Common worker for pciR3SaveExec and pcibridgeR3SaveExec. … … 1271 1237 1272 1238 /** 1273 * Saves a state of the PCI device. 1274 * 1275 * @returns VBox status code. 1276 * @param pDevIns The device instance. 1277 * @param pPciDev Pointer to PCI device. 1278 * @param pSSM The handle to save the state to. 1239 * @callback_method_impl{FNSSMDEVSAVEEXEC} 1279 1240 */ 1280 1241 static DECLCALLBACK(int) pciR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) … … 1593 1554 1594 1555 /** 1595 * Loads a saved PCI device state. 1596 * 1597 * @returns VBox status code. 1598 * @param pDevIns The device instance. 1599 * @param pSSM The handle to the saved state. 1600 * @param uVersion The data unit version number. 1601 * @param uPass The data pass. 1556 * @callback_method_impl{FNSSMDEVLOADEXEC} 1602 1557 */ 1603 1558 static DECLCALLBACK(int) pciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) … … 1648 1603 1649 1604 1650 /* -=-=-=-=-=- real code-=-=-=-=-=- */1605 /* -=-=-=-=-=- PCI Bus Interface Methods (PDMPCIBUSREG) -=-=-=-=-=- */ 1651 1606 1652 1607 /** … … 1791 1746 1792 1747 /** 1793 * Registers the device with the default PCI bus. 1794 * 1795 * @returns VBox status code. 1796 * @param pDevIns Device instance of the PCI Bus. 1797 * @param pPciDev The PCI device structure. 1798 * Any PCI enabled device must keep this in it's instance data! 1799 * Fill in the PCI data config before registration, please. 1800 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique. 1801 * @param iDev The PCI device number. Use a negative value for auto assigning one. 1748 * @interface_method_impl{PDMPCIBUSREG,pfnRegister} 1802 1749 */ 1803 1750 static DECLCALLBACK(int) pciR3Register(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev) … … 1824 1771 1825 1772 1773 /** 1774 * @interface_method_impl{PDMPCIBUSREG,pfnIORegionRegisterR3} 1775 */ 1826 1776 static DECLCALLBACK(int) pciR3CommonIORegionRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, 1827 1777 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback) … … 1866 1816 1867 1817 /** 1868 * @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksR3 1869 */ 1870 static DECLCALLBACK(void) pciR3CommonSetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 1871 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld) 1818 * @interface_method_impl{PDMPCIBUSREG,pfnSetConfigCallbacksR3} 1819 */ 1820 static DECLCALLBACK(void) 1821 pciR3CommonSetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 1822 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld) 1872 1823 { 1873 1824 NOREF(pDevIns); … … 1884 1835 1885 1836 /** 1886 * Called to perform the job of the bios. 1887 * 1888 * @returns VBox status. 1889 * @param pDevIns Device instance of the first bus. 1837 * @interface_method_impl{PDMPCIBUSREG,pfnFakePCIBIOSR3} 1890 1838 */ 1891 1839 static DECLCALLBACK(int) pciR3FakePCIBIOS(PPDMDEVINS pDevIns) … … 1942 1890 } 1943 1891 1944 /** 1945 * Info handler, device version. 1946 * 1947 * @param pDevIns Device instance which registered the info. 1948 * @param pHlp Callback functions for doing output. 1949 * @param pszArgs Argument string. Optional and specific to the handler. 1892 1893 /* -=-=-=-=-=- Debug Info Handlers -=-=-=-=-=- */ 1894 1895 /** 1896 * @callback_method_impl{FNDBGFHANDLERDEV} 1950 1897 */ 1951 1898 static DECLCALLBACK(void) pciR3IrqInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1952 1899 { 1953 1900 PPCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS); 1954 uint16_t router;1955 uint8_t irq_map;1956 int i;1957 1901 NOREF(pszArgs); 1958 1902 1959 router = pGlobals->PIIX3State.dev.devfn;1903 uint16_t router = pGlobals->PIIX3State.dev.devfn; 1960 1904 pHlp->pfnPrintf(pHlp, "PCI interrupt router at: %02X:%02X:%X\n", 1961 1905 router >> 8, (router >> 3) & 0x1f, router & 0x7); 1962 1906 1963 for (i = 0; i < 4; ++i)1964 { 1965 irq_map = pci_config_readb(pGlobals, 0, router, 0x60 + i);1907 for (int i = 0; i < 4; ++i) 1908 { 1909 uint8_t irq_map = pci_config_readb(pGlobals, 0, router, 0x60 + i); 1966 1910 if (irq_map & 0x80) 1967 1911 pHlp->pfnPrintf(pHlp, "PIRQ%c disabled\n", 'A' + i); … … 1971 1915 } 1972 1916 1917 /** 1918 * Outputs indent. 1919 * 1920 * @param pHlp Output helpers. 1921 * @param iIndent Indentation level. 1922 */ 1973 1923 static void pciR3PrintIndent(PCDBGFINFOHLP pHlp, int iIndent) 1974 1924 { … … 1977 1927 } 1978 1928 1929 /** 1930 * Recursive worker for pciR3Info. 1931 * 1932 * @param pBus The bus to display. 1933 * @param pHlp Output helpers. 1934 * @param iIndent Indentation level. 1935 * @param fRegisters Whether to also display the PCI configuration registers 1936 * of each device on the bus. 1937 */ 1979 1938 static void pciR3BusInfo(PPCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bool fRegisters) 1980 1939 { … … 2081 2040 } 2082 2041 2083 /** 2084 * Info handler, device version. 2085 * 2086 * @param pDevIns Device instance which registered the info. 2087 * @param pHlp Callback functions for doing output. 2088 * @param pszArgs Argument string. Optional and specific to the handler. 2042 2043 /** 2044 * @callback_method_impl{FNDBGFHANDLERDEV} 2089 2045 */ 2090 2046 static DECLCALLBACK(void) pciR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) … … 2100 2056 } 2101 2057 2102 /** 2103 * @copydoc FNPDMDEVRELOCATE 2058 2059 /* -=-=-=-=-=- PDMDEVREG -=-=-=-=-=- */ 2060 2061 /** 2062 * @interface_method_impl{PDMDEVREG,pfnRelocate} 2104 2063 */ 2105 2064 static DECLCALLBACK(void) pciR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) … … 2122 2081 2123 2082 /** 2124 * @ copydoc FNPDMDEVRESET2083 * @interface_method_impl{PDMDEVREG,pfnReset} 2125 2084 */ 2126 2085 static DECLCALLBACK(void) pciR3Reset(PPDMDEVINS pDevIns) … … 2128 2087 pciR3FakePCIBIOS(pDevIns); 2129 2088 } 2089 2130 2090 2131 2091 /** … … 2343 2303 2344 2304 2345 /** 2346 * Set the IRQ for a PCI device on a secondary bus. 2347 * 2348 * @param pDevIns Device instance of the PCI Bus. 2349 * @param pPciDev The PCI device structure. 2350 * @param iIrq IRQ number to set. 2351 * @param iLevel IRQ level. 2352 * @param uTagSrc The IRQ tag and source ID (for tracing). 2305 2306 /* -=-=-=-=-=- The PCI bridge specific bits -=-=-=-=-=- */ 2307 2308 /** 2309 * @interface_method_impl{PDMPCIBUSREG,pfnSetIrq} 2353 2310 */ 2354 2311 PDMBOTHCBDECL(void) pcibridgeSetIrq(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) … … 2390 2347 PPCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS); 2391 2348 2392 LogFlowFunc((" :pDevIns=%p iBus=%d iDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, u32Value, cb));2349 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, u32Value, cb)); 2393 2350 2394 2351 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 2414 2371 } 2415 2372 2373 2416 2374 /** 2417 2375 * @callback_method_impl{FNPCIBRIDGECONFIGREAD} … … 2422 2380 uint32_t u32Value = 0xffffffff; /* Return value in case there is no device. */ 2423 2381 2424 LogFlowFunc((" :pDevIns=%p iBus=%d iDevice=%d u32Address=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, cb));2382 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, cb)); 2425 2383 2426 2384 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 2450 2408 2451 2409 /** 2452 * @c opydoc FNSSMDEVSAVEEXEC2410 * @callback_method_impl{FNSSMDEVSAVEEXEC} 2453 2411 */ 2454 2412 static DECLCALLBACK(int) pcibridgeR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) … … 2460 2418 2461 2419 /** 2462 * @c opydoc FNSSMDEVLOADEXEC2420 * @callback_method_impl{FNSSMDEVLOADEXEC} 2463 2421 */ 2464 2422 static DECLCALLBACK(int) pcibridgeR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) … … 2472 2430 2473 2431 /** 2474 * Registers the device with the default PCI bus. 2475 * 2476 * @returns VBox status code. 2477 * @param pDevIns Device instance of the PCI Bus. 2478 * @param pPciDev The PCI device structure. 2479 * Any PCI enabled device must keep this in it's instance data! 2480 * Fill in the PCI data config before registration, please. 2481 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique. 2482 * @param iDev The PCI device number. Use a negative value for auto assigning one. 2432 * @interface_method_impl{PDMPCIBUSREG,pfnRegister} 2483 2433 */ 2484 2434 static DECLCALLBACK(int) pcibridgeR3RegisterDevice(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev) … … 2505 2455 2506 2456 /** 2507 * @ copydoc FNPDMDEVRESET2457 * @interface_method_impl{PDMDEVREG, pfnReset} 2508 2458 */ 2509 2459 static DECLCALLBACK(void) pcibridgeR3Reset(PPDMDEVINS pDevIns) … … 2519 2469 2520 2470 /** 2521 * @ copydoc FNPDMDEVRELOCATE2471 * @interface_method_impl{PDMDEVREG, pfnRelocate} 2522 2472 */ 2523 2473 static DECLCALLBACK(void) pcibridgeR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) … … 2612 2562 * devices attached to the bus is unaffected. 2613 2563 */ 2614 PCIDevSetInterruptPin 2564 PCIDevSetInterruptPin(&pBus->PciDev, 0x00); 2615 2565 2616 2566 pBus->PciDev.pDevIns = pDevIns; … … 2624 2574 * Register this PCI bridge. The called function will take care on which bus we will get registered. 2625 2575 */ 2626 rc = PDMDevHlpPCIRegister 2576 rc = PDMDevHlpPCIRegister(pDevIns, &pBus->PciDev); 2627 2577 if (RT_FAILURE(rc)) 2628 2578 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.