Changeset 99750 in vbox
- Timestamp:
- May 11, 2023 1:37:24 PM (19 months ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevPCI.cpp
r98103 r99750 1305 1305 memset((void *)&pGlobals->auPciApicIrqLevels, 0, sizeof(pGlobals->auPciApicIrqLevels)); 1306 1306 1307 pGlobals->PciBus.fTypePiix3 = true; 1308 pGlobals->PciBus.fTypeIch9 = false; 1307 pGlobals->PciBus.enmType = DEVPCIBUSTYPE_PIIX3; 1309 1308 pGlobals->PciBus.fPureBridge = false; 1310 1309 pGlobals->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, … … 1696 1695 * Init data and register the PCI bus. 1697 1696 */ 1698 pBus->fTypePiix3 = true; 1699 pBus->fTypeIch9 = false; 1700 pBus->fPureBridge = true; 1697 pBus->enmType = DEVPCIBUSTYPE_PIIX3; 1698 pBus->fPureBridge = true; 1701 1699 pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices)); 1702 1700 AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY); -
trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
r98103 r99750 116 116 #ifdef IN_RING3 117 117 static int ich9pciFakePCIBIOS(PPDMDEVINS pDevIns); 118 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(PDEVPCIBUS pBus, uint8_t uBus);119 118 static void ich9pciBiosInitAllDevicesOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus); 120 119 static bool ich9pciBiosInitAllDevicesPrefetchableOnBus(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUS pBus, bool fUse64Bit, bool fDryrun); … … 342 341 { 343 342 #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 */ 344 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(&pPciRoot->PciBus, pPciAddr->iBus);343 PPDMPCIDEV pBridgeDevice = devpciR3FindBridge(&pPciRoot->PciBus, pPciAddr->iBus); 345 344 if (pBridgeDevice) 346 345 { … … 437 436 { 438 437 #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 */ 439 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(&pPciRoot->PciBus, pPciAddr->iBus);438 PPDMPCIDEV pBridgeDevice = devpciR3FindBridge(&pPciRoot->PciBus, pPciAddr->iBus); 440 439 if (pBridgeDevice) 441 440 { … … 658 657 * Emulates writes to configuration space.} 659 658 */ 660 static DECLCALLBACK(VBOXSTRICTRC) ich9pciMcfgMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)659 DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) devpciCommonMcfgMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) 661 660 { 662 661 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); … … 700 699 * Emulates reads from configuration space.} 701 700 */ 702 static DECLCALLBACK(VBOXSTRICTRC) ich9pciMcfgMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)701 DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) devpciCommonMcfgMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) 703 702 { 704 703 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); … … 739 738 740 739 #ifdef IN_RING3 741 742 DECLINLINE(PPDMPCIDEV) ich9pciFindBridge(PDEVPCIBUS pBus, uint8_t uBus)743 {744 /* Search for a fitting bridge. */745 for (uint32_t iBridge = 0; iBridge < pBus->cBridges; iBridge++)746 {747 /*748 * Examine secondary and subordinate bus number.749 * If the target bus is in the range we pass the request on to the bridge.750 */751 PPDMPCIDEV pBridge = pBus->papBridgesR3[iBridge];752 AssertMsg(pBridge && pciDevIsPci2PciBridge(pBridge),753 ("Device is not a PCI bridge but on the list of PCI bridges\n"));754 /* safe, only needs to go to the config space array */755 uint32_t uSecondary = PDMPciDevGetByte(pBridge, VBOX_PCI_SECONDARY_BUS);756 /* safe, only needs to go to the config space array */757 uint32_t uSubordinate = PDMPciDevGetByte(pBridge, VBOX_PCI_SUBORDINATE_BUS);758 Log3Func(("bus %p, bridge %d: %d in %d..%d\n", pBus, iBridge, uBus, uSecondary, uSubordinate));759 if (uBus >= uSecondary && uBus <= uSubordinate)760 return pBridge;761 }762 763 /* Nothing found. */764 return NULL;765 }766 740 767 741 uint32_t devpciR3GetCfg(PPDMPCIDEV pPciDev, int32_t iRegister, int cb) … … 978 952 pPciDev->Int.s.pfnConfigWrite = NULL; 979 953 pPciDev->Int.s.hMmioMsix = NIL_IOMMMIOHANDLE; 980 if (pBus-> fTypePiix3 && pPciDev->cbConfig > 256)954 if (pBus->enmType == DEVPCIBUSTYPE_PIIX3 && pPciDev->cbConfig > 256) 981 955 pPciDev->cbConfig = 256; 982 956 … … 1176 1150 } 1177 1151 1178 static DECLCALLBACK(int) ich9pciR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)1152 DECL_HIDDEN_CALLBACK(int) devpciR3CommonSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1179 1153 { 1180 1154 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); … … 1221 1195 if (iBus != PDMPciDevGetByte(pDevIns->apPciDevs[0], VBOX_PCI_SECONDARY_BUS)) 1222 1196 { 1223 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(pBus, iBus);1197 PPDMPCIDEV pBridgeDevice = devpciR3FindBridge(pBus, iBus); 1224 1198 if (pBridgeDevice) 1225 1199 { … … 1261 1235 if (iBus != PDMPciDevGetByte(pDevIns->apPciDevs[0], VBOX_PCI_SECONDARY_BUS)) 1262 1236 { 1263 PPDMPCIDEV pBridgeDevice = ich9pciFindBridge(pBus, iBus);1237 PPDMPCIDEV pBridgeDevice = devpciR3FindBridge(pBus, iBus); 1264 1238 if (pBridgeDevice) 1265 1239 { … … 1749 1723 } 1750 1724 1751 static DECLCALLBACK(int) ich9pciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)1725 DECL_HIDDEN_CALLBACK(int) devpciR3CommonLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1752 1726 { 1753 1727 PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT); … … 3079 3053 } 3080 3054 3055 static const char *devpciR3InInfoPciBusType(DEVPCIBUSTYPE enmType) 3056 { 3057 static const char *s_szBusType[] = 3058 { 3059 /* 00h */ "INVALID", 3060 /* 01h */ "PIIX3", 3061 /* 02h */ "ICH9", 3062 /* 03h */ "GenericEcam", 3063 /* 04h */ "?32-bit hack?", 3064 }; 3065 3066 if (enmType < RT_ELEMENTS(s_szBusType)) 3067 return s_szBusType[enmType]; 3068 return "?type?"; 3069 } 3081 3070 3082 3071 /** … … 3113 3102 pciDevIsPassthrough(pPciDev) ? " (PASSTHROUGH)" : "", 3114 3103 devpciR3GetWord(pPciDev, VBOX_PCI_VENDOR_ID), devpciR3GetWord(pPciDev, VBOX_PCI_DEVICE_ID), 3115 pBus->fTypeIch9 ? "ICH9" : pBus->fTypePiix3 ? "PIIX3" : "?type?",3104 devpciR3InInfoPciBusType(pBus->enmType), 3116 3105 pciDevIsMsiCapable(pPciDev) ? " MSI" : "", 3117 3106 pciDevIsMsixCapable(pPciDev) ? " MSI-X" : "" … … 3359 3348 pPciRoot->hIoPortMagic = NIL_IOMIOPORTHANDLE; 3360 3349 pPciRoot->hMmioMcfg = NIL_IOMMMIOHANDLE; 3361 pPciRoot->PciBus.fTypePiix3 = false; 3362 pPciRoot->PciBus.fTypeIch9 = true; 3350 pPciRoot->PciBus.enmType = DEVPCIBUSTYPE_GENERIC_ECAM; 3363 3351 pPciRoot->PciBus.fPureBridge = false; 3364 3352 pPciRoot->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pPciRoot->PciBus.apDevices)); … … 3441 3429 { 3442 3430 rc = PDMDevHlpMmioCreateAndMap(pDevIns, pPciRoot->u64PciConfigMMioAddress, pPciRoot->u64PciConfigMMioLength, 3443 ich9pciMcfgMMIOWrite, ich9pciMcfgMMIORead,3431 devpciCommonMcfgMmioWrite, devpciCommonMcfgMmioRead, 3444 3432 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 3445 3433 "MCFG ranges", &pPciRoot->hMmioMcfg); … … 3453 3441 sizeof(*pBus) + 16*128, "pgm", 3454 3442 NULL, NULL, NULL, 3455 NULL, ich9pciR3SaveExec, NULL,3456 NULL, ich9pciR3LoadExec, NULL);3443 NULL, devpciR3CommonSaveExec, NULL, 3444 NULL, devpciR3CommonLoadExec, NULL); 3457 3445 AssertRCReturn(rc, rc); 3458 3446 … … 3572 3560 * @param pDevIns ICH9 bridge (root or PCI-to-PCI) instance. 3573 3561 */ 3574 static void ich9pciResetBridge(PPDMDEVINS pDevIns)3562 DECLHIDDEN(void) devpciR3CommonResetBridge(PPDMDEVINS pDevIns) 3575 3563 { 3576 3564 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); … … 3586 3574 { 3587 3575 if (pBus->papBridgesR3[iBridge]) 3588 ich9pciResetBridge(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns));3576 devpciR3CommonResetBridge(pBus->papBridgesR3[iBridge]->Int.s.CTX_SUFF(pDevIns)); 3589 3577 } 3590 3578 … … 3610 3598 { 3611 3599 /* Reset everything under the root bridge. */ 3612 ich9pciResetBridge(pDevIns);3600 devpciR3CommonResetBridge(pDevIns); 3613 3601 } 3614 3602 … … 3678 3666 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS); 3679 3667 3680 pBus->fTypePiix3 = false; 3681 pBus->fTypeIch9 = true; 3668 pBus->enmType = DEVPCIBUSTYPE_ICH9; 3682 3669 pBus->fPureBridge = true; 3683 3670 pBusCC->pDevInsR3 = pDevIns; … … 3859 3846 if (pPciRoot->hMmioMcfg != NIL_IOMMMIOHANDLE) 3860 3847 { 3861 rc = PDMDevHlpMmioSetUpContext(pDevIns, pPciRoot->hMmioMcfg, ich9pciMcfgMMIOWrite, ich9pciMcfgMMIORead, NULL /*pvUser*/);3848 rc = PDMDevHlpMmioSetUpContext(pDevIns, pPciRoot->hMmioMcfg, devpciCommonMcfgMmioWrite, devpciCommonMcfgMmioRead, NULL /*pvUser*/); 3862 3849 AssertLogRelRCReturn(rc, rc); 3863 3850 } -
trunk/src/VBox/Devices/Bus/DevPciInternal.h
r98103 r99750 36 36 #endif 37 37 #include <VBox/vmm/pdmdev.h> 38 39 #include "PciInline.h" 40 41 42 /** 43 * Supported PCI bus types. 44 */ 45 typedef enum DEVPCIBUSTYPE 46 { 47 /** The usual invalid type. */ 48 DEVPCIBUSTYPE_INVALID = 0, 49 /** PIIX3 PCI bus type. */ 50 DEVPCIBUSTYPE_PIIX3, 51 /** ICH9 PCI bus type. */ 52 DEVPCIBUSTYPE_ICH9, 53 /** Generic ECAM PCI bus type. */ 54 DEVPCIBUSTYPE_GENERIC_ECAM, 55 /** 32bit blowup. */ 56 DEVPCIBUSTYPE_32BIT_HACK = 0x7fffffff 57 } DEVPCIBUSTYPE; 38 58 39 59 … … 51 71 /** Start device number - always zero (only for DevPCI source compat). */ 52 72 uint32_t iDevSearch; 53 /** Set if PIIX3 type. */ 54 uint32_t fTypePiix3 : 1; 55 /** Set if ICH9 type. */ 56 uint32_t fTypeIch9 : 1; 73 /** PCI Bus type. */ 74 DEVPCIBUSTYPE enmType; 57 75 /** Set if this is a pure bridge, i.e. not part of DEVPCIGLOBALS struct. */ 58 76 uint32_t fPureBridge : 1; 59 77 /** Reserved for future config flags. */ 60 uint32_t uReservedConfigFlags : 29;78 uint32_t uReservedConfigFlags : 31; 61 79 62 80 /** Array of bridges attached to the bus. */ 63 81 R3PTRTYPE(PPDMPCIDEV *) papBridgesR3; 64 82 /** Cache line align apDevices. */ 65 uint32_t au32Alignment1[HC_ARCH_BITS == 32 ? 3 + 8 : 2 +8];83 uint32_t au32Alignment1[HC_ARCH_BITS == 32 ? 2 + 8 : 8]; 66 84 /** Array of PCI devices. We assume 32 slots, each with 8 functions. */ 67 85 R3PTRTYPE(PPDMPCIDEV) apDevices[256]; … … 69 87 /** Pointer to PCI bus shared instance data. */ 70 88 typedef DEVPCIBUS *PDEVPCIBUS; 89 AssertCompileMemberAlignment(DEVPCIBUS, apDevices, 64); 90 71 91 72 92 /** … … 145 165 /** Length of PCI config space MMIO region. */ 146 166 uint64_t u64PciConfigMMioLength; 167 /** Physical address of PCI PIO emulation MMIO region. */ 168 RTGCPHYS GCPhysMmioPioEmuBase; 169 /** Length of PCI PIO emulation MMIO region. */ 170 RTGCPHYS GCPhysMmioPioEmuSize; 171 147 172 148 173 /** I/O APIC irq levels */ … … 176 201 /** The MCFG MMIO region. */ 177 202 IOMMMIOHANDLE hMmioMcfg; 203 /** The PIO emulation MMIO region. */ 204 IOMMMIOHANDLE hMmioPioEmu; 178 205 179 206 #if 1 /* Will be moved into the BIOS "soon". */ … … 217 244 PDEVPCIBUS *ppBus, uint8_t *puDevFnBridge, int *piIrqPinBridge); 218 245 246 DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) devpciCommonMcfgMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb); 247 DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) devpciCommonMcfgMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb); 248 249 219 250 #ifdef IN_RING3 220 251 252 # ifndef VBOX_DEVICE_STRUCT_TESTCASE 221 253 DECLCALLBACK(void) devpciR3InfoPci(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs); 222 254 DECLCALLBACK(void) devpciR3InfoPciIrq(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs); … … 243 275 uint32_t devpciR3GetCfg(PPDMPCIDEV pPciDev, int32_t iRegister, int cb); 244 276 void devpciR3SetCfg(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int32_t iRegister, uint32_t u32, int cb); 277 DECLHIDDEN(void) devpciR3CommonResetBridge(PPDMDEVINS pDevIns); 278 DECL_HIDDEN_CALLBACK(int) devpciR3CommonSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM); 279 DECL_HIDDEN_CALLBACK(int) devpciR3CommonLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass); 280 245 281 246 282 DECLINLINE(uint8_t) devpciR3GetByte(PPDMPCIDEV pPciDev, int32_t iRegister) … … 274 310 } 275 311 312 313 DECLINLINE(PPDMPCIDEV) devpciR3FindBridge(PDEVPCIBUS pBus, uint8_t uBus) 314 { 315 /* Search for a fitting bridge. */ 316 for (uint32_t iBridge = 0; iBridge < pBus->cBridges; iBridge++) 317 { 318 /* 319 * Examine secondary and subordinate bus number. 320 * If the target bus is in the range we pass the request on to the bridge. 321 */ 322 PPDMPCIDEV pBridge = pBus->papBridgesR3[iBridge]; 323 AssertMsg(pBridge && pciDevIsPci2PciBridge(pBridge), 324 ("Device is not a PCI bridge but on the list of PCI bridges\n")); 325 /* safe, only needs to go to the config space array */ 326 uint32_t uSecondary = PDMPciDevGetByte(pBridge, VBOX_PCI_SECONDARY_BUS); 327 /* safe, only needs to go to the config space array */ 328 uint32_t uSubordinate = PDMPciDevGetByte(pBridge, VBOX_PCI_SUBORDINATE_BUS); 329 Log3Func(("bus %p, bridge %d: %d in %d..%d\n", pBus, iBridge, uBus, uSecondary, uSubordinate)); 330 if (uBus >= uSecondary && uBus <= uSubordinate) 331 return pBridge; 332 } 333 334 /* Nothing found. */ 335 return NULL; 336 } 337 # endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 338 276 339 #endif /* IN_RING3 */ 277 340 -
trunk/src/VBox/Devices/Makefile.kmk
r99544 r99750 921 921 VBoxDD_DEFS += VBOX_VMM_TARGET_ARMV8 922 922 VBoxDD_SOURCES += \ 923 Bus/DevPciGenericEcam.cpp \ 923 924 Misc/DevFlashCFI.cpp \ 924 925 Misc/DevPL031.cpp \ -
trunk/src/VBox/Devices/build/VBoxDD.cpp
r99544 r99750 260 260 if (RT_FAILURE(rc)) 261 261 return rc; 262 263 rc = pCallbacks->pfnRegister(pCallbacks, &g_DevicePciGenericEcam); 264 if (RT_FAILURE(rc)) 265 return rc; 262 266 #endif 263 267 -
trunk/src/VBox/Devices/build/VBoxDD.h
r99544 r99750 233 233 extern const PDMDEVREG g_DevicePl031Rtc; 234 234 extern const PDMDEVREG g_DeviceFlashCFI; 235 extern const PDMDEVREG g_DevicePciGenericEcam; 235 236 #endif 236 237
Note:
See TracChangeset
for help on using the changeset viewer.