apm_bios.h revision 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 *
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 */
24#ifdef PC98
25#define APM_BIOS		0x9a
26#define SYSTEM_BIOS		0x1f
27#else
28#define APM_BIOS		0x53
29#define SYSTEM_BIOS		0x15
30#endif
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_ */
196