Deleted Added
full compact
apm_bios.h (15360) apm_bios.h (18265)
1/*
2 * APM (Advanced Power Management) BIOS Device Driver
3 *
4 * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
5 *
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
11 * use.
12 *
13 * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
14 *
1/*
2 * APM (Advanced Power Management) BIOS Device Driver
3 *
4 * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
5 *
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
11 * use.
12 *
13 * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
14 *
15 * $Id: apm_bios.h,v 1.9 1996/03/13 00:41:45 nate Exp $
15 * $Id: apm_bios.h,v 1.10 1996/04/23 16:02:53 nate Exp $
16 */
17
18#ifndef _MACHINE_APM_BIOS_H_
19#define _MACHINE_APM_BIOS_H_ 1
20
21#ifdef KERNEL
22
23/* BIOS id */
16 */
17
18#ifndef _MACHINE_APM_BIOS_H_
19#define _MACHINE_APM_BIOS_H_ 1
20
21#ifdef KERNEL
22
23/* BIOS id */
24#ifdef PC98
25#define APM_BIOS 0x9a
26#define SYSTEM_BIOS 0x1f
27#else
24#define APM_BIOS 0x53
25#define SYSTEM_BIOS 0x15
28#define APM_BIOS 0x53
29#define SYSTEM_BIOS 0x15
30#endif
26
27/* APM flags */
28#define APM_16BIT_SUPPORT 0x01
29#define APM_32BIT_SUPPORT 0x02
30#define APM_CPUIDLE_SLOW 0x04
31#define APM_DISABLED 0x08
32#define APM_DISENGAGED 0x10
33
34/* APM initializer physical address */
35#define APM_OURADDR 0x00080000
36
37/* Error code of APM initializer */
38#define APMINI_CANTFIND 0xffffffff
39#define APMINI_NOT32BIT 0xfffffffe
40#define APMINI_CONNECTERR 0xfffffffd
41
42/* APM functions */
43#define APM_INSTCHECK 0x00
44#define APM_REALCONNECT 0x01
45#define APM_PROT16CONNECT 0x02
46#define APM_PROT32CONNECT 0x03
47#define APM_DISCONNECT 0x04
48#define APM_CPUIDLE 0x05
49#define APM_CPUBUSY 0x06
50#define APM_SETPWSTATE 0x07
51#define APM_ENABLEDISABLEPM 0x08
52#define APM_RESTOREDEFAULT 0x09
53#define APM_GETPWSTATUS 0x0a
54#define APM_GETPMEVENT 0x0b
55#define APM_GETPWSTATE 0x0c
56#define APM_ENABLEDISABLEDPM 0x0d
57#define APM_DRVVERSION 0x0e
58#define APM_ENGAGEDISENGAGEPM 0x0f
59#define APM_OEMFUNC 0x80
60
61/* error code */
62#define APME_OK 0x00
63#define APME_PMDISABLED 0x01
64#define APME_REALESTABLISHED 0x02
65#define APME_NOTCONNECTED 0x03
66#define APME_PROT16ESTABLISHED 0x05
67#define APME_PROT16NOTSUPPORTED 0x06
68#define APME_PROT32ESTABLISHED 0x07
69#define APME_PROT32NOTDUPPORTED 0x08
70#define APME_UNKNOWNDEVICEID 0x09
71#define APME_OUTOFRANGE 0x0a
72#define APME_NOTENGAGED 0x0b
73#define APME_CANTENTERSTATE 0x60
74#define APME_NOPMEVENT 0x80
75#define APME_NOAPMPRESENT 0x86
76
77
78/* device code */
79#define PMDV_APMBIOS 0x0000
80#define PMDV_ALLDEV 0x0001
81#define PMDV_DISP0 0x0100
82#define PMDV_DISP1 0x0101
83#define PMDV_2NDSTORAGE0 0x0200
84#define PMDV_2NDSTORAGE1 0x0201
85#define PMDV_2NDSTORAGE2 0x0202
86#define PMDV_2NDSTORAGE3 0x0203
87#define PMDV_PARALLEL0 0x0300
88#define PMDV_PARALLEL1 0x0301
89#define PMDV_SERIAL0 0x0400
90#define PMDV_SERIAL1 0x0401
91#define PMDV_SERIAL2 0x0402
92#define PMDV_SERIAL3 0x0403
93#define PMDV_SERIAL4 0x0404
94#define PMDV_SERIAL5 0x0405
95#define PMDV_SERIAL6 0x0406
96#define PMDV_SERIAL7 0x0407
97#define PMDV_NET0 0x0500
98#define PMDV_NET1 0x0501
99#define PMDV_NET2 0x0502
100#define PMDV_NET3 0x0503
101#define PMDV_PCMCIA0 0x0600
102#define PMDV_PCMCIA1 0x0601
103#define PMDV_PCMCIA2 0x0602
104#define PMDV_PCMCIA3 0x0603
105/* 0x0700 - 0xdfff Reserved */
106/* 0xe000 - 0xefff OEM-defined power device IDs */
107/* 0xf000 - 0xffff Reserved */
108
109/* Power state */
110#define PMST_APMENABLED 0x0000
111#define PMST_STANDBY 0x0001
112#define PMST_SUSPEND 0x0002
113#define PMST_OFF 0x0003
114#define PMST_LASTREQNOTIFY 0x0004
115#define PMST_LASTREQREJECT 0x0005
116/* 0x0006 - 0x001f Reserved system states */
117/* 0x0020 - 0x003f OEM-defined system states */
118/* 0x0040 - 0x007f OEM-defined device states */
119/* 0x0080 - 0xffff Reserved device states */
120
121#if !defined(ASSEMBLER) && !defined(INITIALIZER)
122
123/* C definitions */
124struct apmhook {
125 struct apmhook *ah_next;
126 int (*ah_fun) __P((void *ah_arg));
127 void *ah_arg;
128 const char *ah_name;
129 int ah_order;
130};
131#define APM_HOOK_NONE (-1)
132#define APM_HOOK_SUSPEND 0
133#define APM_HOOK_RESUME 1
134#define NAPM_HOOK 2
135
136void apm_suspend(void);
137struct apmhook *apm_hook_establish (int apmh, struct apmhook *);
138void apm_hook_disestablish (int apmh, struct apmhook *);
139void apm_cpu_idle(void);
140void apm_cpu_busy(void);
141
142#endif /* !ASSEMBLER && !INITIALIZER */
143
144#define APM_MIN_ORDER 0x00
145#define APM_MID_ORDER 0x80
146#define APM_MAX_ORDER 0xff
147
148#endif /* KERNEL */
149
150/* power management event code */
151#define PMEV_NOEVENT 0x0000
152#define PMEV_STANDBYREQ 0x0001
153#define PMEV_SUSPENDREQ 0x0002
154#define PMEV_NORMRESUME 0x0003
155#define PMEV_CRITRESUME 0x0004
156#define PMEV_BATTERYLOW 0x0005
157#define PMEV_POWERSTATECHANGE 0x0006
158#define PMEV_UPDATETIME 0x0007
159#define PMEV_CRITSUSPEND 0x0008
160#define PMEV_USERSTANDBYREQ 0x0009
161#define PMEV_USERSUSPENDREQ 0x000a
162#define PMEV_STANDBYRESUME 0x000b
163/* 0x000c - 0x00ff Reserved system events */
164/* 0x0100 - 0x01ff Reserved device events */
165/* 0x0200 - 0x02ff OEM-defined APM events */
166/* 0x0300 - 0xffff Reserved */
167#define PMEV_DEFAULT 0xffffffff /* used for customization */
168
169#if !defined(ASSEMBLER) && !defined(INITIALIZER)
170
171typedef struct apm_info {
172 u_int ai_major; /* APM major version */
173 u_int ai_minor; /* APM minor version */
174 u_int ai_acline; /* AC line status */
175 u_int ai_batt_stat; /* Battery status */
176 u_int ai_batt_life; /* Remaining battery life */
177 u_int ai_status; /* Status of APM support (enabled/disabled) */
178} *apm_info_t;
179
180#define APMIO_SUSPEND _IO('P', 1)
181#define APMIO_GETINFO _IOR('P', 2, struct apm_info)
182#define APMIO_ENABLE _IO('P', 5)
183#define APMIO_DISABLE _IO('P', 6)
184#define APMIO_HALTCPU _IO('P', 7)
185#define APMIO_NOTHALTCPU _IO('P', 8)
186#define APMIO_DISPLAYOFF _IO('P', 9)
187
188#endif /* !ASSEMBLER && !INITIALIZER */
189
190#endif /* _MACHINE_APM_BIOS_H_ */
31
32/* APM flags */
33#define APM_16BIT_SUPPORT 0x01
34#define APM_32BIT_SUPPORT 0x02
35#define APM_CPUIDLE_SLOW 0x04
36#define APM_DISABLED 0x08
37#define APM_DISENGAGED 0x10
38
39/* APM initializer physical address */
40#define APM_OURADDR 0x00080000
41
42/* Error code of APM initializer */
43#define APMINI_CANTFIND 0xffffffff
44#define APMINI_NOT32BIT 0xfffffffe
45#define APMINI_CONNECTERR 0xfffffffd
46
47/* APM functions */
48#define APM_INSTCHECK 0x00
49#define APM_REALCONNECT 0x01
50#define APM_PROT16CONNECT 0x02
51#define APM_PROT32CONNECT 0x03
52#define APM_DISCONNECT 0x04
53#define APM_CPUIDLE 0x05
54#define APM_CPUBUSY 0x06
55#define APM_SETPWSTATE 0x07
56#define APM_ENABLEDISABLEPM 0x08
57#define APM_RESTOREDEFAULT 0x09
58#define APM_GETPWSTATUS 0x0a
59#define APM_GETPMEVENT 0x0b
60#define APM_GETPWSTATE 0x0c
61#define APM_ENABLEDISABLEDPM 0x0d
62#define APM_DRVVERSION 0x0e
63#define APM_ENGAGEDISENGAGEPM 0x0f
64#define APM_OEMFUNC 0x80
65
66/* error code */
67#define APME_OK 0x00
68#define APME_PMDISABLED 0x01
69#define APME_REALESTABLISHED 0x02
70#define APME_NOTCONNECTED 0x03
71#define APME_PROT16ESTABLISHED 0x05
72#define APME_PROT16NOTSUPPORTED 0x06
73#define APME_PROT32ESTABLISHED 0x07
74#define APME_PROT32NOTDUPPORTED 0x08
75#define APME_UNKNOWNDEVICEID 0x09
76#define APME_OUTOFRANGE 0x0a
77#define APME_NOTENGAGED 0x0b
78#define APME_CANTENTERSTATE 0x60
79#define APME_NOPMEVENT 0x80
80#define APME_NOAPMPRESENT 0x86
81
82
83/* device code */
84#define PMDV_APMBIOS 0x0000
85#define PMDV_ALLDEV 0x0001
86#define PMDV_DISP0 0x0100
87#define PMDV_DISP1 0x0101
88#define PMDV_2NDSTORAGE0 0x0200
89#define PMDV_2NDSTORAGE1 0x0201
90#define PMDV_2NDSTORAGE2 0x0202
91#define PMDV_2NDSTORAGE3 0x0203
92#define PMDV_PARALLEL0 0x0300
93#define PMDV_PARALLEL1 0x0301
94#define PMDV_SERIAL0 0x0400
95#define PMDV_SERIAL1 0x0401
96#define PMDV_SERIAL2 0x0402
97#define PMDV_SERIAL3 0x0403
98#define PMDV_SERIAL4 0x0404
99#define PMDV_SERIAL5 0x0405
100#define PMDV_SERIAL6 0x0406
101#define PMDV_SERIAL7 0x0407
102#define PMDV_NET0 0x0500
103#define PMDV_NET1 0x0501
104#define PMDV_NET2 0x0502
105#define PMDV_NET3 0x0503
106#define PMDV_PCMCIA0 0x0600
107#define PMDV_PCMCIA1 0x0601
108#define PMDV_PCMCIA2 0x0602
109#define PMDV_PCMCIA3 0x0603
110/* 0x0700 - 0xdfff Reserved */
111/* 0xe000 - 0xefff OEM-defined power device IDs */
112/* 0xf000 - 0xffff Reserved */
113
114/* Power state */
115#define PMST_APMENABLED 0x0000
116#define PMST_STANDBY 0x0001
117#define PMST_SUSPEND 0x0002
118#define PMST_OFF 0x0003
119#define PMST_LASTREQNOTIFY 0x0004
120#define PMST_LASTREQREJECT 0x0005
121/* 0x0006 - 0x001f Reserved system states */
122/* 0x0020 - 0x003f OEM-defined system states */
123/* 0x0040 - 0x007f OEM-defined device states */
124/* 0x0080 - 0xffff Reserved device states */
125
126#if !defined(ASSEMBLER) && !defined(INITIALIZER)
127
128/* C definitions */
129struct apmhook {
130 struct apmhook *ah_next;
131 int (*ah_fun) __P((void *ah_arg));
132 void *ah_arg;
133 const char *ah_name;
134 int ah_order;
135};
136#define APM_HOOK_NONE (-1)
137#define APM_HOOK_SUSPEND 0
138#define APM_HOOK_RESUME 1
139#define NAPM_HOOK 2
140
141void apm_suspend(void);
142struct apmhook *apm_hook_establish (int apmh, struct apmhook *);
143void apm_hook_disestablish (int apmh, struct apmhook *);
144void apm_cpu_idle(void);
145void apm_cpu_busy(void);
146
147#endif /* !ASSEMBLER && !INITIALIZER */
148
149#define APM_MIN_ORDER 0x00
150#define APM_MID_ORDER 0x80
151#define APM_MAX_ORDER 0xff
152
153#endif /* KERNEL */
154
155/* power management event code */
156#define PMEV_NOEVENT 0x0000
157#define PMEV_STANDBYREQ 0x0001
158#define PMEV_SUSPENDREQ 0x0002
159#define PMEV_NORMRESUME 0x0003
160#define PMEV_CRITRESUME 0x0004
161#define PMEV_BATTERYLOW 0x0005
162#define PMEV_POWERSTATECHANGE 0x0006
163#define PMEV_UPDATETIME 0x0007
164#define PMEV_CRITSUSPEND 0x0008
165#define PMEV_USERSTANDBYREQ 0x0009
166#define PMEV_USERSUSPENDREQ 0x000a
167#define PMEV_STANDBYRESUME 0x000b
168/* 0x000c - 0x00ff Reserved system events */
169/* 0x0100 - 0x01ff Reserved device events */
170/* 0x0200 - 0x02ff OEM-defined APM events */
171/* 0x0300 - 0xffff Reserved */
172#define PMEV_DEFAULT 0xffffffff /* used for customization */
173
174#if !defined(ASSEMBLER) && !defined(INITIALIZER)
175
176typedef struct apm_info {
177 u_int ai_major; /* APM major version */
178 u_int ai_minor; /* APM minor version */
179 u_int ai_acline; /* AC line status */
180 u_int ai_batt_stat; /* Battery status */
181 u_int ai_batt_life; /* Remaining battery life */
182 u_int ai_status; /* Status of APM support (enabled/disabled) */
183} *apm_info_t;
184
185#define APMIO_SUSPEND _IO('P', 1)
186#define APMIO_GETINFO _IOR('P', 2, struct apm_info)
187#define APMIO_ENABLE _IO('P', 5)
188#define APMIO_DISABLE _IO('P', 6)
189#define APMIO_HALTCPU _IO('P', 7)
190#define APMIO_NOTHALTCPU _IO('P', 8)
191#define APMIO_DISPLAYOFF _IO('P', 9)
192
193#endif /* !ASSEMBLER && !INITIALIZER */
194
195#endif /* _MACHINE_APM_BIOS_H_ */