APM Theory of Operation for Windows

Updated: December 4, 2001
*

What Is APM and How Is It Different from ACPI?

APM (Advanced Power Management) is the legacy power management scheme, based on an SMI/SMM (hidden hardware) BIOS approach that was first widely supported in Microsoft Windows 95. Most of the interesting functionality for APM is in a machine-specific BIOS that is hidden from the operating system.

APM is a legacy solution that has been superseded by ACPI (Advanced Configuration and Power Interface), which is the robust scheme for power management and system configuration supported in the Windows 98 and Windows 2000 family of operating systems. Microsoft strongly recommends that system designers build systems based on ACPI. For more information about ACPI and Windows, see the web site at http://www.microsoft.com/whdc/system/pnppwr/powermgmt/devicepm.mspx.

However, Microsoft recognizes that many machines will have only APM support, and many others will have both ACPI and APM support.

Top of pageTop of page

Goals of APM Support in Windows 2000

The APM support in Windows 2000 is intended only to support legacy notebook computers. It is not designed to run on desktop systems, and desktop support is very limited.

Further, the goal for APM in Windows 2000 is to support battery status, suspend, resume, and auto-off for hibernate. The following are explicitly not supported: timer wakeup, wake on LAN, wake on ring, and so on.

Top of pageTop of page

When Should APM be Used or Not Used?

ACPI should always be used if the machine has a working ACPI BIOS. ACPI has received the focus of the Microsoft development and testing effort for power management under Windows 2000. In addition, many useful features in Windows 2000, such as timed wakeups, are available only with ACPI support.

APM should not be used in the following cases:

If the machine or BIOS is on the Windows 2000 "Disable APM" list. The system will refuse to run APM on such machines, because Microsoft Development found that it does not work on them. Do not attempt to override this.

If the machine is made unstable, because a non-compliant APM BIOS can cause loss of data.

It mightbe possible to use APM in the following cases:

If there is no ACPI BIOS.

If the ACPI BIOS on a particular machine is not implemented properly. However, APM may not work any better.

There are conditional uses for APM in the following cases:

On desktops and other machines that do not have batteries, APM will install in a mode which supports auto-power-off for shutdown and hibernate, but not standby. This is because many of these machines are desktops with video cards that do not support standby.

For some machines, the APM BIOS alone may result in unstable behavior, but turning on Windows 2000 APM support (that is, using Ntapm.sys) will make the system behave properly.

Top of pageTop of page

Classes of APM Systems under Windows 2000

AutoEnable APM. This indicates that the system passed testing at Microsoft and was placed on the "AutoEnable APM List," which Windows 2000 Setup checks before installing the operating system. Windows 2000 Setup will install and enable APM support automatically on such systems. This list includes the APM system/BIOS combinations that Microsoft believes are stable and ready to support APM while running Windows 2000.

Disable APM. This means that Microsoft has determined that APM does not work properly on the system. Microsoft placed entries for specific system/BIOS combinations on the Disable APM List that malfunctioned in testing when APM was turned on. For system/BIOS combinations on the Disable APM List, Windows 2000 Setup will not install or enable APM support. Note that it may still be necessary to disable the APM BIOS using the machine's BIOS setup utility to get things to be reliable.

Neutral Systems. This means that Microsoft doesn't know how well this system works with APM under Windows 2000. Systems that are not on the AutoEnable APM List or the Disable APM List are considered "neutral." In such cases, Windows 2000 installs the Ntapm.sys software, but leaves it disabled. The user can manually enable the APM support in Windows 2000 by using the installation method provided with the operating system:

In the Control Panel Power applet, click the APM tab, and select the option to enable (or disable) APM support. (This is the only approved or supported way to manually turn on APM.)

Note that turning APM support off requires a reboot. Turning APM on does not require a reboot.

Top of pageTop of page

Key APM Components and What They Do

APM BIOS: Placed in ROM or flash by the OEM. Does most of the real work of powering the system on and off. The operating system can call the BIOS, and it either works or it doesn't; its operation is opaque to the operating system. The APM BIOS must be turned on using the BIOS setup utility for APM to work. If the APM BIOS is unstable, it may be necessary to turn the APM BIOS off using the BIOS setup utility, in addition to turning off Windows 2000 APM support. The APM BIOS should be configured such that timeouts are either turned off or set for the longest period possible, so that the operating system can control timeouts instead of the APM BIOS.

Ntdetect.com: It detects whether the APM BIOS is present before booting the operating system, determines whether Windows 2000 can use it, and reports the results of detection in the registry.

NtLdr: Restarts APM upon resume from hibernate, if APM was active before hibernation.

Ntapm.sys: A Windows 2000 driver that hooks the system and the APM BIOS together. It includes certain system operations for dispatch to the APM BIOS, and it polls APM BIOS events and status. Note than when the APM BIOS presents an event (such as suspend or power off), Ntapm.sys catches this, and then issues an NtInitiatePowerAction call, which tells the operating system to respond appropriately. At the end, the Windows 2000 power manager calls into the HAL, which calls back into Ntapm.sys, which calls the APM BIOS. In this process, almost all operating system and driver power code is the same between APM and ACPI.

Hal.dll: Windows 2000 APM support works only with Halx86, which is the only HAL to have the hooks needed to call into Ntapm.sys. It's also the only HAL relevant to important APM machines in the market.

Apmbatt.sys: This emulates a battery unit so the system battery status code can work.

Power Applet: The Control Panel applet that allows the user to enable or disable APM support on a computer. This is the only supported way to turn operating system APM support on or off.

Biosinfo.inf: Windows 2000 file that lists machines on the Autoenable APM list and the Disable APM list, and also lists the BIOS detection sequences used to match them.

Key Elements in the Registry

