Changeset 32189 in vbox for trunk/src/VBox
- Timestamp:
- Sep 2, 2010 10:10:47 AM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevACPI.cpp
r31963 r32189 213 213 uint32_t cbRamLow; 214 214 215 /** Current ACPI S* state. We support S0 and S5 */215 /** Current ACPI S* state. We support S0 and S5. */ 216 216 uint32_t uSleepState; 217 217 uint8_t au8RSDPPage[0x1000]; … … 248 248 /** Which CPU to check for the locked status. */ 249 249 uint32_t idCpuLockCheck; 250 /** Mask of locked CPUs (used by the guest) */250 /** Mask of locked CPUs (used by the guest). */ 251 251 VMCPUSET CpuSetLocked; 252 /** The CPU event type */252 /** The CPU event type. */ 253 253 uint32_t u32CpuEventType; 254 /** The CPU id affected */254 /** The CPU id affected. */ 255 255 uint32_t u32CpuEvent; 256 /** Flag whether CPU hot plugging is enabled */256 /** Flag whether CPU hot plugging is enabled. */ 257 257 bool fCpuHotPlug; 258 /** Primary NIC PCI address */258 /** Primary NIC PCI address. */ 259 259 uint32_t u32NicPciAddress; 260 /** Primary audio card PCI address */260 /** Primary audio card PCI address. */ 261 261 uint32_t u32AudioPciAddress; 262 /** Flag whether S1 power state is enabled */262 /** Flag whether S1 power state is enabled. */ 263 263 bool fS1Enabled; 264 /** Flag whether S4 power state is enabled */264 /** Flag whether S4 power state is enabled. */ 265 265 bool fS4Enabled; 266 /** Flag whether S1 triggers a state save */ 267 bool fSuspendToDisk; 268 // uint32_t u32Pad0; 266 /** Flag whether S1 triggers a state save. */ 267 bool fSuspendToSavedState; 268 /** Flag whether to set WAK_STS on resume (restore included). */ 269 bool fSetWakeupOnResume; 269 270 270 271 /** ACPI port base interface. */ … … 274 275 /** Pointer to the device instance. */ 275 276 PPDMDEVINSR3 pDevIns; 276 /** Pointer to the driver base interface */277 /** Pointer to the driver base interface. */ 277 278 R3PTRTYPE(PPDMIBASE) pDrvBase; 278 /** Pointer to the driver connector interface */279 /** Pointer to the driver connector interface. */ 279 280 R3PTRTYPE(PPDMIACPICONNECTOR) pDrv; 280 281 281 /* Pointer to default PCI config read function*/282 /** Pointer to default PCI config read function. */ 282 283 R3PTRTYPE(PFNPCICONFIGREAD) pfnAcpiPciConfigRead; 283 /* Pointer to default PCI config write function*/284 /** Pointer to default PCI config write function. */ 284 285 R3PTRTYPE(PFNPCICONFIGWRITE) pfnAcpiPciConfigWrite; 285 286 } ACPIState; … … 1052 1053 } 1053 1054 1054 static int acpiSleep(ACPIState * s)1055 static int acpiSleep(ACPIState *pThis) 1055 1056 { 1056 1057 int rc; 1057 /* First pause the VM to stop it executing. Note that failures aren't fatal, we can 1058 * just continue the guest as if it was immediately resumed. 1059 */ 1060 rc = PDMDevHlpVMSuspend(s->pDevIns); /* This is VM pause, not really ACPI suspend. */ 1061 1062 /* The guest was probably reading the PMSTS register in a loop. The resume flag must 1063 * be set before continuing in any way - needs to be part of saved state. 1064 */ 1065 s->pm1a_sts |= WAK_STS; 1066 1067 if (RT_FAILURE(rc)) 1068 AssertMsgFailed(("Could not pause the VM. rc = %Rrc\n", rc)); 1069 1070 if (s->fSuspendToDisk) { 1071 // rc = PDMDevHlpVMSuspendToDisk(s->pDevIns); 1072 if (RT_FAILURE(rc)) 1073 AssertMsgFailed(("Could not save VM state. rc = %Rrc\n", rc)); 1058 1059 /* We must set WAK_STS on resume (includes restore) so the guest knows that 1060 we've woken up and can continue executing code. The guest is probably 1061 reading the PMSTS register in a loop to check this. */ 1062 pThis->fSetWakeupOnResume = true; 1063 if (pThis->fSuspendToSavedState) 1064 { 1065 rc = PDMDevHlpVMSuspendSaveAndPowerOff(pThis->pDevIns); 1066 AssertRC(rc); 1067 } 1068 else 1069 { 1070 rc = PDMDevHlpVMSuspend(pThis->pDevIns); 1071 AssertRC(rc); 1074 1072 } 1075 1073 return rc; … … 2005 2003 }; 2006 2004 2007 2008 static DECLCALLBACK(int) acpi_save_state(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 2009 { 2010 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *); 2011 return SSMR3PutStruct(pSSMHandle, s, &g_AcpiSavedStateFields5[0]); 2012 } 2013 2014 static DECLCALLBACK(int) acpi_load_state(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, 2015 uint32_t uVersion, uint32_t uPass) 2016 { 2017 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *); 2018 2005 /** 2006 * Saved state structure description, version 6. 2007 */ 2008 static const SSMFIELD g_AcpiSavedStateFields6[] = 2009 { 2010 SSMFIELD_ENTRY(ACPIState, pm1a_en), 2011 SSMFIELD_ENTRY(ACPIState, pm1a_sts), 2012 SSMFIELD_ENTRY(ACPIState, pm1a_ctl), 2013 SSMFIELD_ENTRY(ACPIState, pm_timer_initial), 2014 SSMFIELD_ENTRY(ACPIState, gpe0_en), 2015 SSMFIELD_ENTRY(ACPIState, gpe0_sts), 2016 SSMFIELD_ENTRY(ACPIState, uBatteryIndex), 2017 SSMFIELD_ENTRY(ACPIState, uSystemInfoIndex), 2018 SSMFIELD_ENTRY(ACPIState, uSleepState), 2019 SSMFIELD_ENTRY(ACPIState, u8IndexShift), 2020 SSMFIELD_ENTRY(ACPIState, uPmIoPortBase), 2021 SSMFIELD_ENTRY(ACPIState, fSuspendToSavedState), 2022 SSMFIELD_ENTRY_TERM() 2023 }; 2024 2025 2026 /** 2027 * @callback_method_impl{FNSSMDEVSAVEEXEC} 2028 */ 2029 static DECLCALLBACK(int) acpiSaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 2030 { 2031 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2032 return SSMR3PutStruct(pSSMHandle, pThis, &g_AcpiSavedStateFields6[0]); 2033 } 2034 2035 /** 2036 * @callback_method_impl{FNSSMDEVLOADEXEC} 2037 */ 2038 static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, 2039 uint32_t uVersion, uint32_t uPass) 2040 { 2041 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2019 2042 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 2043 2020 2044 /* 2021 * Unregister PM handlers, will register with actual base 2022 * after statesuccessfully loaded.2045 * Unregister PM handlers, will register with actual base after state 2046 * successfully loaded. 2023 2047 */ 2024 int rc = acpiUnregisterPmHandlers( s);2048 int rc = acpiUnregisterPmHandlers(pThis); 2025 2049 if (RT_FAILURE(rc)) 2026 2050 return rc; … … 2029 2053 { 2030 2054 case 4: 2031 rc = SSMR3GetStruct(pSSMHandle, s, &g_AcpiSavedStateFields4[0]); 2032 /** @todo Provide saner defaults for fields not found in saved state. */ 2055 rc = SSMR3GetStruct(pSSMHandle, pThis, &g_AcpiSavedStateFields4[0]); 2033 2056 break; 2034 2057 case 5: 2035 rc = SSMR3GetStruct(pSSMHandle, s, &g_AcpiSavedStateFields5[0]); 2058 rc = SSMR3GetStruct(pSSMHandle, pThis, &g_AcpiSavedStateFields5[0]); 2059 break; 2060 case 6: 2061 rc = SSMR3GetStruct(pSSMHandle, pThis, &g_AcpiSavedStateFields6[0]); 2036 2062 break; 2037 2063 default: 2038 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 2064 rc = VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 2065 break; 2039 2066 } 2040 2067 if (RT_SUCCESS(rc)) 2041 2068 { 2042 rc = acpiRegisterPmHandlers( s);2069 rc = acpiRegisterPmHandlers(pThis); 2043 2070 if (RT_FAILURE(rc)) 2044 2071 return rc; 2045 rc = acpiFetchBatteryStatus( s);2072 rc = acpiFetchBatteryStatus(pThis); 2046 2073 if (RT_FAILURE(rc)) 2047 2074 return rc; 2048 rc = acpiFetchBatteryInfo( s);2075 rc = acpiFetchBatteryInfo(pThis); 2049 2076 if (RT_FAILURE(rc)) 2050 2077 return rc; 2051 rc = acpiPMTimerReset( s);2078 rc = acpiPMTimerReset(pThis); 2052 2079 if (RT_FAILURE(rc)) 2053 2080 return rc; … … 2351 2378 } 2352 2379 2380 /** 2381 * @interface_method_impl{PDMDEVREG,pfnResume} 2382 */ 2383 static DECLCALLBACK(void) acpiResume(PPDMDEVINS pDevIns) 2384 { 2385 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2386 if (pThis->fSetWakeupOnResume) 2387 { 2388 Log(("acpiResume: setting WAK_STS\n")); 2389 pThis->fSetWakeupOnResume = false; 2390 pThis->pm1a_sts |= WAK_STS; 2391 } 2392 } 2393 2394 /** 2395 * @interface_method_impl{PDMDEVREG,pfnReset} 2396 */ 2353 2397 static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns) 2354 2398 { … … 2373 2417 2374 2418 /** 2375 * Relocates the GC pointer members.2419 * @interface_method_impl{PDMDEVREG,pfnRelocate} 2376 2420 */ 2377 2421 static DECLCALLBACK(void) acpiRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) … … 2481 2525 2482 2526 /* query whether S1 power state should save the VM state */ 2483 rc = CFGMR3QueryBoolDef(pCfg, "EnableSuspendToDisk", &s->fSuspendTo Disk, false);2527 rc = CFGMR3QueryBoolDef(pCfg, "EnableSuspendToDisk", &s->fSuspendToSavedState, false); 2484 2528 if (RT_FAILURE(rc)) 2485 2529 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2659 2703 acpiPciConfigWrite, &s->pfnAcpiPciConfigWrite); 2660 2704 2661 rc = PDMDevHlpSSMRegister(pDevIns, 5, sizeof(*s), acpi_save_state, acpi_load_state);2705 rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*s), acpiSaveState, acpiLoadState); 2662 2706 if (RT_FAILURE(rc)) 2663 2707 return rc; … … 2724 2768 NULL, 2725 2769 /* pfnResume */ 2726 NULL,2770 acpiResume, 2727 2771 /* pfnAttach */ 2728 2772 acpiAttach, -
trunk/src/VBox/VMM/PDMDevHlp.cpp
r30129 r32189 2825 2825 2826 2826 LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc)); 2827 return rc; 2828 } 2829 2830 2831 /** @interface_method_impl{PDMDEVHLPR3,pfnVMSuspendSaveAndPowerOff} */ 2832 static DECLCALLBACK(int) pdmR3DevHlp_VMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns) 2833 { 2834 int rc; 2835 PDMDEV_ASSERT_DEVINS(pDevIns); 2836 PVM pVM = pDevIns->Internal.s.pVMR3; 2837 VM_ASSERT_EMT(pVM); 2838 LogFlow(("pdmR3DevHlp_VMSuspendSaveAndPowerOff: caller='%s'/%d:\n", 2839 pDevIns->pReg->szName, pDevIns->iInstance)); 2840 2841 /** @todo We'll have to queue a request to avoid deadlock issues. */ 2842 rc = VERR_NOT_IMPLEMENTED; 2843 2844 LogFlow(("pdmR3DevHlp_VMSuspendSaveAndPowerOff: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc)); 2827 2845 return rc; 2828 2846 } … … 2995 3013 pdmR3DevHlp_VMReset, 2996 3014 pdmR3DevHlp_VMSuspend, 3015 pdmR3DevHlp_VMSuspendSaveAndPowerOff, 2997 3016 pdmR3DevHlp_VMPowerOff, 2998 3017 pdmR3DevHlp_A20IsEnabled, … … 3052 3071 /** @interface_method_impl{PDMDEVHLPR3,pfnVMSuspend} */ 3053 3072 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMSuspend(PPDMDEVINS pDevIns) 3073 { 3074 PDMDEV_ASSERT_DEVINS(pDevIns); 3075 AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance)); 3076 return VERR_ACCESS_DENIED; 3077 } 3078 3079 3080 /** @interface_method_impl{PDMDEVHLPR3,pfnVMSuspendSaveAndPowerOff} */ 3081 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns) 3054 3082 { 3055 3083 PDMDEV_ASSERT_DEVINS(pDevIns); … … 3191 3219 pdmR3DevHlp_Untrusted_VMReset, 3192 3220 pdmR3DevHlp_Untrusted_VMSuspend, 3221 pdmR3DevHlp_Untrusted_VMSuspendSaveAndPowerOff, 3193 3222 pdmR3DevHlp_Untrusted_VMPowerOff, 3194 3223 pdmR3DevHlp_Untrusted_A20IsEnabled,
Note:
See TracChangeset
for help on using the changeset viewer.