Changeset 82020 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 20, 2019 11:36:21 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevACPI.cpp
r82019 r82020 281 281 *********************************************************************************************************************************/ 282 282 /** 283 * The ACPI device state.283 * The shared ACPI device state. 284 284 */ 285 285 typedef struct ACPISTATE … … 308 308 309 309 uint32_t uSystemInfoIndex; 310 uint32_t u32Alignment0; 310 311 uint64_t u64RamSize; 311 312 /** Offset of the 64-bit prefetchable memory window. */ … … 345 346 /** I/O port address of SMBus device. */ 346 347 RTIOPORT uSMBusIoPortBase; 348 /** Which CPU to check for the locked status. */ 349 uint32_t idCpuLockCheck; 347 350 /** Array of flags of attached CPUs */ 348 351 VMCPUSET CpuSetAttached; 349 /** Which CPU to check for the locked status. */350 uint32_t idCpuLockCheck;351 352 /** Mask of locked CPUs (used by the guest). */ 352 353 VMCPUSET CpuSetLocked; … … 361 362 /** if the 64-bit prefetchable memory window is shown to the guest */ 362 363 bool fPciPref64Enabled; 364 bool afAlignment1; 363 365 /** Primary NIC PCI address. */ 364 366 uint32_t u32NicPciAddress; … … 401 403 /** @name Parallel port config bits 402 404 * @{ */ 405 /** Parallel 0 IO port base */ 406 RTIOPORT uParallel0IoPortBase; 407 /** Parallel 1 IO port base */ 408 RTIOPORT uParallel1IoPortBase; 403 409 /** Parallel 0 IRQ number */ 404 410 uint8_t uParallel0Irq; 405 411 /** Parallel 1 IRQ number */ 406 412 uint8_t uParallel1Irq; 407 /** Parallel 0 IO port base */408 RTIOPORT uParallel0IoPortBase;409 /** Parallel 1 IO port base */410 RTIOPORT uParallel1IoPortBase;411 413 /** @} */ 412 413 uint32_t Alignment2;414 415 /** ACPI port base interface. */416 PDMIBASE IBase;417 /** ACPI port interface. */418 PDMIACPIPORT IACPIPort;419 /** Pointer to the device instance so we can get our bearings from420 * interface functions. */421 PPDMDEVINSR3 pDevIns;422 423 /** Pointer to the driver base interface. */424 R3PTRTYPE(PPDMIBASE) pDrvBase;425 /** Pointer to the driver connector interface. */426 R3PTRTYPE(PPDMIACPICONNECTOR) pDrv;427 414 428 415 /** Number of custom ACPI tables */ … … 432 419 /** ACPI Crator ID */ 433 420 uint8_t au8CreatorId[4]; 421 uint8_t abAlignment2[3]; 434 422 /** ACPI Crator Rev */ 435 423 uint32_t u32CreatorRev; … … 438 426 /** ACPI custom OEM Rev */ 439 427 uint32_t u32OemRevision; 440 uint32_t Alignment4;441 442 /** Custom ACPI tables binary data. */443 R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES];444 /** The size of the custom table binary. */445 uint64_t acbCustBin[MAX_CUST_TABLES];446 428 447 429 /** SMBus Host Status Register */ … … 461 443 /** SMBus Slave Control Register */ 462 444 uint8_t u8SMBusSlvCnt; 463 /** SMBus Shadow Command Register */464 uint8_t u8SMBusShdwCmd;465 445 /** SMBus Slave Event Register */ 466 446 uint16_t u16SMBusSlvEvt; 467 447 /** SMBus Slave Data Register */ 468 448 uint16_t u16SMBusSlvDat; 449 /** SMBus Shadow Command Register */ 450 uint8_t u8SMBusShdwCmd; 451 /** SMBus Host Block Index */ 452 uint8_t u8SMBusBlkIdx; 453 uint8_t abAlignment3[2]; 469 454 /** SMBus Host Block Data Buffer */ 470 455 uint8_t au8SMBusBlkDat[32]; 471 /** SMBus Host Block Index */472 uint8_t u8SMBusBlkIdx;473 456 474 457 /** @todo DEBUGGING */ … … 514 497 /** Pointer to the shared ACPI device state. */ 515 498 typedef ACPISTATE *PACPISTATE; 499 500 501 /** 502 * The ring-3 ACPI device state. 503 */ 504 typedef struct ACPISTATER3 505 { 506 /** ACPI port base interface. */ 507 PDMIBASE IBase; 508 /** ACPI port interface. */ 509 PDMIACPIPORT IACPIPort; 510 /** Pointer to the device instance so we can get our bearings from 511 * interface functions. */ 512 PPDMDEVINSR3 pDevIns; 513 514 /** Pointer to the driver base interface. */ 515 R3PTRTYPE(PPDMIBASE) pDrvBase; 516 /** Pointer to the driver connector interface. */ 517 R3PTRTYPE(PPDMIACPICONNECTOR) pDrv; 518 519 /** Custom ACPI tables binary data. */ 520 R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES]; 521 /** The size of the custom table binary. */ 522 uint64_t acbCustBin[MAX_CUST_TABLES]; 523 } ACPISTATER3; 524 /** Pointer to the ring-3 ACPI device state. */ 525 typedef ACPISTATER3 *PACPISTATER3; 526 516 527 517 528 #pragma pack(1) … … 801 812 *********************************************************************************************************************************/ 802 813 #ifdef IN_RING3 803 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis );814 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC); 804 815 #endif 805 816 … … 944 955 static DECLCALLBACK(int) acpiR3Port_PowerButtonPress(PPDMIACPIPORT pInterface) 945 956 { 946 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 947 PPDMDEVINS pDevIns = pThis->pDevIns; 957 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 958 PPDMDEVINS pDevIns = pThisCC->pDevIns; 959 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 948 960 DEVACPI_LOCK_R3(pDevIns, pThis); 949 961 … … 961 973 static DECLCALLBACK(int) acpiR3Port_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled) 962 974 { 963 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 964 PPDMDEVINS pDevIns = pThis->pDevIns; 975 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 976 PPDMDEVINS pDevIns = pThisCC->pDevIns; 977 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 965 978 DEVACPI_LOCK_R3(pDevIns, pThis); 966 979 … … 977 990 static DECLCALLBACK(int) acpiR3Port_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered) 978 991 { 979 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 980 PPDMDEVINS pDevIns = pThis->pDevIns; 992 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 993 PPDMDEVINS pDevIns = pThisCC->pDevIns; 994 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 981 995 DEVACPI_LOCK_R3(pDevIns, pThis); 982 996 … … 992 1006 static DECLCALLBACK(int) acpiR3Port_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked) 993 1007 { 994 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 995 PPDMDEVINS pDevIns = pThis->pDevIns; 1008 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 1009 PPDMDEVINS pDevIns = pThisCC->pDevIns; 1010 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 996 1011 DEVACPI_LOCK_R3(pDevIns, pThis); 997 1012 … … 1010 1025 static DECLCALLBACK(int) acpiR3Port_SleepButtonPress(PPDMIACPIPORT pInterface) 1011 1026 { 1012 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 1013 PPDMDEVINS pDevIns = pThis->pDevIns; 1027 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 1028 PPDMDEVINS pDevIns = pThisCC->pDevIns; 1029 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 1014 1030 DEVACPI_LOCK_R3(pDevIns, pThis); 1015 1031 … … 1029 1045 static DECLCALLBACK(int) acpiR3Port_MonitorHotPlugEvent(PPDMIACPIPORT pInterface) 1030 1046 { 1031 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 1032 PPDMDEVINS pDevIns = pThis->pDevIns; 1047 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 1048 PPDMDEVINS pDevIns = pThisCC->pDevIns; 1049 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 1033 1050 DEVACPI_LOCK_R3(pDevIns, pThis); 1034 1051 … … 1048 1065 static DECLCALLBACK(int) acpiR3Port_BatteryStatusChangeEvent(PPDMIACPIPORT pInterface) 1049 1066 { 1050 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort); 1051 PPDMDEVINS pDevIns = pThis->pDevIns; 1067 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort); 1068 PPDMDEVINS pDevIns = pThisCC->pDevIns; 1069 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 1052 1070 DEVACPI_LOCK_R3(pDevIns, pThis); 1053 1071 … … 1131 1149 * @returns VINF_SUCCESS. 1132 1150 * @param pThis The ACPI shared instance data. 1133 */ 1134 static int acpiR3FetchBatteryStatus(PACPISTATE pThis) 1151 * @param pThisCC The ACPI instance data for ring-3. 1152 */ 1153 static int acpiR3FetchBatteryStatus(PACPISTATE pThis, PACPISTATER3 pThisCC) 1135 1154 { 1136 1155 uint32_t *p = pThis->au8BatteryInfo; … … 1141 1160 int rc; 1142 1161 1143 if (!pThis ->pDrv)1162 if (!pThisCC->pDrv) 1144 1163 return VINF_SUCCESS; 1145 rc = pThis ->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,1146 &hostBatteryState, &hostPresentRate);1164 rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity, 1165 &hostBatteryState, &hostPresentRate); 1147 1166 AssertRC(rc); 1148 1167 … … 1191 1210 * 1192 1211 * @returns status mask or 0. 1193 * @param pThis The ACPI shared instance data.1194 */ 1195 static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATE pThis)1212 * @param pThisCC The ACPI instance data for ring-3. 1213 */ 1214 static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATER3 pThisCC) 1196 1215 { 1197 1216 bool fPresent; /* battery present? */ … … 1201 1220 int rc; 1202 1221 1203 if (!pThis ->pDrv)1222 if (!pThisCC->pDrv) 1204 1223 return 0; 1205 rc = pThis ->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,1206 &hostBatteryState, &hostPresentRate);1224 rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity, 1225 &hostBatteryState, &hostPresentRate); 1207 1226 AssertRC(rc); 1208 1227 1209 1228 return fPresent 1210 ? STA_DEVICE_PRESENT_MASK /* present */1211 | STA_DEVICE_ENABLED_MASK /* enabled and decodes its resources */1212 | STA_DEVICE_SHOW_IN_UI_MASK /* should be shown in UI */1213 | STA_DEVICE_FUNCTIONING_PROPERLY_MASK /* functioning properly */1214 | STA_BATTERY_PRESENT_MASK /* battery is present */1215 : 0; /* device not present */1229 ? STA_DEVICE_PRESENT_MASK /* present */ 1230 | STA_DEVICE_ENABLED_MASK /* enabled and decodes its resources */ 1231 | STA_DEVICE_SHOW_IN_UI_MASK /* should be shown in UI */ 1232 | STA_DEVICE_FUNCTIONING_PROPERLY_MASK /* functioning properly */ 1233 | STA_BATTERY_PRESENT_MASK /* battery is present */ 1234 : 0; /* device not present */ 1216 1235 } 1217 1236 … … 1220 1239 * 1221 1240 * @returns status. 1222 * @param pThis The ACPI shared instance data.1223 */ 1224 static uint32_t acpiR3GetPowerSource(PACPISTATE pThis)1241 * @param pThisCC The ACPI instance data for ring-3. 1242 */ 1243 static uint32_t acpiR3GetPowerSource(PACPISTATER3 pThisCC) 1225 1244 { 1226 1245 /* query the current power source from the host driver */ 1227 if (!pThis ->pDrv)1246 if (!pThisCC->pDrv) 1228 1247 return AC_ONLINE; 1229 1248 1230 1249 PDMACPIPOWERSOURCE ps; 1231 int rc = pThis ->pDrv->pfnQueryPowerSource(pThis->pDrv, &ps);1250 int rc = pThisCC->pDrv->pfnQueryPowerSource(pThisCC->pDrv, &ps); 1232 1251 AssertRC(rc); 1233 1252 return ps == PDM_ACPI_POWER_SOURCE_BATTERY ? AC_OFFLINE : AC_ONLINE; … … 1270 1289 return VERR_IOM_IOPORT_UNUSED; 1271 1290 1272 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 1291 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 1292 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 1273 1293 DEVACPI_LOCK_R3(pDevIns, pThis); 1274 1294 … … 1277 1297 { 1278 1298 case BAT_STATUS_STATE: 1279 acpiR3FetchBatteryStatus(pThis );1299 acpiR3FetchBatteryStatus(pThis, pThisCC); 1280 1300 RT_FALL_THRU(); 1281 1301 case BAT_STATUS_PRESENT_RATE: … … 1300 1320 1301 1321 case BAT_DEVICE_STATUS: 1302 *pu32 = acpiR3GetBatteryDeviceStatus(pThis );1322 *pu32 = acpiR3GetBatteryDeviceStatus(pThisCC); 1303 1323 break; 1304 1324 1305 1325 case BAT_POWER_SOURCE: 1306 *pu32 = acpiR3GetPowerSource(pThis );1326 *pu32 = acpiR3GetPowerSource(pThisCC); 1307 1327 break; 1308 1328 … … 2107 2127 * @param pDevIns The device instance. 2108 2128 * @param pThis The ACPI shared instance data. 2129 * @param pThisCC The ACPI instance data for ring-3. 2109 2130 * @param NewIoPortBase The new base address of the I/O ports. 2110 2131 */ 2111 static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, RTIOPORT NewIoPortBase)2132 static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC, RTIOPORT NewIoPortBase) 2112 2133 { 2113 2134 Log(("acpi: rebasing PM 0x%x -> 0x%x\n", pThis->uPmIoPortBase, NewIoPortBase)); … … 2125 2146 2126 2147 /* We have to update FADT table acccording to the new base */ 2127 rc = acpiR3PlantTables(pDevIns, pThis );2148 rc = acpiR3PlantTables(pDevIns, pThis, pThisCC); 2128 2149 AssertRC(rc); 2129 2150 if (RT_FAILURE(rc)) … … 2532 2553 static DECLCALLBACK(int) acpiR3LoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 2533 2554 { 2534 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 2535 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 2555 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 2556 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 2557 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 2536 2558 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 2537 2559 … … 2580 2602 rc = acpiR3MapSMBusIoPorts(pDevIns, pThis); 2581 2603 AssertRCReturn(rc, rc); 2582 rc = acpiR3FetchBatteryStatus(pThis );2604 rc = acpiR3FetchBatteryStatus(pThis, pThisCC); 2583 2605 AssertRCReturn(rc, rc); 2584 2606 rc = acpiR3FetchBatteryInfo(pThis); … … 2602 2624 static DECLCALLBACK(void *) acpiR3QueryInterface(PPDMIBASE pInterface, const char *pszIID) 2603 2625 { 2604 PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IBase);2605 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis ->IBase);2606 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThis ->IACPIPort);2626 PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IBase); 2627 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase); 2628 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThisCC->IACPIPort); 2607 2629 return NULL; 2608 2630 } … … 2816 2838 { 2817 2839 ACPITBLXSDT *xsdt; 2818 const size_t size = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]); 2819 2820 xsdt = (ACPITBLXSDT*)RTMemAllocZ(size); 2840 const size_t cbXsdt = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]); 2841 xsdt = (ACPITBLXSDT *)RTMemAllocZ(cbXsdt); 2821 2842 if (!xsdt) 2822 2843 return VERR_NO_TMP_MEMORY; 2823 2844 2824 acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t) size, 1 /* according to ACPI 3.0 specs */);2845 acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)cbXsdt, 1 /* according to ACPI 3.0 specs */); 2825 2846 2826 2847 if (pThis->cCustTbls > 0) … … 2832 2853 Log(("Setup XSDT: [%d] = %RX64\n", i, xsdt->u64Entry[i])); 2833 2854 } 2834 xsdt->header.u8Checksum = acpiR3Checksum(xsdt, size); 2835 acpiR3PhysCopy(pDevIns, addr, xsdt, size); 2855 xsdt->header.u8Checksum = acpiR3Checksum(xsdt, cbXsdt); 2856 acpiR3PhysCopy(pDevIns, addr, xsdt, cbXsdt); 2857 2836 2858 RTMemFree(xsdt); 2837 2859 return VINF_SUCCESS; … … 3172 3194 * Create the ACPI tables in guest memory. 3173 3195 */ 3174 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis )3196 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC) 3175 3197 { 3176 3198 int rc; … … 3284 3306 { 3285 3307 aGCPhysCust[i] = GCPhysCur; 3286 GCPhysCur = RT_ALIGN_32(GCPhysCur + pThis ->acbCustBin[i], 16);3308 GCPhysCur = RT_ALIGN_32(GCPhysCur + pThisCC->acbCustBin[i], 16); 3287 3309 } 3288 3310 … … 3355 3377 { 3356 3378 Assert(i < MAX_CUST_TABLES); 3357 acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThis ->apu8CustBin[i], pThis->acbCustBin[i]);3379 acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThisCC->apu8CustBin[i], pThisCC->acbCustBin[i]); 3358 3380 aGCPhysRsdt[iCust + i] = aGCPhysCust[i] + addend; 3359 3381 aGCPhysXsdt[iCust + i] = aGCPhysCust[i] + addend; 3360 uint8_t* pSig = pThis ->apu8CustBin[i];3382 uint8_t* pSig = pThisCC->apu8CustBin[i]; 3361 3383 LogRel(("ACPI: Planted custom table '%c%c%c%c' at 0x%08X\n", 3362 3384 pSig[0], pSig[1], pSig[2], pSig[3], aGCPhysCust[i] + addend)); … … 3391 3413 uint32_t uAddress, unsigned cb, uint32_t u32Value) 3392 3414 { 3393 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3415 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3416 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3394 3417 3395 3418 Log2(("acpi: PCI config write: 0x%x -> 0x%x (%d)\n", u32Value, uAddress, cb)); … … 3418 3441 } 3419 3442 3420 int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, NewIoPortBase);3443 int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, NewIoPortBase); 3421 3444 AssertRC(rc); 3422 3445 } … … 3452 3475 static DECLCALLBACK(int) acpiR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 3453 3476 { 3454 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3477 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3478 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3455 3479 LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags)); 3456 3480 … … 3466 3490 { 3467 3491 PPDMIBASE IBaseTmp; 3468 rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis ->IBase, &IBaseTmp, "ACPI CPU");3492 rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->IBase, &IBaseTmp, "ACPI CPU"); 3469 3493 if (RT_SUCCESS(rc)) 3470 3494 { … … 3543 3567 static DECLCALLBACK(void) acpiR3MemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx) 3544 3568 { 3545 RT_NOREF1(enmCtx); 3546 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3547 acpiR3PlantTables(pDevIns, pThis); 3569 RT_NOREF(enmCtx); 3570 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3571 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3572 acpiR3PlantTables(pDevIns, pThis, pThisCC); 3548 3573 } 3549 3574 … … 3553 3578 static DECLCALLBACK(void) acpiR3Reset(PPDMDEVINS pDevIns) 3554 3579 { 3555 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3580 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3581 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3556 3582 3557 3583 /* Play safe: make sure that the IRQ isn't stuck after a reset. */ … … 3575 3601 /* Real device behavior is resetting only the PM controller state, 3576 3602 * but we're additionally doing the job of the BIOS. */ 3577 acpiR3UpdatePmHandlers(pDevIns, pThis, PM_PORT_BASE);3603 acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, PM_PORT_BASE); 3578 3604 acpiR3PmPCIBIOSFake(pDevIns, pThis); 3579 3605 … … 3592 3618 { 3593 3619 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 3594 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3620 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3621 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3622 3595 3623 for (uint8_t i = 0; i < pThis->cCustTbls; i++) 3596 3624 { 3597 if (pThis ->apu8CustBin[i])3625 if (pThisCC->apu8CustBin[i]) 3598 3626 { 3599 PDMDevHlpMMHeapFree(pDevIns, pThis ->apu8CustBin[i]);3600 pThis ->apu8CustBin[i] = NULL;3627 PDMDevHlpMMHeapFree(pDevIns, pThisCC->apu8CustBin[i]); 3628 pThisCC->apu8CustBin[i] = NULL; 3601 3629 } 3602 3630 } … … 3611 3639 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 3612 3640 PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE); 3641 PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3); 3613 3642 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3614 3643 … … 3618 3647 /** @todo move more of the code up! */ 3619 3648 3620 pThis ->pDevIns= pDevIns;3649 pThisCC->pDevIns = pDevIns; 3621 3650 VMCPUSET_EMPTY(&pThis->CpuSetAttached); 3622 3651 VMCPUSET_EMPTY(&pThis->CpuSetLocked); … … 3630 3659 3631 3660 /* IBase */ 3632 pThis ->IBase.pfnQueryInterface = acpiR3QueryInterface;3661 pThisCC->IBase.pfnQueryInterface = acpiR3QueryInterface; 3633 3662 /* IACPIPort */ 3634 pThis ->IACPIPort.pfnSleepButtonPress = acpiR3Port_SleepButtonPress;3635 pThis ->IACPIPort.pfnPowerButtonPress = acpiR3Port_PowerButtonPress;3636 pThis ->IACPIPort.pfnGetPowerButtonHandled = acpiR3Port_GetPowerButtonHandled;3637 pThis ->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode;3638 pThis ->IACPIPort.pfnGetCpuStatus = acpiR3Port_GetCpuStatus;3639 pThis ->IACPIPort.pfnMonitorHotPlugEvent = acpiR3Port_MonitorHotPlugEvent;3640 pThis ->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent;3663 pThisCC->IACPIPort.pfnSleepButtonPress = acpiR3Port_SleepButtonPress; 3664 pThisCC->IACPIPort.pfnPowerButtonPress = acpiR3Port_PowerButtonPress; 3665 pThisCC->IACPIPort.pfnGetPowerButtonHandled = acpiR3Port_GetPowerButtonHandled; 3666 pThisCC->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode; 3667 pThisCC->IACPIPort.pfnGetCpuStatus = acpiR3Port_GetCpuStatus; 3668 pThisCC->IACPIPort.pfnMonitorHotPlugEvent = acpiR3Port_MonitorHotPlugEvent; 3669 pThisCC->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent; 3641 3670 3642 3671 /* … … 3851 3880 { 3852 3881 PPDMIBASE IBaseTmp; 3853 rc = PDMDevHlpDriverAttach(pDevIns, i, &pThis ->IBase, &IBaseTmp, "ACPI CPU");3882 rc = PDMDevHlpDriverAttach(pDevIns, i, &pThisCC->IBase, &IBaseTmp, "ACPI CPU"); 3854 3883 3855 3884 if (RT_SUCCESS(rc)) … … 3908 3937 3909 3938 static const char *s_apszCustTblConfigKeys[] = {"CustomTable0", "CustomTable1", "CustomTable2", "CustomTable3"}; 3910 AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThis ->apu8CustBin));3939 AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThisCC->apu8CustBin)); 3911 3940 for (unsigned i = 0; i < RT_ELEMENTS(s_apszCustTblConfigKeys); ++i) 3912 3941 { … … 3930 3959 else if (!*pszCustBinFile) 3931 3960 { 3932 MMR3HeapFree(pszCustBinFile);3961 PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile); 3933 3962 pszCustBinFile = NULL; 3934 3963 } … … 3940 3969 { 3941 3970 uint32_t idxCust = pThis->cCustTbls; 3942 rc = acpiR3ReadCustomTable(pDevIns, &pThis ->apu8CustBin[idxCust],3943 &pThis ->acbCustBin[idxCust], pszCustBinFile, cbBufAvail);3971 rc = acpiR3ReadCustomTable(pDevIns, &pThisCC->apu8CustBin[idxCust], 3972 &pThisCC->acbCustBin[idxCust], pszCustBinFile, cbBufAvail); 3944 3973 LogRel(("ACPI: Reading custom ACPI table(%u) from file '%s' (%d bytes)\n", 3945 idxCust, pszCustBinFile, pThis ->acbCustBin[idxCust]));3946 MMR3HeapFree(pszCustBinFile);3974 idxCust, pszCustBinFile, pThisCC->acbCustBin[idxCust])); 3975 PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile); 3947 3976 if (RT_FAILURE(rc)) 3948 3977 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Error reading custom ACPI table.")); 3949 cbBufAvail -= pThis ->acbCustBin[idxCust];3978 cbBufAvail -= pThisCC->acbCustBin[idxCust]; 3950 3979 3951 3980 /* Update custom OEM attributes based on custom table */ 3952 3981 /** @todo is it intended for custom tables to overwrite user provided values above? */ 3953 ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThis ->apu8CustBin[idxCust];3982 ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThisCC->apu8CustBin[idxCust]; 3954 3983 memcpy(&pThis->au8OemId[0], &pTblHdr->au8OemId[0], 6); 3955 3984 memcpy(&pThis->au8OemTabId[0], &pTblHdr->au8OemTabId[0], 8); … … 3986 4015 return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Can not find space for RSDP. ACPI is disabled")); 3987 4016 3988 rc = acpiR3PlantTables(pDevIns, pThis );4017 rc = acpiR3PlantTables(pDevIns, pThis, pThisCC); 3989 4018 AssertRCReturn(rc, rc); 3990 4019 … … 4117 4146 * Get the corresponding connector interface 4118 4147 */ 4119 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis ->IBase, &pThis->pDrvBase, "ACPI Driver Port");4148 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->IBase, &pThisCC->pDrvBase, "ACPI Driver Port"); 4120 4149 if (RT_SUCCESS(rc)) 4121 4150 { 4122 pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIACPICONNECTOR); 4123 if (!pThis->pDrv) 4124 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE, 4125 N_("LUN #0 doesn't have an ACPI connector interface")); 4151 pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIACPICONNECTOR); 4152 if (!pThisCC->pDrv) 4153 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE, N_("LUN #0 doesn't have an ACPI connector interface")); 4126 4154 } 4127 4155 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4128 4156 { 4129 Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n", 4130 pDevIns->pReg->szName, pDevIns->iInstance)); 4157 Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance)); 4131 4158 rc = VINF_SUCCESS; 4132 4159 } … … 4174 4201 /* .uSharedVersion = */ 42, 4175 4202 /* .cbInstanceShared = */ sizeof(ACPISTATE), 4176 /* .cbInstanceCC = */ 0,4203 /* .cbInstanceCC = */ CTX_EXPR(sizeof(ACPISTATER3), 0, 0), 4177 4204 /* .cbInstanceRC = */ 0, 4178 4205 /* .cMaxPciDevices = */ 1,
Note:
See TracChangeset
for help on using the changeset viewer.