7.4. OEM-Supplied System-Level Control Methods¶
An OEM-supplied Definition Block provides some number of controls appropriate for system-level management. These are used by OSPM to integrate to the OEM-provided features. The following table lists the defined OEM system controls that can be provided.
Object |
Description |
---|---|
\_PTS |
Control method used to notify the platform of impending sleep transition. |
\_S0 |
Package that defines system \_S0 state mode. |
\_S1 |
Package that defines system \_S1 state mode. |
\_S2 |
Package that defines system \_S2 state mode. |
\_S3 |
Package that defines system \_S3 state mode. |
\_S4 |
Package that defines system \_S4 state mode. |
\_S5 |
Package that defines system \_S5 state mode. |
\_TTS |
Control method used to prepare to sleep and run once awakened |
\_WAK |
Control method run once awakened. |
Note
Compatibility issue: The _BFS (Back From Sleep) and _GTS (Going To Sleep) methods were deprecated in ACPI 5.0A.
7.4.1. \_PTS (Prepare To Sleep)¶
The _PTS control method is executed by the OS during the sleep transition process for S1, S2, S3, S4, and for orderly S5 shutdown. The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5 soft-off state) is passed to the _PTS control method. This method is called after OSPM has notified native device drivers of the sleep state transition and before the OSPM has had a chance to fully prepare the system for a sleep state transition. Thus, this control method can be executed a relatively long time before actually entering the desired sleeping state. If OSPM aborts the sleep state transition, OSPM should run the _WAK method to indicate this condition to the platform.
Arguments (1):
Arg0 - An Integer containing the value of the sleeping state (1 for S1, 2 for S2, etc.)
Return Value:
None
The _PTS control method cannot modify the current configuration or power state of any device in the system. For example, _PTS would simply store the sleep type in the embedded controller in sequencing the system into a sleep state when the SLP_EN bit is set.
The platform must not make any assumptions about the state of the machine when _PTS is called. For example, operation region accesses that require devices to be configured and enabled may not succeed, as these devices may be in a non-decoding state due to plug and play or power management operations.
7.4.2. \_Sx (System States)¶
All system states supported by the system must provide a package containing the DWORD value of the following format in the static Definition Block. The system states, known as S0-S5, are referenced in the namespace as \_S0-_S5 and for clarity the short Sx names are used unless specifically referring to the named \_Sx object. For each Sx state, there is a defined system behavior.
Arguments:
None
Return Value:
A Package containing an Integer containing register values for sleeping
Byte Length |
Byte Offset |
Description |
---|---|---|
1 |
0 |
Value for PM1a_CNT.SLP_TYP register to enter this system state. On HW-reduced platforms, this is the HW-reduced Sleep Type value for SLEEP_CONTROL_REG.SLP_TYP. |
1 |
1 |
Value for PM1b_CNT.SLP_TYP register to enter this system state. To enter any given state, OSPM must write the PM1a_CNT.SLP_TYP register before the PM1b_CNT.SLP_TYP register. On HW-reduced platforms, this value is ignored. |
2 |
2 |
Reserved |
States S1-S4 represent some system sleeping state. The S0 state is the system working state. Transition into the S0 state from some other system state (such as sleeping) is automatic, and, by virtue that instructions are being executed, OSPM assumes the system to be in the S0 state. Transition into any system sleeping state is only accomplished by the operating software directing the hardware to enter the appropriate state, and the operating software can only do this within the requirements defined in the Power Resource and Bus/Device Package objects.
All run-time system state transitions (for example, to and from the S0 state), except S4 and S5, are done similarly such that the code sequence to do this is the following:
/*
* Intel Architecture SetSleepingState example
*/
ULONG
SetSystemSleeping (
IN ULONG NewState
)
{
PROCESSOR_CONTEXT Context;
ULONG PowerSeqeunce;
BOOLEAN FlushCaches;
USHORT SlpTyp;
// Required environment: Executing on the system boot
// processor. All other processors stopped. Interrupts
// disabled. All Power Resources (and devices) are in
// corresponding device state to support NewState.
// Get h/w attributes for this system state
FlushCaches = SleepType[NewState].FlushCache;
SlpTyp = SleepType[NewState].SlpTyp & SLP_TYP_MASK;
_asm {
lea eax, OsResumeContext
push eax ; Build real mode handler the resume
push offset sp50 ; context, with eip = sp50
call SaveProcessorState
mov eax, ResumeVector ; set firmware's resume vector
mov [eax], offset OsRealModeResumeCode
mov edx, PM1a_STS ; Make sure wake status is clear
mov ax, WAK_STS ; (cleared by asserting the bit
out dx, ax ; in the status register)
mov edx, PM1b_STS ;
out dx, ax ;
and eax, not SLP_TYP_MASK
or eax, SlpTyp ; set SLP_TYP
or ax, SLP_EN ; set SLP_EN
cmp FlushCaches, 0
jz short sp10 ; If needed, ensure no dirty data in
call FlushProcessorCaches ; the caches while sleeping
sp10: mov edx, PM1a_SLP_TYP ; get address for PM1a_SLP_TYP
out dx, ax ; start h/w sequencing
mov edx, PM1b_SLP_TYP ; get address for PM1b_SLP_TYP
out dx, ax ; start h/w sequencing
mov edx, PM1a_STS ; get address for PM1x_STS
mov ecx, PM1b_STS
sp20: in ax, dx ; wait for WAK status
xchg edx, ecx
test ax, WAK_STS
jz short sp20
sp50:
}
// Done..
*ResumeVector = NULL;
return 0;
}
On HW-reduced ACPI platforms all run-time system state transitions (for example, to and from the S0 state) are done similarly, but include the following instead of PM1*_BLK register bit manipulation:
After ensuring that any desired wake-capable interrupts are enabled, OSPM writes the HW-reduced Sleep Type value to the Sleep Control Register and spins waiting for the WAK_STS bit of the Sleep Status Register to be set, indicating a platform transition to the Working state.
7.4.2.1. System \_S0 State (Working)¶
While the system is in the S0 state, it is in the system working state. The behavior of this state is defined as:
The processors are either running, or in a C-state, or in an LPI state. The processor-complex context is maintained and instructions are executed as defined by any of these processor states.
Dynamic RAM context is maintained and is read/write by the processors.
Devices states are individually managed by the operating software and can be in any device state (D0, D1, D2, D3hot, or D3).
Power Resources are in a state compatible with the current device states.
Transition into the S0 state from some system sleeping state is automatic, and by virtue that instructions are being executed OSPM, assumes the system to be in the S0 state.
7.4.2.2. System \_S1 State (Sleeping with Processor Context Maintained)¶
While the system is in the S1 sleeping state, its behavior is the following:
The processors are not executing instructions. The processor-complex context is maintained.
Dynamic RAM context is maintained.
Power Resources are in a state compatible with the system S1 state. All Power Resources that supply a System-Level reference of S0 are in the OFF state.
Devices states are compatible with the current Power Resource states. Only devices that solely reference Power Resources that are in the ON state for a given device state can be in that device state. In all other cases, the device is in the D3 (off) state. (Or it is at least assumed to be in the D3 state by its device driver. For example, if the device doesn’t explicitly describe how it can stay in some non-off state while the system is in a sleeping state, the operating software must assume that the device can lose its power and state.)
Devices that are enabled to wake the system and that can do so from their current device state can initiate a hardware event that transitions the system state to S0. This transition causes the processor to continue execution where it left off.
To transition into the S1 state, the OSPM must flush all processor caches.
7.4.2.3. System \_S2 State¶
The S2 sleeping state is logically deeper than the S1 state and is assumed to conserve more power. The behavior of this state is defined as:
The processors are not executing instructions. The processor-complex context is not maintained.
Dynamic RAM context is maintained.
Power Resources are in a state compatible with the system S2 state. All Power Resources that supply a System-Level reference of S0 or S1 are in the OFF state.
Devices states are compatible with the current Power Resource states. Only devices that solely reference Power Resources that are in the ON state for a given device state can be in that device state. In all other cases, the device is in the D3 (off) state.
Devices that are enabled to wake the system and that can do so from their current device state can initiate a hardware event that transitions the system state to S0. This transition causes the processor to begin execution at its boot location. The platform runtime firmware performs initialization of core functions as needed to exit an S2 state and passes control to the firmware resume vector. See Platform Boot Firmware Initialization of Memory for more details on platform firmware initialization.
Because the processor context can be lost while in the S2 state, the transition to the S2 state requires that the operating software flush all dirty cache to dynamic RAM (DRAM).
7.4.2.4. System \_S3 State¶
The S3 state is logically deeper than the S2 state and is assumed to conserve more power. The behavior of this state is defined as follows:
The processors are not executing instructions. The processor-complex context is not maintained.
Dynamic RAM context is maintained.
Power Resources are in a state compatible with the system S3 state. All Power Resources that supply a System-Level reference of S0, S1, or S2 are in the OFF state.
Devices states are compatible with the current Power Resource states. Only devices that solely reference Power Resources that are in the ON state for a given device state can be in that device state. In all other cases, the device is in the D3 (off) state.
Devices that are enabled to wake the system and that can do so from their current device state can initiate a hardware event that transitions the system state to S0. This transition causes the processor to begin execution at its boot location. The platform runtime firmware performs initialization of core functions as necessary to exit an S3 state and passes control to the firmware resume vector. See Platform Boot Firmware Initialization of Memory for more details on platform firmware initialization.
From the software viewpoint, this state is functionally the same as the S2 state. The operational difference can be that some Power Resources that could be left ON to be in the S2 state might not be available to the S3 state. As such, additional devices may need to be in a deeper state for S3 than S2. Similarly, some device wake events can function in S2 but not S3.
Because the processor context can be lost while in the S3 state, the transition to the S3 state requires that the operating software flush all dirty cache to DRAM.
7.4.2.5. System \_S4 State¶
While the system is in this state, it is in the system S4 sleeping state. The state is logically deeper than the S3 state and is assumed to conserve more power. The behavior of this state is defined as follows:
The processors are not executing instructions. The processor-complex context is not maintained.
DRAM context is not maintained.
Power Resources are in a state compatible with the system S4 state. All Power Resources that supply a System-Level reference of S0, S1, S2, or S3 are in the OFF state.
Devices states are compatible with the current Power Resource states. In other words, all devices are in the D3 state when the system state is S4.
Devices that are enabled to wake the system and that can do so from their device state in S4 can initiate a hardware event that transitions the system state to S0. This transition causes the processor to begin execution at its boot location.
After OSPM has executed the _PTS control method and has put the entire system state into main memory, there are two ways that OSPM may handle the next phase of the S4 state transition; saving and restoring main memory. The first way is to use the operating system’s drivers to access the disks and file system structures to save a copy of memory to disk and then initiate the hardware S4 sequence by setting the SLP_EN register bit. When the system wakes, the firmware performs a normal boot process and transfers control to the OS via the firmware_waking_vector loader. The OS then restores the system’s memory and resumes execution.
The alternate method for entering the S4 state is to utilize the platform runtime firmware via the S4BIOS transition. The platform runtime firmware uses firmware to save a copy of memory to disk and then initiates the hardware S4 sequence. When the system wakes, the firmware restores memory from disk and wakes OSPM by transferring control to the FACS waking vector.
The S4BIOS transition is optional, but any system that supports this mechanism must support entering the S4 state via the direct OS mechanism. Thus the preferred mechanism for S4 support is the direct OS mechanism as it provides broader platform support. The alternate S4BIOS transition provides a way to achieve S4 support on operating systems that do not have support for the direct method.
7.4.2.6. System \_S5 State (Soft Off)¶
The S5 state is similar to the S4 state except that OSPM does not save any context. The system is in the soft off state and requires a complete boot when awakened (platform boot firmware and OS). Software uses a different state value to distinguish between this state and the S4 state to allow for initial boot operations within the platform boot firmware to distinguish whether or not the boot is going to wake from a saved memory image. OSPM does not disable wake events before setting the SLP_EN bit when entering the S5 system state. This provides support for remote management initiatives by enabling Remote Start capability. An ACPI-compliant OS must provide an end user accessible mechanism for disabling all wake devices, with the exception of the system power button, from a single point in the user interface.
7.4.3. \_SWS (System Wake Source)¶
This object provides a means for OSPM to definitively determine the source of an event that caused the system to enter the S0 state. General-purpose event and fixed-feature hardware registers containing wake event sources information are insufficient for this purpose as the source event information may not be available after transitions to the S0 state from all other system states (S1-S5).
To determine the source event that caused the system to transition to the S0 state, OSPM will evaluate the _SWS object, when it exists, under the \_GPE scope (for all fixed-feature general-purpose events from the GPE Blocks), under the \_SB scope (for fixed-feature hardware events), and within the scope of a GPE Block device (for GPE events from this device). _SWS objects may exist in any or all of these locations as necessary for the platform to determine the source event that caused the system to transition to the S0 state.
Arguments:
None
Return Value:
An Integer containing the Source Event as described below
The value of the Source Event is dependent on the location of the _SWS object:
If _SWS is evaluated under the \_GPE scope, Source Event is the index of the GPE that caused the system to transition to S0. StepNumList-1 If _SWS is evaluated under the \_GPE scope, Source Event is the index of the GPE that caused the system to transition to S0.
If _SWS is evaluated within the scope of a GPE block device, Source Event is the index of the GPE that caused the system to transition to S0. In this case, the index is relative to the GPE block device and is not unique system-wide.
If _SWS is evaluated under the \_SB scope, Source Event is the the index in the PM1 status register that caused the system to transition to S0.
In all cases above, if the cause of the S0 transition cannot be determined, _SWS returns Ones (-1).
To enable OSPM to determine the source of the S0 state transition via the _SWS object,the hardware or firmware should detect and save the event that caused the transition so that it can be returned during _SWS object evaluation. The single wake source for the system may be latched in hardware during the transition so that no false wake events can be returned by _SWS. An implementation that does not use hardware to latch a single wake source for the system and instead uses firmware to save the wake source must do so as quickly as possible after the wakeup event occurs, so that _SWS does not return values that correspond to events that occurred after the sleep-to-wake transition. Such an implementation must also take care to ensure that events that occur subsequent to the wakeup source being saved do not overwrite the original wakeup source.
The source event data returned by _SWS must be determined for each transition into the S0 state. The value returned by _SWS must also be persistent during the system’s residency in the S0 state as OSPM may evaluate _SWS multiple times. In this case, the platform must return the same source event information for each invocation.
After evaluating an _SWS object within the \_GPE scope or within the scope of a GPE block device, OSPM will invoke the _Wxx control method corresponding to the GPE index returned by _SWS if it exists. This allows the platform to further determine source event if the GPE is shared among multiple devices. See Determining the System Wake Source Using _Wxx Control Methods for details.
7.4.4. \_TTS (Transition To State)¶
The _TTS control method is executed by the OSPM at the beginning of the sleep transition process for S1, S2, S3, S4, and orderly S5 shutdown. OSPM will invoke _TTS before it has notified any native mode device drivers of the sleep state transition. The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5 soft-off state) is passed to the _TTS control method.
The _TTS control method is also executed by the OSPM at the end of any sleep transition process when the system transitions to S0 from S1, S2, S3, or S4. OSPM will invoke _TTS after it has notified any native mode device drivers of the end of the sleep state transition. The working state value (0) is passed to the _TTS control method.
Arguments:
Arg0 - An Integer containing the value of the sleeping state (1 for S1, 2 for S2, etc.)
Return Value
None
If OSPM aborts the sleep transition process, OSPM will still run _TTS for an S0 transition to indicate the OSPM has returned to the S0 state. The platform must assume that if OSPM invokes the _TTS control method for an S1, S2, S3, or S4 transition, that OSPM will invoke _TTS control method for an S0 transition before returning to the S0 state.
The platform must not make any assumptions about the state of the machine when _TTS is called. For example, operation region accesses that require devices to be configured and enabled may not succeed, as these devices may be in a non-decoding state due to plug and play or power management operations.
7.4.5. \_WAK (System Wake)¶
After the system wakes from a sleeping state, it will invoke the \_WAK method and pass the sleeping state value that has ended. This operation occurs asynchronously with other driver notifications in the system and is not the first action to be taken when the system wakes. The AML code for this control method issues device, thermal, and other notifications to ensure that OSPM checks the state of devices, thermal zones, and so on, that could not be maintained during the system sleeping state. For example, if the system cannot determine whether a device was inserted or removed from a bus while in the S2 state, the _WAK method would issue a devicecheck type of notification for that bus when issued with the sleeping state value of 2 (for more information about types of notifications, see Device Object Notifications.
Notice that a device check notification from the _SB node will cause OSPM to re-enumerate the entire tree. Only buses that support hardware-defined enumeration methods are done automatically at run-time. This would include ACPI-enumerated devices.
Hardware is not obligated to track the state needed to supply the resulting status; however, this method must return status concerning the last sleep operation initiated by OSPM. The return values can be used to provide additional information to OSPM or user.
Arguments:
Arg0 - An Integer containing the value of the sleeping state (1 for S1, 2 for S2, etc.)
Return value:
A Package containing two Integers containing status and the power supply S-state
Return Value Information
_WAK returns a package with the following format:
Element 0 - An Integer containing a bitfield that represents conditions that occurred during sleep:
0x00000000 - Wake was signaled and was successful
0x00000001 - Wake was signaled but failed due to lack of power
0x00000002 - Wake was signaled but failed due to thermal condition
Other values - Reserved
Element 1 - An Integer containing the power supply S-state:
If non-zero, this is the effective S-state the power supply that was actually entered. This value is used to detect when the targeted S-state was not entered because of too much current being drawn from the power supply. For example, this might occur when some active device’s current consumption pushes the system’s power requirements over the low power supply mark, thus preventing the deeper system sleeping state from being entered as desired.