1 /* $NetBSD: apmbios.h,v 1.5 2008/04/28 20:23:47 martin Exp $ */ 2 /*- 3 * Copyright (c) 1995 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by John Kohl. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef _DEV_APM_APMBIOS_H_ 31 #define _DEV_APM_APMBIOS_H_ 32 33 /* Advanced Power Management (v1.0 and v1.1 specification) 34 * functions/defines/etc. 35 */ 36 #define APM_BIOS_FNCODE (0x53) 37 #define APM_SYSTEM_BIOS (0x15) 38 #define APM_BIOS_FN(x) ((APM_BIOS_FNCODE<<8)|(x)) 39 40 /* 41 * APM info bits from BIOS 42 */ 43 #define APM_16BIT_SUPPORT 0x01 44 #define APM_32BIT_SUPPORT 0x02 45 #define APM_CPUIDLE_SLOW 0x04 46 #define APM_DISABLED 0x08 47 #define APM_DISENGAGED 0x10 48 49 #define APM_ERR_LIMIT 10 50 51 #define APM_ERR_CODE(regs) (((regs)->AX & 0xff00) >> 8) 52 #define APM_ERR_PM_DISABLED 0x01 53 #define APM_ERR_REALALREADY 0x02 54 #define APM_ERR_NOTCONN 0x03 55 #define APM_ERR_16ALREADY 0x05 56 #define APM_ERR_16NOTSUPP 0x06 57 #define APM_ERR_32ALREADY 0x07 58 #define APM_ERR_32NOTSUPP 0x08 59 #define APM_ERR_UNRECOG_DEV 0x09 60 #define APM_ERR_ERANGE 0x0A 61 #define APM_ERR_NOTENGAGED 0x0B 62 #define APM_ERR_EOPNOTSUPP 0x0C 63 #define APM_ERR_RTIMER_DISABLED 0x0D 64 #define APM_ERR_UNABLE 0x60 65 #define APM_ERR_NOEVENTS 0x80 66 #define APM_ERR_NOT_PRESENT 0x86 67 68 #define APM_DEV_APM_BIOS 0x0000 69 #define APM_DEV_ALLDEVS 0x0001 70 /* device classes are high byte; device IDs go in low byte */ 71 #define APM_DEV_DISPLAY(x) (0x0100|((x)&0xff)) 72 #define APM_DEV_DISK(x) (0x0200|((x)&0xff)) 73 #define APM_DEV_PARALLEL(x) (0x0300|((x)&0xff)) 74 #define APM_DEV_SERIAL(x) (0x0400|((x)&0xff)) 75 #define APM_DEV_NETWORK(x) (0x0500|((x)&0xff)) 76 #define APM_DEV_PCMCIA(x) (0x0600|((x)&0xff)) 77 #define APM_DEV_BATTERY(x) (0x8000|((x)&0xff)) /* V1.2 */ 78 #define APM_DEV_ALLUNITS 0xff 79 80 #define APM_INSTALLATION_CHECK 0x00 /* int15 only */ 81 #define APM_INSTALL_SIGNATURE 0x504d /* %bh = 'P', %bl = 'M' */ 82 #define APM_REALMODE_CONNECT 0x01 /* int15 only */ 83 #define APM_16BIT_CONNECT 0x02 /* int15 only */ 84 #define APM_32BIT_CONNECT 0x03 /* int15 only */ 85 #define APM_DISCONNECT 0x04 /* %bx = APM_DEV_APM_BIOS */ 86 #define APM_CPU_IDLE 0x05 87 #define APM_CPU_BUSY 0x06 88 #define APM_SET_PWR_STATE 0x07 89 #define APM_SYS_READY 0x0000 /* %cx */ 90 #define APM_SYS_STANDBY 0x0001 91 #define APM_SYS_SUSPEND 0x0002 92 #define APM_SYS_OFF 0x0003 93 #define APM_LASTREQ_INPROG 0x0004 94 #define APM_LASTREQ_REJECTED 0x0005 95 96 /* system standby is device ID (%bx) 0x0001, APM_SYS_STANDBY */ 97 /* system suspend is device ID (%bx) 0x0001, APM_SYS_SUSPEND */ 98 99 #define APM_PWR_MGT_ENABLE 0x08 100 #define APM_MGT_ALL 0xffff /* %bx */ 101 #define APM_MGT_DISABLE 0x0 /* %cx */ 102 #define APM_MGT_ENABLE 0x1 103 104 #define APM_SYSTEM_DEFAULTS 0x09 105 #define APM_DEFAULTS_ALL 0xffff /* %bx */ 106 #define APM_DEFAULTS_ALL_V12 0x0001 /* %bx */ 107 108 #define APM_POWER_STATUS 0x0a 109 #define APM_AC_OFF 0x00 110 #define APM_AC_ON 0x01 111 #define APM_AC_BACKUP 0x02 112 #define APM_AC_UNKNOWN 0xff 113 /* the first set of battery constants is 1.0 style values; 114 the second set is 1.1 style bit definitions */ 115 #define APM_BATT_HIGH 0x00 116 #define APM_BATT_LOW 0x01 117 #define APM_BATT_CRITICAL 0x02 118 #define APM_BATT_CHARGING 0x03 119 #define APM_BATT_ABSENT 0x04 /* Software only--not in spec! */ 120 #define APM_BATT_UNKNOWN 0xff 121 122 #define APM_BATT_FLAG_HIGH 0x01 123 #define APM_BATT_FLAG_LOW 0x02 124 #define APM_BATT_FLAG_CRITICAL 0x04 125 #define APM_BATT_FLAG_CHARGING 0x08 126 #define APM_BATT_FLAG_NOBATTERY 0x10 127 #define APM_BATT_FLAG_NO_SYSTEM_BATTERY 0x80 128 #define APM_BATT_FLAG_UNKNOWN 0xff 129 130 #define APM_BATT_LIFE_UNKNOWN 0xff 131 #define APM_BATT_STATE(regp) ((regp)->BX & 0xff) 132 #define APM_BATT_FLAGS(regp) (((regp)->CX & 0xff00) >> 8) 133 #define APM_AC_STATE(regp) (((regp)->BX & 0xff00) >> 8) 134 #define APM_BATT_LIFE(regp) ((regp)->CX & 0xff) /* in % */ 135 /* BATT_REMAINING returns minutes remaining */ 136 #define APM_BATT_REMAINING(regp) (((regp)->DX & 0x8000) ? \ 137 ((regp)->DX & 0x7fff) : \ 138 ((regp)->DX & 0x7fff)/60) 139 #define APM_BATT_REM_VALID(regp) (((regp)->DX & 0xffff) != 0xffff) 140 #define APM_BATTERY_COUNT(regp) ((regp)->SI) 141 142 #define APM_GET_PM_EVENT 0x0b 143 #define APM_STANDBY_REQ 0x0001 /* %bx on return */ 144 #define APM_SUSPEND_REQ 0x0002 145 #define APM_NORMAL_RESUME 0x0003 146 #define APM_CRIT_RESUME 0x0004 /* suspend/resume happened 147 without us */ 148 /* If set, the pccard sockets were powered off in the 149 suspend/standby state (V1.2 only) */ 150 #define APM_PCCARD_POWEREDOFF(regp) ((regp)->CX & 0x0001) 151 152 #define APM_BATTERY_LOW 0x0005 153 #define APM_POWER_CHANGE 0x0006 154 #define APM_UPDATE_TIME 0x0007 155 #define APM_CRIT_SUSPEND_REQ 0x0008 156 #define APM_USER_STANDBY_REQ 0x0009 157 #define APM_USER_SUSPEND_REQ 0x000A 158 #define APM_SYS_STANDBY_RESUME 0x000B 159 #define APM_CAP_CHANGE 0x000C /* V1.2 */ 160 161 #define APM_GET_POWER_STATE 0x0c 162 /* device to query in %bx */ 163 /* returns power states in %cx */ 164 #define APM_DEVICE_MGMT_ENABLE 0x0d 165 /* device to enable/disable in %bx */ 166 167 #define APM_DRIVER_VERSION 0x0e 168 /* %bx should be DEV value (APM_DEV_APM_BIOS) 169 %ch = driver major vno 170 %cl = driver minor vno 171 return: %ah = conn major; %al = conn minor 172 */ 173 #define APM_CONN_MINOR(regp) ((regp)->AX & 0xff) 174 #define APM_CONN_MAJOR(regp) (((regp)->AX & 0xff00) >> 8) 175 176 #define APM_PWR_MGT_ENGAGE 0x0F 177 /* device in %bx */ 178 #define APM_MGT_DISENGAGE 0x0 /* %cx */ 179 #define APM_MGT_ENGAGE 0x1 180 181 #define APM_GET_CAPABILITIES 0x10 182 /* device in %bx (APM_DEV_APM_BIOS) */ 183 /* %bl: number of batteries */ 184 #define APM_NBATTERIES(regp) ((regp)->BX & 0xff) 185 /* %cx capabilities */ 186 #define APM_GLOBAL_STANDBY 0x0001 187 #define APM_GLOBAL_SUSPEND 0x0002 188 #define APM_RTIMER_STANDBY 0x0004 /* resume timer wakes standby */ 189 #define APM_RTIMER_SUSPEND 0x0008 /* resume timer wakes suspend */ 190 #define APM_IRRING_SUSPEND 0x0010 /* internal ring wakes suspend */ 191 #define APM_IRRING_STANDBY 0x0020 /* internal ring wakes standby */ 192 #define APM_PCRING_SUSPEND 0x0040 /* pccard ring wakes suspend */ 193 #define APM_PCRING_STANDBY 0x0080 /* pccard ring wakes standby */ 194 195 #define APM_RESUME_TIMER_CTL 0x11 /* get/set/disable resume timer */ 196 /* device in %bx (APM_DEV_APM_BIOS) */ 197 /* function code in %cl */ 198 #define APM_RTIMER_DISABLE 0x00 199 #define APM_RTIMER_GET 0x01 200 #define APM_RTIMER_SET 0x02 201 /* if %cl = set, or %cl = get, then: */ 202 /* %ch: seconds */ 203 /* %dh: hours */ 204 /* %dl: minutes */ 205 /* %sih: month (bcd), %sil: day (bcd) */ 206 /* %di: year (bcd, 4 digits) */ 207 #define APM_RESUME_RING_CTL 0x12 208 /* device in %bx (APM_DEV_APM_BIOS) */ 209 /* %cx: function code */ 210 #define APM_RRING_DISABLE 0x0000 211 #define APM_RRING_ENABLE 0x0001 212 #define APM_RRING_GET 0x0002 213 /* returns state in %cx */ 214 #define APM_RRING_DISABLED 0x0000 215 #define APM_RRING_ENABLED 0x0001 216 217 #define APM_TIMER_REQS_CTL 0x13 218 /* device in %bx (APM_DEV_APM_BIOS) */ 219 /* %cx: function code */ 220 #define APM_TIMER_REQS_DISABLE 0x0000 221 #define APM_TIMER_REQS_ENABLE 0x0001 222 #define APM_TIMER_REQS_GET 0x0002 223 /* returns state in %cx */ 224 #define APM_TIMER_REQS_DISABLED 0x0000 225 #define APM_TIMER_REQS_ENABLED 0x0001 226 227 #define APM_OEM 0x80 228 229 /* 230 * APM info word from the real-mode handler is adjusted to put 231 * major/minor version in low half and support bits in upper half. 232 */ 233 #define APM_MAJOR_VERS(info) (((info)&0xff00)>>8) 234 #define APM_MINOR_VERS(info) ((info)&0xff) 235 236 #define APM_16BIT_SUPPORTED (APM_16BIT_SUPPORT << 16) 237 #define APM_32BIT_SUPPORTED (APM_32BIT_SUPPORT << 16) 238 #define APM_IDLE_SLOWS (APM_CPUIDLE_SLOW << 16) 239 #define APM_BIOS_PM_DISABLED (APM_DISABLED << 16) 240 #define APM_BIOS_PM_DISENGAGED (APM_DISENGAGED << 16) 241 242 #define APMDEBUG_INFO 0x01 243 #define APMDEBUG_APMCALLS 0x02 244 #define APMDEBUG_EVENTS 0x04 245 #define APMDEBUG_PROBE 0x10 246 #define APMDEBUG_ATTACH 0x40 247 #define APMDEBUG_DEVICE 0x20 248 #define APMDEBUG_ANOM 0x40 249 250 #endif /* _DEV_APM_APMBIOS_H_ */ 251