1.\" $OpenBSD: apm.4,v 1.15 2021/03/20 19:36:29 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 macppc 14.Os 15.Sh NAME 16.Nm apm 17.Nd advanced power management device interface 18.Sh SYNOPSIS 19.Cd "apm0 at adb?" 20.Sh DESCRIPTION 21The 22.Nm 23driver provides an interface which simulates the Advanced Power Management 24.Pq APM 25BIOS functions. 26The BIOS functions are translated into the appropriate PowerManager requests. 27Currently only battery level, AC connection, and charging status is available 28from the 29.Nm 30device. 31.Pp 32Suspend/resume and other power events are 33.Em NOT YET SUPPORTED . 34.Pp 35Configuration options: 36.Pp 37.Bl -tag -width DIAGNOSTIC -compact -offset indent 38.It Dv APMDEBUG 39Enable various driver status messages. 40.It Dv DIAGNOSTIC 41Enable debugging messages. 42.It Dv DEBUG 43Enable other debugging messages. 44.El 45.Pp 46The 47.Nm 48driver implements the following 49.Xr ioctl 2 50calls. 51They are defined in 52.In machine/apmvar.h . 53.Bl -tag -width Ds 54.It Dv APM_IOC_REJECT 55.Em Not implemented . DO NOT USE . 56.It Dv APM_IOC_STANDBY 57.Em NOT YET SUPPORTED on macppc . 58.Pp 59.Pq Li "no parameters" 60Request 61.Dq standby 62mode. 63.It Dv APM_IOC_SUSPEND 64.Em NOT YET SUPPORTED on macppc . 65.Pp 66.Pq Li "no parameters" 67Request 68.Dq suspend 69mode. 70.\" .It Dv APM_IOC_HIBERNATE 71.\" .Em NOT YET SUPPORTED on macppc . 72.\" .Pp 73.\" .Pq Li "no parameters" 74.\" Request 75.\" .Dq hibernate 76.\" mode. 77.It Dv APM_IOC_GETPOWER 78.Pq Li "struct apm_power_info" 79Request the current power state. 80The argument structure is as follows: 81.Bd -literal -offset indent 82struct apm_power_info { 83 u_char battery_state; 84 u_char ac_state; 85 u_char battery_life; 86 u_char spare1; 87 u_int minutes_left; 88 u_int spare2[6]; 89}; 90.Ed 91.Pp 92The following values are defined for 93.Va battery_state : 94.Bl -tag -width Ds 95.It Dv APM_BATT_HIGH 96Battery has a high state of charge. 97.It Dv APM_BATT_LOW 98Battery has a low state of charge. 99.It Dv APM_BATT_CRITICAL 100Battery has a critical state of charge. 101.It Dv APM_BATT_CHARGING 102Battery is not high, low, or critical and is currently charging. 103.It Dv APM_BATT_UNKNOWN 104Cannot read the current battery state. 105.It Dv APM_BATTERY_ABSENT 106No battery installed. 107.El 108.Pp 109The following values are defined for 110.Va ac_state : 111.Bl -tag -width Ds 112.It Dv APM_AC_OFF 113External power not detected. 114.It Dv APM_AC_ON 115External power detected. 116.It Dv APM_AC_BACKUP 117Backup power in use. 118.It Dv APM_AC_UNKNOWN 119External power state unknown. 120.El 121.Pp 122The 123.Va battery_life 124value contains the estimated percentage of battery life available. 125100% indicates a full charge. 126.Pp 127If the battery is charging, i.e. when 128.Va battery_state 129is equal to 130.Dv APM_BATT_CHARGING , 131the 132.Va battery_life 133value contains the estimated number of minutes until the battery will be 134fully charged. 135Otherwise, the 136.Va minutes_left 137value contains the estimated number of minutes of battery life remaining. 138.It Dv APM_IOC_NEXTEVENT 139.Em NOT YET SUPPORTED on macppc 140.Pq Li "struct apm_event_info" 141The APM driver stores up to 142.Dv APM_NEVENTS 143events. 144This was defined as 16 at the time this documentation was written. 145If the event list is full when a new event is detected the new event is lost. 146.Dv APM_IOC_NEXTEVENT 147ioctl returns the next event on the list or 148.Er EAGAIN 149if the event list is empty. 150The format of the returned event is: 151.Bd -literal -offset indent 152struct apm_event_info { 153 u_int type; 154 u_int index; 155 u_int spare[8]; 156}; 157.Ed 158where 159.Va index 160is a sequential count of events that can be used to check if any 161events were lost and 162.Va type 163is one of: 164.Pp 165.Bl -tag -width Ds -offset indent -compact 166.It Dv APM_STANDBY_REQ 167.It Dv APM_SUSPEND_REQ 168.It Dv APM_NORMAL_RESUME 169.It Dv APM_CRIT_RESUME 170.It Dv APM_BATTERY_LOW 171.It Dv APM_POWER_CHANGE 172.It Dv APM_UPDATE_TIME 173.It Dv APM_CRIT_SUSPEND_REQ 174.It Dv APM_USER_STANDBY_REQ 175.It Dv APM_USER_SUSPEND_REQ 176.It Dv APM_SYS_STANDBY_RESUME 177.El 178.It Dv APM_IOC_DEV_CTL 179.Em NOT YET SUPPORTED on macppc . 180.Pp 181.Pq Li "struct apm_ctl" 182Allows an application to directly set the 183APM operating mode. 184The argument structure is as follows: 185.Bd -literal -offset indent 186struct apm_ctl { 187 u_int dev; 188 u_int mode; 189}; 190.Ed 191.Pp 192.Va dev 193indicates the device, typically 194.Dv APM_DEV_ALLDEVS . 195.Pp 196.Va mode 197indicates the desired operating mode. 198Possible values are 199.Bl -tag -width Ds -compact -offset indent 200.It Dv APM_SYS_READY 201.It Dv APM_SYS_STANDBY 202.It Dv APM_SYS_SUSPEND 203.It Dv APM_SYS_OFF 204.It Dv APM_LASTREQ_INPROG 205.It Dv APM_LASTREQ_REJECTED 206.El 207.It Dv APM_IOC_PRN_CTL 208.Em NOT YET SUPPORTED on macppc . 209.Pp 210.Pq Li "int" 211This 212.Xr ioctl 2 213controls message output by the APM 214driver when a power change event is detected. 215The integer parameter is one of: 216.Bl -tag -width Ds 217.It Dv APM_PRINT_ON 218All power change events result in a message. 219This is the normal operating mode for the driver. 220.It Dv APM_PRINT_OFF 221Power change event messages are suppressed. 222.It Dv APM_PRINT_PCT 223Power change event messages are suppressed unless the estimated 224battery life percentage changes. 225.El 226.El 227.Sh FILES 228.Bl -tag -width "/dev/apmctlXXX" 229.It /dev/apm 230Power management data device. 231May only be opened read-only. 232May be opened by multiple concurrent users. 233.It /dev/apmctl 234Power management control device. 235May be opened read-write or write-only. 236May only be opened by one user at a time. 237An attempt to open the file when in use will fail, returning 238.Er EBUSY . 239.El 240.Sh SEE ALSO 241.Xr adb 4 , 242.Xr intro 4 , 243.Xr apm 8 , 244.Xr apmd 8 , 245.Xr halt 8 246.Sh HISTORY 247The 248.Nm 249driver source code contains these copyrights: 250.Pp 251.Bl -item -compact 252.It 253.Li Copyright (c) 1995 John T. Kohl. All rights reserved. 254.It 255.Li Copyright (C) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp> 256.El 257.Pp 258\&...and has been hacked on by many others since. 259.Sh BUGS 260Sleep modes and power events are not supported. 261