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