xref: /openbsd-src/share/man/man4/man4.arm64/apm.4 (revision f1dd7b858388b4a23f4f67a4957ec5ff656ebbe8)
1.\"	$OpenBSD: apm.4,v 1.4 2021/03/20 19:41:44 kn 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: March 20 2021 $
13.Dt APM 4 arm64
14.Os
15.Sh NAME
16.Nm apm
17.Nd power management interface
18.Sh SYNOPSIS
19.Cd "apm0 at mainbus?"
20.Sh DESCRIPTION
21The
22.Nm
23driver provides an interface which simulates the Advanced Power Management
24.Pq APM
25BIOS functions.
26.Pp
27Suspend/resume and other power events are
28.Em NOT YET SUPPORTED .
29.Pp
30The
31.Nm
32driver implements the following
33.Xr ioctl 2
34calls.
35They are defined in
36.In machine/apmvar.h .
37.Bl -tag -width Ds
38.It Dv APM_IOC_REJECT
39.Em Not implemented . DO NOT USE .
40.It Dv APM_IOC_STANDBY
41.Em NOT YET SUPPORTED on arm64 .
42.Pp
43.Pq Li "no parameters"
44Request
45.Dq standby
46mode.
47.It Dv APM_IOC_SUSPEND
48.Em NOT YET SUPPORTED on arm64 .
49.Pp
50.Pq Li "no parameters"
51Request
52.Dq suspend
53mode.
54.It Dv APM_IOC_HIBERNATE
55.Em NOT YET SUPPORTED on arm64 .
56.Pp
57.Pq Li "no parameters"
58Request
59.Dq hibernate
60mode.
61.It Dv APM_IOC_GETPOWER
62.Pq Li "struct apm_power_info"
63Request the current power state.
64The argument structure is as follows:
65.Bd -literal -offset indent
66struct apm_power_info {
67	u_char battery_state;
68	u_char ac_state;
69	u_char battery_life;
70	u_char spare1;
71	u_int minutes_left;
72	u_int spare2[6];
73};
74.Ed
75.Pp
76The following values are defined for
77.Va battery_state :
78.Bl -tag -width Ds
79.It Dv APM_BATT_HIGH
80Battery has a high state of charge.
81.It Dv APM_BATT_LOW
82Battery has a low state of charge.
83.It Dv APM_BATT_CRITICAL
84Battery has a critical state of charge.
85.It Dv APM_BATT_CHARGING
86Battery is not high, low, or critical and is currently charging.
87.It Dv APM_BATT_UNKNOWN
88Cannot read the current battery state.
89.It Dv APM_BATTERY_ABSENT
90No battery installed.
91.El
92.Pp
93The following values are defined for
94.Va ac_state :
95.Bl -tag -width Ds
96.It Dv APM_AC_OFF
97External power not detected.
98.It Dv APM_AC_ON
99External power detected.
100.It Dv APM_AC_BACKUP
101Backup power in use.
102.It Dv APM_AC_UNKNOWN
103External power state unknown.
104.El
105.Pp
106The
107.Va battery_life
108value contains the estimated percentage of battery life available.
109100% indicates a full charge.
110.Pp
111The
112.Va minutes_left
113value contains the estimated number of minutes of battery life
114remaining.
115.It Dv APM_IOC_NEXTEVENT
116.Pq Li "struct apm_event_info"
117The APM driver stores up to
118.Dv APM_NEVENTS
119events.
120This was defined as 16 at the time this documentation was written.
121If the event list is full when a new event is detected the new event is lost.
122.Dv APM_IOC_NEXTEVENT
123ioctl returns the next event on the list or
124.Er EAGAIN
125if the event list is empty.
126The format of the returned event is:
127.Bd -literal -offset indent
128struct apm_event_info {
129	u_int type;
130	u_int index;
131	u_int spare[8];
132};
133.Ed
134where
135.Va index
136is a sequential count of events that can be used to check if any
137events were lost and
138.Va type
139is one of:
140.Bl -tag -width Ds -offset indent -compact
141.It Dv APM_STANDBY_REQ
142.It Dv APM_SUSPEND_REQ
143.It Dv APM_NORMAL_RESUME
144.It Dv APM_CRIT_RESUME
145.It Dv APM_BATTERY_LOW
146.It Dv APM_POWER_CHANGE
147.It Dv APM_UPDATE_TIME
148.It Dv APM_CRIT_SUSPEND_REQ
149.It Dv APM_USER_STANDBY_REQ
150.It Dv APM_USER_SUSPEND_REQ
151.It Dv APM_SYS_STANDBY_RESUME
152.El
153.It Dv APM_IOC_DEV_CTL
154.Em NOT YET SUPPORTED on arm64 .
155.Pp
156.Pq Li "struct apm_ctl"
157Allows an application to directly set the
158APM operating mode.
159The argument structure is as follows:
160.Bd -literal -offset indent
161struct apm_ctl {
162	u_int dev;
163	u_int mode;
164};
165.Ed
166.Pp
167.Va dev
168indicates the device, typically
169.Dv APM_DEV_ALLDEVS .
170.Pp
171.Va mode
172indicates the desired operating mode.
173Possible values are
174.Bl -tag -width Ds -compact -offset indent
175.It Dv APM_SYS_READY
176.It Dv APM_SYS_STANDBY
177.It Dv APM_SYS_SUSPEND
178.It Dv APM_SYS_OFF
179.It Dv APM_LASTREQ_INPROG
180.It Dv APM_LASTREQ_REJECTED
181.El
182.It Dv APM_IOC_PRN_CTL
183.Pq Li "int"
184This
185.Xr ioctl 2
186controls message output by the APM
187driver when a power change event is detected.
188The integer parameter is one of:
189.Bl -tag -width Ds
190.It Dv APM_PRINT_ON
191All power change events result in a message.
192This is the normal operating mode for the driver.
193.It Dv APM_PRINT_OFF
194Power change event messages are suppressed.
195.It Dv APM_PRINT_PCT
196Power change event messages are suppressed unless the estimated
197battery life percentage changes.
198.El
199.El
200.Sh FILES
201.Bl -tag -width "/dev/apmctlXXX"
202.It /dev/apm
203Power management data device.
204May only be opened read-only.
205May be opened by multiple concurrent users.
206.It /dev/apmctl
207Power management control device.
208May be opened read-write or write-only.
209May only be opened by one user at a time.
210An attempt to open the file when in use will fail, returning
211.Er EBUSY .
212.El
213.Sh SEE ALSO
214.Xr acpi 4 ,
215.Xr intro 4 ,
216.Xr halt 8
217