apm_bios.h revision 14608
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.8 1996/03/12 05:51:35 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 */
24#define APM_BIOS		0x53
25#define SYSTEM_BIOS		0x15
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 *);
138#ifdef notused
139void apm_hook_disestablish (int apmh, struct apmhook *);
140#endif
141void apm_cpu_idle(void);
142void apm_cpu_busy(void);
143
144#endif /* !ASSEMBLER && !INITIALIZER */
145
146#define APM_MIN_ORDER		0x00
147#define APM_MID_ORDER		0x80
148#define APM_MAX_ORDER		0xff
149
150#endif /* KERNEL */
151
152/* power management event code */
153#define PMEV_NOEVENT		0x0000
154#define PMEV_STANDBYREQ		0x0001
155#define PMEV_SUSPENDREQ		0x0002
156#define PMEV_NORMRESUME		0x0003
157#define PMEV_CRITRESUME		0x0004
158#define PMEV_BATTERYLOW		0x0005
159#define PMEV_POWERSTATECHANGE	0x0006
160#define PMEV_UPDATETIME		0x0007
161#define PMEV_CRITSUSPEND	0x0008
162#define PMEV_USERSTANDBYREQ	0x0009
163#define PMEV_USERSUSPENDREQ	0x000a
164#define PMEV_STANDBYRESUME	0x000b
165/* 0x000c - 0x00ff	Reserved system events	*/
166/* 0x0100 - 0x01ff	Reserved device events	*/
167/* 0x0200 - 0x02ff	OEM-defined APM events	*/
168/* 0x0300 - 0xffff	Reserved		*/
169#define PMEV_DEFAULT		0xffffffff	/* used for customization */
170
171#if !defined(ASSEMBLER) && !defined(INITIALIZER)
172
173typedef struct apm_info {
174	u_int	ai_major;	/* APM major version */
175	u_int	ai_minor;	/* APM minor version */
176	u_int	ai_acline;	/* AC line status */
177	u_int	ai_batt_stat;	/* Battery status */
178	u_int	ai_batt_life;	/* Remaining battery life */
179	u_int	ai_status;	/* Status of APM support (enabled/disabled) */
180} *apm_info_t;
181
182#define APMIO_SUSPEND		_IO('P', 1)
183#define APMIO_GETINFO		_IOR('P', 2, struct apm_info)
184#define APMIO_ENABLE		_IO('P', 5)
185#define APMIO_DISABLE		_IO('P', 6)
186#define APMIO_HALTCPU		_IO('P', 7)
187#define APMIO_NOTHALTCPU	_IO('P', 8)
188#define APMIO_DISPLAYOFF	_IO('P', 9)
189
190#endif /* !ASSEMBLER && !INITIALIZER */
191
192#endif /* _MACHINE_APM_BIOS_H_ */
193