OpenBSD manual page server

Manual Page Search Parameters
APM(4) Device Drivers Manual (i386) APM(4)

apmadvanced power management device interface

apm0 at bios0 flags 0x0000

The apm driver provides an interface to the Advanced Power Management (APM) BIOS functions. The driver supports versions 1.0, 1.1, and 1.2 interface specifications.

This driver also provides an interface to acpi(4) on some machines.

The low two bytes of the flags specify the version of the specification driver should conform to in binary decimal notation. The value of 0x0101 would specify version 1.1 of the interface specification to be used.

The value of 0x10000 specifies whether to leave interrupts enabled when calling APM BIOS routines. This is needed for some IBM laptops, the symptoms are hangs and freezes on suspend, stand by, and hibernation activities.

The value of 0x20000 specifies to swap the bytes of the battery life estimation (the DX register) as given from the APM BIOS. This is needed for some SONY VAIO laptops, such as some 505 models.

Configuration options:

Enable various driver status messages.
Enable debugging messages.
Enable other debugging messages.

The apm driver implements the following ioctl(2) calls. They are defined in <machine/apmvar.h>.

. .
(no parameters) Request “standby” mode.
(no parameters) Request “suspend” mode.
(no parameters) Request “hibernate” mode.
(struct apm_power_info) Request the current power state. The argument structure is as follows:
struct apm_power_info {
	u_char battery_state;
	u_char ac_state;
	u_char battery_life;
	u_char spare1;
	u_int minutes_left;
	u_int spare2[6];
};

The following values are defined for battery_state:

Battery has a high state of charge.
Battery has a low state of charge.
Battery has a critical state of charge.
Battery is not high, low, or critical and is currently charging.
Cannot read the current battery state.
No battery installed.

The following values are defined for ac_state:

External power not detected.
External power detected.
Backup power in use.
External power state unknown.

The battery_life value contains the estimated percentage of battery life available. 100% indicates a full charge.

The minutes_left value contains the estimated number of minutes of battery life remaining.

(struct apm_ctl) Allows an application to directly set the APM operating mode. The argument structure is as follows:
struct apm_ctl {
	u_int dev;
	u_int mode;
};

dev indicates the device, typically APM_DEV_ALLDEVS.

mode indicates the desired operating mode. Possible values are

(int) This ioctl(2) controls message output by the APM driver when a power change event is detected. The integer parameter is one of:
All power change events result in a message. This is the normal operating mode for the driver.
Power change event messages are suppressed.
Power change event messages are suppressed unless the estimated battery life percentage changes.

/dev/apm
Power management data device. May only be opened read-only. May be opened by multiple concurrent users.
/dev/apmctl
Power management control device. May be opened read-write or write-only. May only be opened by one user at a time. An attempt to open the file when in use will fail, returning EBUSY.

acpi(4), intro(4), apm(8), apmd(8), halt(8)

The apm driver source code contains these copyrights:

...and has been hacked on by many others since.

Not all the BIOSes support power down the way we are attempting to execute it.

Not all BIOS vendors even read the specification.

January 30, 2023 OpenBSD-7.6