1 .\" Copyright (c) 1995,1996 John T. Kohl
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. The name of the author may not be used to endorse or promote products
13 .\" derived from this software without specific prior written permission.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
27 .\" $NetBSD: apm.4,v 1.16 2003/04/16 13:35:21 wiz Exp $
35 Advanced Power Management pseudo-device driver
37 .Cd "apm0 at mainbus0"
43 driver provides support for the Advanced Power Management features of
44 some i386 system BIOSes. The driver supports the Advanced Power
45 Management (APM) BIOS Interface Specification (revision 1.2), published
46 jointly by the Intel Corporation and the Microsoft Corporation.
48 The APM driver's behavior may be adjusted by specifying any of the
49 following kernel configuration options:
50 .Bl -tag -width indent -compact
52 Do not call the BIOS CPU idle function from the system idle loop. (Some
53 systems will hang on certain device accesses, such as sound cards or
54 floppy diskette drives, without this option)
56 Use only the APM revision 1.0 specification calls. (Some systems do not
57 implement APM v1.1 very well, and generate weird events instead of the
58 expected events when the system suspend key is pressed.)
60 Don't attach to the BIOS as APM v1.2 compliant device.
61 (In case there are problems with v1.2 support.)
63 Do not attempt to put the system into standby mode.
64 .It Dv APM_NO_POWEROFF
65 Do not attempt to turn off power when halting the system.
66 .It Dv APM_FORCE_64K_SEGMENTS
67 Force the length of the APM BIOS code and data segments to 64KB.
68 .It Dv APM_ALLOW_BOGUS_SEGMENTS
69 Allow the use of data segments which are in unexpected locations.
71 Enable kernel printout of events received from the APM BIOS.
73 Enable kernel printout of every call to the APM BIOS (this is very noisy).
74 .It Dv APM_POWER_PRINT
75 Print power state on console at
77 events. (Since it increases
79 activity, it may consume increased
80 battery power. Some systems generate the events too frequently,
81 and printing the status may disturb single-user operations.)
82 .It Dv APM_DISABLE_INTERRUPTS
83 Set this to zero if you don't want the kernel to disable interrupts
84 before calling the BIOS. This is required for most IBM ThinkPads, and
85 some other newer laptops. A good indication that you need this is that
86 the machine hangs just after resuming from suspended state. It's
87 unclear if doing this has negative effects on older BIOS, therefore it
88 defaults to one (i.e interrupts are disabled).
91 If no processes are holding open file descriptors to the APM device, the
92 driver will process the APM BIOS events itself. If a process has the
93 device open for write, the driver defers all suspend and standby
94 processing to the user process as long as there is sufficient queue
95 space to store the event for the process. If the device is only open
96 for read, the driver will report events but handle them itself.
98 The APM device may be opened by multiple readers but only one
99 writer. Multiple readers may fetch the status with
101 without worrying about interference, but they must cooperate to share
102 events as only a single event queue is provided. The device may only be
113 .Bl -tag -width indent -compact
114 .It Dv APM_IOC_SUSPEND
115 Initiate an APM suspend mode. This is a deep sleep mode which powers down
116 most devices. The device must be open for writing for this command to succeed.
117 .It Dv APM_IOC_STANDBY
118 Initiate an APM standby mode. This is a light sleep mode from which the
119 system can quickly restore normal operation. The device must be open
120 for writing for this command to succeed.
121 .It Dv APM_IOC_GETPOWER
122 Fetch the current power status into an
126 struct apm_power_info {
127 u_char battery_state;
131 u_int minutes_left; /* estimate */
138 The structure should be zeroed (except for
147 .Dv APM_BATT_CRITICAL ,
148 .Dv APM_BATT_CHARGING ,
150 .Dv APM_BATT_UNKNOWN .
161 is the percentage estimated remaining normal battery life (or 0 if the
162 BIOS cannot provide an estimate).
165 is an estimated remaining lifetime (or 0 if the BIOS cannot provide an
169 is the number of batteries in the system. If the system is using APM
170 v1.1 or earlier, nbattery will always return 0.
172 Batteries are numbered from a base of 1.
173 If the passed value of
175 is 0, the returned values will reflect the percentage remaining, minutes
176 left, etc. of all of the system's batteries taken together.
177 If the passed value of
179 is nonzero, the return values will reflect the indicated
180 battery's percentage remaining, minutes left, etc.
181 It is an error to set
183 to a value greater than that returned by
185 If the system is using APM v1.1 or earlier, individual batteries
186 cannot be queried, and
188 will always return 0.
190 is always set to the passed value upon return.
191 .It Dv APM_IOC_NEXTEVENT
192 Fetch the next event from the APM BIOS into an
194 structure. If no more events are ready, this will return
197 struct apm_event_info {
204 is one of the APM event types (APM_STANDBY_REQ through
205 APM_SYS_STANDBY_RESUME).
207 is the ordinal event sequence number.
212 Advanced Power Management (APM) BIOS Interface Specification (Revision
213 1.1), Intel Corporation and Microsoft Corporation. Intel order number
214 241704-001; Microsoft part number 781-110-X01.
218 pseudo-device driver appeared in