apm_bios.h revision 18444
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.11 1996/09/12 11:08:04 asami 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#define	APM_GETPWSTATUS		0x0a
64#define APM_GETPMEVENT		0x0b
65#define APM_GETPWSTATE		0x0c
66#define APM_ENABLEDISABLEDPM	0x0d
67#define APM_DRVVERSION		0x0e
68#define APM_ENGAGEDISENGAGEPM	0x0f
69#define APM_OEMFUNC		0x80
70
71/* error code */
72#define APME_OK			0x00
73#define APME_PMDISABLED		0x01
74#define APME_REALESTABLISHED	0x02
75#define APME_NOTCONNECTED	0x03
76#define APME_PROT16ESTABLISHED	0x05
77#define APME_PROT16NOTSUPPORTED	0x06
78#define APME_PROT32ESTABLISHED	0x07
79#define APME_PROT32NOTDUPPORTED	0x08
80#define APME_UNKNOWNDEVICEID	0x09
81#define APME_OUTOFRANGE		0x0a
82#define APME_NOTENGAGED		0x0b
83#define APME_CANTENTERSTATE	0x60
84#define APME_NOPMEVENT		0x80
85#define APME_NOAPMPRESENT	0x86
86
87
88/* device code */
89#define PMDV_APMBIOS		0x0000
90#define PMDV_ALLDEV		0x0001
91#define PMDV_DISP0		0x0100
92#define PMDV_DISP1		0x0101
93#define PMDV_2NDSTORAGE0	0x0200
94#define PMDV_2NDSTORAGE1	0x0201
95#define PMDV_2NDSTORAGE2	0x0202
96#define PMDV_2NDSTORAGE3	0x0203
97#define PMDV_PARALLEL0		0x0300
98#define PMDV_PARALLEL1		0x0301
99#define PMDV_SERIAL0		0x0400
100#define PMDV_SERIAL1		0x0401
101#define PMDV_SERIAL2		0x0402
102#define PMDV_SERIAL3		0x0403
103#define PMDV_SERIAL4		0x0404
104#define PMDV_SERIAL5		0x0405
105#define PMDV_SERIAL6		0x0406
106#define PMDV_SERIAL7		0x0407
107#define PMDV_NET0		0x0500
108#define PMDV_NET1		0x0501
109#define PMDV_NET2		0x0502
110#define PMDV_NET3		0x0503
111#define PMDV_PCMCIA0		0x0600
112#define PMDV_PCMCIA1		0x0601
113#define PMDV_PCMCIA2		0x0602
114#define PMDV_PCMCIA3		0x0603
115/* 0x0700 - 0xdfff	Reserved			*/
116/* 0xe000 - 0xefff	OEM-defined power device IDs	*/
117/* 0xf000 - 0xffff	Reserved			*/
118
119/* Power state */
120#define PMST_APMENABLED		0x0000
121#define PMST_STANDBY		0x0001
122#define PMST_SUSPEND		0x0002
123#define PMST_OFF		0x0003
124#define PMST_LASTREQNOTIFY	0x0004
125#define PMST_LASTREQREJECT	0x0005
126/* 0x0006 - 0x001f	Reserved system states		*/
127/* 0x0020 - 0x003f	OEM-defined system states	*/
128/* 0x0040 - 0x007f	OEM-defined device states	*/
129/* 0x0080 - 0xffff	Reserved device states		*/
130
131#if !defined(ASSEMBLER) && !defined(INITIALIZER)
132
133/* C definitions */
134struct apmhook {
135	struct apmhook	*ah_next;
136	int		(*ah_fun) __P((void *ah_arg));
137	void		*ah_arg;
138	const char	*ah_name;
139	int		ah_order;
140};
141#define APM_HOOK_NONE		(-1)
142#define APM_HOOK_SUSPEND        0
143#define APM_HOOK_RESUME         1
144#define NAPM_HOOK               2
145
146void apm_suspend(void);
147struct apmhook *apm_hook_establish (int apmh, struct apmhook *);
148void apm_hook_disestablish (int apmh, struct apmhook *);
149void apm_cpu_idle(void);
150void apm_cpu_busy(void);
151
152#endif /* !ASSEMBLER && !INITIALIZER */
153
154#define APM_MIN_ORDER		0x00
155#define APM_MID_ORDER		0x80
156#define APM_MAX_ORDER		0xff
157
158#endif /* KERNEL */
159
160/* power management event code */
161#define PMEV_NOEVENT		0x0000
162#define PMEV_STANDBYREQ		0x0001
163#define PMEV_SUSPENDREQ		0x0002
164#define PMEV_NORMRESUME		0x0003
165#define PMEV_CRITRESUME		0x0004
166#define PMEV_BATTERYLOW		0x0005
167#define PMEV_POWERSTATECHANGE	0x0006
168#define PMEV_UPDATETIME		0x0007
169#define PMEV_CRITSUSPEND	0x0008
170#define PMEV_USERSTANDBYREQ	0x0009
171#define PMEV_USERSUSPENDREQ	0x000a
172#define PMEV_STANDBYRESUME	0x000b
173/* 0x000c - 0x00ff	Reserved system events	*/
174/* 0x0100 - 0x01ff	Reserved device events	*/
175/* 0x0200 - 0x02ff	OEM-defined APM events	*/
176/* 0x0300 - 0xffff	Reserved		*/
177#define PMEV_DEFAULT		0xffffffff	/* used for customization */
178
179#if !defined(ASSEMBLER) && !defined(INITIALIZER)
180
181typedef struct apm_info {
182	u_int	ai_major;	/* APM major version */
183	u_int	ai_minor;	/* APM minor version */
184	u_int	ai_acline;	/* AC line status */
185	u_int	ai_batt_stat;	/* Battery status */
186	u_int	ai_batt_life;	/* Remaining battery life */
187	u_int	ai_status;	/* Status of APM support (enabled/disabled) */
188} *apm_info_t;
189
190#define APMIO_SUSPEND		_IO('P', 1)
191#define APMIO_GETINFO		_IOR('P', 2, struct apm_info)
192#define APMIO_ENABLE		_IO('P', 5)
193#define APMIO_DISABLE		_IO('P', 6)
194#define APMIO_HALTCPU		_IO('P', 7)
195#define APMIO_NOTHALTCPU	_IO('P', 8)
196#define APMIO_DISPLAYOFF	_IO('P', 9)
197
198#endif /* !ASSEMBLER && !INITIALIZER */
199
200#endif /* !_MACHINE_APM_BIOS_H_ */
201