1.\" $OpenBSD: apm.4,v 1.6 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 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_DEV_CTL 116.Em NOT YET SUPPORTED on arm64 . 117.Pp 118.Pq Li "struct apm_ctl" 119Allows an application to directly set the 120APM operating mode. 121The argument structure is as follows: 122.Bd -literal -offset indent 123struct apm_ctl { 124 u_int dev; 125 u_int mode; 126}; 127.Ed 128.Pp 129.Va dev 130indicates the device, typically 131.Dv APM_DEV_ALLDEVS . 132.Pp 133.Va mode 134indicates the desired operating mode. 135Possible values are 136.Bl -tag -width Ds -compact -offset indent 137.It Dv APM_SYS_READY 138.It Dv APM_SYS_STANDBY 139.It Dv APM_SYS_SUSPEND 140.It Dv APM_SYS_OFF 141.It Dv APM_LASTREQ_INPROG 142.It Dv APM_LASTREQ_REJECTED 143.El 144.It Dv APM_IOC_PRN_CTL 145.Pq Li "int" 146This 147.Xr ioctl 2 148controls message output by the APM 149driver when a power change event is detected. 150The integer parameter is one of: 151.Bl -tag -width Ds 152.It Dv APM_PRINT_ON 153All power change events result in a message. 154This is the normal operating mode for the driver. 155.It Dv APM_PRINT_OFF 156Power change event messages are suppressed. 157.It Dv APM_PRINT_PCT 158Power change event messages are suppressed unless the estimated 159battery life percentage changes. 160.El 161.El 162.Sh FILES 163.Bl -tag -width "/dev/apmctlXXX" 164.It /dev/apm 165Power management data device. 166May only be opened read-only. 167May be opened by multiple concurrent users. 168.It /dev/apmctl 169Power management control device. 170May be opened read-write or write-only. 171May only be opened by one user at a time. 172An attempt to open the file when in use will fail, returning 173.Er EBUSY . 174.El 175.Sh SEE ALSO 176.Xr acpi 4 , 177.Xr intro 4 , 178.Xr halt 8 179