Changeset 80943 in vbox
- Timestamp:
- Sep 23, 2019 9:36:14 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133523
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r80845 r80943 1436 1436 * terminated all VMs and upgraded any extension packs. If this error 1437 1437 * persists, try re-installing VirtualBox. */ 1438 #define VERR_PDM_DEVHLP R3_VERSION_MISMATCH(-2871)1438 #define VERR_PDM_DEVHLP_VERSION_MISMATCH (-2871) 1439 1439 /** The USB device instance structure version has changed. 1440 1440 * … … 1523 1523 /** The I/O request is in an invalid state for this operation. */ 1524 1524 #define VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE (-2899) 1525 1526 /** Returned by PCI config space callbacks to indicate taking default action. */ 1527 #define VINF_PDM_PCI_DO_DEFAULT (7200) 1525 1528 /** @} */ 1526 1529 -
trunk/include/VBox/vmm/gvm.h
r80641 r80943 202 202 struct PDMR0PERVM s; 203 203 #endif 204 uint8_t padding[1 536];204 uint8_t padding[1792]; 205 205 } pdmr0; 206 206 … … 215 215 /** Padding so aCpus starts on a page boundrary. */ 216 216 #ifdef VBOX_WITH_NEM_R0 217 uint8_t abPadding2[4096 - 64 - 256 - 512 - 256 - 64 - 1 536- 256 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];218 #else 219 uint8_t abPadding2[4096 - 64 - 256 - 512 - 64 - 1 536- 256 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];217 uint8_t abPadding2[4096 - 64 - 256 - 512 - 256 - 64 - 1792 - 256 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT]; 218 #else 219 uint8_t abPadding2[4096 - 64 - 256 - 512 - 64 - 1792 - 256 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT]; 220 220 #endif 221 221 -
trunk/include/VBox/vmm/pdmdev.h
r80722 r80943 806 806 * All the callbacks, except the PCIBIOS hack, are working on PCI devices. 807 807 */ 808 typedef struct PDMPCIBUSREG 809 { 810 /** Structure version number. PDM_PCIBUSREG _VERSION defines the current version. */808 typedef struct PDMPCIBUSREGR3 809 { 810 /** Structure version number. PDM_PCIBUSREGR3_VERSION defines the current version. */ 811 811 uint32_t u32Version; 812 812 … … 868 868 869 869 /** 870 * Register PCI configuration space read/write callbacks.870 * Register PCI configuration space read/write intercept callbacks. 871 871 * 872 872 * @param pDevIns Device instance of the PCI Bus. 873 873 * @param pPciDev The PCI device structure. 874 874 * @param pfnRead Pointer to the user defined PCI config read function. 875 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)876 * PCI config read function. This way, user can decide when (and if)877 * to call default PCI config read function. Can be NULL.878 875 * @param pfnWrite Pointer to the user defined PCI config write function. 879 * @param ppfnWriteOld Pointer to function pointer which will receive the old (default)880 * PCI config write function. This way, user can decide when (and if)881 876 * to call default PCI config write function. Can be NULL. 882 877 * @remarks Caller enters the PDM critical section. 883 878 * @thread EMT 884 879 */ 885 DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 886 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 887 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)); 880 DECLR3CALLBACKMEMBER(void, pfnInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 881 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite)); 882 883 /** 884 * Perform a PCI configuration space write, bypassing interception. 885 * 886 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses(). 887 * 888 * @returns Strict VBox status code (mainly DBGFSTOP). 889 * @param pDevIns Device instance of the PCI Bus. 890 * @param pPciDev The PCI device which config space is being read. 891 * @param uAddress The config space address. 892 * @param cb The size of the read: 1, 2 or 4 bytes. 893 * @param u32Value The value to write. 894 * @note The caller (PDM) does not enter the PDM critsect, but it is possible 895 * that the (root) bus will have done that already. 896 */ 897 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 898 uint32_t uAddress, unsigned cb, uint32_t u32Value)); 899 900 /** 901 * Perform a PCI configuration space read, bypassing interception. 902 * 903 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses(). 904 * 905 * @returns Strict VBox status code (mainly DBGFSTOP). 906 * @param pDevIns Device instance of the PCI Bus. 907 * @param pPciDev The PCI device which config space is being read. 908 * @param uAddress The config space address. 909 * @param cb The size of the read: 1, 2 or 4 bytes. 910 * @param pu32Value Where to return the value. 911 * @note The caller (PDM) does not enter the PDM critsect, but it is possible 912 * that the (root) bus will have done that already. 913 */ 914 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 915 uint32_t uAddress, unsigned cb, uint32_t *pu32Value)); 888 916 889 917 /** … … 899 927 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 900 928 901 /** The name of the SetIrq RC entry point. */ 902 const char *pszSetIrqRC; 903 904 /** The name of the SetIrq R0 entry point. */ 905 const char *pszSetIrqR0; 906 907 } PDMPCIBUSREG; 929 /** Marks the end of the structure with PDM_PCIBUSREGR3_VERSION. */ 930 uint32_t u32EndVersion; 931 } PDMPCIBUSREGR3; 908 932 /** Pointer to a PCI bus registration structure. */ 909 typedef PDMPCIBUSREG *PPDMPCIBUSREG; 910 911 /** Current PDMPCIBUSREG version number. */ 912 #define PDM_PCIBUSREG_VERSION PDM_VERSION_MAKE(0xfffe, 7, 0) 933 typedef PDMPCIBUSREGR3 *PPDMPCIBUSREGR3; 934 /** Current PDMPCIBUSREGR3 version number. */ 935 #define PDM_PCIBUSREGR3_VERSION PDM_VERSION_MAKE(0xff86, 1, 0) 936 937 /** 938 * PCI Bus registration structure for ring-0. 939 */ 940 typedef struct PDMPCIBUSREGR0 941 { 942 /** Structure version number. PDM_PCIBUSREGR0_VERSION defines the current version. */ 943 uint32_t u32Version; 944 /** The PCI bus number (from ring-3 registration). */ 945 uint32_t iBus; 946 /** 947 * Set the IRQ for a PCI device. 948 * 949 * @param pDevIns Device instance of the PCI Bus. 950 * @param pPciDev The PCI device structure. 951 * @param iIrq IRQ number to set. 952 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines. 953 * @param uTagSrc The IRQ tag and source (for tracing). 954 * @remarks Caller enters the PDM critical section. 955 */ 956 DECLR0CALLBACKMEMBER(void, pfnSetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 957 /** Marks the end of the structure with PDM_PCIBUSREGR0_VERSION. */ 958 uint32_t u32EndVersion; 959 } PDMPCIBUSREGR0; 960 /** Pointer to a PCI bus ring-0 registration structure. */ 961 typedef PDMPCIBUSREGR0 *PPDMPCIBUSREGR0; 962 /** Current PDMPCIBUSREGR0 version number. */ 963 #define PDM_PCIBUSREGR0_VERSION PDM_VERSION_MAKE(0xff87, 1, 0) 964 965 /** 966 * PCI Bus registration structure for raw-mode. 967 */ 968 typedef struct PDMPCIBUSREGRC 969 { 970 /** Structure version number. PDM_PCIBUSREGRC_VERSION defines the current version. */ 971 uint32_t u32Version; 972 /** The PCI bus number (from ring-3 registration). */ 973 uint32_t iBus; 974 /** 975 * Set the IRQ for a PCI device. 976 * 977 * @param pDevIns Device instance of the PCI Bus. 978 * @param pPciDev The PCI device structure. 979 * @param iIrq IRQ number to set. 980 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines. 981 * @param uTagSrc The IRQ tag and source (for tracing). 982 * @remarks Caller enters the PDM critical section. 983 */ 984 DECLRCCALLBACKMEMBER(void, pfnSetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 985 /** Marks the end of the structure with PDM_PCIBUSREGRC_VERSION. */ 986 uint32_t u32EndVersion; 987 } PDMPCIBUSREGRC; 988 /** Pointer to a PCI bus raw-mode registration structure. */ 989 typedef PDMPCIBUSREGRC *PPDMPCIBUSREGRC; 990 /** Current PDMPCIBUSREGRC version number. */ 991 #define PDM_PCIBUSREGRC_VERSION PDM_VERSION_MAKE(0xff88, 1, 0) 992 993 /** PCI bus registration structure for the current context. */ 994 typedef CTX_SUFF(PDMPCIBUSREG) PDMPCIBUSREGCC; 995 /** Pointer to a PCI bus registration structure for the current context. */ 996 typedef CTX_SUFF(PPDMPCIBUSREG) PPDMPCIBUSREGCC; 997 /** PCI bus registration structure version for the current context. */ 998 #define PDM_PCIBUSREGCC_VERSION CTX_MID(PDM_PCIBUSREG,_VERSION) 999 913 1000 914 1001 /** … … 3374 3461 * Register PCI configuration space read/write callbacks. 3375 3462 * 3463 * @returns VBox status code. 3376 3464 * @param pDevIns The device instance. 3377 3465 * @param pPciDev The PCI device structure. If NULL the default 3378 3466 * PCI device for this device instance is used. 3379 3467 * @param pfnRead Pointer to the user defined PCI config read function. 3380 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)3381 * PCI config read function. This way, user can decide when (and if)3382 3468 * to call default PCI config read function. Can be NULL. 3383 3469 * @param pfnWrite Pointer to the user defined PCI config write function. 3384 * @param ppfnWriteOld Pointer to function pointer which will receive3385 * the old (default) PCI config write function.3386 * This way, user can decide when (and if) to call3387 * default PCI config write function. Can be NULL.3388 3470 * @remarks The callbacks will be invoked holding the PDM lock. The device lock 3389 3471 * is NOT take because that is very likely be a lock order violation. 3390 * @thread EMT 3391 */ 3392 DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3393 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 3394 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)); 3472 * @thread EMT(0) 3473 * @note Only callable during VM creation. 3474 * @sa PDMDevHlpPCIConfigRead, PDMDevHlpPCIConfigWrite 3475 */ 3476 DECLR3CALLBACKMEMBER(int, pfnPCIInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3477 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite)); 3478 3479 /** 3480 * Perform a PCI configuration space write. 3481 * 3482 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses(). 3483 * 3484 * @returns Strict VBox status code (mainly DBGFSTOP). 3485 * @param pDevIns The device instance. 3486 * @param pPciDev The PCI device which config space is being read. 3487 * @param uAddress The config space address. 3488 * @param cb The size of the read: 1, 2 or 4 bytes. 3489 * @param u32Value The value to write. 3490 */ 3491 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3492 uint32_t uAddress, unsigned cb, uint32_t u32Value)); 3493 3494 /** 3495 * Perform a PCI configuration space read. 3496 * 3497 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses(). 3498 * 3499 * @returns Strict VBox status code (mainly DBGFSTOP). 3500 * @param pDevIns The device instance. 3501 * @param pPciDev The PCI device which config space is being read. 3502 * @param uAddress The config space address. 3503 * @param cb The size of the read: 1, 2 or 4 bytes. 3504 * @param pu32Value Where to return the value. 3505 */ 3506 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3507 uint32_t uAddress, unsigned cb, uint32_t *pu32Value)); 3395 3508 3396 3509 /** … … 3671 3784 * @param piBus Where to return the PDM bus number. Optional. 3672 3785 */ 3673 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg,3674 PCPDMPCIHLPR3 *ppPciHlp R3, uint32_t *piBus));3786 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg, 3787 PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus)); 3675 3788 3676 3789 /** … … 4578 4691 */ 4579 4692 DECLRCCALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns)); 4693 4694 /** 4695 * Sets up the PCI bus for the raw-mode context. 4696 * 4697 * This must be called after ring-3 has registered the PCI bus using 4698 * PDMDevHlpPCIBusRegister(). 4699 * 4700 * @returns VBox status code. 4701 * @param pDevIns The device instance. 4702 * @param pPciBusReg The PCI bus registration information for raw-mode, 4703 * considered volatile. 4704 * @param ppPciHlp Where to return the raw-mode PCI bus helpers. 4705 */ 4706 DECLRCCALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGRC pPciBusReg, PCPDMPCIHLPRC *ppPciHlp)); 4580 4707 4581 4708 /** Space reserved for future members. … … 4951 5078 DECLR0CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns)); 4952 5079 5080 /** 5081 * Sets up the PCI bus for the ring-0 context. 5082 * 5083 * This must be called after ring-3 has registered the PCI bus using 5084 * PDMDevHlpPCIBusRegister(). 5085 * 5086 * @returns VBox status code. 5087 * @param pDevIns The device instance. 5088 * @param pPciBusReg The PCI bus registration information for ring-0, 5089 * considered volatile. 5090 * @param ppPciHlp Where to return the ring-0 PCI bus helpers. 5091 */ 5092 DECLR0CALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR0 pPciBusReg, PCPDMPCIHLPR0 *ppPciHlp)); 5093 4953 5094 /** Space reserved for future members. 4954 5095 * @{ */ … … 5224 5365 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \ 5225 5366 VERR_PDM_DEVINS_VERSION_MISMATCH); \ 5226 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)-> pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \5227 ("DevHlp=%#x mine=%#x\n", (pDevIns)-> pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \5228 VERR_PDM_DEVHLP R3_VERSION_MISMATCH); \5367 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \ 5368 ("DevHlp=%#x mine=%#x\n", (pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \ 5369 VERR_PDM_DEVHLP_VERSION_MISMATCH); \ 5229 5370 } while (0) 5230 5371 … … 5243 5384 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) )) \ 5244 5385 { /* likely */ } else return VERR_PDM_DEVINS_VERSION_MISMATCH; \ 5245 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)-> pHlpR3->u32Version, PDM_DEVHLPR3_VERSION) )) \5246 { /* likely */ } else return VERR_PDM_DEVHLP R3_VERSION_MISMATCH; \5386 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)) )) \ 5387 { /* likely */ } else return VERR_PDM_DEVHLP_VERSION_MISMATCH; \ 5247 5388 } while (0) 5248 5389 … … 6310 6451 6311 6452 /** 6312 * @copydoc PDMDEVHLPR3::pfnPCISetConfigCallbacks 6313 */ 6314 DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 6315 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 6316 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld) 6317 { 6318 pDevIns->pHlpR3->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld); 6453 * @copydoc PDMDEVHLPR3::pfnPCIInterceptConfigAccesses 6454 */ 6455 DECLINLINE(int) PDMDevHlpPCIInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 6456 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite) 6457 { 6458 return pDevIns->pHlpR3->pfnPCIInterceptConfigAccesses(pDevIns, pPciDev, pfnRead, pfnWrite); 6459 } 6460 6461 /** 6462 * @copydoc PDMDEVHLPR3::pfnPCIConfigRead 6463 */ 6464 DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, 6465 unsigned cb, uint32_t *pu32Value) 6466 { 6467 return pDevIns->pHlpR3->pfnPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value); 6468 } 6469 6470 /** 6471 * @copydoc PDMDEVHLPR3::pfnPCIConfigWrite 6472 */ 6473 DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, 6474 unsigned cb, uint32_t u32Value) 6475 { 6476 return pDevIns->pHlpR3->pfnPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value); 6319 6477 } 6320 6478 … … 6664 6822 * @copydoc PDMDEVHLPR3::pfnPCIBusRegister 6665 6823 */ 6666 DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3, uint32_t *piBus)6667 { 6668 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlp R3, piBus);6824 DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg, PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus) 6825 { 6826 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlp, piBus); 6669 6827 } 6670 6828 … … 6813 6971 } 6814 6972 6815 #endif /* IN_RING3 */ 6973 #else /* !IN_RING3 */ 6974 6975 /** 6976 * @copydoc PDMDEVHLPR0::pfnPCIBusSetUp 6977 */ 6978 DECLINLINE(int) PDMDevHlpPCIBusSetUpContext(PPDMDEVINS pDevIns, CTX_SUFF(PPDMPCIBUSREG) pPciBusReg, CTX_SUFF(PCPDMPCIHLP) *ppPciHlp) 6979 { 6980 return pDevIns->CTX_SUFF(pHlp)->pfnPCIBusSetUpContext(pDevIns, pPciBusReg, ppPciHlp); 6981 } 6982 6983 #endif /* !IN_RING3 */ 6816 6984 6817 6985 /** -
trunk/include/VBox/vmm/pdmpcidev.h
r77299 r80943 40 40 41 41 /** 42 * Callback function for reading from the PCI configuration space. 43 * 44 * @returns The register value. 42 * Callback function for intercept reading from the PCI configuration space. 43 * 44 * @returns VINF_SUCCESS or PDMDevHlpDBGFStop status (maybe others later). 45 * @retval VINF_PDM_PCI_DO_DEFAULT to do default read (same as calling 46 * PDMDevHlpPCIConfigRead()). 47 * 45 48 * @param pDevIns Pointer to the device instance the PCI device 46 49 * belongs to. … … 48 51 * @param uAddress The configuration space register address. [0..4096] 49 52 * @param cb The register size. [1,2,4] 53 * @param pu32Value Where to return the register value. 50 54 * 51 55 * @remarks Called with the PDM lock held. The device lock is NOT take because 52 56 * that is very likely be a lock order violation. 53 57 */ 54 typedef DECLCALLBACK(uint32_t) FNPCICONFIGREAD(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb); 58 typedef DECLCALLBACK(VBOXSTRICTRC) FNPCICONFIGREAD(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 59 uint32_t uAddress, unsigned cb, uint32_t *pu32Value); 55 60 /** Pointer to a FNPCICONFIGREAD() function. */ 56 61 typedef FNPCICONFIGREAD *PFNPCICONFIGREAD; … … 61 66 * Callback function for writing to the PCI configuration space. 62 67 * 63 * @returns VINF_SUCCESS or PDMDevHlpDBGFStop status. 68 * @returns VINF_SUCCESS or PDMDevHlpDBGFStop status (maybe others later). 69 * @retval VINF_PDM_PCI_DO_DEFAULT to do default read (same as calling 70 * PDMDevHlpPCIConfigWrite()). 64 71 * 65 72 * @param pDevIns Pointer to the device instance the PCI device … … 67 74 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 68 75 * @param uAddress The configuration space register address. [0..4096] 76 * @param cb The register size. [1,2,4] 69 77 * @param u32Value The value that's being written. The number of bits actually used from 70 78 * this value is determined by the cb parameter. 71 * @param cb The register size. [1,2,4]72 79 * 73 80 * @remarks Called with the PDM lock held. The device lock is NOT take because … … 75 82 */ 76 83 typedef DECLCALLBACK(VBOXSTRICTRC) FNPCICONFIGWRITE(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 77 uint32_t uAddress, u int32_t u32Value, unsigned cb);84 uint32_t uAddress, unsigned cb, uint32_t u32Value); 78 85 /** Pointer to a FNPCICONFIGWRITE() function. */ 79 86 typedef FNPCICONFIGWRITE *PFNPCICONFIGWRITE; -
trunk/include/VBox/vmm/pdmpcidevint.h
r80722 r80943 63 63 * Callback function for reading from the PCI configuration space. 64 64 * 65 * @returns The register value.65 * @returns Strict VBox status code. 66 66 * @param pDevIns Pointer to the device instance of the PCI bus. 67 67 * @param iBus The bus number this device is on. … … 69 69 * @param u32Address The configuration space register address. [0..255] 70 70 * @param cb The register size. [1,2,4] 71 */ 72 typedef DECLCALLBACK(uint32_t) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb); 71 * @param pu32Value Where to return the register value. 72 */ 73 typedef DECLCALLBACK(VBOXSTRICTRC) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, 74 uint32_t u32Address, unsigned cb, uint32_t *pu32Value); 73 75 /** Pointer to a FNPCICONFIGREAD() function. */ 74 76 typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD; … … 79 81 * Callback function for writing to the PCI configuration space. 80 82 * 83 * @returns Strict VBox status code. 81 84 * @param pDevIns Pointer to the device instance of the PCI bus. 82 85 * @param iBus The bus number this device is on. 83 86 * @param iDevice The number of the device on the bus. 84 87 * @param u32Address The configuration space register address. [0..255] 88 * @param cb The register size. [1,2,4] 85 89 * @param u32Value The value that's being written. The number of bits actually used from 86 90 * this value is determined by the cb parameter. 87 * @param cb The register size. [1,2,4]88 */ 89 typedef DECLCALLBACK(void) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb);91 */ 92 typedef DECLCALLBACK(VBOXSTRICTRC) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, 93 uint32_t u32Address, unsigned cb, uint32_t u32Value); 90 94 /** Pointer to a FNPCICONFIGWRITE() function. */ 91 95 typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE; -
trunk/src/VBox/Devices/Bus/DevPCI.cpp
r80854 r80943 84 84 RT_C_DECLS_BEGIN 85 85 86 PDMBOTHCBDECL(void) pciSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTag); 87 PDMBOTHCBDECL(void) pcibridgeSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTag); 86 static DECLCALLBACK(void) pcibridgeSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTag); 88 87 PDMBOTHCBDECL(int) pciIOPortAddressWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 89 88 PDMBOTHCBDECL(int) pciIOPortAddressRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); … … 111 110 112 111 113 static int pci_data_write(PDEVPCIROOT pGlobals, uint32_t addr, uint32_t val, int len) 114 { 115 uint8_t iBus, iDevice; 116 uint32_t config_addr; 117 118 LogFunc(("addr=%08x val=%08x len=%d\n", pGlobals->uConfigReg, val, len)); 119 120 if (!(pGlobals->uConfigReg & (1 << 31))) { 112 static int pci_data_write(PPDMDEVINS pDevIns, PDEVPCIROOT pGlobals, uint32_t addr, uint32_t u32Value, int cb) 113 { 114 LogFunc(("addr=%08x u32Value=%08x cb=%d\n", pGlobals->uConfigReg, u32Value, cb)); 115 116 if (!(pGlobals->uConfigReg & (1 << 31))) 121 117 return VINF_SUCCESS; 122 } 123 if ((pGlobals->uConfigReg & 0x3) != 0) { 118 if ((pGlobals->uConfigReg & 0x3) != 0) 124 119 return VINF_SUCCESS; 125 } 126 iBus = (pGlobals->uConfigReg >> 16) & 0xff; 127 iDevice = (pGlobals->uConfigReg >> 8) & 0xff; 128 config_addr = (pGlobals->uConfigReg & 0xfc) | (addr & 3); 120 121 uint8_t const iBus = (pGlobals->uConfigReg >> 16) & 0xff; 122 uint8_t const iDevice = (pGlobals->uConfigReg >> 8) & 0xff; 123 #ifdef IN_RING3 124 uint32_t const config_addr = (pGlobals->uConfigReg & 0xfc) | (addr & 3); 125 #endif 129 126 RT_UNTRUSTED_VALIDATED_FENCE(); /* paranoia */ 127 128 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 130 129 if (iBus != 0) 131 130 { … … 137 136 { 138 137 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigWrite); 139 pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, iDevice, config_addr, val, len); 138 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, 139 iDevice, config_addr, cb, u32Value); 140 140 } 141 141 #else 142 RT_NOREF 2(val, len);143 r eturnVINF_IOM_R3_IOPORT_WRITE;142 RT_NOREF(pDevIns, addr, u32Value, cb); 143 rcStrict = VINF_IOM_R3_IOPORT_WRITE; 144 144 #endif 145 145 } … … 147 147 else 148 148 { 149 R3PTRTYPE(PDMPCIDEV *) p ci_dev = pGlobals->PciBus.apDevices[iDevice];150 if (p ci_dev)149 R3PTRTYPE(PDMPCIDEV *) pPciDev = pGlobals->PciBus.apDevices[iDevice]; 150 if (pPciDev) 151 151 { 152 152 #ifdef IN_RING3 153 LogFunc(("%s: addr=%02x val=%08x len=%d\n", pci_dev->pszNameR3, config_addr, val, len)); 154 return VBOXSTRICTRC_TODO(pci_dev->Int.s.pfnConfigWrite(pci_dev->Int.s.CTX_SUFF(pDevIns), pci_dev, config_addr, val, len)); 153 LogFunc(("%s: addr=%02x u32Value=%08x cb=%d\n", pPciDev->pszNameR3, config_addr, u32Value, cb)); 154 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 155 if (pPciDev->Int.s.pfnConfigWrite) 156 rcStrict = pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, config_addr, cb, u32Value); 157 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 158 rcStrict = devpciR3CommonConfigWriteWorker(pDevIns, PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 159 pPciDev, config_addr, cb, u32Value); 155 160 #else 156 r eturnVINF_IOM_R3_IOPORT_WRITE;161 rcStrict = VINF_IOM_R3_IOPORT_WRITE; 157 162 #endif 158 163 } 159 164 } 160 return VINF_SUCCESS; 161 } 162 163 static int pci_data_read(PDEVPCIROOT pGlobals, uint32_t addr, int len, uint32_t *pu32) 164 { 165 uint8_t iBus, iDevice; 166 uint32_t config_addr; 167 168 *pu32 = 0xffffffff; 165 return rcStrict; 166 } 167 168 static int pci_data_read(PDEVPCIROOT pGlobals, uint32_t addr, int cb, uint32_t *pu32Value) 169 { 170 *pu32Value = UINT32_MAX; 169 171 170 172 if (!(pGlobals->uConfigReg & (1 << 31))) … … 172 174 if ((pGlobals->uConfigReg & 0x3) != 0) 173 175 return VINF_SUCCESS; 174 iBus = (pGlobals->uConfigReg >> 16) & 0xff; 175 iDevice = (pGlobals->uConfigReg >> 8) & 0xff; 176 config_addr = (pGlobals->uConfigReg & 0xfc) | (addr & 3); 176 uint8_t const iBus = (pGlobals->uConfigReg >> 16) & 0xff; 177 uint8_t const iDevice = (pGlobals->uConfigReg >> 8) & 0xff; 178 #ifdef IN_RING3 179 uint32_t const config_addr = (pGlobals->uConfigReg & 0xfc) | (addr & 3); 180 #endif 177 181 RT_UNTRUSTED_VALIDATED_FENCE(); 182 183 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 178 184 if (iBus != 0) 179 185 { … … 185 191 { 186 192 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigRead); 187 *pu32 = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, iDevice, config_addr, len); 193 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), 194 iBus, iDevice, config_addr, cb, pu32Value); 188 195 } 189 196 #else 190 NOREF(len);191 r eturnVINF_IOM_R3_IOPORT_READ;197 RT_NOREF(addr, cb); 198 rcStrict = VINF_IOM_R3_IOPORT_READ; 192 199 #endif 193 200 } … … 195 202 else 196 203 { 197 R3PTRTYPE(PDMPCIDEV *) p ci_dev = pGlobals->PciBus.apDevices[iDevice];198 if (p ci_dev)204 R3PTRTYPE(PDMPCIDEV *) pPciDev = pGlobals->PciBus.apDevices[iDevice]; 205 if (pPciDev) 199 206 { 200 207 #ifdef IN_RING3 201 *pu32 = pci_dev->Int.s.pfnConfigRead(pci_dev->Int.s.CTX_SUFF(pDevIns), pci_dev, config_addr, len); 202 LogFunc(("%s: addr=%02x val=%08x len=%d\n", pci_dev->pszNameR3, config_addr, *pu32, len)); 208 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 209 if (pPciDev->Int.s.pfnConfigRead) 210 rcStrict = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, config_addr, cb, pu32Value); 211 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 212 rcStrict = devpciR3CommonConfigReadWorker(pPciDev, config_addr, cb, pu32Value); 213 LogFunc(("%s: addr=%02x val=%08x cb=%d\n", pPciDev->pszNameR3, config_addr, *pu32Value, cb)); 203 214 #else 204 NOREF( len);205 r eturnVINF_IOM_R3_IOPORT_READ;215 NOREF(cb); 216 rcStrict = VINF_IOM_R3_IOPORT_READ; 206 217 #endif 207 218 } 208 219 } 209 220 210 return VINF_SUCCESS;221 return rcStrict; 211 222 } 212 223 … … 234 245 } 235 246 236 static void apic_set_irq(PDEVPCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, int iAcpiIrq, uint32_t uTagSrc) 247 static void apic_set_irq(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PDEVPCIBUSCC pBusCC, 248 uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, int iAcpiIrq, uint32_t uTagSrc) 237 249 { 238 250 /* This is only allowed to be called with a pointer to the host bus. */ … … 253 265 Log3Func(("%s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d\n", 254 266 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, apic_irq, apic_level, irq_num)); 255 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), apic_irq, apic_level, uTagSrc);267 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, apic_irq, apic_level, uTagSrc); 256 268 257 269 if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) { … … 261 273 Log3Func(("%s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d (flop)\n", 262 274 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, apic_irq, apic_level, irq_num)); 263 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), apic_irq, apic_level, uTagSrc);275 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, apic_irq, apic_level, uTagSrc); 264 276 } 265 277 } else { 266 278 Log3Func(("%s: irq_num1=%d level=%d iAcpiIrq=%d\n", 267 279 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, iAcpiIrq)); 268 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), iAcpiIrq, iLevel, uTagSrc);280 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, iAcpiIrq, iLevel, uTagSrc); 269 281 } 270 282 } … … 278 290 * Set the IRQ for a PCI device on the host bus - shared by host bus and bridge. 279 291 * 280 * @param pGlobals Device instance of the host PCI Bus. 292 * @param pPdmDev The PDM device instance for the PCI bus. 293 * @param pGlobals Device instance of the host PCI bus. 294 * @param pBusCC Context specific data for the PCI bus. 281 295 * @param uDevFn The device number on the host bus which will raise the IRQ 282 296 * @param pPciDev The PCI device structure which raised the interrupt. … … 288 302 * is needed to calculate the PIRQ value. 289 303 */ 290 static void pciSetIrqInternal(PDEVPCIROOT pGlobals, uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 304 static void pciSetIrqInternal(PPDMDEVINS pDevIns, PDEVPCIROOT pGlobals, PDEVPCIBUSCC pBusCC, 305 uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 291 306 { 292 307 PDEVPCIBUS pBus = &pGlobals->PciBus; … … 316 331 * PCI device configuration space). 317 332 */ 318 apic_set_irq(p Bus, uDevFn, pPciDev, -1, iLevel, pPciDev->abConfig[PCI_INTERRUPT_LINE], uTagSrc);333 apic_set_irq(pDevIns, pBus, pBusCC, uDevFn, pPciDev, -1, iLevel, pPciDev->abConfig[PCI_INTERRUPT_LINE], uTagSrc); 319 334 else 320 apic_set_irq(p Bus, uDevFn, pPciDev, iIrq, iLevel, -1, uTagSrc);335 apic_set_irq(pDevIns, pBus, pBusCC, uDevFn, pPciDev, iIrq, iLevel, -1, uTagSrc); 321 336 return; 322 337 } … … 368 383 Log3Func(("%s: iLevel=%d iIrq=%d pic_irq=%d pic_level=%d uTagSrc=%#x\n", 369 384 R3STRING(pPciDev->pszNameR3), iLevel, iIrq, pic_irq, pic_level, uTagSrc)); 370 pBus ->CTX_SUFF(pPciHlp)->pfnIsaSetIrq(pBus->CTX_SUFF(pDevIns), pic_irq, pic_level, uTagSrc);385 pBusCC->CTX_SUFF(pPciHlp)->pfnIsaSetIrq(pDevIns, pic_irq, pic_level, uTagSrc); 371 386 372 387 /** @todo optimize pci irq flip-flop some rainy day. */ 373 388 if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) 374 pciSetIrqInternal(p Globals, uDevFn, pPciDev, iIrq, PDM_IRQ_LEVEL_LOW, uTagSrc);389 pciSetIrqInternal(pDevIns, pGlobals, pBusCC, uDevFn, pPciDev, iIrq, PDM_IRQ_LEVEL_LOW, uTagSrc); 375 390 } 376 391 } … … 380 395 * @interface_method_impl{PDMPCIBUSREG,pfnSetIrqR3} 381 396 */ 382 PDMBOTHCBDECL(void) pciSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 383 { 384 pciSetIrqInternal(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 397 static DECLCALLBACK(void) pciSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 398 { 399 PDEVPCIROOT pBus = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 400 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 401 LogFlow(("pciSetIrq: %p %u %u %#x\n", pPciDev, iIrq, iLevel, uTagSrc)); 402 pciSetIrqInternal(pDevIns, pBus, pBusCC, pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 385 403 } 386 404 … … 454 472 static const uint8_t pci_irqs[4] = { 11, 10, 9, 11 }; /* bird: added const */ 455 473 456 static void pci_bios_init_device(PDEVPCIROOT pGlobals, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, uint8_t cBridgeDepth, uint8_t *paBridgePositions) 474 static void pci_bios_init_device(PPDMDEVINS pDevIns, PDEVPCIROOT pGlobals, PDEVPCIBUS pBus, 475 PPDMPCIDEV pPciDev, uint8_t cBridgeDepth, uint8_t *paBridgePositions) 457 476 { 458 477 uint32_t *paddr; … … 474 493 { 475 494 /* PIIX3, PIIX4 or ICH6 IDE */ 476 devpciR3SetWord(p PciDev, 0x40, 0x8011); /* enable IDE0 + fast timing */477 devpciR3SetWord(p PciDev, 0x42, 0x8011); /* enable IDE1 + fast timing */495 devpciR3SetWord(pDevIns, pPciDev, 0x40, 0x8011); /* enable IDE0 + fast timing */ 496 devpciR3SetWord(pDevIns, pPciDev, 0x42, 0x8011); /* enable IDE1 + fast timing */ 478 497 goto default_map; 479 498 } … … 481 500 { 482 501 /* IDE: we map it as in ISA mode */ 483 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 0, 0x1f0);484 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 1, 0x3f4);485 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 2, 0x170);486 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 3, 0x374);487 devpciR3SetWord(p PciDev, PCI_COMMAND,502 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 0, 0x1f0); 503 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 1, 0x3f4); 504 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 2, 0x170); 505 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 3, 0x374); 506 devpciR3SetWord(pDevIns, pPciDev, PCI_COMMAND, 488 507 devpciR3GetWord(pPciDev, PCI_COMMAND) 489 508 | PCI_COMMAND_IOACCESS); … … 495 514 goto default_map; 496 515 /* VGA: map frame buffer to default Bochs VBE address */ 497 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 0, 0xe0000000);516 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 0, 0xe0000000); 498 517 /* 499 518 * Legacy VGA I/O ports are implicitly decoded by a VGA class device. But … … 501 520 * devpciR3BiosInitSetRegionAddress, so don't forget to enable I/O decoding. 502 521 */ 503 devpciR3SetWord(p PciDev, PCI_COMMAND,522 devpciR3SetWord(pDevIns, pPciDev, PCI_COMMAND, 504 523 devpciR3GetWord(pPciDev, PCI_COMMAND) 505 524 | PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS); … … 516 535 { 517 536 /* MPIC & MPIC2 */ 518 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 0, 0x80800000 + 0x00040000);519 devpciR3SetWord(p PciDev, PCI_COMMAND,537 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 0, 0x80800000 + 0x00040000); 538 devpciR3SetWord(pDevIns, pPciDev, PCI_COMMAND, 520 539 devpciR3GetWord(pPciDev, PCI_COMMAND) 521 540 | PCI_COMMAND_MEMACCESS); … … 528 547 { 529 548 /* macio bridge */ 530 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, 0, 0x80800000);531 devpciR3SetWord(p PciDev, PCI_COMMAND,549 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, 0, 0x80800000); 550 devpciR3SetWord(pDevIns, pPciDev, PCI_COMMAND, 532 551 devpciR3GetWord(pPciDev, PCI_COMMAND) 533 552 | PCI_COMMAND_MEMACCESS); … … 537 556 { 538 557 /* Init PCI-to-PCI bridge. */ 539 devpciR3SetByte(p PciDev, VBOX_PCI_PRIMARY_BUS, pBus->iBus);558 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_PRIMARY_BUS, pBus->iBus); 540 559 541 560 AssertMsg(pGlobals->uPciBiosBus < 255, ("Too many bridges on the bus\n")); 542 561 pGlobals->uPciBiosBus++; 543 devpciR3SetByte(p PciDev, VBOX_PCI_SECONDARY_BUS, pGlobals->uPciBiosBus);544 devpciR3SetByte(p PciDev, VBOX_PCI_SUBORDINATE_BUS, 0xff); /* Temporary until we know how many other bridges are behind this one. */562 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_SECONDARY_BUS, pGlobals->uPciBiosBus); 563 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_SUBORDINATE_BUS, 0xff); /* Temporary until we know how many other bridges are behind this one. */ 545 564 546 565 /* Add position of this bridge into the array. */ … … 555 574 pGlobals->uPciBiosIo = RT_ALIGN_32(pGlobals->uPciBiosIo, _4K); 556 575 LogFunc(("Aligned I/O start address. New address %#x\n", pGlobals->uPciBiosIo)); 557 devpciR3SetByte(p PciDev, VBOX_PCI_IO_BASE, (pGlobals->uPciBiosIo >> 8) & 0xf0);576 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_IO_BASE, (pGlobals->uPciBiosIo >> 8) & 0xf0); 558 577 559 578 /* The MMIO range for the bridge must be aligned to a 1MB boundary. */ … … 561 580 pGlobals->uPciBiosMmio = RT_ALIGN_32(pGlobals->uPciBiosMmio, _1M); 562 581 LogFunc(("Aligned MMIO start address. New address %#x\n", pGlobals->uPciBiosMmio)); 563 devpciR3SetWord(p PciDev, VBOX_PCI_MEMORY_BASE, (pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xffff0));582 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_MEMORY_BASE, (pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xffff0)); 564 583 565 584 /* Save values to compare later to. */ … … 573 592 PPDMPCIDEV pChildPciDev = pChildBus->apDevices[uDevFn]; 574 593 if (pChildPciDev) 575 pci_bios_init_device(p Globals, pChildBus, pChildPciDev, cBridgeDepth + 1, paBridgePositions);594 pci_bios_init_device(pDevIns, pGlobals, pChildBus, pChildPciDev, cBridgeDepth + 1, paBridgePositions); 576 595 } 577 596 578 597 /* The number of bridges behind the this one is now available. */ 579 devpciR3SetByte(p PciDev, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uPciBiosBus);598 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uPciBiosBus); 580 599 581 600 /* … … 590 609 pGlobals->uPciBiosIo = RT_ALIGN_32(pGlobals->uPciBiosIo, _4K); 591 610 } 592 devpciR3SetByte(p PciDev, VBOX_PCI_IO_LIMIT, ((pGlobals->uPciBiosIo >> 8) & 0xf0) - 1);611 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_IO_LIMIT, ((pGlobals->uPciBiosIo >> 8) & 0xf0) - 1); 593 612 594 613 /* Same with the MMIO limit register but with 1MB boundary here. */ … … 598 617 pGlobals->uPciBiosMmio = RT_ALIGN_32(pGlobals->uPciBiosMmio, _1M); 599 618 } 600 devpciR3SetWord(p PciDev, VBOX_PCI_MEMORY_LIMIT, ((pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xfff0)) - 1);619 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_MEMORY_LIMIT, ((pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xfff0)) - 1); 601 620 602 621 /* … … 605 624 * the base register than in the limit register. 606 625 */ 607 devpciR3SetWord(p PciDev, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0);608 devpciR3SetWord(p PciDev, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0);609 devpciR3SetDWord(p PciDev, VBOX_PCI_PREF_BASE_UPPER32, 0x00);610 devpciR3SetDWord(p PciDev, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00);626 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0); 627 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0); 628 devpciR3SetDWord(pDevIns, pPciDev, VBOX_PCI_PREF_BASE_UPPER32, 0x00); 629 devpciR3SetDWord(pDevIns, pPciDev, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00); 611 630 break; 612 631 } … … 629 648 /* Calculate size. */ 630 649 u8RessourceType = devpciR3GetByte(pPciDev, u32Address); 631 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0xffffffff));650 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0xffffffff)); 632 651 u32Size = devpciR3GetDWord(pPciDev, u32Address); 633 652 bool fIsPio = ((u8RessourceType & PCI_COMMAND_IOACCESS) == PCI_COMMAND_IOACCESS); … … 665 684 i, pBus->iBus, pPciDev->uDevFn >> 3, pPciDev->uDevFn & 7, vendor_id, device_id)); /** @todo make this a VM start failure later. */ 666 685 /* Undo the mapping mess caused by the size probing. */ 667 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0));686 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0)); 668 687 } 669 688 else 670 689 { 671 690 LogFunc(("Start address of %s region %u is %#x\n", (fIsPio ? "I/O" : "MMIO"), i, uNew)); 672 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, i, uNew);691 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, i, uNew); 673 692 if (fIsPio) 674 693 fActiveIORegion = true; … … 682 701 683 702 /* Update the command word appropriately. */ 684 devpciR3SetWord(p PciDev, PCI_COMMAND,703 devpciR3SetWord(pDevIns, pPciDev, PCI_COMMAND, 685 704 devpciR3GetWord(pPciDev, PCI_COMMAND) 686 705 | (fActiveMemRegion ? PCI_COMMAND_MEMACCESS : 0) … … 709 728 pin = pci_slot_get_pirq(pPciDev->uDevFn, pin); 710 729 pic_irq = pci_irqs[pin]; 711 devpciR3SetByte(p PciDev, PCI_INTERRUPT_LINE, pic_irq);730 devpciR3SetByte(pDevIns, pPciDev, PCI_INTERRUPT_LINE, pic_irq); 712 731 } 713 732 } … … 750 769 elcr[irq >> 3] |= (1 << (irq & 7)); 751 770 /* Activate irq remapping in PIIX3. */ 752 devpciR3SetByte(p PIIX3, 0x60 + i, irq);771 devpciR3SetByte(pDevIns, pPIIX3, 0x60 + i, irq); 753 772 } 754 773 … … 770 789 { 771 790 PPDMPCIDEV pPciDev = pBus->apDevices[uDevFn]; 772 uint8_t aBridgePositions[256];773 774 791 if (pPciDev) 775 792 { 776 memset(aBridgePositions, 0, sizeof(aBridgePositions));777 Log2(("PCI: Initializing device %d (%#x)\n",778 uDevFn, 0x80000000 | (uDevFn << 8)));779 pci_bios_init_device(p Globals, pBus, pPciDev, 0, aBridgePositions);793 Log2(("PCI: Initializing device %d (%#x)\n", uDevFn, 0x80000000 | (uDevFn << 8))); 794 uint8_t aBridgePositions[256]; 795 RT_ZERO(aBridgePositions); 796 pci_bios_init_device(pDevIns, pGlobals, pBus, pPciDev, 0, aBridgePositions); 780 797 } 781 798 } … … 842 859 { 843 860 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE); 844 rc = pci_data_write( PDMINS_2_DATA(pDevIns, PDEVPCIROOT), Port, u32, cb);861 rc = pci_data_write(pDevIns, PDMINS_2_DATA(pDevIns, PDEVPCIROOT), Port, u32, cb); 845 862 PCI_UNLOCK(pDevIns); 846 863 } … … 984 1001 * 985 1002 * @returns VBox status code. 1003 * @param pDevIns The device instance. 986 1004 * @param pBus The bus which data is being loaded. 987 1005 * @param pSSM The saved state handle. … … 989 1007 * @param uPass The pass. 990 1008 */ 991 static DECLCALLBACK(int) pciR3CommonLoadExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)1009 static int pciR3CommonLoadExec(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 992 1010 { 993 1011 uint32_t u32; … … 1010 1028 { 1011 1029 uint16_t u16 = PCIDevGetCommand(pDev); 1012 pDev->Int.s.pfnConfigWrite(pDev->Int.s.CTX_SUFF(pDevIns), pDev, VBOX_PCI_COMMAND, 0, 2);1030 devpciR3SetCfg(pDevIns, pDev, VBOX_PCI_COMMAND, 0 /*u32Value*/, 2 /*cb*/); 1013 1031 PCIDevSetCommand(pDev, u16); 1014 1032 Assert(PCIDevGetCommand(pDev) == u16); … … 1102 1120 if (RT_FAILURE(rc)) 1103 1121 break; 1104 devpciR3CommonRestoreConfig(pDev , &DevTmp.abConfig[0]);1122 devpciR3CommonRestoreConfig(pDevIns, pDev, &DevTmp.abConfig[0]); 1105 1123 1106 1124 pDev->Int.s.uIrqPinState = DevTmp.Int.s.uIrqPinState; … … 1157 1175 * The devices. 1158 1176 */ 1159 return pciR3CommonLoadExec(p Bus, pSSM, uVersion, uPass);1177 return pciR3CommonLoadExec(pDevIns, pBus, pSSM, uVersion, uPass); 1160 1178 } 1161 1179 … … 1204 1222 1205 1223 /* -=-=-=-=-=- PDMDEVREG -=-=-=-=-=- */ 1224 1225 /** 1226 * @interface_method_impl{PDMDEVREG,pfnReset} 1227 */ 1228 static DECLCALLBACK(void) pciR3Reset(PPDMDEVINS pDevIns) 1229 { 1230 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1231 PDEVPCIBUS pBus = &pGlobals->PciBus; 1232 1233 /* PCI-specific reset for each device. */ 1234 for (uint32_t uDevFn = 0; uDevFn < RT_ELEMENTS(pBus->apDevices); uDevFn++) 1235 { 1236 if (pBus->apDevices[uDevFn]) 1237 devpciR3ResetDevice(pDevIns, pBus->apDevices[uDevFn]); 1238 } 1239 1240 pciR3Piix3Reset(&pGlobals->Piix3.PIIX3State); 1241 } 1242 1243 1244 /** 1245 * @interface_method_impl{PDMDEVREG,pfnDestruct} 1246 */ 1247 static DECLCALLBACK(int) pciR3Destruct(PPDMDEVINS pDevIns) 1248 { 1249 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1250 if (pGlobals->PciBus.papBridgesR3) 1251 { 1252 PDMDevHlpMMHeapFree(pDevIns, pGlobals->PciBus.papBridgesR3); 1253 pGlobals->PciBus.papBridgesR3 = NULL; 1254 } 1255 return VINF_SUCCESS; 1256 } 1206 1257 1207 1258 … … 1243 1294 Log(("PCI: fUseIoApic=%RTbool fGCEnabled=%RTbool fR0Enabled=%RTbool\n", fUseIoApic, fGCEnabled, fR0Enabled)); 1244 1295 1296 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 1297 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1298 1245 1299 /* 1246 1300 * Init data and register the PCI bus. 1247 1301 */ 1248 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);1249 1302 pGlobals->uPciBiosIo = 0xc000; 1250 1303 pGlobals->uPciBiosMmio = 0xf0000000; … … 1253 1306 memset((void *)&pGlobals->auPciApicIrqLevels, 0, sizeof(pGlobals->auPciApicIrqLevels)); 1254 1307 1255 pGlobals->pDevInsR3 = pDevIns;1256 pGlobals->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);1257 pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);1258 1259 1308 pGlobals->PciBus.fTypePiix3 = true; 1260 1309 pGlobals->PciBus.fTypeIch9 = false; 1261 1310 pGlobals->PciBus.fPureBridge = false; 1262 pGlobals->PciBus.pDevInsR3 = pDevIns;1263 pGlobals->PciBus.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);1264 pGlobals->PciBus.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);1265 1311 pGlobals->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, 1266 1312 sizeof(PPDMPCIDEV) … … 1268 1314 AssertLogRelReturn(pGlobals->PciBus.papBridgesR3, VERR_NO_MEMORY); 1269 1315 1270 1271 PDMPCIBUSREG PciBusReg;1272 P DEVPCIBUS pBus = &pGlobals->PciBus;1273 PciBusReg. u32Version = PDM_PCIBUSREG_VERSION;1274 PciBusReg.pfnRegister R3 = pciR3MergedRegister;1275 PciBusReg.pfn RegisterMsiR3 = NULL;1276 PciBusReg.pfnI ORegionRegisterR3 = devpciR3CommonIORegionRegister;1277 PciBusReg.pfn SetConfigCallbacksR3 = devpciR3CommonSetConfigCallbacks;1278 PciBusReg.pfn SetIrqR3 = pciSetIrq;1279 PciBusReg.p szSetIrqRC = fGCEnabled ? "pciSetIrq" : NULL;1280 PciBusReg. pszSetIrqR0 = fR0Enabled ? "pciSetIrq" : NULL;1281 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBus ->pPciHlpR3, &pBus->iBus);1316 PDEVPCIBUS pBus = &pGlobals->PciBus; 1317 PDMPCIBUSREGCC PciBusReg; 1318 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 1319 PciBusReg.pfnRegisterR3 = pciR3MergedRegister; 1320 PciBusReg.pfnRegisterMsiR3 = NULL; 1321 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 1322 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses; 1323 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead; 1324 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite; 1325 PciBusReg.pfnSetIrqR3 = pciSetIrq; 1326 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 1327 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus); 1282 1328 if (RT_FAILURE(rc)) 1283 return PDMDEV_SET_ERROR(pDevIns, rc, 1284 N_("Failed to register ourselves as a PCI Bus")); 1329 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as a PCI Bus")); 1285 1330 Assert(pBus->iBus == 0); 1286 if (pBus ->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)1331 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION) 1287 1332 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS, 1288 1333 N_("PCI helper version mismatch; got %#x expected %#x"), 1289 pBus->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 1290 1291 pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns); 1292 pBus->pPciHlpR0 = pBus->pPciHlpR3->pfnGetR0Helpers(pDevIns); 1334 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 1293 1335 1294 1336 /* Disable default device locking. */ … … 1351 1393 } 1352 1394 1353 rc = PDMDevHlpIOPortRegister(pDevIns, 0x0410, 1, NULL, pciR3IOPortMagicPCIWrite, pciR3IOPortMagicPCIRead, NULL, NULL, "i440FX (Fake PCI BIOS trigger)") 1354 ; 1395 rc = PDMDevHlpIOPortRegister(pDevIns, 0x0410, 1, NULL, pciR3IOPortMagicPCIWrite, pciR3IOPortMagicPCIRead, NULL, NULL, "i440FX (Fake PCI BIOS trigger)"); 1355 1396 if (RT_FAILURE(rc)) 1356 1397 return rc; … … 1374 1415 } 1375 1416 1376 1377 /** 1378 * @interface_method_impl{PDMDEVREG,pfnDestruct} 1379 */ 1380 static DECLCALLBACK(int) pciR3Destruct(PPDMDEVINS pDevIns) 1381 { 1382 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1383 if (pGlobals->PciBus.papBridgesR3) 1384 { 1385 PDMDevHlpMMHeapFree(pDevIns, pGlobals->PciBus.papBridgesR3); 1386 pGlobals->PciBus.papBridgesR3 = NULL; 1387 } 1388 return VINF_SUCCESS; 1389 } 1390 1391 1392 /** 1393 * @interface_method_impl{PDMDEVREG,pfnReset} 1394 */ 1395 static DECLCALLBACK(void) pciR3Reset(PPDMDEVINS pDevIns) 1396 { 1397 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1398 PDEVPCIBUS pBus = &pGlobals->PciBus; 1399 1400 /* PCI-specific reset for each device. */ 1401 for (uint32_t uDevFn = 0; uDevFn < RT_ELEMENTS(pBus->apDevices); uDevFn++) 1402 { 1403 if (pBus->apDevices[uDevFn]) 1404 devpciR3ResetDevice(pBus->apDevices[uDevFn]); 1405 } 1406 1407 pciR3Piix3Reset(&pGlobals->Piix3.PIIX3State); 1408 } 1409 1410 #endif /* IN_RING3 */ 1417 #else /* !IN_RING3 */ 1418 1419 /** 1420 * @interface_method_impl{PDMDEVREGR0,pfnConstruct} 1421 */ 1422 static DECLCALLBACK(int) pciRZRootConstruct(PPDMDEVINS pDevIns) 1423 { 1424 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 1425 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 1426 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 1427 1428 PDMPCIBUSREGCC PciBusReg; 1429 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 1430 PciBusReg.iBus = pGlobals->PciBus.iBus; 1431 PciBusReg.pfnSetIrq = pciSetIrq; 1432 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 1433 int rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp)); 1434 AssertRC(rc); 1435 1436 return rc; 1437 } 1438 1439 #endif /* !IN_RING3 */ 1411 1440 1412 1441 /** … … 1423 1452 /* .uSharedVersion = */ 42, 1424 1453 /* .cbInstanceShared = */ sizeof(DEVPCIROOT), 1425 /* .cbInstanceCC = */ 0,1426 /* .cbInstanceRC = */ 0,1454 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)), 1455 /* .cbInstanceRC = */ sizeof(DEVPCIBUSRC), 1427 1456 /* .cMaxPciDevices = */ 2, 1428 1457 /* .cMaxMsixVectors = */ 0, … … 1455 1484 #elif defined(IN_RING0) 1456 1485 /* .pfnEarlyConstruct = */ NULL, 1457 /* .pfnConstruct = */ NULL,1486 /* .pfnConstruct = */ pciRZRootConstruct, 1458 1487 /* .pfnDestruct = */ NULL, 1459 1488 /* .pfnFinalDestruct = */ NULL, … … 1468 1497 /* .pfnReserved7 = */ NULL, 1469 1498 #elif defined(IN_RC) 1470 /* .pfnConstruct = */ NULL,1499 /* .pfnConstruct = */ pciRZRootConstruct, 1471 1500 /* .pfnReserved0 = */ NULL, 1472 1501 /* .pfnReserved1 = */ NULL, … … 1491 1520 * @interface_method_impl{PDMPCIBUSREG,pfnSetIrqR3} 1492 1521 */ 1493 PDMBOTHCBDECL(void) pcibridgeSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 1494 { 1522 static DECLCALLBACK(void) pcibridgeSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 1523 { 1524 LogFlow(("pcibridgeSetIrq: %p %u %u %#x\n", pPciDev, iIrq, iLevel, uTagSrc)); 1525 1495 1526 /* 1496 1527 * The PCI-to-PCI bridge specification defines how the interrupt pins … … 1500 1531 * of our parent passing the device which asserted the interrupt instead of the device of the bridge. 1501 1532 */ 1502 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1503 PPDMPCIDEV pPciDevBus = pPciDev; 1504 int iIrqPinBridge = iIrq; 1505 uint8_t uDevFnBridge = 0; 1533 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1534 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 1535 PPDMPCIDEV pPciDevBus = pPciDev; 1536 int iIrqPinBridge = iIrq; 1537 uint8_t uDevFnBridge = 0; 1506 1538 1507 1539 /* Walk the chain until we reach the host bus. */ … … 1517 1549 1518 1550 AssertMsg(pBus->iBus == 0, ("This is not the host pci bus iBus=%d\n", pBus->iBus)); 1519 pciSetIrqInternal( DEVPCIBUS_2_DEVPCIROOT(pBus), uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc);1551 pciSetIrqInternal(pDevIns, DEVPCIBUS_2_DEVPCIROOT(pBus), pBusCC, uDevFnBridge, pPciDev, iIrqPinBridge, iLevel, uTagSrc); 1520 1552 } 1521 1553 … … 1525 1557 * @callback_method_impl{FNPCIBRIDGECONFIGWRITE} 1526 1558 */ 1527 static DECLCALLBACK(void) pcibridgeR3ConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb) 1528 { 1529 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1530 1531 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, u32Value, cb)); 1559 static DECLCALLBACK(VBOXSTRICTRC) pcibridgeR3ConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, 1560 uint32_t u32Address, unsigned cb, uint32_t u32Value) 1561 { 1562 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u cb=%d u32Value=%u\n", pDevIns, iBus, iDevice, u32Address, cb, u32Value)); 1563 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1564 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 1532 1565 1533 1566 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 1538 1571 { 1539 1572 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigWrite); 1540 pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, iDevice, u32Address, u32Value, cb); 1573 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, iDevice, 1574 u32Address, cb, u32Value); 1541 1575 } 1542 1576 } … … 1548 1582 { 1549 1583 LogFunc(("%s: addr=%02x val=%08x len=%d\n", pPciDev->pszNameR3, u32Address, u32Value, cb)); 1550 /** @todo return rc */ 1551 pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, u32Value, cb); 1552 } 1553 } 1584 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 1585 if (pPciDev->Int.s.pfnConfigWrite) 1586 rcStrict = pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb, u32Value); 1587 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 1588 rcStrict = devpciR3CommonConfigWriteWorker(pDevIns, PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 1589 pPciDev, u32Address, cb, u32Value); 1590 } 1591 } 1592 return rcStrict; 1554 1593 } 1555 1594 … … 1558 1597 * @callback_method_impl{FNPCIBRIDGECONFIGREAD} 1559 1598 */ 1560 static DECLCALLBACK(uint32_t) pcibridgeR3ConfigRead(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb) 1561 { 1562 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1563 uint32_t u32Value = 0xffffffff; /* Return value in case there is no device. */ 1564 1599 static DECLCALLBACK(VBOXSTRICTRC) pcibridgeR3ConfigRead(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, 1600 uint32_t u32Address, unsigned cb, uint32_t *pu32Value) 1601 { 1565 1602 LogFlowFunc(("pDevIns=%p iBus=%d iDevice=%d u32Address=%u cb=%d\n", pDevIns, iBus, iDevice, u32Address, cb)); 1603 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1604 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 1566 1605 1567 1606 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 1571 1610 if (pBridgeDevice) 1572 1611 { 1573 AssertPtr( pBridgeDevice->Int.s.pfnBridgeConfigRead); 1574 u32Value = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), iBus, iDevice, u32Address, cb); 1575 } 1612 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigRead); 1613 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), 1614 iBus, iDevice, u32Address, cb, pu32Value); 1615 } 1616 else 1617 *pu32Value = UINT32_MAX; 1576 1618 } 1577 1619 else … … 1581 1623 if (pPciDev) 1582 1624 { 1583 u32Value = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb); 1584 LogFunc(("%s: u32Address=%02x u32Value=%08x cb=%d\n", pPciDev->pszNameR3, u32Address, u32Value, cb)); 1585 } 1586 } 1587 1588 return u32Value; 1625 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 1626 if (pPciDev->Int.s.pfnConfigRead) 1627 rcStrict = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb, pu32Value); 1628 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 1629 rcStrict = devpciR3CommonConfigReadWorker(pPciDev, u32Address, cb, pu32Value); 1630 1631 LogFunc(("%s: u32Address=%02x u32Value=%08x cb=%d\n", pPciDev->pszNameR3, u32Address, *pu32Value, cb)); 1632 } 1633 else 1634 *pu32Value = UINT32_MAX; 1635 } 1636 1637 return rcStrict; 1589 1638 } 1590 1639 … … 1608 1657 if (uVersion > VBOX_PCI_SAVED_STATE_VERSION) 1609 1658 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 1610 return pciR3CommonLoadExec(p This, pSSM, uVersion, uPass);1659 return pciR3CommonLoadExec(pDevIns, pThis, pSSM, uVersion, uPass); 1611 1660 } 1612 1661 … … 1623 1672 pBus->PciDev.abConfig[VBOX_PCI_SECONDARY_BUS] = 0; 1624 1673 pBus->PciDev.abConfig[VBOX_PCI_SUBORDINATE_BUS] = 0; 1674 } 1675 1676 1677 /** 1678 * @interface_method_impl{PDMDEVREG,pfnDestruct} 1679 */ 1680 static DECLCALLBACK(int) pcibridgeR3Destruct(PPDMDEVINS pDevIns) 1681 { 1682 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1683 if (pBus->papBridgesR3) 1684 { 1685 PDMDevHlpMMHeapFree(pDevIns, pBus->papBridgesR3); 1686 pBus->papBridgesR3 = NULL; 1687 } 1688 return VINF_SUCCESS; 1625 1689 } 1626 1690 … … 1655 1719 Log(("PCI: fGCEnabled=%RTbool fR0Enabled=%RTbool\n", fGCEnabled, fR0Enabled)); 1656 1720 1721 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1722 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 1723 1657 1724 /* 1658 1725 * Init data and register the PCI bus. 1659 1726 */ 1660 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);1661 1727 pBus->fTypePiix3 = true; 1662 1728 pBus->fTypeIch9 = false; 1663 1729 pBus->fPureBridge = true; 1664 pBus->pDevInsR3 = pDevIns;1665 pBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);1666 pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);1667 1730 pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices)); 1668 1731 AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY); 1669 1732 1670 PDMPCIBUSREG PciBusReg; 1671 PciBusReg.u32Version = PDM_PCIBUSREG_VERSION; 1672 PciBusReg.pfnRegisterR3 = pcibridgeR3MergedRegisterDevice; 1673 PciBusReg.pfnRegisterMsiR3 = NULL; 1674 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 1675 PciBusReg.pfnSetConfigCallbacksR3 = devpciR3CommonSetConfigCallbacks; 1676 PciBusReg.pfnSetIrqR3 = pcibridgeSetIrq; 1677 PciBusReg.pszSetIrqRC = fGCEnabled ? "pcibridgeSetIrq" : NULL; 1678 PciBusReg.pszSetIrqR0 = fR0Enabled ? "pcibridgeSetIrq" : NULL; 1679 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBus->pPciHlpR3, &pBus->iBus); 1733 PDMPCIBUSREGCC PciBusReg; 1734 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 1735 PciBusReg.pfnRegisterR3 = pcibridgeR3MergedRegisterDevice; 1736 PciBusReg.pfnRegisterMsiR3 = NULL; 1737 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 1738 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses; 1739 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite; 1740 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead; 1741 PciBusReg.pfnSetIrqR3 = pcibridgeSetIrq; 1742 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 1743 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus); 1680 1744 if (RT_FAILURE(rc)) 1681 1745 return PDMDEV_SET_ERROR(pDevIns, rc, 1682 1746 N_("Failed to register ourselves as a PCI Bus")); 1683 1747 Assert(pBus->iBus == (uint32_t)iInstance + 1); /* Can be removed when adding support for multiple bridge implementations. */ 1684 if (pBus ->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)1748 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION) 1685 1749 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS, 1686 1750 N_("PCI helper version mismatch; got %#x expected %#x"), 1687 pBus->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 1688 1689 pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns); 1690 pBus->pPciHlpR0 = pBus->pPciHlpR3->pfnGetR0Helpers(pDevIns); 1751 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 1691 1752 1692 1753 /* … … 1736 1797 } 1737 1798 1738 1739 /** 1740 * @interface_method_impl{PDMDEVREG,pfnDestruct} 1741 */ 1742 static DECLCALLBACK(int) pcibridgeR3Destruct(PPDMDEVINS pDevIns) 1743 { 1744 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1745 if (pBus->papBridgesR3) 1746 { 1747 PDMDevHlpMMHeapFree(pDevIns, pBus->papBridgesR3); 1748 pBus->papBridgesR3 = NULL; 1749 } 1750 return VINF_SUCCESS; 1751 } 1752 1753 #endif /* IN_RING3 */ 1799 #else /* !IN_RING3 */ 1800 1801 /** 1802 * @interface_method_impl{PDMDEVREGR0,pfnConstruct} 1803 */ 1804 static DECLCALLBACK(int) pcibridgeRZConstruct(PPDMDEVINS pDevIns) 1805 { 1806 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 1807 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1808 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 1809 1810 PDMPCIBUSREGCC PciBusReg; 1811 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 1812 PciBusReg.iBus = pBus->iBus; 1813 PciBusReg.pfnSetIrq = pcibridgeSetIrq; 1814 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 1815 int rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp)); 1816 AssertRC(rc); 1817 1818 return rc; 1819 } 1820 1821 #endif /* !IN_RING3 */ 1754 1822 1755 1823 /** … … 1767 1835 /* .uSharedVersion = */ 42, 1768 1836 /* .cbInstanceShared = */ sizeof(DEVPCIBUS), 1769 /* .cbInstanceCC = */ 0,1837 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)), 1770 1838 /* .cbInstanceRC = */ 0, 1771 1839 /* .cMaxPciDevices = */ 1, … … 1799 1867 #elif defined(IN_RING0) 1800 1868 /* .pfnEarlyConstruct = */ NULL, 1801 /* .pfnConstruct = */ NULL,1869 /* .pfnConstruct = */ pcibridgeRZConstruct, 1802 1870 /* .pfnDestruct = */ NULL, 1803 1871 /* .pfnFinalDestruct = */ NULL, … … 1812 1880 /* .pfnReserved7 = */ NULL, 1813 1881 #elif defined(IN_RC) 1814 /* .pfnConstruct = */ NULL,1882 /* .pfnConstruct = */ pcibridgeRZConstruct, 1815 1883 /* .pfnReserved0 = */ NULL, 1816 1884 /* .pfnReserved1 = */ NULL, -
trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
r80704 r80943 93 93 *********************************************************************************************************************************/ 94 94 /* Prototypes */ 95 static void ich9pciSetIrqInternal(P DEVPCIROOT pPciRoot, uint8_t uDevFn, PPDMPCIDEV pPciDev,96 int iIrq, int iLevel, uint32_t uTagSrc);95 static void ich9pciSetIrqInternal(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUSCC pBusCC, 96 uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc); 97 97 #ifdef IN_RING3 98 98 static int ich9pciFakePCIBIOS(PPDMDEVINS pDevIns); 99 99 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(PDEVPCIBUS pBus, uint8_t uBus); 100 static void ich9pciBiosInitAllDevicesOnBus(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus);101 static bool ich9pciBiosInitAllDevicesPrefetchableOnBus(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun);100 static void ich9pciBiosInitAllDevicesOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus); 101 static bool ich9pciBiosInitAllDevicesPrefetchableOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun); 102 102 #endif 103 103 … … 125 125 { 126 126 LogFlowFunc(("invoked by %p/%d: iIrq=%d iLevel=%d uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, iIrq, iLevel, uTagSrc)); 127 ich9pciSetIrqInternal(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 127 ich9pciSetIrqInternal(pDevIns, PDMINS_2_DATA(pDevIns, PDEVPCIROOT), PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 128 pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc); 128 129 } 129 130 … … 163 164 || MsixIsEnabled(pPciDev)) 164 165 iIrqPinVector = iIrq; 165 ich9pciSetIrqInternal(DEVPCIBUS_2_DEVPCIROOT(pBus), uDevFnBridge, pPciDev, iIrqPinVector, iLevel, uTagSrc); 166 ich9pciSetIrqInternal(pDevIns, DEVPCIBUS_2_DEVPCIROOT(pBus), PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 167 uDevFnBridge, pPciDev, iIrqPinVector, iLevel, uTagSrc); 166 168 } 167 169 … … 292 294 * Perform configuration space write. 293 295 */ 294 static int ich9pciConfigWrite(PDEVPCIROOT pPciRoot, PciAddress* pAddr, 295 uint32_t val, int cb, int rcReschedule) 296 { 297 int rc = VINF_SUCCESS; 298 #ifdef IN_RING3 299 NOREF(rcReschedule); 300 #else 301 RT_NOREF2(val, cb); 302 #endif 303 304 if (pAddr->iBus != 0) /* forward to subordinate bus */ 296 static VBOXSTRICTRC ich9pciConfigWrite(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PciAddress const *pPciAddr, 297 uint32_t u32Value, int cb, int rcReschedule) 298 { 299 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 300 301 if (pPciAddr->iBus != 0) /* forward to subordinate bus */ 305 302 { 306 303 if (pPciRoot->PciBus.cBridges) 307 304 { 308 305 #ifdef IN_RING3 /** @todo do lookup in R0/RC too! r=klaus don't think that it can work, since the config space access callback only works in R3 */ 309 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(&pPciRoot->PciBus, p Addr->iBus);306 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(&pPciRoot->PciBus, pPciAddr->iBus); 310 307 if (pBridgeDevice) 311 308 { 312 309 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigWrite); 313 pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), pAddr->iBus, pAddr->iDeviceFunc,314 pAddr->iRegister, val, cb);310 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), pPciAddr->iBus, 311 pPciAddr->iDeviceFunc, pPciAddr->iRegister, cb, u32Value); 315 312 } 316 313 #else 317 rc = rcReschedule;314 rcStrict = rcReschedule; 318 315 #endif 319 316 } … … 321 318 else /* forward to directly connected device */ 322 319 { 323 R3PTRTYPE(PDMPCIDEV *) pPciDev = pPciRoot->PciBus.apDevices[p Addr->iDeviceFunc];320 R3PTRTYPE(PDMPCIDEV *) pPciDev = pPciRoot->PciBus.apDevices[pPciAddr->iDeviceFunc]; 324 321 if (pPciDev) 325 322 { 326 323 #ifdef IN_RING3 327 rc = VBOXSTRICTRC_TODO(pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, 328 pAddr->iRegister, val, cb)); 324 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 325 if (pPciDev->Int.s.pfnConfigWrite) 326 rcStrict = pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, 327 pPciAddr->iRegister, cb, u32Value); 328 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 329 rcStrict = devpciR3CommonConfigWriteWorker(pDevIns, PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 330 pPciDev, pPciAddr->iRegister, cb, u32Value); 331 RT_NOREF(rcReschedule); 329 332 #else 330 rc = rcReschedule; 333 rcStrict = rcReschedule; 334 RT_NOREF(pDevIns, u32Value, cb); 331 335 #endif 332 336 } 333 337 } 334 338 335 Log2Func(("%02x:%02x.% d reg %x(%d) %x %Rrc\n",336 p Addr->iBus, pAddr->iDeviceFunc >> 3, pAddr->iDeviceFunc & 0x7, pAddr->iRegister, cb, val, rc));337 return rc ;339 Log2Func(("%02x:%02x.%u reg %x(%u) %x %Rrc\n", pPciAddr->iBus, pPciAddr->iDeviceFunc >> 3, pPciAddr->iDeviceFunc & 0x7, 340 pPciAddr->iRegister, cb, u32Value, VBOXSTRICTRC_VAL(rcStrict))); 341 return rcStrict; 338 342 } 339 343 … … 374 378 375 379 /* Perform configuration space write */ 376 rc = ich9pciConfigWrite(p This, &aPciAddr, u32, cb, VINF_IOM_R3_IOPORT_WRITE);380 rc = ich9pciConfigWrite(pDevIns, pThis, &aPciAddr, u32, cb, VINF_IOM_R3_IOPORT_WRITE); 377 381 } while (0); 378 382 … … 388 392 * Perform configuration space read. 389 393 */ 390 static int ich9pciConfigRead(PDEVPCIROOT pPciRoot, PciAddress* pPciAddr, int cb, 391 uint32_t *pu32, int rcReschedule) 392 { 393 int rc = VINF_SUCCESS; 394 static VBOXSTRICTRC ich9pciConfigRead(PDEVPCIROOT pPciRoot, PciAddress* pPciAddr, int cb, uint32_t *pu32Value, int rcReschedule) 395 { 396 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 394 397 #ifdef IN_RING3 395 398 NOREF(rcReschedule); … … 407 410 { 408 411 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigRead); 409 *pu32= pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), pPciAddr->iBus,410 pPciAddr->iDeviceFunc, pPciAddr->iRegister, cb);412 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), pPciAddr->iBus, 413 pPciAddr->iDeviceFunc, pPciAddr->iRegister, cb, pu32Value); 411 414 } 412 415 else 413 *pu32 = 0xffffffff;416 *pu32Value = UINT32_MAX; 414 417 #else 415 rc = rcReschedule;418 rcStrict = rcReschedule; 416 419 #endif 417 420 } 418 421 else 419 *pu32 = 0xffffffff;422 *pu32Value = 0xffffffff; 420 423 } 421 424 else /* forward to directly connected device */ … … 425 428 { 426 429 #ifdef IN_RING3 427 *pu32 = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, pPciAddr->iRegister, cb); 430 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 431 if (pPciDev->Int.s.pfnConfigRead) 432 rcStrict = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, 433 pPciAddr->iRegister, cb, pu32Value); 434 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 435 rcStrict = devpciR3CommonConfigReadWorker(pPciDev, pPciAddr->iRegister, cb, pu32Value); 428 436 #else 429 rc = rcReschedule;437 rcStrict = rcReschedule; 430 438 #endif 431 439 } 432 440 else 433 *pu32 = 0xffffffff;434 } 435 436 Log3Func(("%02x:%02x.%d reg %x(%d) gave %x %Rrc\n", 437 pPciAddr->i Bus, pPciAddr->iDeviceFunc >> 3, pPciAddr->iDeviceFunc & 0x7, pPciAddr->iRegister, cb, *pu32, rc));438 return rc ;441 *pu32Value = UINT32_MAX; 442 } 443 444 Log3Func(("%02x:%02x.%d reg %x(%d) gave %x %Rrc\n", pPciAddr->iBus, pPciAddr->iDeviceFunc >> 3, pPciAddr->iDeviceFunc & 0x7, 445 pPciAddr->iRegister, cb, *pu32Value, VBOXSTRICTRC_VAL(rcStrict) )); 446 return rcStrict; 439 447 } 440 448 … … 457 465 { 458 466 NOREF(pvUser); 459 int rc = VINF_SUCCESS;460 467 if (!(uPort % cb)) 461 468 { … … 465 472 PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ); 466 473 467 do 468 { 469 /* Configuration space mapping enabled? */ 470 if (!(pThis->uConfigReg & (1 << 31))) 471 { 472 rc = VINF_SUCCESS; 473 break; 474 } 475 474 /* Configuration space mapping enabled? */ 475 int rc; 476 if (!(pThis->uConfigReg & (1 << 31))) 477 rc = VINF_SUCCESS; 478 else 479 { 476 480 /* Decode target device and configuration space register */ 477 481 PciAddress aPciAddr; … … 479 483 480 484 /* Perform configuration space read */ 481 rc = 482 } while (0);485 rc = ich9pciConfigRead(pThis, &aPciAddr, cb, pu32, VINF_IOM_R3_IOPORT_READ); 486 } 483 487 484 488 PCI_UNLOCK(pDevIns); … … 528 532 } 529 533 530 static void ich9pciApicSetIrq(P DEVPCIBUS pBus, uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel,531 uint 32_t uTagSrc, int iForcedIrq)534 static void ich9pciApicSetIrq(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PDEVPCIBUSCC pBusCC, 535 uint8_t uDevFn, PDMPCIDEV *pPciDev, int irq_num1, int iLevel, uint32_t uTagSrc, int iForcedIrq) 532 536 { 533 537 /* This is only allowed to be called with a pointer to the root bus. */ … … 549 553 Log3Func(("%s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d uTagSrc=%#x\n", 550 554 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, apic_irq, apic_level, irq_num, uTagSrc)); 551 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), apic_irq, apic_level, uTagSrc);555 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, apic_irq, apic_level, uTagSrc); 552 556 553 557 if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) … … 562 566 Log3Func(("%s: irq_num1=%d level=%d apic_irq=%d apic_level=%d irq_num1=%d uTagSrc=%#x (flop)\n", 563 567 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, apic_irq, apic_level, irq_num, uTagSrc)); 564 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), apic_irq, apic_level, uTagSrc);568 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, apic_irq, apic_level, uTagSrc); 565 569 } 566 570 } else { 567 571 Log3Func(("(forced) %s: irq_num1=%d level=%d acpi_irq=%d uTagSrc=%#x\n", 568 572 R3STRING(pPciDev->pszNameR3), irq_num1, iLevel, iForcedIrq, uTagSrc)); 569 pBus ->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pBus->CTX_SUFF(pDevIns), iForcedIrq, iLevel, uTagSrc);570 } 571 } 572 573 static void ich9pciSetIrqInternal(P DEVPCIROOT pPciRoot, uint8_t uDevFn, PPDMPCIDEV pPciDev,574 int iIrq, int iLevel, uint32_t uTagSrc)573 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, iForcedIrq, iLevel, uTagSrc); 574 } 575 } 576 577 static void ich9pciSetIrqInternal(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUSCC pBusCC, 578 uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc) 575 579 { 576 580 /* If MSI or MSI-X is enabled, PCI INTx# signals are disabled regardless of the PCI command … … 583 587 Assert(!MsixIsEnabled(pPciDev)); /* Not allowed -- see note above. */ 584 588 LogFlowFunc(("PCI Dev %p : MSI\n", pPciDev)); 585 PPDMDEVINS pDevIns = pPciRoot->PciBus.CTX_SUFF(pDevIns); 586 MsiNotify(pDevIns, pPciRoot->PciBus.CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc); 589 MsiNotify(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc); 587 590 return; 588 591 } … … 591 594 { 592 595 LogFlowFunc(("PCI Dev %p : MSI-X\n", pPciDev)); 593 PPDMDEVINS pDevIns = pPciRoot->PciBus.CTX_SUFF(pDevIns); 594 MsixNotify(pDevIns, pPciRoot->PciBus.CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc); 596 MsixNotify(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc); 595 597 return; 596 598 } … … 618 620 */ 619 621 /* safe, only needs to go to the config space array */ 620 ich9pciApicSetIrq(p Bus, uDevFn, pPciDev, -1, iLevel, uTagSrc, PDMPciDevGetInterruptLine(pPciDev));622 ich9pciApicSetIrq(pDevIns, pBus, pBusCC, uDevFn, pPciDev, -1, iLevel, uTagSrc, PDMPciDevGetInterruptLine(pPciDev)); 621 623 else 622 ich9pciApicSetIrq(p Bus, uDevFn, pPciDev, iIrq, iLevel, uTagSrc, -1);624 ich9pciApicSetIrq(pDevIns, pBus, pBusCC, uDevFn, pPciDev, iIrq, iLevel, uTagSrc, -1); 623 625 } 624 626 } … … 670 672 671 673 /* Perform configuration space write */ 672 int rc = ich9pciConfigWrite(p PciRoot, &aDest, u32, cb, VINF_IOM_R3_MMIO_WRITE);674 int rc = ich9pciConfigWrite(pDevIns, pPciRoot, &aDest, u32, cb, VINF_IOM_R3_MMIO_WRITE); 673 675 PCI_UNLOCK(pDevIns); 674 676 … … 770 772 uint32_t devpciR3GetCfg(PPDMPCIDEV pPciDev, int32_t iRegister, int cb) 771 773 { 772 return pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, iRegister, cb); 774 uint32_t u32Value = UINT32_MAX; 775 VBOXSTRICTRC rcStrict = VINF_PDM_PCI_DO_DEFAULT; 776 if (pPciDev->Int.s.pfnConfigRead) 777 rcStrict = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, iRegister, cb, &u32Value); 778 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 779 rcStrict = devpciR3CommonConfigReadWorker(pPciDev, iRegister, cb, &u32Value); 780 AssertRCSuccess(rcStrict); 781 return u32Value; 773 782 } 774 783 … … 779 788 } 780 789 781 void devpciR3SetCfg(PPDMPCIDEV pPciDev, int32_t iRegister, uint32_t u32, int cb) 782 { 783 pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, iRegister, u32, cb); 790 /** 791 * Worker for devpciR3SetByte(), devpciR3SetWord() and devpciR3SetDWord(), also 792 * used during state restore. 793 */ 794 void devpciR3SetCfg(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint32_t u32Value, int cb) 795 { 796 Assert(cb <= 4 && cb != 3); 797 VBOXSTRICTRC rcStrict = VINF_PDM_PCI_DO_DEFAULT; 798 if (pPciDev->Int.s.pfnConfigWrite) 799 rcStrict = pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, iRegister, cb, u32Value); 800 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 801 rcStrict = devpciR3CommonConfigWriteWorker(pDevIns, PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 802 pPciDev, iRegister, cb, u32Value); 803 AssertRCSuccess(rcStrict); 784 804 } 785 805 … … 790 810 static DECLCALLBACK(int) ich9pciRegisterMsi(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg) 791 811 { 792 NOREF(pDevIns); 793 int rc; 794 795 rc = MsiR3Init(pPciDev, pMsiReg); 796 if (RT_FAILURE(rc)) 797 return rc; 798 799 rc = MsixR3Init(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg); 800 if (RT_FAILURE(rc)) 801 return rc; 802 803 return VINF_SUCCESS; 812 //PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 813 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 814 815 int rc = MsiR3Init(pPciDev, pMsiReg); 816 if (RT_SUCCESS(rc)) 817 rc = MsixR3Init(pBusCC->CTX_SUFF(pPciHlp), pPciDev, pMsiReg); 818 819 return rc; 804 820 } 805 821 … … 871 887 872 888 /** 873 * @interface_method_impl{PDMPCIBUSREG,pfnSetConfigCallbacksR3} 874 */ 875 DECLCALLBACK(void) devpciR3CommonSetConfigCallbacks(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 876 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 877 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld) 889 * @interface_method_impl{PDMPCIBUSREG,pfnInterceptConfigAccesses} 890 */ 891 DECLCALLBACK(void) devpciR3CommonInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 892 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite) 878 893 { 879 894 NOREF(pDevIns); 880 895 881 if (ppfnReadOld)882 *ppfnReadOld = pPciDev->Int.s.pfnConfigRead;883 896 pPciDev->Int.s.pfnConfigRead = pfnRead; 884 885 if (ppfnWriteOld)886 *ppfnWriteOld = pPciDev->Int.s.pfnConfigWrite;887 897 pPciDev->Int.s.pfnConfigWrite = pfnWrite; 888 898 } … … 979 989 980 990 981 static DECLCALLBACK(void) ich9pcibridgeConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t uBus, uint8_t uDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb) 982 { 983 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 984 985 LogFlowFunc(("pDevIns=%p uBus=%d uDevice=%d u32Address=%u u32Value=%u cb=%d\n", pDevIns, uBus, uDevice, u32Address, u32Value, cb)); 991 /** 992 * @callback_method_impl{FNPCIBRIDGECONFIGWRITE} 993 */ 994 static DECLCALLBACK(VBOXSTRICTRC) ich9pcibridgeConfigWrite(PPDMDEVINSR3 pDevIns, uint8_t uBus, uint8_t uDevice, 995 uint32_t u32Address, unsigned cb, uint32_t u32Value) 996 { 997 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 998 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 999 LogFlowFunc(("pDevIns=%p uBus=%d uDevice=%d u32Address=%#x cb=%d u32Value=%#x\n", pDevIns, uBus, uDevice, u32Address, cb, u32Value)); 986 1000 987 1001 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 994 1008 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigWrite); 995 1009 pBridgeDevice->Int.s.pfnBridgeConfigWrite(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), uBus, uDevice, 996 u32Address, u32Value, cb);1010 u32Address, cb, u32Value); 997 1011 } 998 1012 } … … 1004 1018 { 1005 1019 LogFunc(("%s: addr=%02x val=%08x len=%d\n", pPciDev->pszNameR3, u32Address, u32Value, cb)); 1006 /** @todo return rc */ 1007 pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, u32Value, cb); 1008 } 1009 } 1010 } 1011 1012 static DECLCALLBACK(uint32_t) ich9pcibridgeConfigRead(PPDMDEVINSR3 pDevIns, uint8_t uBus, uint8_t uDevice, uint32_t u32Address, unsigned cb) 1013 { 1014 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1015 uint32_t u32Value; 1016 1017 LogFlowFunc(("pDevIns=%p uBus=%d uDevice=%d u32Address=%u cb=%d\n", pDevIns, uBus, uDevice, u32Address, cb)); 1020 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 1021 if (pPciDev->Int.s.pfnConfigWrite) 1022 rcStrict = pPciDev->Int.s.pfnConfigWrite(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb, u32Value); 1023 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 1024 rcStrict = devpciR3CommonConfigWriteWorker(pDevIns, PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC), 1025 pPciDev, u32Address, cb, u32Value); 1026 } 1027 } 1028 return rcStrict; 1029 } 1030 1031 /** 1032 * @callback_method_impl{FNPCIBRIDGECONFIGREAD} 1033 */ 1034 static DECLCALLBACK(VBOXSTRICTRC) ich9pcibridgeConfigRead(PPDMDEVINSR3 pDevIns, uint8_t uBus, uint8_t uDevice, 1035 uint32_t u32Address, unsigned cb, uint32_t *pu32Value) 1036 { 1037 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1038 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 1039 LogFlowFunc(("pDevIns=%p uBus=%d uDevice=%d u32Address=%#x cb=%d\n", pDevIns, uBus, uDevice, u32Address, cb)); 1018 1040 1019 1041 /* If the current bus is not the target bus search for the bus which contains the device. */ … … 1024 1046 if (pBridgeDevice) 1025 1047 { 1026 AssertPtr( 1027 u32Value= pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), uBus, uDevice,1028 u32Address, cb );1048 AssertPtr(pBridgeDevice->Int.s.pfnBridgeConfigRead); 1049 rcStrict = pBridgeDevice->Int.s.pfnBridgeConfigRead(pBridgeDevice->Int.s.CTX_SUFF(pDevIns), uBus, uDevice, 1050 u32Address, cb, pu32Value); 1029 1051 } 1030 1052 else 1031 u32Value = 0xffffffff;1053 *pu32Value = UINT32_MAX; 1032 1054 } 1033 1055 else … … 1037 1059 if (pPciDev) 1038 1060 { 1039 u32Value = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb); 1040 LogFunc(("%s: u32Address=%02x u32Value=%08x cb=%d\n", pPciDev->pszNameR3, u32Address, u32Value, cb)); 1061 rcStrict = VINF_PDM_PCI_DO_DEFAULT; 1062 if (pPciDev->Int.s.pfnConfigRead) 1063 rcStrict = pPciDev->Int.s.pfnConfigRead(pPciDev->Int.s.CTX_SUFF(pDevIns), pPciDev, u32Address, cb, pu32Value); 1064 if (rcStrict == VINF_PDM_PCI_DO_DEFAULT) 1065 rcStrict = devpciR3CommonConfigReadWorker(pPciDev, u32Address, cb, pu32Value); 1066 LogFunc(("%s: u32Address=%02x *pu32Value=%#010x cb=%d\n", pPciDev->pszNameR3, u32Address, *pu32Value, cb)); 1041 1067 } 1042 1068 else 1043 u32Value = 0xffffffff;1044 } 1045 1046 return u32Value;1069 *pu32Value = UINT32_MAX; 1070 } 1071 1072 return rcStrict; 1047 1073 } 1048 1074 … … 1055 1081 * Common routine for restoring the config registers of a PCI device. 1056 1082 * 1083 * @param pDevIns The device instance of the PC bus. 1057 1084 * @param pDev The PCI device. 1058 1085 * @param pbSrcConfig The configuration register values to be loaded. 1059 1086 */ 1060 void devpciR3CommonRestoreConfig(PPDM PCIDEV pDev, uint8_t const *pbSrcConfig)1087 void devpciR3CommonRestoreConfig(PPDMDEVINS pDevIns, PPDMPCIDEV pDev, uint8_t const *pbSrcConfig) 1061 1088 { 1062 1089 /* … … 1199 1226 /* safe, only needs to go to the config space array */ 1200 1227 PDMPciDevSetCommand(pDev, 0); /* For remapping, see pciR3CommonLoadExec/ich9pciR3CommonLoadExec. */ 1201 pDev->Int.s.pfnConfigWrite(pDev->Int.s.CTX_SUFF(pDevIns), pDev, off, u32Src, cb);1228 devpciR3SetCfg(pDevIns, pDev, off, u32Src, cb); 1202 1229 } 1203 1230 } … … 1312 1339 * 1313 1340 * @returns VBox status code. 1341 * @param pDevIns The device instance of the bus. 1314 1342 * @param pBus The bus which data is being loaded. 1315 1343 * @param pSSM The saved state handle. … … 1317 1345 * @param uPass The pass. 1318 1346 */ 1319 static DECLCALLBACK(int) ich9pciR3CommonLoadExec(PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)1320 { 1321 uint32_t u32;1322 int rc;1347 static int ich9pciR3CommonLoadExec(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1348 { 1349 uint32_t u32; 1350 int rc; 1323 1351 1324 1352 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); … … 1342 1370 /* safe, only needs to go to the config space array */ 1343 1371 uint16_t u16 = PDMPciDevGetCommand(pDev); 1344 pDev->Int.s.pfnConfigWrite(pDev->Int.s.CTX_SUFF(pDevIns), pDev, VBOX_PCI_COMMAND, 0, 2);1372 devpciR3SetCfg(pDevIns, pDev, VBOX_PCI_COMMAND, 0 /*u32Value*/, 2 /*cb*/); 1345 1373 /* safe, only needs to go to the config space array */ 1346 1374 PDMPciDevSetCommand(pDev, u16); … … 1463 1491 break; 1464 1492 Assert(!pciDevIsPassthrough(pDev)); 1465 devpciR3CommonRestoreConfig(pDev , &DevTmp.abConfig[0]);1493 devpciR3CommonRestoreConfig(pDevIns, pDev, &DevTmp.abConfig[0]); 1466 1494 1467 1495 pDev->Int.s.uIrqPinState = DevTmp.Int.s.uIrqPinState; … … 1514 1542 AssertMsgFailedReturn(("u32=%#x\n", u32), rc); 1515 1543 1516 return ich9pciR3CommonLoadExec(p Bus, pSSM, uVersion, uPass);1544 return ich9pciR3CommonLoadExec(pDevIns, pBus, pSSM, uVersion, uPass); 1517 1545 } 1518 1546 … … 1520 1548 { 1521 1549 PDEVPCIBUS pThis = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 1522 return ich9pciR3CommonLoadExec(p This, pSSM, uVersion, uPass);1550 return ich9pciR3CommonLoadExec(pDevIns, pThis, pSSM, uVersion, uPass); 1523 1551 } 1524 1552 … … 1528 1556 1529 1557 1530 void devpciR3BiosInitSetRegionAddress(P DEVPCIBUS pBus, PPDMPCIDEV pPciDev, int iRegion, uint64_t addr)1558 void devpciR3BiosInitSetRegionAddress(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, int iRegion, uint64_t addr) 1531 1559 { 1532 1560 NOREF(pBus); … … 1542 1570 1543 1571 /* Write address of the device. */ 1544 devpciR3SetDWord(p PciDev, uReg, (uint32_t)addr);1572 devpciR3SetDWord(pDevIns, pPciDev, uReg, (uint32_t)addr); 1545 1573 if (f64Bit) 1546 devpciR3SetDWord(p PciDev, uReg + 4, (uint32_t)(addr >> 32));1547 } 1548 1549 1550 static void ich9pciBiosInitBridge(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus)1574 devpciR3SetDWord(pDevIns, pPciDev, uReg + 4, (uint32_t)(addr >> 32)); 1575 } 1576 1577 1578 static void ich9pciBiosInitBridge(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus) 1551 1579 { 1552 1580 PPDMPCIDEV pBridge = &pBus->PciDev; … … 1563 1591 LogFunc(("Aligned I/O start address. New address %#x\n", pPciRoot->uPciBiosIo)); 1564 1592 } 1565 devpciR3SetByte(p Bridge, VBOX_PCI_IO_BASE, (pPciRoot->uPciBiosIo >> 8) & 0xf0);1593 devpciR3SetByte(pDevIns, pBridge, VBOX_PCI_IO_BASE, (pPciRoot->uPciBiosIo >> 8) & 0xf0); 1566 1594 1567 1595 /* The MMIO range for the bridge must be aligned to a 1MB boundary. */ … … 1571 1599 LogFunc(("Aligned MMIO start address. New address %#x\n", pPciRoot->uPciBiosMmio)); 1572 1600 } 1573 devpciR3SetWord(p Bridge, VBOX_PCI_MEMORY_BASE, (pPciRoot->uPciBiosMmio >> 16) & UINT32_C(0xffff0));1601 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_MEMORY_BASE, (pPciRoot->uPciBiosMmio >> 16) & UINT32_C(0xffff0)); 1574 1602 1575 1603 /* Save values to compare later to. */ … … 1578 1606 1579 1607 /* Init all devices behind the bridge (recursing to further buses). */ 1580 ich9pciBiosInitAllDevicesOnBus(p PciRoot, pBus);1608 ich9pciBiosInitAllDevicesOnBus(pDevIns, pPciRoot, pBus); 1581 1609 1582 1610 /* … … 1588 1616 /* Need again alignment to a 4KB boundary. */ 1589 1617 pPciRoot->uPciBiosIo = RT_ALIGN_32(pPciRoot->uPciBiosIo, _4K); 1590 devpciR3SetByte(p Bridge, VBOX_PCI_IO_LIMIT, ((pPciRoot->uPciBiosIo - 1) >> 8) & 0xf0);1618 devpciR3SetByte(pDevIns, pBridge, VBOX_PCI_IO_LIMIT, ((pPciRoot->uPciBiosIo - 1) >> 8) & 0xf0); 1591 1619 } 1592 1620 else 1593 1621 { 1594 devpciR3SetByte(p Bridge, VBOX_PCI_IO_BASE, 0xf0);1595 devpciR3SetByte(p Bridge, VBOX_PCI_IO_LIMIT, 0x00);1622 devpciR3SetByte(pDevIns, pBridge, VBOX_PCI_IO_BASE, 0xf0); 1623 devpciR3SetByte(pDevIns, pBridge, VBOX_PCI_IO_LIMIT, 0x00); 1596 1624 } 1597 1625 … … 1600 1628 { 1601 1629 pPciRoot->uPciBiosMmio = RT_ALIGN_32(pPciRoot->uPciBiosMmio, _1M); 1602 devpciR3SetWord(p Bridge, VBOX_PCI_MEMORY_LIMIT, ((pPciRoot->uPciBiosMmio - 1) >> 16) & UINT32_C(0xfff0));1630 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_MEMORY_LIMIT, ((pPciRoot->uPciBiosMmio - 1) >> 16) & UINT32_C(0xfff0)); 1603 1631 } 1604 1632 else 1605 1633 { 1606 devpciR3SetWord(p Bridge, VBOX_PCI_MEMORY_BASE, 0xfff0);1607 devpciR3SetWord(p Bridge, VBOX_PCI_MEMORY_LIMIT, 0x0000);1634 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_MEMORY_BASE, 0xfff0); 1635 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_MEMORY_LIMIT, 0x0000); 1608 1636 } 1609 1637 … … 1613 1641 * the base register than in the limit register. 1614 1642 */ 1615 devpciR3SetWord(p Bridge, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0);1616 devpciR3SetWord(p Bridge, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0000);1617 devpciR3SetDWord(p Bridge, VBOX_PCI_PREF_BASE_UPPER32, 0x00000000);1618 devpciR3SetDWord(p Bridge, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00000000);1643 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0); 1644 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0000); 1645 devpciR3SetDWord(pDevIns, pBridge, VBOX_PCI_PREF_BASE_UPPER32, 0x00000000); 1646 devpciR3SetDWord(pDevIns, pBridge, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00000000); 1619 1647 } 1620 1648 … … 1635 1663 } 1636 1664 1637 static void ich9pciBiosInitDeviceBARs(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev)1665 static void ich9pciBiosInitDeviceBARs(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev) 1638 1666 { 1639 1667 int cRegions = ich9pciBiosInitDeviceGetRegions(pPciDev); … … 1669 1697 if (f64Bit) 1670 1698 { 1671 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0xffffffff));1672 devpciR3SetDWord(p PciDev, u32Address+4, UINT32_C(0xffffffff));1699 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0xffffffff)); 1700 devpciR3SetDWord(pDevIns, pPciDev, u32Address+4, UINT32_C(0xffffffff)); 1673 1701 cbRegSize64 = RT_MAKE_U64(devpciR3GetDWord(pPciDev, u32Address), 1674 1702 devpciR3GetDWord(pPciDev, u32Address+4)); … … 1684 1712 { 1685 1713 uint32_t cbRegSize32; 1686 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0xffffffff));1714 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0xffffffff)); 1687 1715 cbRegSize32 = devpciR3GetDWord(pPciDev, u32Address); 1688 1716 … … 1731 1759 uNew = (uNew + cbRegSize64 - 1) & ~(cbRegSize64 - 1); 1732 1760 LogFunc(("Start address of 64-bit MMIO region %u/%u is %#llx\n", iRegion, iRegion + 1, uNew)); 1733 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, iRegion, uNew);1761 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, iRegion, uNew); 1734 1762 fActiveMemRegion = true; 1735 1763 pPciRoot->uPciBiosMmio64 = uNew + cbRegSize64; … … 1743 1771 iRegion, pBus->iBus, pPciDev->uDevFn >> 3, pPciDev->uDevFn & 7, uVendor, uDevice)); /** @todo make this a VM start failure later. */ 1744 1772 /* Undo the mapping mess caused by the size probing. */ 1745 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0));1773 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0)); 1746 1774 } 1747 1775 } … … 1749 1777 { 1750 1778 LogFunc(("Start address of %s region %u is %#x\n", (fIsPio ? "I/O" : "MMIO"), iRegion, uNew)); 1751 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, iRegion, uNew);1779 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, iRegion, uNew); 1752 1780 if (fIsPio) 1753 1781 fActiveIORegion = true; … … 1769 1797 if (fActiveIORegion) 1770 1798 uCmd |= VBOX_PCI_COMMAND_IO; /* Enable I/O space access. */ 1771 devpciR3SetWord(p PciDev, VBOX_PCI_COMMAND, uCmd);1772 } 1773 1774 static bool ich9pciBiosInitDevicePrefetchableBARs(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, bool fUse64Bit, bool fDryrun)1799 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_COMMAND, uCmd); 1800 } 1801 1802 static bool ich9pciBiosInitDevicePrefetchableBARs(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, bool fUse64Bit, bool fDryrun) 1775 1803 { 1776 1804 int cRegions = ich9pciBiosInitDeviceGetRegions(pPciDev); … … 1792 1820 if (f64Bit) 1793 1821 { 1794 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0xffffffff));1795 devpciR3SetDWord(p PciDev, u32Address+4, UINT32_C(0xffffffff));1822 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0xffffffff)); 1823 devpciR3SetDWord(pDevIns, pPciDev, u32Address+4, UINT32_C(0xffffffff)); 1796 1824 cbRegSize64 = RT_MAKE_U64(devpciR3GetDWord(pPciDev, u32Address), 1797 1825 devpciR3GetDWord(pPciDev, u32Address+4)); … … 1802 1830 { 1803 1831 uint32_t cbRegSize32; 1804 devpciR3SetDWord(p PciDev, u32Address, UINT32_C(0xffffffff));1832 devpciR3SetDWord(pDevIns, pPciDev, u32Address, UINT32_C(0xffffffff)); 1805 1833 cbRegSize32 = devpciR3GetDWord(pPciDev, u32Address); 1806 1834 cbRegSize32 &= ~UINT32_C(0x0f); … … 1831 1859 { 1832 1860 LogFunc(("Start address of MMIO region %u is %#x\n", iRegion, uNew)); 1833 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, iRegion, uNew);1861 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, iRegion, uNew); 1834 1862 fActiveMemRegion = true; 1835 1863 } … … 1851 1879 { 1852 1880 LogFunc(("Start address of 64-bit MMIO region %u/%u is %#llx\n", iRegion, iRegion + 1, uNew)); 1853 devpciR3BiosInitSetRegionAddress(p Bus, pPciDev, iRegion, uNew);1881 devpciR3BiosInitSetRegionAddress(pDevIns, pBus, pPciDev, iRegion, uNew); 1854 1882 fActiveMemRegion = true; 1855 1883 } … … 1867 1895 if (fActiveMemRegion) 1868 1896 uCmd |= VBOX_PCI_COMMAND_MEMORY; /* Enable MMIO access. */ 1869 devpciR3SetWord(p PciDev, VBOX_PCI_COMMAND, uCmd);1897 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_COMMAND, uCmd); 1870 1898 } 1871 1899 else … … 1875 1903 } 1876 1904 1877 static bool ich9pciBiosInitBridgePrefetchable(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun)1905 static bool ich9pciBiosInitBridgePrefetchable(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun) 1878 1906 { 1879 1907 PPDMPCIDEV pBridge = &pBus->PciDev; … … 1888 1916 1889 1917 /* Init all devices behind the bridge (recursing to further buses). */ 1890 bool fRes = ich9pciBiosInitAllDevicesPrefetchableOnBus(p PciRoot, pBus, fUse64Bit, fDryrun);1918 bool fRes = ich9pciBiosInitAllDevicesPrefetchableOnBus(pDevIns, pPciRoot, pBus, fUse64Bit, fDryrun); 1891 1919 if (fDryrun) 1892 1920 return fRes; … … 1909 1937 uLimit = RT_ALIGN_32(pPciRoot->uPciBiosMmio, _1M) - 1; 1910 1938 } 1911 devpciR3SetDWord(p Bridge, VBOX_PCI_PREF_BASE_UPPER32, uBase >> 32);1912 devpciR3SetWord(p Bridge, VBOX_PCI_PREF_MEMORY_BASE, (uint32_t)(uBase >> 16) & UINT32_C(0xfff0));1913 devpciR3SetDWord(p Bridge, VBOX_PCI_PREF_LIMIT_UPPER32, uLimit >> 32);1914 devpciR3SetWord(p Bridge, VBOX_PCI_PREF_MEMORY_LIMIT, (uint32_t)(uLimit >> 16) & UINT32_C(0xfff0));1939 devpciR3SetDWord(pDevIns, pBridge, VBOX_PCI_PREF_BASE_UPPER32, uBase >> 32); 1940 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_PREF_MEMORY_BASE, (uint32_t)(uBase >> 16) & UINT32_C(0xfff0)); 1941 devpciR3SetDWord(pDevIns, pBridge, VBOX_PCI_PREF_LIMIT_UPPER32, uLimit >> 32); 1942 devpciR3SetWord(pDevIns, pBridge, VBOX_PCI_PREF_MEMORY_LIMIT, (uint32_t)(uLimit >> 16) & UINT32_C(0xfff0)); 1915 1943 1916 1944 return false; 1917 1945 } 1918 1946 1919 static bool ich9pciBiosInitAllDevicesPrefetchableOnBus(PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun) 1947 static bool ich9pciBiosInitAllDevicesPrefetchableOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, 1948 bool fUse64Bit, bool fDryrun) 1920 1949 { 1921 1950 /* First pass: assign resources to all devices. */ … … 1931 1960 1932 1961 /* prefetchable memory mappings */ 1933 bool fRes = ich9pciBiosInitDevicePrefetchableBARs(p PciRoot, pBus, pPciDev, fUse64Bit, fDryrun);1962 bool fRes = ich9pciBiosInitDevicePrefetchableBARs(pDevIns, pPciRoot, pBus, pPciDev, fUse64Bit, fDryrun); 1934 1963 if (fRes) 1935 1964 { … … 1947 1976 PDEVPCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 1948 1977 1949 bool fRes = ich9pciBiosInitBridgePrefetchable(p PciRoot, pChildBus, fUse64Bit, fDryrun);1978 bool fRes = ich9pciBiosInitBridgePrefetchable(pDevIns, pPciRoot, pChildBus, fUse64Bit, fDryrun); 1950 1979 if (fRes) 1951 1980 { … … 1957 1986 } 1958 1987 1959 static void ich9pciBiosInitAllDevicesOnBus(P DEVPCIROOT pPciRoot, PDEVPCIBUS pBus)1988 static void ich9pciBiosInitAllDevicesOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus) 1960 1989 { 1961 1990 /* First pass: assign resources to all devices and map the interrupt. */ … … 1971 2000 1972 2001 /* default memory mappings */ 1973 ich9pciBiosInitDeviceBARs(p PciRoot, pBus, pPciDev);2002 ich9pciBiosInitDeviceBARs(pDevIns, pPciRoot, pBus, pPciDev); 1974 2003 uint16_t uDevClass = devpciR3GetWord(pPciDev, VBOX_PCI_CLASS_DEVICE); 1975 2004 switch (uDevClass) … … 1977 2006 case 0x0101: 1978 2007 /* IDE controller */ 1979 devpciR3SetWord(p PciDev, 0x40, 0x8000); /* enable IDE0 */1980 devpciR3SetWord(p PciDev, 0x42, 0x8000); /* enable IDE1 */2008 devpciR3SetWord(pDevIns, pPciDev, 0x40, 0x8000); /* enable IDE0 */ 2009 devpciR3SetWord(pDevIns, pPciDev, 0x42, 0x8000); /* enable IDE1 */ 1981 2010 break; 1982 2011 case 0x0300: … … 1994 2023 */ 1995 2024 uint16_t uCmd = devpciR3GetWord(pPciDev, VBOX_PCI_COMMAND); 1996 devpciR3SetWord(p PciDev, VBOX_PCI_COMMAND, uCmd | VBOX_PCI_COMMAND_IO);2025 devpciR3SetWord(pDevIns, pPciDev, VBOX_PCI_COMMAND, uCmd | VBOX_PCI_COMMAND_IO); 1997 2026 break; 1998 2027 } … … 2019 2048 Log(("Using pin %d and IRQ %d for device %02x:%02x.%d\n", 2020 2049 iPin, iIrq, pBus->iBus, uDevFn>>3, uDevFn&7)); 2021 devpciR3SetByte(p PciDev, VBOX_PCI_INTERRUPT_LINE, iIrq);2050 devpciR3SetByte(pDevIns, pPciDev, VBOX_PCI_INTERRUPT_LINE, iIrq); 2022 2051 } 2023 2052 } … … 2031 2060 PDEVPCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 2032 2061 2033 ich9pciBiosInitBridge(p PciRoot, pChildBus);2062 ich9pciBiosInitBridge(pDevIns, pPciRoot, pChildBus); 2034 2063 } 2035 2064 … … 2049 2078 uint64_t u64MMIOAddressBase = pPciRoot->uPciBiosMmio64; 2050 2079 2051 bool fProbe = ich9pciBiosInitBridgePrefetchable(p PciRoot, pChildBus, false /* fUse64Bit */, true /* fDryrun */);2080 bool fProbe = ich9pciBiosInitBridgePrefetchable(pDevIns, pPciRoot, pChildBus, false /* fUse64Bit */, true /* fDryrun */); 2052 2081 pPciRoot->uPciBiosMmio = u32MMIOAddressBase; 2053 2082 pPciRoot->uPciBiosMmio64 = u64MMIOAddressBase; 2054 2083 if (fProbe) 2055 2084 { 2056 fProbe = ich9pciBiosInitBridgePrefetchable(p PciRoot, pChildBus, true /* fUse64Bit */, true /* fDryrun */);2085 fProbe = ich9pciBiosInitBridgePrefetchable(pDevIns, pPciRoot, pChildBus, true /* fUse64Bit */, true /* fDryrun */); 2057 2086 pPciRoot->uPciBiosMmio = u32MMIOAddressBase; 2058 2087 pPciRoot->uPciBiosMmio64 = u64MMIOAddressBase; … … 2060 2089 LogRel(("PCI: unresolvable prefetchable memory behind bridge %02x:%02x.%d\n", pChildBus->iBus, pBridge->uDevFn >> 3, pBridge->uDevFn & 7)); 2061 2090 else 2062 ich9pciBiosInitBridgePrefetchable(p PciRoot, pChildBus, true /* fUse64Bit */, false /* fDryrun */);2091 ich9pciBiosInitBridgePrefetchable(pDevIns, pPciRoot, pChildBus, true /* fUse64Bit */, false /* fDryrun */); 2063 2092 } 2064 2093 else 2065 ich9pciBiosInitBridgePrefetchable(p PciRoot, pChildBus, false /* fUse64Bit */, false /* fDryrun */);2094 ich9pciBiosInitBridgePrefetchable(pDevIns, pPciRoot, pChildBus, false /* fUse64Bit */, false /* fDryrun */); 2066 2095 } 2067 2096 } … … 2082 2111 * @param uBusPrimary The primary bus number the bus is connected to. 2083 2112 */ 2084 static uint8_t ich9pciBiosInitBridgeTopology(PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, uint32_t *pbmUsed, uint8_t uBusPrimary) 2113 static uint8_t ich9pciBiosInitBridgeTopology(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, 2114 uint32_t *pbmUsed, uint8_t uBusPrimary) 2085 2115 { 2086 2116 PPDMPCIDEV pBridgeDev = &pBus->PciDev; … … 2095 2125 if (pBus->iBus != 0) 2096 2126 { 2097 devpciR3SetByte(p BridgeDev, VBOX_PCI_PRIMARY_BUS, uBusPrimary);2098 devpciR3SetByte(p BridgeDev, VBOX_PCI_SECONDARY_BUS, pBus->iBus);2127 devpciR3SetByte(pDevIns, pBridgeDev, VBOX_PCI_PRIMARY_BUS, uBusPrimary); 2128 devpciR3SetByte(pDevIns, pBridgeDev, VBOX_PCI_SECONDARY_BUS, pBus->iBus); 2099 2129 /* Since the subordinate bus value can only be finalized once we 2100 2130 * finished recursing through everything behind the bridge, the only … … 2103 2133 * (for our own sloppy emulation it apparently doesn't matter, but 2104 2134 * this is vital for real PCI bridges/devices in passthrough mode). */ 2105 devpciR3SetByte(p BridgeDev, VBOX_PCI_SUBORDINATE_BUS, 0xff);2135 devpciR3SetByte(pDevIns, pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, 0xff); 2106 2136 } 2107 2137 … … 2113 2143 ("Device is not a PCI bridge but on the list of PCI bridges\n")); 2114 2144 PDEVPCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PDEVPCIBUS); 2115 uint8_t uMaxChildSubBus = ich9pciBiosInitBridgeTopology(p PciRoot, pChildBus, pbmUsed, pBus->iBus);2145 uint8_t uMaxChildSubBus = ich9pciBiosInitBridgeTopology(pDevIns, pPciRoot, pChildBus, pbmUsed, pBus->iBus); 2116 2146 uMaxSubNum = RT_MAX(uMaxSubNum, uMaxChildSubBus); 2117 2147 } 2118 2148 2119 2149 if (pBus->iBus != 0) 2120 devpciR3SetByte(p BridgeDev, VBOX_PCI_SUBORDINATE_BUS, uMaxSubNum);2150 devpciR3SetByte(pDevIns, pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, uMaxSubNum); 2121 2151 for (uint32_t i = pBus->iBus; i <= uMaxSubNum; i++) 2122 2152 *pbmUsed |= RT_BIT_32(i); … … 2126 2156 * but on the other hand it can't hurt either. */ 2127 2157 if (pBus->iBus != 0) 2128 devpciR3SetWord(p BridgeDev, VBOX_PCI_COMMAND,2158 devpciR3SetWord(pDevIns, pBridgeDev, VBOX_PCI_COMMAND, 2129 2159 VBOX_PCI_COMMAND_IO 2130 2160 | VBOX_PCI_COMMAND_MEMORY … … 2132 2162 2133 2163 /* safe, only needs to go to the config space array */ 2134 Log2Func(("for bus %p: primary=%d secondary=%d subordinate=%d\n", 2135 pBus, 2136 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_PRIMARY_BUS), 2137 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_SECONDARY_BUS), 2138 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS) 2139 )); 2164 Log2Func(("for bus %p: primary=%d secondary=%d subordinate=%d\n", pBus, 2165 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_PRIMARY_BUS), 2166 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_SECONDARY_BUS), 2167 PDMPciDevGetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS) )); 2140 2168 2141 2169 return uMaxSubNum; … … 2184 2212 AssertLogRel(pBus->iBus == 0); 2185 2213 uint32_t bmUsed = 0; 2186 ich9pciBiosInitBridgeTopology(p PciRoot, pBus, &bmUsed, 0);2214 ich9pciBiosInitBridgeTopology(pDevIns, pPciRoot, pBus, &bmUsed, 0); 2187 2215 2188 2216 /* 2189 2217 * Init all devices on bus 0 (recursing to further buses). 2190 2218 */ 2191 ich9pciBiosInitAllDevicesOnBus(p PciRoot, pBus);2219 ich9pciBiosInitAllDevicesOnBus(pDevIns, pPciRoot, pBus); 2192 2220 2193 2221 return VINF_SUCCESS; … … 2199 2227 2200 2228 /** 2201 * @callback_method_impl{PFNPCICONFIGREAD, Default config space read callback.} 2202 */ 2203 DECLCALLBACK(uint32_t) devpciR3CommonDefaultConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb) 2204 { 2205 NOREF(pDevIns); 2206 2229 * Reads config space for a device, ignoring interceptors. 2230 */ 2231 DECLHIDDEN(VBOXSTRICTRC) devpciR3CommonConfigReadWorker(PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 2232 { 2207 2233 uint32_t uValue; 2208 2234 if (uAddress + cb <= 256) … … 2246 2272 uValue = 0; 2247 2273 } 2248 return uValue; 2274 2275 *pu32Value = uValue; 2276 return VINF_SUCCESS; 2277 } 2278 2279 2280 /** 2281 * @interface_method_impl{PDMPCIBUSREGR3,pfnConfigRead} 2282 */ 2283 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 2284 uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 2285 { 2286 RT_NOREF(pDevIns); 2287 return devpciR3CommonConfigReadWorker(pPciDev, uAddress, cb, pu32Value); 2249 2288 } 2250 2289 … … 2254 2293 * 2255 2294 * @returns VBox status code. 2295 * @param pDevIns The PCI bus device instance. 2256 2296 * @param pDev The PCI device. 2257 2297 * @param iRegion The region to unmap. 2258 2298 */ 2259 static int devpciR3UnmapRegion(PPDM PCIDEV pDev, int iRegion)2299 static int devpciR3UnmapRegion(PPDMDEVINS pDevIns, PPDMPCIDEV pDev, int iRegion) 2260 2300 { 2261 2301 PCIIORegion *pRegion = &pDev->Int.s.aIORegions[iRegion]; … … 2275 2315 else 2276 2316 { 2277 PDEVPCIBUS pBus = pDev->Int.s.CTX_SUFF(pBus);2278 RTGCPHYS GCPhysBase = pRegion->addr;2279 if (pBus ->pPciHlpR3->pfnIsMMIOExBase(pBus->pDevInsR3, pDev->Int.s.pDevInsR3, GCPhysBase))2317 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 2318 RTGCPHYS GCPhysBase = pRegion->addr; 2319 if (pBusCC->pPciHlpR3->pfnIsMMIOExBase(pDevIns, pDev->Int.s.pDevInsR3, GCPhysBase)) 2280 2320 { 2281 2321 /* unmap it. */ … … 2299 2339 * 2300 2340 * @returns VINF_SUCCESS of DBGFSTOP result. 2341 * @param pDevIns The PCI bus device instance. 2301 2342 * @param pPciDev The PCI device to update the mappings for. 2302 2343 * @param fP2PBridge Whether this is a PCI to PCI bridge or not. 2303 2344 */ 2304 static VBOXSTRICTRC devpciR3UpdateMappings(PPDM PCIDEV pPciDev, bool fP2PBridge)2345 static VBOXSTRICTRC devpciR3UpdateMappings(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, bool fP2PBridge) 2305 2346 { 2306 2347 /* safe, only needs to go to the config space array */ … … 2406 2447 pPciDev->pszNameR3, iRegion, pRegion->addr, uNew, cbRegion, cbRegion)); 2407 2448 2408 devpciR3UnmapRegion(p PciDev, iRegion);2449 devpciR3UnmapRegion(pDevIns, pPciDev, iRegion); 2409 2450 pRegion->addr = uNew; 2410 2451 if (uNew != INVALID_PCI_ADDRESS) 2411 2452 { 2412 2453 int rc = pRegion->map_func(pPciDev->Int.s.pDevInsR3, pPciDev, iRegion, uNew, cbRegion, 2413 (PCIADDRESSSPACE) (pRegion->type));2454 (PCIADDRESSSPACE)pRegion->type); 2414 2455 AssertRC(rc); 2415 2456 } … … 2546 2587 2547 2588 /** 2548 * @callback_method_impl{PFNPCICONFIGWRITE, 2549 * Default config space write callback.} 2589 * Writes config space for a device, ignoring interceptors. 2550 2590 * 2551 2591 * See paragraph 7.5 of PCI Express specification (p. 349) for 2552 2592 * definition of registers and their writability policy. 2553 2593 */ 2554 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonDefaultConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 2555 uint32_t uAddress, uint32_t u32Value, unsigned cb) 2556 { 2557 NOREF(pDevIns); 2558 Assert(cb <= 4); 2559 VBOXSTRICTRC rcRet = VINF_SUCCESS; 2594 DECLHIDDEN(VBOXSTRICTRC) devpciR3CommonConfigWriteWorker(PPDMDEVINS pDevIns, PDEVPCIBUSCC pBusCC, 2595 PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t u32Value) 2596 { 2597 Assert(cb <= 4 && cb != 3); 2598 VBOXSTRICTRC rcStrict = VINF_SUCCESS; 2560 2599 2561 2600 if (uAddress + cb <= 256) … … 2566 2605 if ( pciDevIsMsiCapable(pPciDev) 2567 2606 && uAddress - (uint32_t)pPciDev->Int.s.u8MsiCapOffset < (uint32_t)pPciDev->Int.s.u8MsiCapSize) 2568 MsiR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns), 2569 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), 2570 pPciDev, uAddress, u32Value, cb); 2607 MsiR3PciConfigWrite(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, uAddress, u32Value, cb); 2571 2608 else if ( pciDevIsMsixCapable(pPciDev) 2572 2609 && uAddress - (uint32_t)pPciDev->Int.s.u8MsixCapOffset < (uint32_t)pPciDev->Int.s.u8MsixCapSize) 2573 MsixR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns), 2574 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), 2575 pPciDev, uAddress, u32Value, cb); 2610 MsixR3PciConfigWrite(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, uAddress, u32Value, cb); 2576 2611 else 2577 2612 { … … 2684 2719 */ 2685 2720 if (fUpdateMappings) 2686 rc Ret = devpciR3UpdateMappings(pPciDev, fP2PBridge);2721 rcStrict = devpciR3UpdateMappings(pDevIns, pPciDev, fP2PBridge); 2687 2722 } 2688 2723 } … … 2693 2728 AssertMsgFailed(("Write after end of PCI config space\n")); 2694 2729 2695 return rcRet; 2730 return rcStrict; 2731 } 2732 2733 2734 /** 2735 * @interface_method_impl{PDMPCIBUSREGR3,pfnConfigWrite} 2736 */ 2737 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 2738 uint32_t uAddress, unsigned cb, uint32_t u32Value) 2739 { 2740 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 2741 return devpciR3CommonConfigWriteWorker(pDevIns, pBusCC, pPciDev, uAddress, cb, u32Value); 2696 2742 } 2697 2743 … … 2976 3022 * @interface_method_impl{PDMDEVREG,pfnConstruct} 2977 3023 */ 2978 static DECLCALLBACK(int) ich9pci Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)3024 static DECLCALLBACK(int) ich9pciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 2979 3025 { 2980 3026 RT_NOREF1(iInstance); … … 3019 3065 * Init data. 3020 3066 */ 3021 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 3022 PDEVPCIBUS pBus = &pPciRoot->PciBus; 3067 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 3068 PDEVPCIBUS pBus = &pPciRoot->PciBus; 3069 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 3070 3023 3071 /* Zero out everything */ 3024 memset(pPciRoot, 0, sizeof(*pPciRoot)); 3072 Assert(ASMMemIsZero(pPciRoot, sizeof(*pPciRoot))); 3073 memset(pPciRoot, 0, sizeof(*pPciRoot)); /** @todo unnecessary as instance data is always set to zero by the allocator, see assertion above. */ 3074 3025 3075 /* And fill values */ 3026 3076 if (!fUseIoApic) … … 3036 3086 N_("Configuration error: Failed to read \"McfgLength\"")); 3037 3087 3038 pPciRoot->fUseIoApic = fUseIoApic; 3039 pPciRoot->pDevInsR3 = pDevIns; 3040 pPciRoot->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 3041 pPciRoot->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3042 3043 pPciRoot->PciBus.fTypePiix3 = false; 3044 pPciRoot->PciBus.fTypeIch9 = true; 3045 pPciRoot->PciBus.fPureBridge = false; 3046 pPciRoot->PciBus.pDevInsR3 = pDevIns; 3047 pPciRoot->PciBus.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 3048 pPciRoot->PciBus.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3088 pBusCC->pDevInsR3 = pDevIns; 3089 pPciRoot->fUseIoApic = fUseIoApic; 3090 pPciRoot->PciBus.fTypePiix3 = false; 3091 pPciRoot->PciBus.fTypeIch9 = true; 3092 pPciRoot->PciBus.fPureBridge = false; 3049 3093 pPciRoot->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pPciRoot->PciBus.apDevices)); 3050 3094 AssertLogRelReturn(pPciRoot->PciBus.papBridgesR3, VERR_NO_MEMORY); … … 3053 3097 * Register bus 3054 3098 */ 3055 PDMPCIBUSREG PciBusReg; 3056 PciBusReg.u32Version = PDM_PCIBUSREG_VERSION; 3057 PciBusReg.pfnRegisterR3 = pciR3MergedRegister; 3058 PciBusReg.pfnRegisterMsiR3 = ich9pciRegisterMsi; 3059 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 3060 PciBusReg.pfnSetConfigCallbacksR3 = devpciR3CommonSetConfigCallbacks; 3061 PciBusReg.pfnSetIrqR3 = ich9pciSetIrq; 3062 PciBusReg.pszSetIrqRC = fGCEnabled ? "ich9pciSetIrq" : NULL; 3063 PciBusReg.pszSetIrqR0 = fR0Enabled ? "ich9pciSetIrq" : NULL; 3064 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBus->pPciHlpR3, &pBus->iBus); 3099 PDMPCIBUSREGCC PciBusReg; 3100 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 3101 PciBusReg.pfnRegisterR3 = pciR3MergedRegister; 3102 PciBusReg.pfnRegisterMsiR3 = ich9pciRegisterMsi; 3103 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 3104 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses; 3105 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead; 3106 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite; 3107 PciBusReg.pfnSetIrqR3 = ich9pciSetIrq; 3108 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 3109 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus); 3065 3110 if (RT_FAILURE(rc)) 3066 return PDMDEV_SET_ERROR(pDevIns, rc, 3067 N_("Failed to register ourselves as a PCI Bus")); 3111 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as a PCI Bus")); 3068 3112 Assert(pBus->iBus == 0); 3069 if (pBus ->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)3113 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION) 3070 3114 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS, 3071 3115 N_("PCI helper version mismatch; got %#x expected %#x"), 3072 pBus->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 3073 3074 pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns); 3075 pBus->pPciHlpR0 = pBus->pPciHlpR3->pfnGetR0Helpers(pDevIns); 3116 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 3076 3117 3077 3118 /* … … 3177 3218 * @interface_method_impl{PDMDEVREG,pfnDestruct} 3178 3219 */ 3179 static DECLCALLBACK(int) ich9pci Destruct(PPDMDEVINS pDevIns)3220 static DECLCALLBACK(int) ich9pciR3Destruct(PPDMDEVINS pDevIns) 3180 3221 { 3181 3222 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); … … 3189 3230 3190 3231 3191 void devpciR3ResetDevice(PPDMPCIDEV pDev) 3232 /** 3233 * @param pDevIns The PCI bus device instance. 3234 * @param pDev The PCI device to reset. 3235 */ 3236 void devpciR3ResetDevice(PPDMDEVINS pDevIns, PPDMPCIDEV pDev) 3192 3237 { 3193 3238 /* Clear regions */ … … 3200 3245 == PCI_ADDRESS_SPACE_BAR64; 3201 3246 3202 devpciR3UnmapRegion(pDev , iRegion);3247 devpciR3UnmapRegion(pDevIns, pDev, iRegion); 3203 3248 3204 3249 if (f64Bit) … … 3213 3258 else 3214 3259 { 3215 devpciR3SetWord(pDev , VBOX_PCI_COMMAND,3260 devpciR3SetWord(pDevIns, pDev, VBOX_PCI_COMMAND, 3216 3261 devpciR3GetWord(pDev, VBOX_PCI_COMMAND) 3217 3262 & ~(VBOX_PCI_COMMAND_IO | VBOX_PCI_COMMAND_MEMORY | … … 3223 3268 if (!pciDevIsPci2PciBridge(pDev)) 3224 3269 { 3225 devpciR3SetByte(pDev , VBOX_PCI_CACHE_LINE_SIZE, 0x0);3226 devpciR3SetByte(pDev , VBOX_PCI_INTERRUPT_LINE, 0x0);3270 devpciR3SetByte(pDevIns, pDev, VBOX_PCI_CACHE_LINE_SIZE, 0x0); 3271 devpciR3SetByte(pDevIns, pDev, VBOX_PCI_INTERRUPT_LINE, 0x0); 3227 3272 } 3228 3273 3229 3274 /* Reset MSI message control. */ 3230 3275 if (pciDevIsMsiCapable(pDev)) 3231 { 3232 devpciR3SetWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL, 3276 devpciR3SetWord(pDevIns, pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL, 3233 3277 devpciR3GetWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL) & 0xff8e); 3234 }3235 3278 3236 3279 /* Reset MSI-X message control. */ 3237 3280 if (pciDevIsMsixCapable(pDev)) 3238 { 3239 devpciR3SetWord(pDev, pDev->Int.s.u8MsixCapOffset + VBOX_MSIX_CAP_MESSAGE_CONTROL, 3281 devpciR3SetWord(pDevIns, pDev, pDev->Int.s.u8MsixCapOffset + VBOX_MSIX_CAP_MESSAGE_CONTROL, 3240 3282 devpciR3GetWord(pDev, pDev->Int.s.u8MsixCapOffset + VBOX_MSIX_CAP_MESSAGE_CONTROL) & 0x3fff); 3241 }3242 3283 } 3243 3284 } … … 3286 3327 { 3287 3328 if (pBus->apDevices[uDevFn]) 3288 devpciR3ResetDevice(p Bus->apDevices[uDevFn]);3329 devpciR3ResetDevice(pDevIns, pBus->apDevices[uDevFn]); 3289 3330 } 3290 3331 … … 3299 3340 if (pBus->iBus != 0) 3300 3341 { 3301 devpciR3SetByte( &pBus->PciDev, VBOX_PCI_PRIMARY_BUS, 0);3302 devpciR3SetByte( &pBus->PciDev, VBOX_PCI_SECONDARY_BUS, 0);3303 devpciR3SetByte( &pBus->PciDev, VBOX_PCI_SUBORDINATE_BUS, 0);3342 devpciR3SetByte(pDevIns, &pBus->PciDev, VBOX_PCI_PRIMARY_BUS, 0); 3343 devpciR3SetByte(pDevIns, &pBus->PciDev, VBOX_PCI_SECONDARY_BUS, 0); 3344 devpciR3SetByte(pDevIns, &pBus->PciDev, VBOX_PCI_SUBORDINATE_BUS, 0); 3304 3345 /* Not resetting the address decoders of the bridge to 0, since the 3305 3346 * PCI-to-PCI Bridge spec says that there is no default value. */ … … 3324 3365 { 3325 3366 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3326 3327 pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);3328 pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns);3329 3367 3330 3368 /* Relocate RC pointers for the attached pci devices. */ … … 3347 3385 DECLCALLBACK(void) devpciR3RootRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 3348 3386 { 3349 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);3350 pPciRoot->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);3351 3352 3387 AssertCompileMemberOffset(DEVPCIROOT, PciBus, 0); 3353 3388 devpciR3BusRelocate(pDevIns, offDelta); … … 3368 3403 } 3369 3404 3405 /** 3406 * @interface_method_impl{PDMDEVREG,pfnDestruct} 3407 */ 3408 static DECLCALLBACK(int) ich9pcibridgeR3Destruct(PPDMDEVINS pDevIns) 3409 { 3410 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3411 if (pBus->papBridgesR3) 3412 { 3413 PDMDevHlpMMHeapFree(pDevIns, pBus->papBridgesR3); 3414 pBus->papBridgesR3 = NULL; 3415 } 3416 return VINF_SUCCESS; 3417 } 3418 3370 3419 3371 3420 /** 3372 3421 * @interface_method_impl{PDMDEVREG,pfnConstruct} 3373 3422 */ 3374 static DECLCALLBACK(int) ich9pcibridgeConstruct(PPDMDEVINS pDevIns, 3375 int iInstance, 3376 PCFGMNODE pCfg) 3423 static DECLCALLBACK(int) ich9pcibridgeR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 3377 3424 { 3378 3425 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); … … 3421 3468 * Init data and register the PCI bus. 3422 3469 */ 3423 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3470 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 3471 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3424 3472 pBus->fTypePiix3 = false; 3425 3473 pBus->fTypeIch9 = true; 3426 3474 pBus->fPureBridge = true; 3427 pBus->pDevInsR3 = pDevIns; 3428 pBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 3429 pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3475 pBusCC->pDevInsR3 = pDevIns; 3430 3476 /** @todo r=klaus figure out how to extend this to allow PCIe config space 3431 3477 * extension, which increases the config space from 256 bytes to 4K. */ … … 3433 3479 AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY); 3434 3480 3435 PDMPCIBUSREG PciBusReg; 3436 PciBusReg.u32Version = PDM_PCIBUSREG_VERSION; 3437 PciBusReg.pfnRegisterR3 = pcibridgeR3MergedRegisterDevice; 3438 PciBusReg.pfnRegisterMsiR3 = ich9pciRegisterMsi; 3439 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 3440 PciBusReg.pfnSetConfigCallbacksR3 = devpciR3CommonSetConfigCallbacks; 3441 PciBusReg.pfnSetIrqR3 = ich9pcibridgeSetIrq; 3442 PciBusReg.pszSetIrqRC = fGCEnabled ? "ich9pcibridgeSetIrq" : NULL; 3443 PciBusReg.pszSetIrqR0 = fR0Enabled ? "ich9pcibridgeSetIrq" : NULL; 3444 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBus->pPciHlpR3, &pBus->iBus); 3481 PDMPCIBUSREGCC PciBusReg; 3482 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 3483 PciBusReg.pfnRegisterR3 = pcibridgeR3MergedRegisterDevice; 3484 PciBusReg.pfnRegisterMsiR3 = ich9pciRegisterMsi; 3485 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister; 3486 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses; 3487 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite; 3488 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead; 3489 PciBusReg.pfnSetIrqR3 = ich9pcibridgeSetIrq; 3490 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 3491 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus); 3445 3492 if (RT_FAILURE(rc)) 3446 return PDMDEV_SET_ERROR(pDevIns, rc, 3447 N_("Failed to register ourselves as a PCI Bus")); 3493 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as a PCI Bus")); 3448 3494 Assert(pBus->iBus == (uint32_t)iInstance + 1); /* Can be removed when adding support for multiple bridge implementations. */ 3449 if (pBus ->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)3495 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION) 3450 3496 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS, 3451 3497 N_("PCI helper version mismatch; got %#x expected %#x"), 3452 pBus->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 3453 3454 pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns); 3455 pBus->pPciHlpR0 = pBus->pPciHlpR3->pfnGetR0Helpers(pDevIns); 3498 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION); 3499 3456 3500 LogRel(("PCI: Registered bridge instance #%u as PDM bus no %u.\n", iInstance, pBus->iBus)); 3457 3501 … … 3574 3618 } 3575 3619 3576 /** 3577 * @interface_method_impl{PDMDEVREG,pfnDestruct} 3578 */ 3579 static DECLCALLBACK(int) ich9pcibridgeDestruct(PPDMDEVINS pDevIns) 3580 { 3581 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3582 if (pBus->papBridgesR3) 3583 { 3584 PDMDevHlpMMHeapFree(pDevIns, pBus->papBridgesR3); 3585 pBus->papBridgesR3 = NULL; 3586 } 3587 return VINF_SUCCESS; 3588 } 3589 3590 #endif /* IN_RING3 */ 3620 #else /* !IN_RING3 */ 3621 3622 /** 3623 * @interface_method_impl{PDMDEVREGR0,pfnConstruct} 3624 */ 3625 DECLCALLBACK(int) ich9pciRZConstruct(PPDMDEVINS pDevIns) 3626 { 3627 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 3628 PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); 3629 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 3630 3631 PDMPCIBUSREGCC PciBusReg; 3632 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 3633 PciBusReg.iBus = pGlobals->PciBus.iBus; 3634 PciBusReg.pfnSetIrq = ich9pciSetIrq; 3635 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 3636 int rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp)); 3637 AssertRC(rc); 3638 3639 /* Disable default device locking. */ 3640 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 3641 AssertRCReturn(rc, rc); 3642 3643 return rc; 3644 } 3645 3646 3647 /** 3648 * @interface_method_impl{PDMDEVREGR0,pfnConstruct} 3649 */ 3650 DECLCALLBACK(int) ich9pcibridgeRZConstruct(PPDMDEVINS pDevIns) 3651 { 3652 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 3653 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3654 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC); 3655 3656 PDMPCIBUSREGCC PciBusReg; 3657 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION; 3658 PciBusReg.iBus = pBus->iBus; 3659 PciBusReg.pfnSetIrq = ich9pcibridgeSetIrq; 3660 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION; 3661 int rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp)); 3662 AssertRC(rc); 3663 3664 /* Disable default device locking. */ 3665 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 3666 AssertRCReturn(rc, rc); 3667 3668 return rc; 3669 } 3670 3671 #endif /* !IN_RING3 */ 3591 3672 3592 3673 /** … … 3603 3684 /* .uSharedVersion = */ 42, 3604 3685 /* .cbInstanceShared = */ sizeof(DEVPCIROOT), 3605 /* .cbInstanceCC = */ 0,3606 /* .cbInstanceRC = */ 0,3686 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)), 3687 /* .cbInstanceRC = */ sizeof(DEVPCIBUSRC), 3607 3688 /* .cMaxPciDevices = */ 1, 3608 3689 /* .cMaxMsixVectors = */ 0, … … 3611 3692 /* .pszRCMod = */ "VBoxDDRC.rc", 3612 3693 /* .pszR0Mod = */ "VBoxDDR0.r0", 3613 /* .pfnConstruct = */ ich9pci Construct,3614 /* .pfnDestruct = */ ich9pci Destruct,3694 /* .pfnConstruct = */ ich9pciR3Construct, 3695 /* .pfnDestruct = */ ich9pciR3Destruct, 3615 3696 /* .pfnRelocate = */ devpciR3RootRelocate, 3616 3697 /* .pfnMemSetup = */ NULL, … … 3635 3716 #elif defined(IN_RING0) 3636 3717 /* .pfnEarlyConstruct = */ NULL, 3637 /* .pfnConstruct = */ NULL,3718 /* .pfnConstruct = */ ich9pciRZConstruct, 3638 3719 /* .pfnDestruct = */ NULL, 3639 3720 /* .pfnFinalDestruct = */ NULL, … … 3648 3729 /* .pfnReserved7 = */ NULL, 3649 3730 #elif defined(IN_RC) 3650 /* .pfnConstruct = */ NULL,3731 /* .pfnConstruct = */ ich9pciRZConstruct, 3651 3732 /* .pfnReserved0 = */ NULL, 3652 3733 /* .pfnReserved1 = */ NULL, … … 3677 3758 /* .uSharedVersion = */ 42, 3678 3759 /* .cbInstanceShared = */ sizeof(DEVPCIBUS), 3679 /* .cbInstanceCC = */ 0,3760 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)), 3680 3761 /* .cbInstanceRC = */ 0, 3681 3762 /* .cMaxPciDevices = */ 1, … … 3685 3766 /* .pszRCMod = */ "VBoxDDRC.rc", 3686 3767 /* .pszR0Mod = */ "VBoxDDR0.r0", 3687 /* .pfnConstruct = */ ich9pcibridge Construct,3688 /* .pfnDestruct = */ ich9pcibridge Destruct,3768 /* .pfnConstruct = */ ich9pcibridgeR3Construct, 3769 /* .pfnDestruct = */ ich9pcibridgeR3Destruct, 3689 3770 /* .pfnRelocate = */ devpciR3BusRelocate, 3690 3771 /* .pfnMemSetup = */ NULL, … … 3709 3790 #elif defined(IN_RING0) 3710 3791 /* .pfnEarlyConstruct = */ NULL, 3711 /* .pfnConstruct = */ NULL,3792 /* .pfnConstruct = */ ich9pcibridgeRZConstruct, 3712 3793 /* .pfnDestruct = */ NULL, 3713 3794 /* .pfnFinalDestruct = */ NULL, … … 3722 3803 /* .pfnReserved7 = */ NULL, 3723 3804 #elif defined(IN_RC) 3724 /* .pfnConstruct = */ NULL,3805 /* .pfnConstruct = */ ich9pcibridgeRZConstruct, 3725 3806 /* .pfnReserved0 = */ NULL, 3726 3807 /* .pfnReserved1 = */ NULL, -
trunk/src/VBox/Devices/Bus/DevPciInternal.h
r76565 r80943 29 29 30 30 /** 31 * PCI bus instance (common to both).31 * PCI bus shared instance data (common to both PCI buses). 32 32 */ 33 33 typedef struct DEVPCIBUS … … 42 42 uint32_t fTypePiix3 : 1; 43 43 /** Set if ICH9 type. */ 44 uint32_t fTypeIch9 : 1;44 uint32_t fTypeIch9 : 1; 45 45 /** Set if this is a pure bridge, i.e. not part of DEVPCIGLOBALS struct. */ 46 46 uint32_t fPureBridge : 1; … … 48 48 uint32_t uReservedConfigFlags : 29; 49 49 50 /** Array of bridges attached to the bus. */ 51 R3PTRTYPE(PPDMPCIDEV *) papBridgesR3; 52 /** Cache line align apDevices. */ 53 uint32_t au32Alignment1[HC_ARCH_BITS == 32 ? 3+8 : 2+8]; 54 /** Array of PCI devices. We assume 32 slots, each with 8 functions. */ 55 R3PTRTYPE(PPDMPCIDEV) apDevices[256]; 56 57 /** The PCI device for the PCI bridge. */ 58 PDMPCIDEV PciDev; 59 } DEVPCIBUS; 60 /** Pointer to PCI bus shared instance data. */ 61 typedef DEVPCIBUS *PDEVPCIBUS; 62 63 /** 64 * PCI bus ring-3 instance data (common to both PCI buses). 65 */ 66 typedef struct DEVPCIBUSR3 67 { 50 68 /** R3 pointer to the device instance. */ 51 69 PPDMDEVINSR3 pDevInsR3; 52 70 /** Pointer to the PCI R3 helpers. */ 53 71 PCPDMPCIHLPR3 pPciHlpR3; 54 72 } DEVPCIBUSR3; 73 /** Pointer to PCI bus ring-3 instance data. */ 74 typedef DEVPCIBUSR3 *PDEVPCIBUSR3; 75 76 /** 77 * PCI bus ring-0 instance data (common to both PCI buses). 78 */ 79 typedef struct DEVPCIBUSR0 80 { 55 81 /** R0 pointer to the device instance. */ 56 82 PPDMDEVINSR0 pDevInsR0; 57 83 /** Pointer to the PCI R0 helpers. */ 58 84 PCPDMPCIHLPR0 pPciHlpR0; 59 60 /** RC pointer to the device instance. */ 85 } DEVPCIBUSR0; 86 /** Pointer to PCI bus ring-0 instance data. */ 87 typedef DEVPCIBUSR0 *PDEVPCIBUSR0; 88 89 /** 90 * PCI bus raw-mode instance data (common to both PCI buses). 91 */ 92 typedef struct DEVPCIBUSRC 93 { 94 /** R0 pointer to the device instance. */ 61 95 PPDMDEVINSRC pDevInsRC; 62 /** Pointer to the PCI RChelpers. */96 /** Pointer to the PCI raw-mode helpers. */ 63 97 PCPDMPCIHLPRC pPciHlpRC; 64 65 /** Array of bridges attached to the bus. */ 66 R3PTRTYPE(PPDMPCIDEV *) papBridgesR3; 67 #if HC_ARCH_BITS == 32 68 uint32_t au32Alignment1[5]; /**< Cache line align apDevices. */ 69 #endif 70 /** Array of PCI devices. We assume 32 slots, each with 8 functions. */ 71 R3PTRTYPE(PPDMPCIDEV) apDevices[256]; 72 73 /** The PCI device for the PCI bridge. */ 74 PDMPCIDEV PciDev; 75 } DEVPCIBUS; 76 /** Pointer to a PCI bus instance. */ 77 typedef DEVPCIBUS *PDEVPCIBUS; 98 } DEVPCIBUSRC; 99 /** Pointer to PCI bus raw-mode instance data. */ 100 typedef DEVPCIBUSRC *PDEVPCIBUSRC; 101 102 /** DEVPCIBUSR3, DEVPCIBUSR0 or DEVPCIBUSRC depending on context. */ 103 typedef CTX_SUFF(DEVPCIBUS) DEVPCIBUSCC; 104 /** PDEVPCIBUSR3, PDEVPCIBUSR0 or PDEVPCIBUSRC depending on context. */ 105 typedef CTX_SUFF(PDEVPCIBUS) PDEVPCIBUSCC; 78 106 79 107 … … 99 127 100 128 /** 101 * PCI Globals - This is the host-to-pci bridge and the root bus .129 * PCI Globals - This is the host-to-pci bridge and the root bus, shared data. 102 130 * 103 131 * @note Only used by the root bus, not the bridges. … … 109 137 DEVPCIBUS PciBus; 110 138 111 /** R3 pointer to the device instance. */112 PPDMDEVINSR3 pDevInsR3;113 /** R0 pointer to the device instance. */114 PPDMDEVINSR0 pDevInsR0;115 /** RC pointer to the device instance. */116 PPDMDEVINSRC pDevInsRC;117 118 139 /** I/O APIC usage flag (always true of ICH9, see constructor). */ 119 140 bool fUseIoApic; 120 141 /** Reserved for future config flags. */ 121 bool afFutureFlags[3 ];142 bool afFutureFlags[3+4]; 122 143 /** Physical address of PCI config space MMIO region. */ 123 144 uint64_t u64PciConfigMMioAddress; … … 163 184 /** Pointer to PCI device globals. */ 164 185 typedef DEVPCIROOT *PDEVPCIROOT; 165 166 167 186 /** Converts a PCI bus device instance pointer to a DEVPCIBUS pointer. */ 168 187 #define DEVINS_2_DEVPCIBUS(pDevIns) (&PDMINS_2_DATA(pDevIns, PDEVPCIROOT)->PciBus) … … 176 195 #define PCI_LOCK(pDevIns, rc) \ 177 196 do { \ 178 int rc2 = DEVINS_2_DEVPCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \197 int rc2 = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \ 179 198 if (rc2 != VINF_SUCCESS) \ 180 199 return rc2; \ 181 200 } while (0) 182 201 #define PCI_UNLOCK(pDevIns) \ 183 DEVINS_2_DEVPCIBUS(pDevIns)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns)202 PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns) 184 203 185 204 … … 192 211 DECLCALLBACK(int) devpciR3CommonIORegionRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion, 193 212 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback); 194 DECLCALLBACK(void) devpciR3CommonSetConfigCallbacks(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 195 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld, 196 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld); 197 DECLCALLBACK(uint32_t) devpciR3CommonDefaultConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb); 198 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonDefaultConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 199 uint32_t uAddress, uint32_t u32Value, unsigned cb); 200 void devpciR3CommonRestoreConfig(PPDMPCIDEV pDev, uint8_t const *pbSrcConfig); 213 DECLCALLBACK(void) devpciR3CommonInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 214 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite); 215 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 216 uint32_t uAddress, unsigned cb, uint32_t *pu32Value); 217 DECLHIDDEN(VBOXSTRICTRC) devpciR3CommonConfigReadWorker(PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t *pu32Value); 218 DECLCALLBACK(VBOXSTRICTRC) devpciR3CommonConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 219 uint32_t uAddress, unsigned cb, uint32_t u32Value); 220 DECLHIDDEN(VBOXSTRICTRC) devpciR3CommonConfigWriteWorker(PPDMDEVINS pDevIns, PDEVPCIBUSCC pBusCC, 221 PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t u32Value); 222 void devpciR3CommonRestoreConfig(PPDMDEVINS pDevIns, PPDMPCIDEV pDev, uint8_t const *pbSrcConfig); 201 223 int devpciR3CommonRestoreRegions(PSSMHANDLE pSSM, PPDMPCIDEV pPciDev, PPCIIOREGION paIoRegions, bool fNewState); 202 void devpciR3ResetDevice(PPDM PCIDEV pDev);203 void devpciR3BiosInitSetRegionAddress(P DEVPCIBUS pBus, PPDMPCIDEV pPciDev, int iRegion, uint64_t addr);224 void devpciR3ResetDevice(PPDMDEVINS pDevIns, PPDMPCIDEV pDev); 225 void devpciR3BiosInitSetRegionAddress(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, int iRegion, uint64_t addr); 204 226 uint32_t devpciR3GetCfg(PPDMPCIDEV pPciDev, int32_t iRegister, int cb); 205 void devpciR3SetCfg(PPDM PCIDEV pPciDev, int32_t iRegister, uint32_t u32, int cb);227 void devpciR3SetCfg(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint32_t u32, int cb); 206 228 207 229 DECLINLINE(uint8_t) devpciR3GetByte(PPDMPCIDEV pPciDev, int32_t iRegister) … … 220 242 } 221 243 222 DECLINLINE(void) devpciR3SetByte(PPDM PCIDEV pPciDev, int32_t iRegister, uint8_t u8)223 { 224 devpciR3SetCfg(p PciDev, iRegister, u8, 1);225 } 226 227 DECLINLINE(void) devpciR3SetWord(PPDM PCIDEV pPciDev, int32_t iRegister, uint16_t u16)228 { 229 devpciR3SetCfg(p PciDev, iRegister, u16, 2);230 } 231 232 DECLINLINE(void) devpciR3SetDWord(PPDM PCIDEV pPciDev, int32_t iRegister, uint32_t u32)233 { 234 devpciR3SetCfg(p PciDev, iRegister, u32, 4);244 DECLINLINE(void) devpciR3SetByte(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint8_t u8) 245 { 246 devpciR3SetCfg(pDevIns, pPciDev, iRegister, u8, 1); 247 } 248 249 DECLINLINE(void) devpciR3SetWord(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint16_t u16) 250 { 251 devpciR3SetCfg(pDevIns, pPciDev, iRegister, u16, 2); 252 } 253 254 DECLINLINE(void) devpciR3SetDWord(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint32_t u32) 255 { 256 devpciR3SetCfg(pDevIns, pPciDev, iRegister, u32, 4); 235 257 } 236 258 -
trunk/src/VBox/Devices/Bus/DevPciMerge1.cpp.h
r80531 r80943 60 60 * function number (0-7). 61 61 * @param pszName Device name (static but not unique). 62 * @param pfnConfigRead The default config read method.63 * @param pfnConfigWrite The default config read method.64 62 * 65 63 * @remarks Caller enters the PDM critical section. 66 64 */ 67 65 static int pciR3MergedRegisterDeviceOnBus(PPDMDEVINS pDevIns, PDEVPCIBUS pBus, PPDMPCIDEV pPciDev, uint32_t fFlags, 68 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName, 69 PFNPCICONFIGREAD pfnConfigRead, PFNPCICONFIGWRITE pfnConfigWrite) 66 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName) 70 67 { 71 68 /* … … 197 194 pPciDev->Int.s.pBusR0 = PDMINS_2_DATA_R0PTR(pDevIns); 198 195 pPciDev->Int.s.pBusRC = PDMINS_2_DATA_RCPTR(pDevIns); 199 pPciDev->Int.s.pfnConfigRead = pfnConfigRead;200 pPciDev->Int.s.pfnConfigWrite = pfnConfigWrite;196 pPciDev->Int.s.pfnConfigRead = NULL; 197 pPciDev->Int.s.pfnConfigWrite = NULL; 201 198 202 199 /* Remember and mark bridges. */ … … 225 222 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 226 223 AssertCompileMemberOffset(DEVPCIROOT, PciBus, 0); 227 return pciR3MergedRegisterDeviceOnBus(pDevIns, pBus, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName, 228 devpciR3CommonDefaultConfigRead, devpciR3CommonDefaultConfigWrite); 224 return pciR3MergedRegisterDeviceOnBus(pDevIns, pBus, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName); 229 225 } 230 226 … … 237 233 { 238 234 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 239 return pciR3MergedRegisterDeviceOnBus(pDevIns, pBus, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName, 240 devpciR3CommonDefaultConfigRead, devpciR3CommonDefaultConfigWrite); 241 } 242 235 return pciR3MergedRegisterDeviceOnBus(pDevIns, pBus, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName); 236 } 237 -
trunk/src/VBox/Devices/Bus/MsiCommon.cpp
r76553 r80943 33 33 uint32_t idxMessageControl = pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL; 34 34 #ifdef IN_RING3 35 if (pciDevIsPassthrough(pDev)) 36 return pDev->Int.s.pfnConfigRead(pDev->Int.s.CTX_SUFF(pDevIns), pDev, idxMessageControl, 2); 35 if (pciDevIsPassthrough(pDev) && pDev->Int.s.pfnConfigRead) 36 { 37 uint32_t u32Value = 0; 38 VBOXSTRICTRC rcStrict = pDev->Int.s.pfnConfigRead(pDev->Int.s.CTX_SUFF(pDevIns), pDev, idxMessageControl, 2, &u32Value); 39 AssertRCSuccess(rcStrict); 40 return (uint16_t)u32Value; 41 } 37 42 #endif 38 43 return PCIDevGetWord(pDev, idxMessageControl); -
trunk/src/VBox/Devices/Makefile.kmk
r80732 r80943 524 524 VBoxDD_DEFS += VBOX_WITH_VIRTIO_SCSI 525 525 VBoxDD_SOURCES += \ 526 526 Virtio/Virtio_1_0.cpp \ 527 527 Storage/DevVirtioSCSI.cpp 528 528 endif -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r80704 r80943 435 435 /** Pointer to the driver connector interface. */ 436 436 R3PTRTYPE(PPDMIACPICONNECTOR) pDrv; 437 438 /** Pointer to default PCI config read function. */439 R3PTRTYPE(PFNPCICONFIGREAD) pfnAcpiPciConfigRead;440 /** Pointer to default PCI config write function. */441 R3PTRTYPE(PFNPCICONFIGWRITE) pfnAcpiPciConfigWrite;442 437 443 438 /** Number of custom ACPI tables */ … … 3358 3353 * @callback_method_impl{FNPCICONFIGREAD} 3359 3354 */ 3360 static DECLCALLBACK( uint32_t) acpiR3PciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb)3361 { 3362 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 3363 3364 Log2(("acpi: PCI config read: 0x%x (%d)\n", uAddress, cb));3365 return pThis->pfnAcpiPciConfigRead(pDevIns, pPciDev, uAddress, cb);3355 static DECLCALLBACK(VBOXSTRICTRC) acpiR3PciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3356 uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 3357 { 3358 VBOXSTRICTRC rcStrict = PDMDevHlpPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value); 3359 Log2(("acpi: PCI config read: %#x (%d) -> %#x %Rrc\n", uAddress, cb, *pu32Value, VBOXSTRICTRC_VAL(rcStrict))); 3360 return rcStrict; 3366 3361 } 3367 3362 … … 3369 3364 * @callback_method_impl{FNPCICONFIGWRITE} 3370 3365 */ 3371 static DECLCALLBACK(VBOXSTRICTRC) acpiR3PciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,3372 uint32_t u 32Value, unsigned cb)3366 static DECLCALLBACK(VBOXSTRICTRC) acpiR3PciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 3367 uint32_t uAddress, unsigned cb, uint32_t u32Value) 3373 3368 { 3374 3369 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); … … 3383 3378 } 3384 3379 3385 VBOXSTRICTRC rc Base = pThis->pfnAcpiPciConfigWrite(pDevIns, pPciDev, uAddress, u32Value, cb);3380 VBOXSTRICTRC rcStrict = PDMDevHlpPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value); 3386 3381 3387 3382 /* Assume that the base address is only changed when the corresponding … … 3418 3413 3419 3414 DEVACPI_UNLOCK(pThis); 3420 return rc Base;3415 return rcStrict; 3421 3416 } 3422 3417 … … 4142 4137 return rc; 4143 4138 4144 PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->dev, 4145 acpiR3PciConfigRead, &pThis->pfnAcpiPciConfigRead, 4146 acpiR3PciConfigWrite, &pThis->pfnAcpiPciConfigWrite); 4139 rc = PDMDevHlpPCIInterceptConfigAccesses(pDevIns, &pThis->dev, acpiR3PciConfigRead, acpiR3PciConfigWrite); 4140 AssertRCReturn(rc, rc); 4147 4141 4148 4142 /* -
trunk/src/VBox/Devices/PC/DevLpc-new.cpp
r80704 r80943 59 59 /** Explicit padding. */ 60 60 uint8_t abPadding[HC_ARCH_BITS == 32 ? 2 : 6]; 61 62 /** Pointer to generic PCI config reader. */63 R3PTRTYPE(PFNPCICONFIGREAD) pfnPciConfigReadFallback;64 /** Pointer to generic PCI config write. */65 R3PTRTYPE(PFNPCICONFIGWRITE) pfnPciConfigWriteFallback;66 61 67 62 /** Number of MMIO reads. */ … … 140 135 * @callback_method_impl{FNPCICONFIGREAD} 141 136 */ 142 static DECLCALLBACK(uint32_t) lpcPciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb) 137 static DECLCALLBACK(VBOXSTRICTRC) lpcR3PciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 138 uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 143 139 { 144 140 PLPCSTATE pThis = PDMINS_2_DATA(pDevIns, PLPCSTATE); … … 146 142 147 143 STAM_REL_COUNTER_INC(&pThis->StatPciCfgReads); 148 uint32_t uValue = pThis->pfnPciConfigReadFallback(pDevIns, pPciDev, uAddress, cb);144 VBOXSTRICTRC rcStrict = PDMDevHlpPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value); 149 145 switch (cb) 150 146 { 151 case 1: Log(("lpc PciConfigRead: %#04x -> %#04x\n", uAddress, uValue)); break;152 case 2: Log(("lpc PciConfigRead: %#04x -> %#06x\n", uAddress, uValue)); break;153 case 4: Log(("lpc PciConfigRead: %#04x -> %#010x\n", uAddress, uValue)); break;154 } 155 return uValue;147 case 1: Log(("lpcR3PciConfigRead: %#04x -> %#04x (%Rrc)\n", uAddress, *pu32Value, VBOXSTRICTRC_VAL(rcStrict))); break; 148 case 2: Log(("lpcR3PciConfigRead: %#04x -> %#06x (%Rrc)\n", uAddress, *pu32Value, VBOXSTRICTRC_VAL(rcStrict))); break; 149 case 4: Log(("lpcR3PciConfigRead: %#04x -> %#010x (%Rrc)\n", uAddress, *pu32Value, VBOXSTRICTRC_VAL(rcStrict))); break; 150 } 151 return rcStrict; 156 152 } 157 153 … … 160 156 * @callback_method_impl{FNPCICONFIGWRITE} 161 157 */ 162 static DECLCALLBACK(VBOXSTRICTRC) 163 lpcPciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, uint32_t u32Value, unsigned cb)158 static DECLCALLBACK(VBOXSTRICTRC) lpcR3PciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 159 uint32_t uAddress, unsigned cb, uint32_t u32Value) 164 160 { 165 161 PLPCSTATE pThis = PDMINS_2_DATA(pDevIns, PLPCSTATE); … … 169 165 switch (cb) 170 166 { 171 case 1: Log(("lpc PciConfigWrite: %#04x <- %#04x\n", uAddress, u32Value)); break;172 case 2: Log(("lpc PciConfigWrite: %#04x <- %#06x\n", uAddress, u32Value)); break;173 case 4: Log(("lpc PciConfigWrite: %#04x <- %#010x\n", uAddress, u32Value)); break;174 } 175 176 return pThis->pfnPciConfigWriteFallback(pDevIns, pPciDev, uAddress, u32Value, cb);167 case 1: Log(("lpcR3PciConfigWrite: %#04x <- %#04x\n", uAddress, u32Value)); break; 168 case 2: Log(("lpcR3PciConfigWrite: %#04x <- %#06x\n", uAddress, u32Value)); break; 169 case 4: Log(("lpcR3PciConfigWrite: %#04x <- %#010x\n", uAddress, u32Value)); break; 170 } 171 172 return PDMDevHlpPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value); 177 173 } 178 174 … … 354 350 31 /*uPciDevNo*/, 0 /*uPciFunNo*/, "lpc"); 355 351 AssertRCReturn(rc, rc); 356 PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->PciDev, 357 lpcPciConfigRead, &pThis->pfnPciConfigReadFallback, 358 lpcPciConfigWrite, &pThis->pfnPciConfigWriteFallback); 352 rc = PDMDevHlpPCIInterceptConfigAccesses(pDevIns, &pThis->PciDev, lpcR3PciConfigRead, lpcR3PciConfigWrite); 353 AssertRCReturn(rc, rc); 359 354 360 355 /* -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r80931 r80943 545 545 * 546 546 * @param pVirtio Virtio instance state 547 * @param fWrite If write access (otherwise read access)547 * @param fWrite Set if write access, clear if read access. 548 548 * @param pv Pointer to location to write to or read from 549 549 * @param cb Number of bytes to read or write 550 550 */ 551 static int virtioCommonCfgAccessed(PVIRTIOSTATE pVirtio, intfWrite, off_t uOffset, unsigned cb, void const *pv)551 static int virtioCommonCfgAccessed(PVIRTIOSTATE pVirtio, bool fWrite, off_t uOffset, unsigned cb, void const *pv) 552 552 { 553 553 int rc = VINF_SUCCESS; … … 765 765 { 766 766 uint32_t uOffset = GCPhysAddr - pVirtio->pGcPhysCommonCfg; 767 virtioCommonCfgAccessed(pVirtio, 0/* fWrite */, uOffset, cb, (void const *)pv);767 virtioCommonCfgAccessed(pVirtio, false /* fWrite */, uOffset, cb, (void const *)pv); 768 768 } 769 769 else … … 816 816 { 817 817 uint32_t uOffset = GCPhysAddr - pVirtio->pGcPhysCommonCfg; 818 virtioCommonCfgAccessed(pVirtio, 1/* fWrite */, uOffset, cb, pv);818 virtioCommonCfgAccessed(pVirtio, true /* fWrite */, uOffset, cb, pv); 819 819 } 820 820 else … … 884 884 885 885 /** 886 * Callback function for reading from the PCI configuration space. 887 * 888 * @returns The register value. 889 * @param pDevIns Pointer to the device instance the PCI device 890 * belongs to. 891 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 892 * @param uAddress The configuration space register address. [0..4096] 893 * @param cb The register size. [1,2,4] 894 * 895 * @remarks Called with the PDM lock held. The device lock is NOT take because 896 * that is very likely be a lock order violation. 897 */ 898 static DECLCALLBACK(uint32_t) virtioPciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 899 uint32_t uAddress, unsigned cb) 886 * @callback_method_impl{FNPCICONFIGRead} 887 */ 888 static DECLCALLBACK(VBOXSTRICTRC) virtioR3PciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 889 uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 900 890 { 901 891 PVIRTIOSTATE pVirtio = *PDMINS_2_DATA(pDevIns, PVIRTIOSTATE *); 902 892 RT_NOREF(pPciDev); 893 894 /** @todo r=bird: this comparison just cannot be correct. */ 903 895 if (uAddress == (uint64_t)&pVirtio->pPciCfgCap->uPciCfgData) 904 896 { … … 909 901 uint32_t uOffset = pVirtio->pPciCfgCap->pciCap.uOffset; 910 902 uint8_t uBar = pVirtio->pPciCfgCap->pciCap.uBar; 911 uint32_t pv= 0;903 *pu32Value = 0; 912 904 if (uBar == VIRTIO_REGION_PCI_CAP) 913 (void)virtioR3MmioRead(pDevIns, NULL, (RTGCPHYS)((uint32_t)pVirtio->pGcPhysPciCapBase + uOffset), 914 &pv, uLength); 905 { 906 virtioR3MmioRead(pDevIns, NULL, (RTGCPHYS)((uint32_t)pVirtio->pGcPhysPciCapBase + uOffset), pu32Value, uLength); 907 Log2Func(("virtio: Guest read virtio_pci_cfg_cap.pci_cfg_data, bar=%d, offset=%d, length=%d, result=%d\n", 908 uBar, uOffset, uLength, *pu32Value)); 909 } 915 910 else 916 {917 911 Log2Func(("Guest read virtio_pci_cfg_cap.pci_cfg_data using unconfigured BAR. Ignoring")); 918 return 0; 919 } 920 Log2Func(("virtio: Guest read virtio_pci_cfg_cap.pci_cfg_data, bar=%d, offset=%d, length=%d, result=%d\n", 921 uBar, uOffset, uLength, pv)); 922 return pv; 923 } 924 return pVirtio->pfnPciConfigReadOld(pDevIns, pPciDev, uAddress, cb); 925 } 926 927 /** 928 * Callback function for writing to the PCI configuration space. 929 * 930 * @returns VINF_SUCCESS or PDMDevHlpDBGFStop status. 931 * 932 * @param pDevIns Pointer to the device instance the PCI device 933 * belongs to. 934 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 935 * @param uAddress The configuration space register address. [0..4096] 936 * @param u32Value The value that's being written. The number of bits actually used from 937 * this value is determined by the cb parameter. 938 * @param cb The register size. [1,2,4] 939 * 940 * @remarks Called with the PDM lock held. The device lock is NOT take because 941 * that is very likely be a lock order violation. 942 */ 943 static DECLCALLBACK(VBOXSTRICTRC) virtioPciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 944 uint32_t uAddress, uint32_t u32Value, unsigned cb) 912 return VINF_SUCCESS; 913 } 914 return VINF_PDM_PCI_DO_DEFAULT; 915 } 916 917 /** 918 * @callback_method_impl{FNPCICONFIGWRITE} 919 */ 920 static DECLCALLBACK(VBOXSTRICTRC) virtioR3PciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 921 uint32_t uAddress, unsigned cb, uint32_t u32Value) 945 922 { 946 923 PVIRTIOSTATE pVirtio = *PDMINS_2_DATA(pDevIns, PVIRTIOSTATE *); 924 RT_NOREF(pPciDev); 947 925 948 926 if (uAddress == pVirtio->uPciCfgDataOff) … … 955 933 uint8_t uBar = pVirtio->pPciCfgCap->pciCap.uBar; 956 934 if (uBar == VIRTIO_REGION_PCI_CAP) 957 (void)virtioR3MmioWrite(pDevIns, NULL, (RTGCPHYS)((uint32_t)pVirtio->pGcPhysPciCapBase + uOffset), 958 (void *)&u32Value, uLength); 935 { 936 Assert(uLength <= sizeof(u32Value)); 937 virtioR3MmioWrite(pDevIns, NULL, (RTGCPHYS)((uint32_t)pVirtio->pGcPhysPciCapBase + uOffset), &u32Value, uLength); 938 } 959 939 else 960 940 { … … 966 946 return VINF_SUCCESS; 967 947 } 968 return pVirtio->pfnPciConfigWriteOld(pDevIns, pPciDev, uAddress, u32Value, cb);948 return VINF_PDM_PCI_DO_DEFAULT; 969 949 } 970 950 … … 1097 1077 { 1098 1078 RTMemFree(pVirtio); 1099 return PDMDEV_SET_ERROR(pDevIns, rc, 1100 N_("virtio: cannot register PCI Device")); /* can we put params in this error? */ 1079 return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio: cannot register PCI Device")); /* can we put params in this error? */ 1101 1080 } 1102 1081 … … 1107 1086 { 1108 1087 RTMemFree(pVirtio); 1109 return PDMDEV_SET_ERROR(pDevIns, rc, 1110 N_("virtio: cannot register SSM callbacks")); 1111 } 1112 1113 PDMDevHlpPCISetConfigCallbacks(pDevIns, &pVirtio->dev, 1114 virtioPciConfigRead, &pVirtio->pfnPciConfigReadOld, 1115 virtioPciConfigWrite, &pVirtio->pfnPciConfigWriteOld); 1088 return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio: cannot register SSM callbacks")); 1089 } 1090 1091 rc = PDMDevHlpPCIInterceptConfigAccesses(pDevIns, &pVirtio->dev, virtioR3PciConfigRead, virtioR3PciConfigWrite); 1092 AssertRCReturnStmt(rc, RTMemFree(pVirtio), rc); 1116 1093 1117 1094 … … 1272 1249 " pfnSSMDevLiveExec = %p\n pfnSSMDevSaveExec = %p\n" 1273 1250 " pfnSSMDevLoadExec = %p\n pfnSSMDevLoadDone = %p\n" 1274 " pfnPciConfigReadOld = %p\n pfnPciConfigWriteOld = %p\n",1275 1251 pcszCaller ? pcszCaller : "<unspecified>", 1276 1252 pVirtio->uDeviceFeatures, pVirtio->uDriverFeatures, pVirtio->uDeviceFeaturesSelect, … … 1283 1259 pVirtio->virtioCallbacks.pfnVirtioDevCapWrite, pVirtio->virtioCallbacks.pfnSSMDevLiveExec, 1284 1260 pVirtio->virtioCallbacks.pfnSSMDevSaveExec, pVirtio->virtioCallbacks.pfnSSMDevLoadExec, 1285 pVirtio->virtioCallbacks.pfnSSMDevLoadDone, pVirtio->pfnPciConfigReadOld, 1286 pVirtio->pfnPciConfigWriteOld 1261 pVirtio->virtioCallbacks.pfnSSMDevLoadDone 1287 1262 )); 1288 1263 … … 1339 1314 rc = SSMR3PutU64(pSSM, (uint64_t)pVirtio->virtioCallbacks.pfnSSMDevLoadExec); 1340 1315 rc = SSMR3PutU64(pSSM, (uint64_t)pVirtio->virtioCallbacks.pfnSSMDevLoadDone); 1341 rc = SSMR3PutU64(pSSM, (uint64_t)pVirtio->pfnPciConfigReadOld);1342 rc = SSMR3PutU64(pSSM, (uint64_t)pVirtio->pfnPciConfigWriteOld);1343 1316 rc = SSMR3PutGCPhys(pSSM, pVirtio->pGcPhysCommonCfg); 1344 1317 rc = SSMR3PutGCPhys(pSSM, pVirtio->pGcPhysNotifyCap); … … 1401 1374 rc = SSMR3GetU64(pSSM, (uint64_t *)&pVirtio->virtioCallbacks.pfnSSMDevLoadExec); 1402 1375 rc = SSMR3GetU64(pSSM, (uint64_t *)&pVirtio->virtioCallbacks.pfnSSMDevLoadDone); 1403 rc = SSMR3GetU64(pSSM, (uint64_t *)&pVirtio->pfnPciConfigReadOld);1404 rc = SSMR3GetU64(pSSM, (uint64_t *)&pVirtio->pfnPciConfigWriteOld);1405 1376 rc = SSMR3GetGCPhys(pSSM, &pVirtio->pGcPhysCommonCfg); 1406 1377 rc = SSMR3GetGCPhys(pSSM, &pVirtio->pGcPhysNotifyCap); -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h
r80931 r80943 177 177 VIRTQSTATE virtqState[VIRTQ_MAX_CNT]; /**< Local impl-specific queue context */ 178 178 VIRTIOCALLBACKS virtioCallbacks; /**< Callback vectors to client */ 179 180 PFNPCICONFIGREAD pfnPciConfigReadOld; /**< Prev rd. cb. intercepting PCI Cfg I/O */181 PFNPCICONFIGWRITE pfnPciConfigWriteOld; /**< Prev wr. cb. intercepting PCI Cfg I/O */182 179 183 180 PVIRTIO_PCI_CFG_CAP_T pPciCfgCap; /**< Pointer to struct in configuration area */ -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r80396 r80943 218 218 GEN_CHECK_OFF(DEVPCIBUS, apDevices); 219 219 GEN_CHECK_OFF(DEVPCIBUS, apDevices[1]); 220 GEN_CHECK_OFF(DEVPCIBUS, pDevInsR3);221 GEN_CHECK_OFF(DEVPCIBUS, pPciHlpR3);222 220 GEN_CHECK_OFF(DEVPCIBUS, papBridgesR3); 223 GEN_CHECK_OFF(DEVPCIBUS, pDevInsR0);224 GEN_CHECK_OFF(DEVPCIBUS, pPciHlpR0);225 GEN_CHECK_OFF(DEVPCIBUS, pDevInsRC);226 GEN_CHECK_OFF(DEVPCIBUS, pPciHlpRC);227 221 GEN_CHECK_OFF(DEVPCIBUS, PciDev); 228 222 GEN_CHECK_SIZE(PIIX3ISABRIDGE); 229 223 GEN_CHECK_SIZE(DEVPCIROOT); 230 224 GEN_CHECK_OFF(DEVPCIROOT, PciBus); 231 GEN_CHECK_OFF(DEVPCIROOT, pDevInsR3);232 GEN_CHECK_OFF(DEVPCIROOT, pDevInsR0);233 GEN_CHECK_OFF(DEVPCIROOT, pDevInsRC);234 225 GEN_CHECK_OFF(DEVPCIROOT, fUseIoApic); 235 226 GEN_CHECK_OFF(DEVPCIROOT, u64PciConfigMMioAddress); -
trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
r80942 r80943 283 283 LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: pPciDev=%p:{%#x} iIrq=%d iLevel=%d\n", 284 284 pDevIns, pDevIns->iInstance, pPciDev, pPciDev->uDevFn, iIrq, iLevel)); 285 PGVM pGVM = pDevIns->Internal.s.pGVM;286 size_t const idxBus = pPciDev->Int.s.idxPdmBus;287 AssertReturnVoid(idxBus < RT_ELEMENTS(pGVM->pdm .s.aPciBuses));288 PPDMPCIBUS pPciBus = &pGVM->pdm.s.aPciBuses[idxBus];285 PGVM pGVM = pDevIns->Internal.s.pGVM; 286 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 287 AssertReturnVoid(idxBus < RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 288 PPDMPCIBUSR0 pPciBusR0 = &pGVM->pdmr0.s.aPciBuses[idxBus]; 289 289 290 290 pdmLock(pGVM); 291 291 292 uint32_t uTagSrc; 292 293 if (iLevel & PDM_IRQ_LEVEL_HIGH) … … 301 302 uTagSrc = pDevIns->Internal.s.pIntR3R0->uLastIrqTag; 302 303 303 if ( pPciBus 304 && pPciBus->pDevInsR0) 305 { 306 pPciBus->pfnSetIrqR0(pPciBus->pDevInsR0, pPciDev, iIrq, iLevel, uTagSrc); 304 if (pPciBusR0->pDevInsR0) 305 { 306 pPciBusR0->pfnSetIrqR0(pPciBusR0->pDevInsR0, pPciDev, iIrq, iLevel, uTagSrc); 307 307 308 308 pdmUnlock(pGVM); … … 793 793 LogFlow(("pdmR0DevHlp_DBGFTraceBuf: caller='%p'/%d: returns %p\n", pDevIns, pDevIns->iInstance, hTraceBuf)); 794 794 return hTraceBuf; 795 } 796 797 798 /** @interface_method_impl{PDMDEVHLPR0,pfnPCIBusSetUpContext} */ 799 static DECLCALLBACK(int) pdmR0DevHlp_PCIBusSetUpContext(PPDMDEVINS pDevIns, PPDMPCIBUSREGR0 pPciBusReg, PCPDMPCIHLPR0 *ppPciHlp) 800 { 801 PDMDEV_ASSERT_DEVINS(pDevIns); 802 LogFlow(("pdmR0DevHlp_PCIBusSetUpContext: caller='%p'/%d: pPciBusReg=%p{.u32Version=%#x, .iBus=%#u, .pfnSetIrq=%p, u32EnvVersion=%#x} ppPciHlp=%p\n", 803 pDevIns, pDevIns->iInstance, pPciBusReg, pPciBusReg->u32Version, pPciBusReg->iBus, pPciBusReg->pfnSetIrq, 804 pPciBusReg->u32EndVersion, ppPciHlp)); 805 PGVM pGVM = pDevIns->Internal.s.pGVM; 806 807 /* 808 * Validate input. 809 */ 810 AssertPtrReturn(pPciBusReg, VERR_INVALID_POINTER); 811 AssertLogRelMsgReturn(pPciBusReg->u32Version == PDM_PCIBUSREGCC_VERSION, 812 ("%#x vs %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREGCC_VERSION), VERR_VERSION_MISMATCH); 813 AssertPtrReturn(pPciBusReg->pfnSetIrq, VERR_INVALID_POINTER); 814 AssertLogRelMsgReturn(pPciBusReg->u32EndVersion == PDM_PCIBUSREGCC_VERSION, 815 ("%#x vs %#x\n", pPciBusReg->u32EndVersion, PDM_PCIBUSREGCC_VERSION), VERR_VERSION_MISMATCH); 816 817 AssertPtrReturn(ppPciHlp, VERR_INVALID_POINTER); 818 819 VM_ASSERT_STATE_RETURN(pGVM, VMSTATE_CREATING, VERR_WRONG_ORDER); 820 VM_ASSERT_EMT0_RETURN(pGVM, VERR_VM_THREAD_NOT_EMT); 821 822 /* Check the shared bus data (registered earlier from ring-3): */ 823 uint32_t iBus = pPciBusReg->iBus; 824 ASMCompilerBarrier(); 825 AssertLogRelMsgReturn(iBus < RT_ELEMENTS(pGVM->pdm.s.aPciBuses), ("iBus=%#x\n", iBus), VERR_OUT_OF_RANGE); 826 PPDMPCIBUS pPciBusShared = &pGVM->pdm.s.aPciBuses[iBus]; 827 AssertLogRelMsgReturn(pPciBusShared->iBus == iBus, ("%u vs %u\n", pPciBusShared->iBus, iBus), VERR_INVALID_PARAMETER); 828 AssertLogRelMsgReturn(pPciBusShared->pDevInsR3 == pDevIns->pDevInsForR3, 829 ("%p vs %p (iBus=%u)\n", pPciBusShared->pDevInsR3, pDevIns->pDevInsForR3, iBus), VERR_NOT_OWNER); 830 831 /* Check that the bus isn't already registered in ring-0: */ 832 AssertCompile(RT_ELEMENTS(pGVM->pdm.s.aPciBuses) == RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 833 PPDMPCIBUSR0 pPciBusR0 = &pGVM->pdmr0.s.aPciBuses[iBus]; 834 AssertLogRelMsgReturn(pPciBusR0->pDevInsR0 == NULL, 835 ("%p (caller pDevIns=%p, iBus=%u)\n", pPciBusR0->pDevInsR0, pDevIns, iBus), 836 VERR_ALREADY_EXISTS); 837 838 /* 839 * Do the registering. 840 */ 841 pPciBusR0->iBus = iBus; 842 pPciBusR0->uPadding0 = 0xbeefbeef; 843 pPciBusR0->pfnSetIrqR0 = pPciBusReg->pfnSetIrq; 844 pPciBusR0->pDevInsR0 = pDevIns; 845 846 *ppPciHlp = &g_pdmR0PciHlp; 847 848 LogFlow(("pdmR0DevHlp_PCIBusSetUpContext: caller='%p'/%d: returns VINF_SUCCESS\n", pDevIns, pDevIns->iInstance)); 849 return VINF_SUCCESS; 795 850 } 796 851 … … 853 908 pdmR0DevHlp_CritSectGetRecursion, 854 909 pdmR0DevHlp_DBGFTraceBuf, 910 pdmR0DevHlp_PCIBusSetUpContext, 855 911 NULL /*pfnReserved1*/, 856 912 NULL /*pfnReserved2*/, -
trunk/src/VBox/VMM/VMMR3/PDM.cpp
r80531 r80943 542 542 543 543 /* 544 * The register PCI Buses.545 */546 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pdm.s.aPciBuses); i++)547 {548 if (pVM->pdm.s.aPciBuses[i].pDevInsRC)549 {550 pVM->pdm.s.aPciBuses[i].pDevInsRC += offDelta;551 pVM->pdm.s.aPciBuses[i].pfnSetIrqRC += offDelta;552 }553 }554 555 /*556 544 * Devices & Drivers. 557 545 */ -
trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
r80722 r80943 1845 1845 */ 1846 1846 pdmLock(pVM); 1847 rc = pBus->pfnRegister R3(pBus->pDevInsR3, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName);1847 rc = pBus->pfnRegister(pBus->pDevInsR3, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName); 1848 1848 pdmUnlock(pVM); 1849 1849 if (RT_SUCCESS(rc)) … … 1919 1919 pdmLock(pVM); 1920 1920 int rc; 1921 if (pBus->pfnRegisterMsi R3)1922 rc = pBus->pfnRegisterMsi R3(pBus->pDevInsR3, pPciDev, pMsiReg);1921 if (pBus->pfnRegisterMsi) 1922 rc = pBus->pfnRegisterMsi(pBus->pDevInsR3, pPciDev, pMsiReg); 1923 1923 else 1924 1924 rc = VERR_NOT_IMPLEMENTED; … … 2024 2024 2025 2025 pdmLock(pVM); 2026 int rc = pBus->pfnIORegionRegister R3(pBus->pDevInsR3, pPciDev, iRegion, cbRegion, enmType, pfnCallback);2026 int rc = pBus->pfnIORegionRegister(pBus->pDevInsR3, pPciDev, iRegion, cbRegion, enmType, pfnCallback); 2027 2027 pdmUnlock(pVM); 2028 2028 … … 2032 2032 2033 2033 2034 /** @interface_method_impl{PDMDEVHLPR3,pfnPCI SetConfigCallbacks} */2035 static DECLCALLBACK( void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,2036 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)2034 /** @interface_method_impl{PDMDEVHLPR3,pfnPCIInterceptConfigAccesses} */ 2035 static DECLCALLBACK(int) pdmR3DevHlp_PCIInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 2036 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite) 2037 2037 { 2038 2038 PDMDEV_ASSERT_DEVINS(pDevIns); … … 2041 2041 if (!pPciDev) /* NULL is an alias for the default PCI device. */ 2042 2042 pPciDev = pDevIns->Internal.s.pHeadPciDevR3; 2043 AssertReturn Void(pPciDev);2044 LogFlow(("pdmR3DevHlp_PCI SetConfigCallbacks: caller='%s'/%d: pPciDev=%p pfnRead=%p ppfnReadOld=%p pfnWrite=%p ppfnWriteOld=%p\n",2045 pDevIns->pReg->szName, pDevIns->iInstance, pPciDev, pfnRead, p pfnReadOld, pfnWrite, ppfnWriteOld));2046 2047 /* 2048 * Validate input and resolve defaults.2043 AssertReturn(pPciDev, VERR_PDM_NOT_PCI_DEVICE); 2044 LogFlow(("pdmR3DevHlp_PCIInterceptConfigAccesses: caller='%s'/%d: pPciDev=%p pfnRead=%p pfnWrite=%p\n", 2045 pDevIns->pReg->szName, pDevIns->iInstance, pPciDev, pfnRead, pfnWrite)); 2046 2047 /* 2048 * Validate input. 2049 2049 */ 2050 2050 AssertPtr(pfnRead); 2051 2051 AssertPtr(pfnWrite); 2052 AssertPtrNull(ppfnReadOld); 2053 AssertPtrNull(ppfnWriteOld); 2054 AssertPtrNull(pPciDev); 2052 AssertPtr(pPciDev); 2055 2053 2056 2054 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2057 AssertRe leaseReturnVoid(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses));2055 AssertReturn(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses), VERR_INTERNAL_ERROR_2); 2058 2056 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2059 2057 AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING); … … 2063 2061 */ 2064 2062 pdmLock(pVM); 2065 pBus->pfn SetConfigCallbacksR3(pBus->pDevInsR3, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);2063 pBus->pfnInterceptConfigAccesses(pBus->pDevInsR3, pPciDev, pfnRead, pfnWrite); 2066 2064 pdmUnlock(pVM); 2067 2065 2068 LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: returns void\n", pDevIns->pReg->szName, pDevIns->iInstance)); 2066 LogFlow(("pdmR3DevHlp_PCIInterceptConfigAccesses: caller='%s'/%d: returns VINF_SUCCESS\n", 2067 pDevIns->pReg->szName, pDevIns->iInstance)); 2068 return VINF_SUCCESS; 2069 } 2070 2071 2072 /** @interface_method_impl{PDMDEVHLPR3,pfnPCIConfigWrite} */ 2073 static DECLCALLBACK(VBOXSTRICTRC) 2074 pdmR3DevHlp_PCIConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t u32Value) 2075 { 2076 PDMDEV_ASSERT_DEVINS(pDevIns); 2077 PVM pVM = pDevIns->Internal.s.pVMR3; 2078 AssertPtrReturn(pPciDev, VERR_PDM_NOT_PCI_DEVICE); 2079 LogFlow(("pdmR3DevHlp_PCIConfigWrite: caller='%s'/%d: pPciDev=%p uAddress=%#x cd=%d u32Value=%#x\n", 2080 pDevIns->pReg->szName, pDevIns->iInstance, pPciDev, uAddress, cb, u32Value)); 2081 2082 /* 2083 * Resolve the bus. 2084 */ 2085 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2086 AssertReturn(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses), VERR_INTERNAL_ERROR_2); 2087 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2088 2089 /* 2090 * Do the job. 2091 */ 2092 VBOXSTRICTRC rcStrict = pBus->pfnConfigWrite(pBus->pDevInsR3, pPciDev, uAddress, cb, u32Value); 2093 2094 LogFlow(("pdmR3DevHlp_PCIConfigWrite: caller='%s'/%d: returns %Rrc\n", 2095 pDevIns->pReg->szName, pDevIns->iInstance, VBOXSTRICTRC_VAL(rcStrict))); 2096 return rcStrict; 2097 } 2098 2099 2100 /** @interface_method_impl{PDMDEVHLPR3,pfnPCIConfigRead} */ 2101 static DECLCALLBACK(VBOXSTRICTRC) 2102 pdmR3DevHlp_PCIConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress, unsigned cb, uint32_t *pu32Value) 2103 { 2104 PDMDEV_ASSERT_DEVINS(pDevIns); 2105 PVM pVM = pDevIns->Internal.s.pVMR3; 2106 AssertPtrReturn(pPciDev, VERR_PDM_NOT_PCI_DEVICE); 2107 LogFlow(("pdmR3DevHlp_PCIConfigRead: caller='%s'/%d: pPciDev=%p uAddress=%#x cd=%d pu32Value=%p:{%#x}\n", 2108 pDevIns->pReg->szName, pDevIns->iInstance, pPciDev, uAddress, cb, pu32Value, *pu32Value)); 2109 2110 /* 2111 * Resolve the bus. 2112 */ 2113 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2114 AssertReturn(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses), VERR_INTERNAL_ERROR_2); 2115 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2116 2117 /* 2118 * Do the job. 2119 */ 2120 VBOXSTRICTRC rcStrict = pBus->pfnConfigRead(pBus->pDevInsR3, pPciDev, uAddress, cb, pu32Value); 2121 2122 LogFlow(("pdmR3DevHlp_PCIConfigRead: caller='%s'/%d: returns %Rrc (*pu32Value=%#x)\n", 2123 pDevIns->pReg->szName, pDevIns->iInstance, VBOXSTRICTRC_VAL(rcStrict), pu32Value, *pu32Value)); 2124 return rcStrict; 2069 2125 } 2070 2126 … … 3132 3188 3133 3189 /** @interface_method_impl{PDMDEVHLPR3,pfnPCIBusRegister} */ 3134 static DECLCALLBACK(int) pdmR3DevHlp_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg,3135 PCPDMPCIHLPR3 *ppPciHlp R3, uint32_t *piBus)3190 static DECLCALLBACK(int) pdmR3DevHlp_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg, 3191 PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus) 3136 3192 { 3137 3193 PDMDEV_ASSERT_DEVINS(pDevIns); … … 3139 3195 VM_ASSERT_EMT(pVM); 3140 3196 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: pPciBusReg=%p:{.u32Version=%#x, .pfnRegisterR3=%p, .pfnIORegionRegisterR3=%p, " 3141 ".pfn SetIrqR3=%p, .pszSetIrqRC=%p:{%s}, .pszSetIrqR0=%p:{%s}} ppPciHlpR3=%p piBus=%p\n",3197 ".pfnInterceptConfigAccesses=%p, pfnConfigRead=%p, pfnConfigWrite=%p, .pfnSetIrqR3=%p, .u32EndVersion=%#x} ppPciHlpR3=%p piBus=%p\n", 3142 3198 pDevIns->pReg->szName, pDevIns->iInstance, pPciBusReg, pPciBusReg->u32Version, pPciBusReg->pfnRegisterR3, 3143 pPciBusReg->pfnIORegionRegisterR3, pPciBusReg->pfnSetIrqR3, pPciBusReg->pszSetIrqRC, pPciBusReg->pszSetIrqRC, 3144 pPciBusReg->pszSetIrqR0, pPciBusReg->pszSetIrqR0, ppPciHlpR3, piBus)); 3145 3146 /* 3147 * Validate the structure. 3148 */ 3149 if (pPciBusReg->u32Version != PDM_PCIBUSREG_VERSION) 3150 { 3151 AssertMsgFailed(("u32Version=%#x expected %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREG_VERSION)); 3152 LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3153 return VERR_INVALID_PARAMETER; 3154 } 3155 if ( !pPciBusReg->pfnRegisterR3 3156 || !pPciBusReg->pfnIORegionRegisterR3 3157 || !pPciBusReg->pfnSetIrqR3) 3158 { 3159 Assert(pPciBusReg->pfnRegisterR3); 3160 Assert(pPciBusReg->pfnIORegionRegisterR3); 3161 Assert(pPciBusReg->pfnSetIrqR3); 3162 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3163 return VERR_INVALID_PARAMETER; 3164 } 3165 if ( pPciBusReg->pszSetIrqRC 3166 && !VALID_PTR(pPciBusReg->pszSetIrqRC)) 3167 { 3168 Assert(VALID_PTR(pPciBusReg->pszSetIrqRC)); 3169 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3170 return VERR_INVALID_PARAMETER; 3171 } 3172 if ( pPciBusReg->pszSetIrqR0 3173 && !VALID_PTR(pPciBusReg->pszSetIrqR0)) 3174 { 3175 Assert(VALID_PTR(pPciBusReg->pszSetIrqR0)); 3176 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3177 return VERR_INVALID_PARAMETER; 3178 } 3179 if (!ppPciHlpR3) 3180 { 3181 Assert(ppPciHlpR3); 3182 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (ppPciHlpR3)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3183 return VERR_INVALID_PARAMETER; 3184 } 3185 AssertLogRelMsgReturn(RT_VALID_PTR(piBus) || !piBus, 3186 ("caller='%s'/%d: piBus=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, piBus), 3187 VERR_INVALID_POINTER); 3199 pPciBusReg->pfnIORegionRegisterR3, pPciBusReg->pfnInterceptConfigAccesses, pPciBusReg->pfnConfigRead, 3200 pPciBusReg->pfnConfigWrite, pPciBusReg->pfnSetIrqR3, pPciBusReg->u32EndVersion, ppPciHlp, piBus)); 3201 3202 /* 3203 * Validate the structure and output parameters. 3204 */ 3205 AssertLogRelMsgReturn(pPciBusReg->u32Version == PDM_PCIBUSREGR3_VERSION, 3206 ("u32Version=%#x expected %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREGR3_VERSION), 3207 VERR_INVALID_PARAMETER); 3208 AssertPtrReturn(pPciBusReg->pfnRegisterR3, VERR_INVALID_PARAMETER); 3209 AssertPtrNullReturn(pPciBusReg->pfnRegisterMsiR3, VERR_INVALID_POINTER); 3210 AssertPtrReturn(pPciBusReg->pfnIORegionRegisterR3, VERR_INVALID_POINTER); 3211 AssertPtrReturn(pPciBusReg->pfnInterceptConfigAccesses, VERR_INVALID_POINTER); 3212 AssertPtrReturn(pPciBusReg->pfnConfigWrite, VERR_INVALID_POINTER); 3213 AssertPtrReturn(pPciBusReg->pfnConfigRead, VERR_INVALID_POINTER); 3214 AssertPtrReturn(pPciBusReg->pfnSetIrqR3, VERR_INVALID_POINTER); 3215 AssertLogRelMsgReturn(pPciBusReg->u32EndVersion == PDM_PCIBUSREGR3_VERSION, 3216 ("u32Version=%#x expected %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREGR3_VERSION), 3217 VERR_INVALID_PARAMETER); 3218 AssertPtrReturn(ppPciHlp, VERR_INVALID_POINTER); 3219 AssertPtrNullReturn(piBus, VERR_INVALID_POINTER); 3220 VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_WRONG_ORDER); 3188 3221 3189 3222 /* … … 3194 3227 if (!pVM->pdm.s.aPciBuses[iBus].pDevInsR3) 3195 3228 break; 3196 if (iBus >= RT_ELEMENTS(pVM->pdm.s.aPciBuses)) 3197 { 3198 AssertMsgFailed(("Too many PCI buses. Max=%u\n", RT_ELEMENTS(pVM->pdm.s.aPciBuses))); 3199 LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (pci bus)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3200 return VERR_INVALID_PARAMETER; 3201 } 3229 AssertLogRelMsgReturn(iBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses), 3230 ("Too many PCI buses. Max=%u\n", RT_ELEMENTS(pVM->pdm.s.aPciBuses)), 3231 VERR_OUT_OF_RESOURCES); 3202 3232 PPDMPCIBUS pPciBus = &pVM->pdm.s.aPciBuses[iBus]; 3203 3233 3204 3234 /* 3205 * Resolve and init the RC bits.3206 */3207 if (pPciBusReg->pszSetIrqRC)3208 {3209 int rc = pdmR3DevGetSymbolRCLazy(pDevIns, pPciBusReg->pszSetIrqRC, &pPciBus->pfnSetIrqRC);3210 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszRCMod, pPciBusReg->pszSetIrqRC, rc));3211 if (RT_FAILURE(rc))3212 {3213 LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));3214 return rc;3215 }3216 pPciBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);3217 }3218 else3219 {3220 pPciBus->pfnSetIrqRC = 0;3221 pPciBus->pDevInsRC = 0;3222 }3223 3224 /*3225 * Resolve and init the R0 bits.3226 */3227 if (pPciBusReg->pszSetIrqR0)3228 {3229 int rc = pdmR3DevGetSymbolR0Lazy(pDevIns, pPciBusReg->pszSetIrqR0, &pPciBus->pfnSetIrqR0);3230 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszR0Mod, pPciBusReg->pszSetIrqR0, rc));3231 if (RT_FAILURE(rc))3232 {3233 LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));3234 return rc;3235 }3236 pPciBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);3237 }3238 else3239 {3240 pPciBus->pfnSetIrqR0 = 0;3241 pPciBus->pDevInsR0 = 0;3242 }3243 3244 /*3245 3235 * Init the R3 bits. 3246 3236 */ 3247 pPciBus->iBus = iBus; 3248 pPciBus->pDevInsR3 = pDevIns; 3249 pPciBus->pfnRegisterR3 = pPciBusReg->pfnRegisterR3; 3250 pPciBus->pfnRegisterMsiR3 = pPciBusReg->pfnRegisterMsiR3; 3251 pPciBus->pfnIORegionRegisterR3 = pPciBusReg->pfnIORegionRegisterR3; 3252 pPciBus->pfnSetConfigCallbacksR3 = pPciBusReg->pfnSetConfigCallbacksR3; 3253 pPciBus->pfnSetIrqR3 = pPciBusReg->pfnSetIrqR3; 3237 pPciBus->iBus = iBus; 3238 pPciBus->pDevInsR3 = pDevIns; 3239 pPciBus->pfnRegister = pPciBusReg->pfnRegisterR3; 3240 pPciBus->pfnRegisterMsi = pPciBusReg->pfnRegisterMsiR3; 3241 pPciBus->pfnIORegionRegister = pPciBusReg->pfnIORegionRegisterR3; 3242 pPciBus->pfnInterceptConfigAccesses = pPciBusReg->pfnInterceptConfigAccesses; 3243 pPciBus->pfnConfigRead = pPciBusReg->pfnConfigRead; 3244 pPciBus->pfnConfigWrite = pPciBusReg->pfnConfigWrite; 3245 pPciBus->pfnSetIrqR3 = pPciBusReg->pfnSetIrqR3; 3254 3246 3255 3247 Log(("PDM: Registered PCI bus device '%s'/%d pDevIns=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, pDevIns)); 3256 3248 3257 3249 /* set the helper pointer and return. */ 3258 *ppPciHlp R3= &g_pdmR3DevPciHlp;3250 *ppPciHlp = &g_pdmR3DevPciHlp; 3259 3251 if (piBus) 3260 3252 *piBus = iBus; … … 4317 4309 pdmR3DevHlp_PCIRegisterMsi, 4318 4310 pdmR3DevHlp_PCIIORegionRegister, 4319 pdmR3DevHlp_PCISetConfigCallbacks, 4311 pdmR3DevHlp_PCIInterceptConfigAccesses, 4312 pdmR3DevHlp_PCIConfigWrite, 4313 pdmR3DevHlp_PCIConfigRead, 4320 4314 pdmR3DevHlp_PCIPhysRead, 4321 4315 pdmR3DevHlp_PCIPhysWrite, … … 4756 4750 pdmR3DevHlp_PCIRegisterMsi, 4757 4751 pdmR3DevHlp_PCIIORegionRegister, 4758 pdmR3DevHlp_PCISetConfigCallbacks, 4752 pdmR3DevHlp_PCIInterceptConfigAccesses, 4753 pdmR3DevHlp_PCIConfigWrite, 4754 pdmR3DevHlp_PCIConfigRead, 4759 4755 pdmR3DevHlp_PCIPhysRead, 4760 4756 pdmR3DevHlp_PCIPhysWrite, -
trunk/src/VBox/VMM/include/PDMInternal.h
r80531 r80943 718 718 719 719 /** 720 * PDM PCI Bus instance.720 * PDM PCI bus instance. 721 721 */ 722 722 typedef struct PDMPCIBUS 723 723 { 724 724 /** PCI bus number. */ 725 RTUINT iBus; 726 RTUINT uPadding0; /**< Alignment padding.*/ 727 728 /** Pointer to PCI Bus device instance. */ 729 PPDMDEVINSR3 pDevInsR3; 730 /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */ 731 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 732 /** @copydoc PDMPCIBUSREG::pfnRegisterR3 */ 733 DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags, 734 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName)); 735 /** @copydoc PDMPCIBUSREG::pfnRegisterMsiR3 */ 736 DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)); 737 /** @copydoc PDMPCIBUSREG::pfnIORegionRegisterR3 */ 738 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion, 739 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)); 740 /** @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksR3 */ 741 DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PFNPCICONFIGREAD pfnRead, 742 PPFNPCICONFIGREAD ppfnReadOld, PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)); 743 744 /** Pointer to the PIC device instance - R0. */ 745 R0PTRTYPE(PPDMDEVINS) pDevInsR0; 746 /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */ 747 DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 748 749 /** Pointer to PCI Bus device instance. */ 750 PPDMDEVINSRC pDevInsRC; 751 /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */ 752 DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 725 uint32_t iBus; 726 uint32_t uPadding0; /**< Alignment padding.*/ 727 728 /** Pointer to PCI bus device instance. */ 729 PPDMDEVINSR3 pDevInsR3; 730 /** @copydoc PDMPCIBUSREGR3::pfnSetIrqR3 */ 731 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 732 733 /** @copydoc PDMPCIBUSREGR3::pfnRegisterR3 */ 734 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags, 735 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName)); 736 /** @copydoc PDMPCIBUSREGR3::pfnRegisterMsiR3 */ 737 DECLR3CALLBACKMEMBER(int, pfnRegisterMsi,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)); 738 /** @copydoc PDMPCIBUSREGR3::pfnIORegionRegisterR3 */ 739 DECLR3CALLBACKMEMBER(int, pfnIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion, 740 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)); 741 /** @copydoc PDMPCIBUSREGR3::pfnInterceptConfigAccesses */ 742 DECLR3CALLBACKMEMBER(void, pfnInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 743 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite)); 744 /** @copydoc PDMPCIBUSREGR3::pfnConfigWrite */ 745 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 746 uint32_t uAddress, unsigned cb, uint32_t u32Value)); 747 /** @copydoc PDMPCIBUSREGR3::pfnConfigRead */ 748 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, 749 uint32_t uAddress, unsigned cb, uint32_t *pu32Value)); 753 750 } PDMPCIBUS; 754 751 752 753 /** 754 * Ring-0 PDM PCI bus instance data. 755 */ 756 typedef struct PDMPCIBUSR0 757 { 758 /** PCI bus number. */ 759 uint32_t iBus; 760 uint32_t uPadding0; /**< Alignment padding.*/ 761 /** Pointer to PCI bus device instance. */ 762 PPDMDEVINSR0 pDevInsR0; 763 /** @copydoc PDMPCIBUSREGR0::pfnSetIrqR0 */ 764 DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)); 765 } PDMPCIBUSR0; 766 /** Pointer to the ring-0 PCI bus data. */ 767 typedef PDMPCIBUSR0 *PPDMPCIBUSR0; 755 768 756 769 #ifdef IN_RING3 … … 1224 1237 typedef struct PDMR0PERVM 1225 1238 { 1239 /** PCI Buses, ring-0 data. */ 1240 PDMPCIBUSR0 aPciBuses[PDM_PCI_BUSSES_MAX]; 1226 1241 /** Number of valid ring-0 device instances (apDevInstances). */ 1227 1242 uint32_t cDevInstances; 1243 uint32_t u32Padding; 1228 1244 /** Pointer to ring-0 device instances. */ 1229 1245 R0PTRTYPE(struct PDMDEVINSR0 *) apDevInstances[190];
Note:
See TracChangeset
for help on using the changeset viewer.