ACPI Power Management
Hardware power management events trigger an OS-visible interrupt called a ``system control interrupt'' (SCI). Operating systems handle simple SCI interrupts (e.g. fixed-feature power button state change) directly. Complex SCI interrupts are are handled by the OS using AML code associated with the interrupt. For example, consider what happens when a ``sleep'' SCI interrupt occurs. The kernel must first save hardware state. The kernel then calls the _PTS (prepare to sleep) method. Finally, it puts the system to sleep by writing the appropriate value to an ACPI register.
In ACPI there are six power states: S0, S1, S2, S3, S4, and S5. These states are defined as follows:
S0:
the run state. In this state, the machine is fully running.
S1:
the suspend state. In this state, the CPU will suspend activity but retain its contexts.
S2 and S3:
sleep states. In these states, memory contexts are held but CPU contexts are lost. The differences between S2 and S3 are in CPU re-initialization done by firmware and device re-initialization.
S4:
a sleep state in which contexts are saved to disk. The context will be restored upon the return to S0. This is identical to soft-off for hardware. This state can be implemented by either OS or firmware.
S5:
the soft-off state. All activity will stop and all contexts are lost.
In addition to managing transitions between system power states, ACPI can also manage the power state of individual devices to a fine-grained level. For example, if two devices share the same power line, that information can be encoded in the ACPI tables in such a way that the power line is active only if one or both of the devices are in use.