apmvar.h revision 1.1 1 1.1 takemura /* $NetBSD: apmvar.h,v 1.1 2000/07/02 09:48:12 takemura Exp $ */
2 1.1 takemura /*-
3 1.1 takemura * Copyright (c) 1995 The NetBSD Foundation, Inc.
4 1.1 takemura * All rights reserved.
5 1.1 takemura *
6 1.1 takemura * This code is derived from software contributed to The NetBSD Foundation
7 1.1 takemura * by John Kohl.
8 1.1 takemura *
9 1.1 takemura * Redistribution and use in source and binary forms, with or without
10 1.1 takemura * modification, are permitted provided that the following conditions
11 1.1 takemura * are met:
12 1.1 takemura * 1. Redistributions of source code must retain the above copyright
13 1.1 takemura * notice, this list of conditions and the following disclaimer.
14 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 takemura * notice, this list of conditions and the following disclaimer in the
16 1.1 takemura * documentation and/or other materials provided with the distribution.
17 1.1 takemura * 3. All advertising materials mentioning features or use of this software
18 1.1 takemura * must display the following acknowledgement:
19 1.1 takemura * This product includes software developed by the NetBSD
20 1.1 takemura * Foundation, Inc. and its contributors.
21 1.1 takemura * 4. Neither the name of The NetBSD Foundation nor the names of its
22 1.1 takemura * contributors may be used to endorse or promote products derived
23 1.1 takemura * from this software without specific prior written permission.
24 1.1 takemura *
25 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 1.1 takemura * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 takemura * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 takemura * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 1.1 takemura * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 takemura * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 takemura * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 takemura * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 takemura * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 takemura * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 takemura * POSSIBILITY OF SUCH DAMAGE.
36 1.1 takemura */
37 1.1 takemura /*
38 1.1 takemura * from: sys/arch/i386/include/apmvar.h,v 1.9 1999/08/17
39 1.1 takemura */
40 1.1 takemura #ifndef __I386_APM_H__
41 1.1 takemura #define __I386_APM_H__
42 1.1 takemura
43 1.1 takemura /* Advanced Power Management (v1.0 and v1.1 specification)
44 1.1 takemura * functions/defines/etc.
45 1.1 takemura */
46 1.1 takemura #define APM_BIOS_FNCODE (0x53)
47 1.1 takemura #define APM_SYSTEM_BIOS (0x15)
48 1.1 takemura #define APM_BIOS_FN(x) ((APM_BIOS_FNCODE<<8)|(x))
49 1.1 takemura
50 1.1 takemura /*
51 1.1 takemura * APM info bits from BIOS
52 1.1 takemura */
53 1.1 takemura #define APM_16BIT_SUPPORT 0x01
54 1.1 takemura #define APM_32BIT_SUPPORT 0x02
55 1.1 takemura #define APM_CPUIDLE_SLOW 0x04
56 1.1 takemura #define APM_DISABLED 0x08
57 1.1 takemura #define APM_DISENGAGED 0x10
58 1.1 takemura
59 1.1 takemura #define APM_ERR_CODE(regs) (((regs)->AX & 0xff00) >> 8)
60 1.1 takemura #define APM_ERR_PM_DISABLED 0x01
61 1.1 takemura #define APM_ERR_REALALREADY 0x02
62 1.1 takemura #define APM_ERR_NOTCONN 0x03
63 1.1 takemura #define APM_ERR_16ALREADY 0x05
64 1.1 takemura #define APM_ERR_16NOTSUPP 0x06
65 1.1 takemura #define APM_ERR_32ALREADY 0x07
66 1.1 takemura #define APM_ERR_32NOTSUPP 0x08
67 1.1 takemura #define APM_ERR_UNRECOG_DEV 0x09
68 1.1 takemura #define APM_ERR_ERANGE 0x0A
69 1.1 takemura #define APM_ERR_NOTENGAGED 0x0B
70 1.1 takemura #define APM_ERR_EOPNOTSUPP 0x0C
71 1.1 takemura #define APM_ERR_RTIMER_DISABLED 0x0D
72 1.1 takemura #define APM_ERR_UNABLE 0x60
73 1.1 takemura #define APM_ERR_NOEVENTS 0x80
74 1.1 takemura #define APM_ERR_NOT_PRESENT 0x86
75 1.1 takemura
76 1.1 takemura #define APM_DEV_APM_BIOS 0x0000
77 1.1 takemura #define APM_DEV_ALLDEVS 0x0001
78 1.1 takemura /* device classes are high byte; device IDs go in low byte */
79 1.1 takemura #define APM_DEV_DISPLAY(x) (0x0100|((x)&0xff))
80 1.1 takemura #define APM_DEV_DISK(x) (0x0200|((x)&0xff))
81 1.1 takemura #define APM_DEV_PARALLEL(x) (0x0300|((x)&0xff))
82 1.1 takemura #define APM_DEV_SERIAL(x) (0x0400|((x)&0xff))
83 1.1 takemura #define APM_DEV_NETWORK(x) (0x0500|((x)&0xff))
84 1.1 takemura #define APM_DEV_PCMCIA(x) (0x0600|((x)&0xff))
85 1.1 takemura #define APM_DEV_BATTERY(x) (0x8000|((x)&0xff)) /* V1.2 */
86 1.1 takemura #define APM_DEV_ALLUNITS 0xff
87 1.1 takemura
88 1.1 takemura #define APM_INSTALLATION_CHECK 0x00 /* int15 only */
89 1.1 takemura #define APM_INSTALL_SIGNATURE 0x504d /* %bh = 'P', %bl = 'M' */
90 1.1 takemura #define APM_REALMODE_CONNECT 0x01 /* int15 only */
91 1.1 takemura #define APM_16BIT_CONNECT 0x02 /* int15 only */
92 1.1 takemura #define APM_32BIT_CONNECT 0x03 /* int15 only */
93 1.1 takemura #define APM_DISCONNECT 0x04 /* %bx = APM_DEV_APM_BIOS */
94 1.1 takemura #define APM_CPU_IDLE 0x05
95 1.1 takemura #define APM_CPU_BUSY 0x06
96 1.1 takemura #define APM_SET_PWR_STATE 0x07
97 1.1 takemura #define APM_SYS_READY 0x0000 /* %cx */
98 1.1 takemura #define APM_SYS_STANDBY 0x0001
99 1.1 takemura #define APM_SYS_SUSPEND 0x0002
100 1.1 takemura #define APM_SYS_OFF 0x0003
101 1.1 takemura #define APM_LASTREQ_INPROG 0x0004
102 1.1 takemura #define APM_LASTREQ_REJECTED 0x0005
103 1.1 takemura
104 1.1 takemura /* system standby is device ID (%bx) 0x0001, APM_SYS_STANDBY */
105 1.1 takemura /* system suspend is device ID (%bx) 0x0001, APM_SYS_SUSPEND */
106 1.1 takemura
107 1.1 takemura #define APM_PWR_MGT_ENABLE 0x08
108 1.1 takemura #define APM_MGT_ALL 0xffff /* %bx */
109 1.1 takemura #define APM_MGT_DISABLE 0x0 /* %cx */
110 1.1 takemura #define APM_MGT_ENABLE 0x1
111 1.1 takemura
112 1.1 takemura #define APM_SYSTEM_DEFAULTS 0x09
113 1.1 takemura #define APM_DEFAULTS_ALL 0xffff /* %bx */
114 1.1 takemura #define APM_DEFAULTS_ALL_V12 0x0001 /* %bx */
115 1.1 takemura
116 1.1 takemura #define APM_POWER_STATUS 0x0a
117 1.1 takemura #define APM_AC_OFF 0x00
118 1.1 takemura #define APM_AC_ON 0x01
119 1.1 takemura #define APM_AC_BACKUP 0x02
120 1.1 takemura #define APM_AC_UNKNOWN 0xff
121 1.1 takemura /* the first set of battery constants is 1.0 style values;
122 1.1 takemura the second set is 1.1 style bit definitions */
123 1.1 takemura #define APM_BATT_HIGH 0x00
124 1.1 takemura #define APM_BATT_LOW 0x01
125 1.1 takemura #define APM_BATT_CRITICAL 0x02
126 1.1 takemura #define APM_BATT_CHARGING 0x03
127 1.1 takemura #define APM_BATT_ABSENT 0x04 /* Software only--not in spec! */
128 1.1 takemura #define APM_BATT_UNKNOWN 0xff
129 1.1 takemura
130 1.1 takemura #define APM_BATT_FLAG_HIGH 0x01
131 1.1 takemura #define APM_BATT_FLAG_LOW 0x02
132 1.1 takemura #define APM_BATT_FLAG_CRITICAL 0x04
133 1.1 takemura #define APM_BATT_FLAG_CHARGING 0x08
134 1.1 takemura #define APM_BATT_FLAG_NOBATTERY 0x10
135 1.1 takemura #define APM_BATT_FLAG_NO_SYSTEM_BATTERY 0x80
136 1.1 takemura #define APM_BATT_FLAG_UNKNOWN 0xff
137 1.1 takemura
138 1.1 takemura #define APM_BATT_LIFE_UNKNOWN 0xff
139 1.1 takemura #define APM_BATT_STATE(regp) ((regp)->BX & 0xff)
140 1.1 takemura #define APM_BATT_FLAGS(regp) (((regp)->CX & 0xff00) >> 8)
141 1.1 takemura #define APM_AC_STATE(regp) (((regp)->BX & 0xff00) >> 8)
142 1.1 takemura #define APM_BATT_LIFE(regp) ((regp)->CX & 0xff) /* in % */
143 1.1 takemura /* BATT_REMAINING returns minutes remaining */
144 1.1 takemura #define APM_BATT_REMAINING(regp) (((regp)->DX & 0x8000) ? \
145 1.1 takemura ((regp)->DX & 0x7fff) : \
146 1.1 takemura ((regp)->DX & 0x7fff)/60)
147 1.1 takemura #define APM_BATT_REM_VALID(regp) (((regp)->DX & 0xffff) != 0xffff)
148 1.1 takemura #define APM_BATTERY_COUNT(regp) ((regp)->SI)
149 1.1 takemura
150 1.1 takemura #define APM_GET_PM_EVENT 0x0b
151 1.1 takemura #define APM_STANDBY_REQ 0x0001 /* %bx on return */
152 1.1 takemura #define APM_SUSPEND_REQ 0x0002
153 1.1 takemura #define APM_NORMAL_RESUME 0x0003
154 1.1 takemura #define APM_CRIT_RESUME 0x0004 /* suspend/resume happened
155 1.1 takemura without us */
156 1.1 takemura /* If set, the pccard sockets were powered off in the
157 1.1 takemura suspend/standby state (V1.2 only) */
158 1.1 takemura #define APM_PCCARD_POWEREDOFF(regp) ((regp)->CX & 0x0001)
159 1.1 takemura
160 1.1 takemura #define APM_BATTERY_LOW 0x0005
161 1.1 takemura #define APM_POWER_CHANGE 0x0006
162 1.1 takemura #define APM_UPDATE_TIME 0x0007
163 1.1 takemura #define APM_CRIT_SUSPEND_REQ 0x0008
164 1.1 takemura #define APM_USER_STANDBY_REQ 0x0009
165 1.1 takemura #define APM_USER_SUSPEND_REQ 0x000A
166 1.1 takemura #define APM_SYS_STANDBY_RESUME 0x000B
167 1.1 takemura #define APM_CAP_CHANGE 0x000C /* V1.2 */
168 1.1 takemura
169 1.1 takemura #define APM_GET_POWER_STATE 0x0c
170 1.1 takemura /* device to query in %bx */
171 1.1 takemura /* returns power states in %cx */
172 1.1 takemura #define APM_DEVICE_MGMT_ENABLE 0x0d
173 1.1 takemura /* device to enable/disable in %bx */
174 1.1 takemura
175 1.1 takemura #define APM_DRIVER_VERSION 0x0e
176 1.1 takemura /* %bx should be DEV value (APM_DEV_APM_BIOS)
177 1.1 takemura %ch = driver major vno
178 1.1 takemura %cl = driver minor vno
179 1.1 takemura return: %ah = conn major; %al = conn minor
180 1.1 takemura */
181 1.1 takemura #define APM_CONN_MINOR(regp) ((regp)->AX & 0xff)
182 1.1 takemura #define APM_CONN_MAJOR(regp) (((regp)->AX & 0xff00) >> 8)
183 1.1 takemura
184 1.1 takemura #define APM_PWR_MGT_ENGAGE 0x0F
185 1.1 takemura /* device in %bx */
186 1.1 takemura #define APM_MGT_DISENGAGE 0x0 /* %cx */
187 1.1 takemura #define APM_MGT_ENGAGE 0x1
188 1.1 takemura
189 1.1 takemura #define APM_GET_CAPABILITIES 0x10
190 1.1 takemura /* device in %bx (APM_DEV_APM_BIOS) */
191 1.1 takemura /* %bl: number of batteries */
192 1.1 takemura #define APM_NBATTERIES(regp) ((regp)->BX & 0xff)
193 1.1 takemura /* %cx capabilities */
194 1.1 takemura #define APM_GLOBAL_STANDBY 0x0001
195 1.1 takemura #define APM_GLOBAL_SUSPEND 0x0002
196 1.1 takemura #define APM_RTIMER_STANDBY 0x0004 /* resume timer wakes standby */
197 1.1 takemura #define APM_RTIMER_SUSPEND 0x0008 /* resume timer wakes suspend */
198 1.1 takemura #define APM_IRRING_SUSPEND 0x0010 /* internal ring wakes suspend */
199 1.1 takemura #define APM_IRRING_STANDBY 0x0020 /* internal ring wakes standby */
200 1.1 takemura #define APM_PCRING_SUSPEND 0x0040 /* pccard ring wakes suspend */
201 1.1 takemura #define APM_PCRING_STANDBY 0x0080 /* pccard ring wakes standby */
202 1.1 takemura
203 1.1 takemura #define APM_RESUME_TIMER_CTL 0x11 /* get/set/disable resume timer */
204 1.1 takemura /* device in %bx (APM_DEV_APM_BIOS) */
205 1.1 takemura /* function code in %cl */
206 1.1 takemura #define APM_RTIMER_DISABLE 0x00
207 1.1 takemura #define APM_RTIMER_GET 0x01
208 1.1 takemura #define APM_RTIMER_SET 0x02
209 1.1 takemura /* if %cl = set, or %cl = get, then: */
210 1.1 takemura /* %ch: seconds */
211 1.1 takemura /* %dh: hours */
212 1.1 takemura /* %dl: minutes */
213 1.1 takemura /* %sih: month (bcd), %sil: day (bcd) */
214 1.1 takemura /* %di: year (bcd, 4 digits) */
215 1.1 takemura #define APM_RESUME_RING_CTL 0x12
216 1.1 takemura /* device in %bx (APM_DEV_APM_BIOS) */
217 1.1 takemura /* %cx: function code */
218 1.1 takemura #define APM_RRING_DISABLE 0x0000
219 1.1 takemura #define APM_RRING_ENABLE 0x0001
220 1.1 takemura #define APM_RRING_GET 0x0002
221 1.1 takemura /* returns state in %cx */
222 1.1 takemura #define APM_RRING_DISABLED 0x0000
223 1.1 takemura #define APM_RRING_ENABLED 0x0001
224 1.1 takemura
225 1.1 takemura #define APM_TIMER_REQS_CTL 0x13
226 1.1 takemura /* device in %bx (APM_DEV_APM_BIOS) */
227 1.1 takemura /* %cx: function code */
228 1.1 takemura #define APM_TIMER_REQS_DISABLE 0x0000
229 1.1 takemura #define APM_TIMER_REQS_ENABLE 0x0001
230 1.1 takemura #define APM_TIMER_REQS_GET 0x0002
231 1.1 takemura /* returns state in %cx */
232 1.1 takemura #define APM_TIMER_REQS_DISABLED 0x0000
233 1.1 takemura #define APM_TIEMR_REQS_ENABLED 0x0001
234 1.1 takemura
235 1.1 takemura #define APM_OEM 0x80
236 1.1 takemura
237 1.1 takemura /*
238 1.1 takemura * APM info word from the real-mode handler is adjusted to put
239 1.1 takemura * major/minor version in low half and support bits in upper half.
240 1.1 takemura */
241 1.1 takemura #define APM_MAJOR_VERS(info) (((info)&0xff00)>>8)
242 1.1 takemura #define APM_MINOR_VERS(info) ((info)&0xff)
243 1.1 takemura
244 1.1 takemura #define APM_16BIT_SUPPORTED (APM_16BIT_SUPPORT << 16)
245 1.1 takemura #define APM_32BIT_SUPPORTED (APM_32BIT_SUPPORT << 16)
246 1.1 takemura #define APM_IDLE_SLOWS (APM_CPUIDLE_SLOW << 16)
247 1.1 takemura #define APM_BIOS_PM_DISABLED (APM_DISABLED << 16)
248 1.1 takemura #define APM_BIOS_PM_DISENGAGED (APM_DISENGAGED << 16)
249 1.1 takemura
250 1.1 takemura /*
251 1.1 takemura * virtual & physical address of the trampoline
252 1.1 takemura * that we use: page 1.
253 1.1 takemura */
254 1.1 takemura #define APM_BIOSTRAMP NBPG
255 1.1 takemura
256 1.1 takemura
257 1.1 takemura #ifndef _LOCORE
258 1.1 takemura
259 1.1 takemura /* filled in by apmcall */
260 1.1 takemura
261 1.1 takemura struct apm_connect_info {
262 1.1 takemura u_int apm_code32_seg_base; /* real-mode style segment selector */
263 1.1 takemura u_int apm_code16_seg_base;
264 1.1 takemura u_int apm_data_seg_base;
265 1.1 takemura u_int apm_entrypt;
266 1.1 takemura u_short apm_segsel; /* segment selector for APM */
267 1.1 takemura u_short _pad1;
268 1.1 takemura u_int apm_code32_seg_len;
269 1.1 takemura u_int apm_code16_seg_len;
270 1.1 takemura u_int apm_data_seg_len;
271 1.1 takemura u_int apm_detail;
272 1.1 takemura };
273 1.1 takemura
274 1.1 takemura struct apm_event_info {
275 1.1 takemura u_int type;
276 1.1 takemura u_int index;
277 1.1 takemura u_int spare[8];
278 1.1 takemura };
279 1.1 takemura
280 1.1 takemura struct apm_power_info {
281 1.1 takemura u_char battery_state;
282 1.1 takemura u_char ac_state;
283 1.1 takemura u_char battery_life;
284 1.1 takemura u_char spare1;
285 1.1 takemura u_int minutes_left; /* estimate */
286 1.1 takemura u_int spare2[6];
287 1.1 takemura };
288 1.1 takemura
289 1.1 takemura struct apm_ctl {
290 1.1 takemura u_int dev;
291 1.1 takemura u_int mode;
292 1.1 takemura };
293 1.1 takemura
294 1.1 takemura #define APM_IOC_REJECT _IOW('A', 0, struct apm_event_info) /* reject request # */
295 1.1 takemura #define APM_IOC_STANDBY _IO('A', 1) /* put system into standby */
296 1.1 takemura #define APM_IOC_SUSPEND _IO('A', 2) /* put system into suspend */
297 1.1 takemura #define APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
298 1.1 takemura #define APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */
299 1.1 takemura #if 0
300 1.1 takemura #define APM_IOC_DEV_CTL _IOW('A', 5, struct apm_ctl) /* put device into mode */
301 1.1 takemura #endif
302 1.1 takemura
303 1.1 takemura #ifdef _KERNEL
304 1.1 takemura struct apm_attach_args {
305 1.1 takemura char *aaa_busname;
306 1.1 takemura };
307 1.1 takemura
308 1.1 takemura struct bioscallregs;
309 1.1 takemura
310 1.1 takemura extern struct apm_connect_info apminfo; /* in locore */
311 1.1 takemura extern int apmpresent;
312 1.1 takemura extern int apmcall __P((int function, struct bioscallregs *regs));
313 1.1 takemura extern void bioscall __P((int function, struct bioscallregs *regs));
314 1.1 takemura extern void apm_cpu_busy __P((void));
315 1.1 takemura extern void apm_cpu_idle __P((void));
316 1.1 takemura extern void apminit __P((void));
317 1.1 takemura int apm_set_powstate __P((u_int devid, u_int powstate));
318 1.1 takemura extern int apm_busprobe __P((void));
319 1.1 takemura extern int apmprint __P((void *, const char *));
320 1.1 takemura
321 1.1 takemura struct apm_accessops {
322 1.1 takemura void (*disconnect) __P((void *));
323 1.1 takemura void (*enable) __P((void *, int));
324 1.1 takemura int (*set_powstate) __P((void *, u_int, u_int));
325 1.1 takemura int (*get_powstat) __P((void *, struct apm_power_info *));
326 1.1 takemura int (*get_event) __P((void *, u_int *, u_int *));
327 1.1 takemura void (*cpu_busy) __P((void *));
328 1.1 takemura void (*cpu_idle) __P((void *));
329 1.1 takemura void (*get_capabilities) __P((void *, u_int *, u_int *));
330 1.1 takemura };
331 1.1 takemura
332 1.1 takemura struct apmdev_attach_args {
333 1.1 takemura struct apm_accessops *accessops;
334 1.1 takemura void *accesscookie;
335 1.1 takemura u_int apm_detail;
336 1.1 takemura };
337 1.1 takemura #endif /* _KERNEL */
338 1.1 takemura #endif /* _LOCORE */
339 1.1 takemura #endif /* __i386_apm_h__ */
340