2 * APM (Advanced Power Management) BIOS Device Driver
4 * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
6 * This software may be used, modified, copied, and distributed, in
7 * both source and binary form provided that the above copyright and
8 * these terms are retained. Under no circumstances is the author
9 * responsible for the proper functioning of this software, nor does
10 * the author assume any responsibility for damages incurred with its
13 * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
15 * $FreeBSD: src/sys/i386/include/apm_bios.h,v 1.27.2.2 2002/04/12 16:47:00 bmah Exp $
16 * $DragonFly: src/sys/i386/include/Attic/apm_bios.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
19 #ifndef _MACHINE_APM_BIOS_H_
20 #define _MACHINE_APM_BIOS_H_
23 #include <sys/types.h>
25 #include <sys/ioccom.h>
37 #define APM_16BIT_SUPPORT 0x01
38 #define APM_32BIT_SUPPORT 0x02
39 #define APM_CPUIDLE_SLOW 0x04
40 #define APM_DISABLED 0x08
41 #define APM_DISENGAGED 0x10
43 /* APM initializer physical address */
44 #define APM_OURADDR 0x00080000
47 #define APM_INSTCHECK 0x00
48 #define APM_REALCONNECT 0x01
49 #define APM_PROT16CONNECT 0x02
50 #define APM_PROT32CONNECT 0x03
51 #define APM_DISCONNECT 0x04
52 #define APM_CPUIDLE 0x05
53 #define APM_CPUBUSY 0x06
54 #define APM_SETPWSTATE 0x07
55 #define APM_ENABLEDISABLEPM 0x08
56 #define APM_RESTOREDEFAULT 0x09
58 #define APM_GETPWSTATUS 0x3a
60 #define APM_GETPWSTATUS 0x0a
62 #define APM_GETPMEVENT 0x0b
63 #define APM_GETPWSTATE 0x0c
64 #define APM_ENABLEDISABLEDPM 0x0d
66 #define APM_DRVVERSION 0x3e
68 #define APM_DRVVERSION 0x0e
70 #define APM_ENGAGEDISENGAGEPM 0x0f
71 #define APM_GETCAPABILITIES 0x10
72 #define APM_RESUMETIMER 0x11
73 #define APM_RESUMEONRING 0x12
74 #define APM_TIMERREQUESTS 0x13
75 #define APM_OEMFUNC 0x80
79 #define APME_PMDISABLED 0x01
80 #define APME_REALESTABLISHED 0x02
81 #define APME_NOTCONNECTED 0x03
82 #define APME_PROT16ESTABLISHED 0x05
83 #define APME_PROT16NOTSUPPORTED 0x06
84 #define APME_PROT32ESTABLISHED 0x07
85 #define APME_PROT32NOTDUPPORTED 0x08
86 #define APME_UNKNOWNDEVICEID 0x09
87 #define APME_OUTOFRANGE 0x0a
88 #define APME_NOTENGAGED 0x0b
89 #define APME_CANTENTERSTATE 0x60
90 #define APME_NOPMEVENT 0x80
91 #define APME_NOAPMPRESENT 0x86
95 #define PMDV_APMBIOS 0x0000
96 #define PMDV_ALLDEV 0x0001
97 #define PMDV_DISP0 0x0100
98 #define PMDV_DISP1 0x0101
99 #define PMDV_DISPALL 0x01ff
100 #define PMDV_2NDSTORAGE0 0x0200
101 #define PMDV_2NDSTORAGE1 0x0201
102 #define PMDV_2NDSTORAGE2 0x0202
103 #define PMDV_2NDSTORAGE3 0x0203
104 #define PMDV_PARALLEL0 0x0300
105 #define PMDV_PARALLEL1 0x0301
106 #define PMDV_SERIAL0 0x0400
107 #define PMDV_SERIAL1 0x0401
108 #define PMDV_SERIAL2 0x0402
109 #define PMDV_SERIAL3 0x0403
110 #define PMDV_SERIAL4 0x0404
111 #define PMDV_SERIAL5 0x0405
112 #define PMDV_SERIAL6 0x0406
113 #define PMDV_SERIAL7 0x0407
114 #define PMDV_NET0 0x0500
115 #define PMDV_NET1 0x0501
116 #define PMDV_NET2 0x0502
117 #define PMDV_NET3 0x0503
118 #define PMDV_PCMCIA0 0x0600
119 #define PMDV_PCMCIA1 0x0601
120 #define PMDV_PCMCIA2 0x0602
121 #define PMDV_PCMCIA3 0x0603
122 /* 0x0700 - 0x7fff Reserved */
123 #define PMDV_BATT_BASE 0x8000
124 #define PMDV_BATT0 0x8001
125 #define PMDV_BATT1 0x8002
126 #define PMDV_BATT_ALL 0x80ff
127 /* 0x8100 - 0xdfff Reserved */
128 /* 0xe000 - 0xefff OEM-defined power device IDs */
129 /* 0xf000 - 0xffff Reserved */
132 #define PMST_APMENABLED 0x0000
133 #define PMST_STANDBY 0x0001
134 #define PMST_SUSPEND 0x0002
135 #define PMST_OFF 0x0003
136 #define PMST_LASTREQNOTIFY 0x0004
137 #define PMST_LASTREQREJECT 0x0005
138 /* 0x0006 - 0x001f Reserved system states */
139 /* 0x0020 - 0x003f OEM-defined system states */
140 /* 0x0040 - 0x007f OEM-defined device states */
141 /* 0x0080 - 0xffff Reserved device states */
143 #if !defined(ASSEMBLER) && !defined(INITIALIZER)
147 struct apmhook *ah_next;
148 int (*ah_fun) __P((void *ah_arg));
153 #define APM_HOOK_NONE (-1)
154 #define APM_HOOK_SUSPEND 0
155 #define APM_HOOK_RESUME 1
160 void apm_suspend(int state);
161 struct apmhook *apm_hook_establish (int apmh, struct apmhook *);
162 void apm_hook_disestablish (int apmh, struct apmhook *);
163 void apm_cpu_idle(void);
164 void apm_cpu_busy(void);
168 #endif /* !ASSEMBLER && !INITIALIZER */
170 #define APM_MIN_ORDER 0x00
171 #define APM_MID_ORDER 0x80
172 #define APM_MAX_ORDER 0xff
174 /* power management event code */
175 #define PMEV_NOEVENT 0x0000
176 #define PMEV_STANDBYREQ 0x0001
177 #define PMEV_SUSPENDREQ 0x0002
178 #define PMEV_NORMRESUME 0x0003
179 #define PMEV_CRITRESUME 0x0004
180 #define PMEV_BATTERYLOW 0x0005
181 #define PMEV_POWERSTATECHANGE 0x0006
182 #define PMEV_UPDATETIME 0x0007
183 #define PMEV_CRITSUSPEND 0x0008
184 #define PMEV_USERSTANDBYREQ 0x0009
185 #define PMEV_USERSUSPENDREQ 0x000a
186 #define PMEV_STANDBYRESUME 0x000b
187 #define PMEV_CAPABILITIESCHANGE 0x000c
188 /* 0x000d - 0x00ff Reserved system events */
189 /* 0x0100 - 0x01ff Reserved device events */
190 /* 0x0200 - 0x02ff OEM-defined APM events */
191 /* 0x0300 - 0xffff Reserved */
192 #define PMEV_DEFAULT 0xffffffff /* used for customization */
194 #if !defined(ASSEMBLER) && !defined(INITIALIZER)
197 * Old apm_info structure, returned by the APMIO_GETINFO_OLD ioctl. This
198 * is for backward compatibility with old executables.
200 typedef struct apm_info_old {
201 u_int ai_major; /* APM major version */
202 u_int ai_minor; /* APM minor version */
203 u_int ai_acline; /* AC line status */
204 u_int ai_batt_stat; /* Battery status */
205 u_int ai_batt_life; /* Remaining battery life */
206 u_int ai_status; /* Status of APM support (enabled/disabled) */
210 * Structure returned by the APMIO_GETINFO ioctl.
212 * In the comments below, the parenthesized numbers indicate the minimum
213 * value of ai_infoversion for which each field is valid.
215 typedef struct apm_info {
216 u_int ai_infoversion; /* Indicates which fields are valid */
217 u_int ai_major; /* APM major version (0) */
218 u_int ai_minor; /* APM minor version (0) */
219 u_int ai_acline; /* AC line status (0) */
220 u_int ai_batt_stat; /* Battery status (0) */
221 u_int ai_batt_life; /* Remaining battery life in percent (0) */
222 int ai_batt_time; /* Remaining battery time in seconds (0) */
223 u_int ai_status; /* True if enabled (0) */
224 u_int ai_batteries; /* Number of batteries (1) */
225 u_int ai_capabilities;/* APM Capabilities (1) */
226 u_int ai_spare[6]; /* For future expansion */
230 #define APM_BATT_HIGH 0x01
231 #define APM_BATT_LOW 0x02
232 #define APM_BATT_CRITICAL 0x04
233 #define APM_BATT_CHARGING 0x08
234 #define APM_BATT_NOT_PRESENT 0x10
235 #define APM_BATT_NO_SYSTEM 0x80
237 typedef struct apm_pwstatus {
238 u_int ap_device; /* Device code of battery */
239 u_int ap_acline; /* AC line status (0) */
240 u_int ap_batt_stat; /* Battery status (0) */
241 u_int ap_batt_flag; /* Battery flag (0) */
242 u_int ap_batt_life; /* Remaining battery life in percent (0) */
243 int ap_batt_time; /* Remaining battery time in seconds (0) */
246 struct apm_bios_arg {
255 struct apm_event_info {
261 #define APMIO_SUSPEND _IO('P', 1)
262 #define APMIO_GETINFO_OLD _IOR('P', 2, struct apm_info_old)
263 #define APMIO_ENABLE _IO('P', 5)
264 #define APMIO_DISABLE _IO('P', 6)
265 #define APMIO_HALTCPU _IO('P', 7)
266 #define APMIO_NOTHALTCPU _IO('P', 8)
267 #define APMIO_DISPLAY _IOW('P', 9, int)
268 #define APMIO_BIOS _IOWR('P', 10, struct apm_bios_arg)
269 #define APMIO_GETINFO _IOR('P', 11, struct apm_info)
270 #define APMIO_STANDBY _IO('P', 12)
271 #define APMIO_GETPWSTATUS _IOWR('P', 13, struct apm_pwstatus)
272 /* for /dev/apmctl */
273 #define APMIO_NEXTEVENT _IOR('A', 100, struct apm_event_info)
274 #define APMIO_REJECTLASTREQ _IO('P', 101)
276 #endif /* !ASSEMBLER && !INITIALIZER */
278 #endif /* !_MACHINE_APM_BIOS_H_ */