VirtualBox

Changeset 6156 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 19, 2007 5:46:03 PM (17 years ago)
Author:
vboxsync
Message:

implemented the ACPI sleep button

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r5999 r6156  
    542542    fadt.u16IAPCBOOTARCH      = RT_H2LE_U16(IAPC_BOOT_ARCH_LEGACY_DEV | IAPC_BOOT_ARCH_8042);
    543543    /** @note WBINVD is required for ACPI versions newer than 1.0 */
    544     fadt.u32Flags             = RT_H2LE_U32(  FADT_FL_WBINVD | FADT_FL_SLP_BUTTON
    545                                             | FADT_FL_FIX_RTC | FADT_FL_TMR_VAL_EXT);
     544    fadt.u32Flags             = RT_H2LE_U32(  FADT_FL_WBINVD
     545                                            | FADT_FL_FIX_RTC
     546                                            | FADT_FL_TMR_VAL_EXT);
    546547    acpiWriteGenericAddr(&fadt.ResetReg,     1,  8, 0, 1, ACPI_RESET_BLK);
    547548    fadt.u8ResetVal           = ACPI_RESET_REG_VAL;
     
    741742    ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface);
    742743    update_pm1a (s, s->pm1a_sts | PWRBTN_STS, s->pm1a_en);
     744    return VINF_SUCCESS;
     745}
     746
     747/**
     748 * Send an ACPI sleep button event.
     749 *
     750 * @returns VBox status code
     751 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     752 */
     753static DECLCALLBACK(int) acpiSleepButtonPress(PPDMIACPIPORT pInterface)
     754{
     755    ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface);
     756    update_pm1a (s, s->pm1a_sts | SLPBTN_STS, s->pm1a_en);
    743757    return VINF_SUCCESS;
    744758}
     
    16641678    s->IBase.pfnQueryInterface         = acpiQueryInterface;
    16651679    /* IACPIPort */
     1680    s->IACPIPort.pfnSleepButtonPress   = acpiSleepButtonPress;
    16661681    s->IACPIPort.pfnPowerButtonPress   = acpiPowerButtonPress;
    16671682
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r6103 r6156  
    404404        RTPrintf("VBoxManage controlvm        <uuid>|<name>\n"
    405405                 "                            pause|resume|reset|poweroff|savestate|\n"
    406                  "                            acpipowerbutton |\n"
     406                 "                            acpipowerbutton|acpisleepbutton|\n"
    407407                 "                            setlinkstate<1-4> on|off |\n"
    408408                 "                            usbattach <uuid>|<address> |\n"
     
    53265326            CHECK_ERROR_BREAK (console, PowerButton());
    53275327        }
     5328        else if (strcmp(argv[1], "acpisleepbutton") == 0)
     5329        {
     5330            CHECK_ERROR_BREAK (console, SleepButton());
     5331        }
    53285332        else if (strncmp(argv[1], "setlinkstate", 12) == 0)
    53295333        {
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r5999 r6156  
    15401540        setError (E_FAIL,
    15411541            tr ("Controlled power off failed (%Vrc)"), vrc);
     1542
     1543    LogFlowThisFunc (("rc=%08X\n", rc));
     1544    LogFlowThisFuncLeave();
     1545    return rc;
     1546}
     1547
     1548STDMETHODIMP Console::SleepButton()
     1549{
     1550    LogFlowThisFuncEnter();
     1551
     1552    AutoCaller autoCaller (this);
     1553    CheckComRCReturnRC (autoCaller.rc());
     1554
     1555    AutoLock lock (this);
     1556
     1557    if (mMachineState != MachineState_Running)
     1558        return setError (E_FAIL, tr ("Cannot send the sleep button event as it is "
     1559                                     "not running (machine state: %d)"),
     1560                         mMachineState);
     1561
     1562    /* protect mpVM */
     1563    AutoVMCaller autoVMCaller (this);
     1564    CheckComRCReturnRC (autoVMCaller.rc());
     1565
     1566    PPDMIBASE pBase;
     1567    int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
     1568    if (VBOX_SUCCESS (vrc))
     1569    {
     1570        Assert (pBase);
     1571        PPDMIACPIPORT pPort =
     1572            (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
     1573        vrc = pPort ? pPort->pfnSleepButtonPress(pPort) : VERR_INVALID_POINTER;
     1574    }
     1575
     1576    HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
     1577        setError (E_FAIL,
     1578            tr ("Sending sleep button event failed (%Vrc)"), vrc);
    15421579
    15431580    LogFlowThisFunc (("rc=%08X\n", rc));
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r6076 r6156  
    37583758    </method>
    37593759
     3760    <method name="sleepButton">
     3761      <desc>Send the ACPI sleep button event to the guest.</desc>
     3762    </method>
     3763
    37603764    <method name="saveState">
    37613765      <desc>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r5999 r6156  
    126126    STDMETHOD(Resume)();
    127127    STDMETHOD(PowerButton)();
     128    STDMETHOD(SleepButton)();
    128129    STDMETHOD(SaveState) (IProgress **aProgress);
    129130    STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette