Amlcontrol Language

ACPI Machine Language (AML) is a pseudocode language used by the operating system's ACPI interpreter to control ACPI compliant components.

These commands, along with a description of a component's power modes, are provided by the device at boot time to the ACPI tables.

The challenge was to develop a way for devices from a wide range of manufacturers to request services from the operating system. For example, a video display program might signal the operating system to ignore the idle computer time-out for as long as a particular program is running even if there is no user input. The same program would cancel this request as it gracefully shuts down.

AML is based on a series of macrocommands called "controls." Each control passes one or more parameters to the operating system's AML interpreter. For example, a command may be issued to see if the device is running on batteries or to read a CPU's temperature.

ACPI uses a series of controls to manage communications, hardware, and software. For example, the control "SetThreadExecutionState" is used to set status for devices that should not be put to sleep, such as a communications monitoring routine awaiting inbound traffic. The device or application later clears their status when no longer needed. This is only needed if the ACPI control software cannot detect activity from user input.

AML controls are created through the ACPI Source Language (ASL). ASL is used by device manufacturers and BIOS chip developers as the source code for controls. This human readable code is then compiled into AML. ACPI Component Architecture (ACPICA) project provides an OS-independent version of ACPI at: www.acpica.org/

ACPI STATES

ACPI describes power management by "states" - what something is ordered to do at a particular time. There are different power management states. The Global states apply to everything in the system and, usually, the attached peripherals. Sleeping states are reduced power levels for individual devices or for the complete machine. Device power states apply to individual devices that may be running on minimal (or no) power even when the main system is running (such as an idle scan gun that puts itself in a low power mode when not needed). As a major consumer of the computer's electricity, CPUs have their own power, performance, and thermal monitor states.

ACPI standard version 3.0b recognizes four power modes, based on the amount of energy used by the computer:

▲ Sleep (or Standby) - The system state (operating system, applications, data) are kept in RAM supported by a few watts of electricity.

▲ Hibernation - The data and operating system context are saved to disk and power is stopped for most components.

GLOBAL STATES

The ACPI Global states (prefixed by a "G") apply to everything in the computer. This is the highest level of abstraction for power management and represents what the person operating the computer can see.

▲ GO - Working State is when the computer is in normal operation and is consuming the most power. Individual devices, such as an attached printer, may move to a reduced power state if they are not needed. The ACPI software may adjust power usage if battery power is detected.

▲ G1 - Sleeping State is when the computer is idle and the system context is cached in RAM or the hard disk. Power consumption is a few watts. Restarting the system back to GO takes a few seconds. The deepest sleep state that uses the least power is called "hibernation."

▲ G2 - Soft Off means the entire system is powered off except for the small amount of power used for Wake On LAN (if enabled). The G2 state is reached when the power switch is moved to the "off" position. The computer must be rebooted to start. The computer is not safe to disassemble as there is still a small amount of power running through the system.

▲ G3 - Mechanical Off is when all electricity has been removed from the computer, including unplugging it from the wall outlet. The mechanical part is pulling the plug or turning off the power strip.

SLEEP STATES

When it is time to transition the computer to Sleep power mode, ACPI broadcasts a notice to all hardware and applications. If none object, it then notifies hardware devices to switch to low power. The exception is when it detects a critically low battery and the system is turned off. In that case, the warning broadcast is followed by a forced shutdown. To prevent an idle system from moving to sleep mode, certain applications will notify the ACPI system to stay on even if it appears to be idle. Examples of this might be presentation software or communications software monitoring inbound traffic.

Once the sleep command is used, applications have two seconds to save their context and complete processing. The applications context includes closing open files and applications registers in RAM, as well as saving data in transient working storage.

ACPI Sleep states (prefixed by a "S") describe the depth of sleep. The less power used during sleep mode, the more time that is required to restore service. When the device "awakens" from sleep, it resumes where it left off. The ACPI software selects the lowest power usage sleep state that is supported by the installed equipment. S1 through S3 are referred to as "sleep" state because of their quick "wake up" time. S4 is commonly referred to as "hibernation," or deep sleep, which requires a longer restart cycle.

Sleep (or Standby) - The system state (operating system, applications, data) is kept in RAM and is supported by a few watts of electricity. Full service can be quickly restarted. However, if total power is lost, so is everything stored in RAM - similar to pulling the plug on a running computer.

Hibernation - The data and operating system context are saved to a special hibernation file on the hard disk, and power is stopped for most components. Restarting from Hibernation takes longer than from Sleep mode, as the hardware must be reenergized, after which then the operating system and application context must be reloaded from the disk. The computer system resumes within the application where it left off when it went into hibernation. If a computer is low on disk space, it may be a good idea to disable Hibernation mode, as it needs disk space to save the system context.

▲ SO is normal system operation

▲ S1 (Sleep) is the lowest level of sleep. No system context is lost. The CPU input clock is stopped and return to full operation is quick.

▲ S2 (Sleep) includes all of S1 plus the CPU; its caches lose power.

▲ S3 (Sleep) removes electrical service from everything in the computer except RAM and selected other devices that maintain the system context.

▲ S4 (Hibernation) turns off everything, including RAM. Less than 3 watts are used. Restarting computer service from hibernation is essentially the same as a cold boot.

▲ S5 (Soft Off) uses very little power but can be restored to normal operation by the keyboard, another input device, or the Wake On LAN feature. Computer must be rebooted.

Waking from a sleep state may be initiated by the computer operator. Using an input device (pressing a keyboard button or moving a mouse) is sufficient to begin the "wake up" process. Another way to wake up computers is through the Wake On LAN process. Remember that even when a computer appears to be in full operation one or more components may be in a sleep state until they are needed.

DEVICE STATES

ACPI manages the power state of the entire computer system, as well as its individual components. This permits saving power even while the machine is in full operation. It is this attention to detail that provides ongoing power savings without negatively impacting the operator.

It is not unusual for some components to be on no or low power while the computer appears to the operator to be in full power operation. For example, if the computer is connected to a high speed network through an Ethernet connect, there is no need for an internal modem to be on. Running the modem in this example is the same as leaving a light bulb turned on in a closed closet when no one is at home.

ACPI data tables are read into the ACPI work space at boot time. They store information on each device in the computer or attached to it. This information includes:

▲ The amount of power the device consumes.

▲ The amount of "context" retained by the device when it shifts to low or no power.

▲ How the device driver restores the device to full operation.

▲ How long it takes to restore the device to full operation.

ACPI Device states (prefixed by a "D") describe the power management state of an individual device. The operating system controls movement of devices between power states.

▲ DO - The device is operating at full power.

▲ D1 - Reduced power consumption where the device may lose its context.

▲ D2 - Reduced power management and the bus has a degree of control over power management.

▲ D3 - Maximum power savings as the device powered off.

Was this article helpful?

0 0

Post a comment