VirtualBox

Changeset 31963 in vbox


Ignore:
Timestamp:
Aug 25, 2010 3:12:50 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65196
Message:

ACPI: Hook S1 power state.

Location:
trunk/src/VBox/Devices/PC
Files:
2 edited

Legend:

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

    r31519 r31963  
    162162    SYSTEM_INFO_INDEX_NIC_ADDRESS       = 15, /**< NIC PCI address, or 0 */
    163163    SYSTEM_INFO_INDEX_AUDIO_ADDRESS     = 16, /**< Audio card PCI address, or 0 */
    164     SYSTEM_INFO_INDEX_END               = 17,
     164    SYSTEM_INFO_INDEX_POWER_STATES      = 17,
     165    SYSTEM_INFO_INDEX_END               = 18,
    165166    SYSTEM_INFO_INDEX_INVALID           = 0x80,
    166167    SYSTEM_INFO_INDEX_VALID             = 0x200
     
    259260    /** Primary audio card PCI address */
    260261    uint32_t            u32AudioPciAddress;
    261     uint32_t            u32Pad0;
     262    /** Flag whether S1 power state is enabled */
     263    bool                fS1Enabled;
     264    /** Flag whether S4 power state is enabled */
     265    bool                fS4Enabled;
     266    /** Flag whether S1 triggers a state save */
     267    bool                fSuspendToDisk;
     268//    uint32_t            u32Pad0;
    262269
    263270    /** ACPI port base interface. */
     
    10451052}
    10461053
     1054static int acpiSleep(ACPIState *s)
     1055{
     1056    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));       
     1074    }
     1075    return rc;
     1076}
     1077
    10471078/** Converts a ACPI port interface pointer to an ACPI state pointer. */
    10481079#define IACPIPORT_2_ACPISTATE(pInterface) ( (ACPIState*)((uintptr_t)pInterface - RT_OFFSETOF(ACPIState, IACPIPort)) )
     
    11651196            case 0x00:                  /* S0 */
    11661197                break;
     1198            case 0x01:                  /* S1 */
     1199                LogRel(("Entering S1 power state (powered-on suspend)\n"));
     1200                return acpiSleep(s);
     1201            case 0x04:                  /* S4 */
     1202                LogRel(("Entering S4 power state (suspend to disk)\n"));
     1203                return acpiPowerDown(s);/* Same behavior as S5 */
    11671204            case 0x05:                  /* S5 */
    1168                 LogRel(("Entering S5 (power down)\n"));
     1205                LogRel(("Entering S5 power state (power down)\n"));
    11691206                return acpiPowerDown(s);
    11701207            default:
     
    15121549                case SYSTEM_INFO_INDEX_AUDIO_ADDRESS:
    15131550                    *pu32 = s->u32AudioPciAddress;
     1551                    break;
     1552
     1553                case SYSTEM_INFO_INDEX_POWER_STATES:
     1554                    *pu32 = RT_BIT(0) | RT_BIT(5);  /* S1 and S5 always exposed */
     1555                    if (s->fS1Enabled)              /* Optionally expose S1 and S4 */
     1556                        *pu32 |= RT_BIT(1);
     1557                    if (s->fS4Enabled)
     1558                        *pu32 |= RT_BIT(4);
    15141559                    break;
    15151560
     
    23602405                              "NicPciAddress\0"
    23612406                              "AudioPciAddress\0"
     2407                              "EnableSuspendToDisk\0"
     2408                              "PowerS1Enabled\0"
     2409                              "PowerS4Enabled\0"
    23622410                              "CpuHotPlug\0"
    23632411                              "AmlFilePath\0"
     
    24192467        return PDMDEV_SET_ERROR(pDevIns, rc,
    24202468                                N_("Configuration error: Failed to read \"AudioPciAddress\""));
     2469
     2470    /* query whether S1 power state should be exposed */
     2471    rc = CFGMR3QueryBoolDef(pCfg, "PowerS1Enabled", &s->fS1Enabled, true);
     2472    if (RT_FAILURE(rc))
     2473        return PDMDEV_SET_ERROR(pDevIns, rc,
     2474                                N_("Configuration error: Failed to read \"PowerS1Enabled\""));
     2475
     2476    /* query whether S4 power state should be exposed */
     2477    rc = CFGMR3QueryBoolDef(pCfg, "PowerS4Enabled", &s->fS4Enabled, true);
     2478    if (RT_FAILURE(rc))
     2479        return PDMDEV_SET_ERROR(pDevIns, rc,
     2480                                N_("Configuration error: Failed to read \"PowerS1Enabled\""));
     2481
     2482    /* query whether S1 power state should save the VM state */
     2483    rc = CFGMR3QueryBoolDef(pCfg, "EnableSuspendToDisk", &s->fSuspendToDisk, false);
     2484    if (RT_FAILURE(rc))
     2485        return PDMDEV_SET_ERROR(pDevIns, rc,
     2486                                N_("Configuration error: Failed to read \"EnableSuspendToDisk\""));
    24212487
    24222488    /* query whether we are allow CPU hot plugging */
  • trunk/src/VBox/Devices/PC/vbox.dsl

    r31519 r31963  
    117117    }
    118118
     119    // Declare indexed registers used for reading configuration information
     120    OperationRegion (SYSI, SystemIO, 0x4048, 0x08)
     121    Field (SYSI, DwordAcc, NoLock, Preserve)
     122    {
     123       IDX0, 32,
     124       DAT0, 32,
     125    }
     126
     127    IndexField (IDX0, DAT0, DwordAcc, NoLock, Preserve)
     128    {
     129        MEML,  32,
     130        UIOA,  32,
     131        UHPT,  32,
     132        USMC,  32,
     133        UFDC,  32,
     134        // UCP0-UCP3 no longer used and only kept here for saved state compatibilty
     135        UCP0,  32,
     136        UCP1,  32,
     137        UCP2,  32,
     138        UCP3,  32,
     139        MEMH,  32,
     140        URTC,  32,
     141        CPUL,  32,
     142        CPUC,  32,
     143        CPET,  32,
     144        CPEV,  32,
     145        NICA,  32,
     146        HDAA,  32,
     147        PWRS,  32,
     148        Offset (0x80),
     149        ININ, 32,
     150        Offset (0x200),
     151        VAIN, 32,
     152    }
     153
    119154    Scope (\_SB)
    120155    {
    121         OperationRegion (SYSI, SystemIO, 0x4048, 0x08)
    122         Field (SYSI, DwordAcc, NoLock, Preserve)
    123         {
    124             IDX0, 32,
    125             DAT0, 32,
    126         }
    127 
    128         IndexField (IDX0, DAT0, DwordAcc, NoLock, Preserve)
    129         {
    130             MEML,  32,
    131             UIOA,  32,
    132             UHPT,  32,
    133             USMC,  32,
    134             UFDC,  32,
    135             // UCP0-UCP3 no longer used and only kept here for saved state compatibilty
    136             UCP0,  32,
    137             UCP1,  32,
    138             UCP2,  32,
    139             UCP3,  32,
    140             MEMH,  32,
    141             URTC,  32,
    142             CPUL,  32,
    143             CPUC,  32,
    144             CPET,  32,
    145             CPEV,  32,
    146             NICA,  32,
    147             HDAA,  32,
    148             Offset (0x80),
    149             ININ, 32,
    150             Offset (0x200),
    151             VAIN, 32,
    152         }
    153 
    154156        Method (_INI, 0, NotSerialized)
    155157        {
     
    13051307    })
    13061308
     1309    // Shift one by the power state number
     1310//    If (And(PWRS, ShiftLeft(One,1))) {
     1311        Name (_S1, Package (2) {
     1312            0x01,
     1313            0x01,
     1314        })
     1315//    }
     1316
     1317//    If (And(PWRS, ShiftLeft(One,4))) {
     1318        Name (_S4, Package (2) {
     1319            0x05,
     1320            0x05,
     1321        })
     1322//    }
     1323
    13071324    Name (_S5, Package (2) {
    13081325        0x05,
Note: See TracChangeset for help on using the changeset viewer.

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