xref: /openbsd/share/man/man4/man4.i386/apm.4 (revision 3bef86f7)
1.\"	$OpenBSD: apm.4,v 1.36 2023/01/30 14:43:29 jcs Exp $
2.\"
3.\"	Copyright (c) 1998 Marco S. Hyman
4.\"
5.\"	Permission to copy all or part of this material for any purpose is
6.\"	granted provided that the above copyright notice and this paragraph
7.\"	are duplicated in all copies.  THIS SOFTWARE IS PROVIDED ``AS IS''
8.\"	AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
9.\"	LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
10.\"	FOR A PARTICULAR PURPOSE.
11.\"
12.Dd $Mdocdate: January 30 2023 $
13.Dt APM 4 i386
14.Os
15.Sh NAME
16.Nm apm
17.Nd advanced power management device interface
18.Sh SYNOPSIS
19.Cd "apm0 at bios0 flags 0x0000"
20.Sh DESCRIPTION
21The
22.Nm
23driver provides an interface to the Advanced Power Management
24.Pq APM
25BIOS functions.
26The driver supports versions 1.0, 1.1, and 1.2 interface specifications.
27.Pp
28This driver also provides an interface to
29.Xr acpi 4
30on some machines.
31.Pp
32The low two bytes of the flags specify the version of the specification
33driver should conform to in binary decimal notation.
34The value of 0x0101 would specify version 1.1 of the interface
35specification to be used.
36.Pp
37The value of 0x10000 specifies whether to leave interrupts enabled
38when calling APM BIOS routines.
39This is needed for some
40.Tn IBM
41laptops, the symptoms are
42hangs and freezes on suspend, stand by, and hibernation activities.
43.Pp
44The value of 0x20000 specifies to swap the bytes of the battery
45life estimation (the DX register) as given from the APM BIOS.
46This is needed for some
47.Tn SONY VAIO
48laptops, such as some 505 models.
49.Pp
50Configuration options:
51.Pp
52.Bl -tag -width DIAGNOSTIC -compact -offset indent
53.It Dv APMDEBUG
54Enable various driver status messages.
55.It Dv DIAGNOSTIC
56Enable debugging messages.
57.It Dv DEBUG
58Enable other debugging messages.
59.El
60.Pp
61The
62.Nm
63driver implements the following
64.Xr ioctl 2
65calls.
66They are defined in
67.In machine/apmvar.h .
68.Bl -tag -width Ds
69.It Dv APM_IOC_REJECT
70.Em Not implemented . DO NOT USE .
71.It Dv APM_IOC_STANDBY
72.Pq Li "no parameters"
73Request
74.Dq standby
75mode.
76.It Dv APM_IOC_SUSPEND
77.Pq Li "no parameters"
78Request
79.Dq suspend
80mode.
81.It Dv APM_IOC_HIBERNATE
82.Pq Li "no parameters"
83Request
84.Dq hibernate
85mode.
86.It Dv APM_IOC_GETPOWER
87.Pq Li "struct apm_power_info"
88Request the current power state.
89The argument structure is as follows:
90.Bd -literal -offset indent
91struct apm_power_info {
92	u_char battery_state;
93	u_char ac_state;
94	u_char battery_life;
95	u_char spare1;
96	u_int minutes_left;
97	u_int spare2[6];
98};
99.Ed
100.Pp
101The following values are defined for
102.Va battery_state :
103.Bl -tag -width Ds
104.It Dv APM_BATT_HIGH
105Battery has a high state of charge.
106.It Dv APM_BATT_LOW
107Battery has a low state of charge.
108.It Dv APM_BATT_CRITICAL
109Battery has a critical state of charge.
110.It Dv APM_BATT_CHARGING
111Battery is not high, low, or critical and is currently charging.
112.It Dv APM_BATT_UNKNOWN
113Cannot read the current battery state.
114.It Dv APM_BATTERY_ABSENT
115No battery installed.
116.El
117.Pp
118The following values are defined for
119.Va ac_state :
120.Bl -tag -width Ds
121.It Dv APM_AC_OFF
122External power not detected.
123.It Dv APM_AC_ON
124External power detected.
125.It Dv APM_AC_BACKUP
126Backup power in use.
127.It Dv APM_AC_UNKNOWN
128External power state unknown.
129.El
130.Pp
131The
132.Va battery_life
133value contains the estimated percentage of battery life available.
134100% indicates a full charge.
135.Pp
136The
137.Va minutes_left
138value contains the estimated number of minutes of battery life
139remaining.
140.It Dv APM_IOC_DEV_CTL
141.Pq Li "struct apm_ctl"
142Allows an application to directly set the
143APM operating mode.
144The argument structure is as follows:
145.Bd -literal -offset indent
146struct apm_ctl {
147	u_int dev;
148	u_int mode;
149};
150.Ed
151.Pp
152.Va dev
153indicates the device, typically
154.Dv APM_DEV_ALLDEVS .
155.Pp
156.Va mode
157indicates the desired operating mode.
158Possible values are
159.Bl -tag -width Ds -compact -offset indent
160.It Dv APM_SYS_READY
161.It Dv APM_SYS_STANDBY
162.It Dv APM_SYS_SUSPEND
163.It Dv APM_SYS_OFF
164.It Dv APM_LASTREQ_INPROG
165.It Dv APM_LASTREQ_REJECTED
166.El
167.It Dv APM_IOC_PRN_CTL
168.Pq Li "int"
169This
170.Xr ioctl 2
171controls message output by the APM
172driver when a power change event is detected.
173The integer parameter is one of:
174.Bl -tag -width Ds
175.It Dv APM_PRINT_ON
176All power change events result in a message.
177This is the normal operating mode for the driver.
178.It Dv APM_PRINT_OFF
179Power change event messages are suppressed.
180.It Dv APM_PRINT_PCT
181Power change event messages are suppressed unless the estimated
182battery life percentage changes.
183.El
184.El
185.Sh FILES
186.Bl -tag -width "/dev/apmctlXXX"
187.It /dev/apm
188Power management data device.
189May only be opened read-only.
190May be opened by multiple concurrent users.
191.It /dev/apmctl
192Power management control device.
193May be opened read-write or write-only.
194May only be opened by one user at a time.
195An attempt to open the file when in use will fail, returning
196.Er EBUSY .
197.El
198.Sh SEE ALSO
199.Xr acpi 4 ,
200.Xr intro 4 ,
201.Xr apm 8 ,
202.Xr apmd 8 ,
203.Xr halt 8
204.Sh HISTORY
205The
206.Nm
207driver source code contains these copyrights:
208.Pp
209.Bl -item -compact
210.It
211.Li Copyright (c) 1995 John T. Kohl.  All rights reserved.
212.It
213.Li Copyright (C) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp>
214.El
215.Pp
216\&...and has been hacked on by many others since.
217.Sh BUGS
218Not all the BIOSes support power down the way we are attempting
219to execute it.
220.Pp
221Not all BIOS vendors even read the specification.
222