Ntdetect Reporting. The data about APM that is discovered by Ntdetect.com is reported in the registry using a Multi-function adapter (MFA) entry in the system description of the hardware tree. To find this, look in HKEY_LOCAL_MACHINE\ hardware\ description\ system\ multifunctionadapter.

There will be a set of keys there named 0, 1, 2, 3, etc. Each of them will have value entries named Component Information, Configuration Data, Identifier, and so on. Find the key whose Identifier entry == "APM". The "Configuration Data" entry of that key will contain the data on APM found and reported by Ntdetect.com. If the key is absent, then APM was not found. The contents of this value entry are reported in sdk\inc\ntapmsdk.h.

Running Apmstat.exe -v will dump this structure, for machines where it's relevant. For machines where it's not relevant (multiprocessors, not x86, not halx86, ACPI is on, and so on), Apmstat.exe will report that.

Biosinfo vs. Machine-Specific Info. The results of machine-specific detection versus Biosinfo.inf are stored in HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Control\ BIOSInfo\ APM. If the "Attributes" value is 1, the machine's APM BIOS is "known good" and the machine is on the Autoenable APM list. If the value 2, the machine's APM BIOS is "known bad" and the machine is on the Disable APM list. Otherwise, the machine is neutral.

Running apmstat will report whether the APM BIOS is known to be good, known to be bad, or is neutral.

HAL Reporting. If the HAL is Halx86.dll, the registry key HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Control\ ApmLegalHal will have a value entry present with data of 1.

Running apmstat will report if this is not the case.

ACPI Reporting. If the machine is an ACPI machine, there will be a services entry for ACPI under (HKLM\System\currentcontrolset\services\ACPI) with value Start == 0. This is telling the system to load and run Acpi.sys at phase 0. If this is not present, the machine is not being run as an ACPI machine, even if, perhaps, it should be.

Running apmstat will report a machine as an ACPI machine if it sees Acpi.sys has Start == 0.

UI Elements

Power Applet APM Tab. The Control Panel includes a Power applet. If the APM is installed at all (enabled or disabled), there will be an APM tab in this applet. You can turn APM on and off by checking the box in this tab. This is the only recommended and supported way to do that. Turning APM on is an on-the-fly Plug and Play action; turning it off requires a reboot. If the tab is absent, it's an ACPI machine, an APM Disabled machine, or the machine simply doesn't have APM.

Standby on Shutdown Menu. If APM is turned on, there will be a Standby entry under the Shutdown option when the user presses CTRL+ALT+DEL. There may also be a Hibernate entry, which is a separate function. (Hibernate can work even if neither APM nor ACPI are present.) Standby under APM has the same use as under ACPI.

Battery Status Icon. If the battery display is turned on in the Control Panel Power applet, there will be a Battery Status icon on the system tray, which works about the same as for ACPI. Note that an APM machine always reports a single composite battery, regardless of how many are present or what the machine reports. (Windows 2000 uses the unified/composite number, because this is thought to be more reliable on a wide range of APM BIOSes, and is simpler.)

Power Button. On most APM machines, the power button, a sleep button, or the like, can suspend the machine (place on standby). Most require the power button to resume, though at least one will come back with a keyboard touch. Windows 2000 APM does not support custom power buttons.

Top of pageTop of page

Tools

Apmstat.exe: As of Windows 2000 RC1, Apmstat.exe is included in the support directory on the Windows 2000 product CD. Support personnel and expert users can run this utility to determine status.

BIOS Setup Utility. Essentially all APM machines will have some sort of machine setup/configuration screen, usually accessed at boot by pressing ESC, DEL, F1, F2, or F10. Support personnel and expert users may be able to improve system behavior by changing or disabling APM options.

Note: Be warned that some APM BIOSes will turn themselves off if all timers are disabled. In this case, it's best to set all timers to some long timeout value.

APM BIOS and Kernel Debugger. Some APM BIOSes will refuse to suspend if the kernel debugger is active on one of the system COM ports.

Event log. If an APM_SETPOWER call fails (that is, a standby/suspend fails at the APM BIOS interface), then Ntapm.sys will write a record into the system event log, with data reporting that this happened and whatever error code the APM BIOS returned. This information is sometimes useful if a machine is refusing to suspend because of activity on some port that isn't obvious to the user.

NOTES:

APM support is not allowed on server products. This means that the APM tab will not appear and that there is no APM support in Windows 2000 Advanced Server or in Windows 2000 Datacenter.

APM will not hook up the standby vector on machines that do not have batteries. This means that on machines that do not have batteries, standby will not appear as an option on the Shutdown list, and will not be available as an operation.

Hibernate is independent of APM or ACPI; hibernate can be used on machines that do not have either APM or ACPI.

To get the battery status icon, you must turn it on with the Power applet in the control panel.

To get hibernate, you must turn it on with the Power applet in the control panel.

Top of pageTop of page

Suggestions for Problem Resolution

The following provides guidelines for support personnel or expert users who are troubleshooting APM support on a system running Windows 2000.

1.

Make sure the user has APM turned on, hibernate turned on, and the battery icon turned on.

2.

Make sure that APM BIOS screen blanking is turned off. This will often make the system seem to behave badly when problem is only that the screen is black. (Use a screen saver of BLANK to get the right effect.)

3.

Run Apmstat.exe. Its output will often make the issue obvious (trying to run APM on a multiple-processor machine, for example).

4.

If the machine is a desktop, it will rarely run APM well, but you can get 90 percent of the value by using hibernate, which does not require either APM or ACPI to work.

5.

If Windows 2000 APM has been turned off, and the machine is still not stable, try turning off the APM BIOS itself in the machine's setup screen.

6.

Some machines will work better with Windows 2000 APM turned on, because this puts the operating system more in sync with the system's APM BIOS.


Top of pageTop of page