Changeset 6852 in vbox
- Timestamp:
- Feb 7, 2008 5:45:47 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
include/VBox/pdmifs.h (modified) (1 diff)
-
src/VBox/Devices/PC/DevACPI.cpp (modified) (5 diffs)
-
src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp (modified) (4 diffs)
-
src/VBox/Main/ConsoleImpl.cpp (modified) (1 diff)
-
src/VBox/Main/idl/VirtualBox.xidl (modified) (1 diff)
-
src/VBox/Main/include/ConsoleImpl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmifs.h
r6312 r6852 1677 1677 */ 1678 1678 DECLR3CALLBACKMEMBER(int, pfnSleepButtonPress,(PPDMIACPIPORT pInterface)); 1679 1680 /** 1681 * Check if the last power button event was handled by the guest. 1682 * 1683 * @returns VBox status code 1684 * @param pInterface Pointer to the interface structure containing the called function pointer. 1685 * @param pfHandled Is set to true if the last power button event was handled, false otherwise. 1686 */ 1687 DECLR3CALLBACKMEMBER(int, pfnGetPowerButtonHandled,(PPDMIACPIPORT pInterface, bool *pfHandled)); 1679 1688 } PDMIACPIPORT; 1680 1689 -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r6305 r6852 181 181 uint8_t u8IndexShift; 182 182 uint8_t u8UseIOApic; 183 bool fPowerButtonHandled; 183 184 184 185 /** ACPI port base interface. */ … … 741 742 { 742 743 ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface); 744 s->fPowerButtonHandled = false; 743 745 update_pm1a (s, s->pm1a_sts | PWRBTN_STS, s->pm1a_en); 746 return VINF_SUCCESS; 747 } 748 749 static DECLCALLBACK(int) acpiGetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled) 750 { 751 ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface); 752 *pfHandled = s->fPowerButtonHandled; 744 753 return VINF_SUCCESS; 745 754 } … … 784 793 { 785 794 Log (("acpi: acpiPM1aStsWritew <- %#x (%#x)\n", val, val & ~(RSR_STS | IGN_STS))); 795 if (val & PWRBTN_STS) 796 s->fPowerButtonHandled = true; /* Remember that the guest handled the last power button event */ 786 797 val = s->pm1a_sts & ~(val & ~(RSR_STS | IGN_STS)); 787 798 update_pm1a (s, val, s->pm1a_en); … … 1063 1074 return VERR_IOM_IOPORT_UNUSED; 1064 1075 } 1065 // LogRel(("Query %04x => %08x\n", s->uBatteryIndex, *pu32));1066 1076 return VINF_SUCCESS; 1067 1077 } … … 1676 1686 */ 1677 1687 /* IBase */ 1678 s->IBase.pfnQueryInterface = acpiQueryInterface;1688 s->IBase.pfnQueryInterface = acpiQueryInterface; 1679 1689 /* IACPIPort */ 1680 s->IACPIPort.pfnSleepButtonPress = acpiSleepButtonPress; 1681 s->IACPIPort.pfnPowerButtonPress = acpiPowerButtonPress; 1690 s->IACPIPort.pfnSleepButtonPress = acpiSleepButtonPress; 1691 s->IACPIPort.pfnPowerButtonPress = acpiPowerButtonPress; 1692 s->IACPIPort.pfnGetPowerButtonHandled = acpiGetPowerButtonHandled; 1682 1693 1683 1694 /* -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r6616 r6852 140 140 static Uint32 StartupTimer(Uint32 interval, void *param); 141 141 static Uint32 ResizeTimer(Uint32 interval, void *param); 142 static Uint32 QuitTimer(Uint32 interval, void *param); 142 143 static int WaitSDLEvent(SDL_Event *event); 143 144 … … 191 192 static SDL_Cursor *gpOffCursor = NULL; 192 193 static SDL_TimerID gSdlResizeTimer = NULL; 194 static SDL_TimerID gSdlQuitTimer = NULL; 193 195 194 196 #ifdef VBOXSDL_WITH_X11 … … 2210 2212 case SDL_QUIT: 2211 2213 { 2212 if (!gfACPITerm )2214 if (!gfACPITerm || gSdlQuitTimer) 2213 2215 goto leave; 2214 2216 if (gConsole) 2215 2217 gConsole->PowerButton(); 2216 g fACPITerm = false; /* don't try a second time */2218 gSdlQuitTimer = SDL_AddTimer(1000, QuitTimer, NULL); 2217 2219 break; 2218 2220 } … … 4371 4373 4372 4374 /** 4375 * Timer callback function to check if an ACPI power button event was handled by the guest. 4376 */ 4377 static Uint32 QuitTimer(Uint32 interval, void *param) 4378 { 4379 PRBool fHandled = FALSE; 4380 4381 gSdlQuitTimer = NULL; 4382 if (gConsole) 4383 { 4384 int rc = gConsole->GetPowerButtonHandled(&fHandled); 4385 LogRel(("QuitTimer: rc=%d handled=%d\n", rc, fHandled)); 4386 if (VBOX_FAILURE(rc) || !fHandled) 4387 { 4388 /* event was not handled, power down the guest */ 4389 gfACPITerm = FALSE; 4390 SDL_Event event = {0}; 4391 event.type = SDL_QUIT; 4392 PushSDLEventForSure(&event); 4393 } 4394 } 4395 /* one-shot */ 4396 return 0; 4397 } 4398 4399 /** 4373 4400 * Wait for the next SDL event. Don't use SDL_WaitEvent since this function 4374 4401 * calls SDL_Delay(10) if the event queue is empty. -
trunk/src/VBox/Main/ConsoleImpl.cpp
r6658 r6852 1554 1554 setError (E_FAIL, 1555 1555 tr ("Controlled power off failed (%Vrc)"), vrc); 1556 1557 LogFlowThisFunc (("rc=%08X\n", rc)); 1558 LogFlowThisFuncLeave(); 1559 return rc; 1560 } 1561 1562 STDMETHODIMP Console::GetPowerButtonHandled(PRBool *aHandled) 1563 { 1564 LogFlowThisFuncEnter(); 1565 1566 AutoCaller autoCaller (this); 1567 1568 AutoLock lock (this); 1569 1570 if (mMachineState != MachineState_Running) 1571 return E_FAIL; 1572 1573 /* protect mpVM */ 1574 AutoVMCaller autoVMCaller (this); 1575 CheckComRCReturnRC (autoVMCaller.rc()); 1576 1577 PPDMIBASE pBase; 1578 int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase); 1579 bool handled = false; 1580 if (VBOX_SUCCESS (vrc)) 1581 { 1582 Assert (pBase); 1583 PPDMIACPIPORT pPort = 1584 (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT); 1585 vrc = pPort ? pPort->pfnGetPowerButtonHandled(pPort, &handled) : VERR_INVALID_POINTER; 1586 } 1587 1588 HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK : 1589 setError (E_FAIL, 1590 tr ("Checking if poweroff was handled failed (%Vrc)"), vrc); 1591 1592 *aHandled = handled; 1556 1593 1557 1594 LogFlowThisFunc (("rc=%08X\n", rc)); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r6616 r6852 3768 3768 </method> 3769 3769 3770 <method name="getPowerButtonHandled"> 3771 <desc>Check if the last power button event was handled by guest.</desc> 3772 <param name="handled" type="boolean" dir="return"/> 3773 </method> 3774 3770 3775 <method name="saveState"> 3771 3776 <desc> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r6464 r6852 127 127 STDMETHOD(PowerButton)(); 128 128 STDMETHOD(SleepButton)(); 129 STDMETHOD(GetPowerButtonHandled)(PRBool *aHandled); 129 130 STDMETHOD(SaveState) (IProgress **aProgress); 130 131 STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
Note:
See TracChangeset
for help on using the changeset viewer.

