apm_bios.h revision 21362
1160814Ssimon/*
2160814Ssimon * APM (Advanced Power Management) BIOS Device Driver
3160814Ssimon *
4160814Ssimon * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
5160814Ssimon *
6160814Ssimon * This software may be used, modified, copied, and distributed, in
7160814Ssimon * both source and binary form provided that the above copyright and
8160814Ssimon * these terms are retained. Under no circumstances is the author
9160814Ssimon * responsible for the proper functioning of this software, nor does
10160814Ssimon * the author assume any responsibility for damages incurred with its
11160814Ssimon * use.
12160814Ssimon *
13160814Ssimon * Aug, 1994	Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
14160814Ssimon *
15160814Ssimon *	$Id: apm_bios.h,v 1.12 1996/09/21 14:57:49 bde Exp $
16160814Ssimon */
17160814Ssimon
18160814Ssimon#ifndef	_MACHINE_APM_BIOS_H_
19160814Ssimon#define	_MACHINE_APM_BIOS_H_
20160814Ssimon
21160814Ssimon#ifndef KERNEL
22160814Ssimon#include <sys/types.h>
23160814Ssimon#endif
24160814Ssimon#include <sys/ioccom.h>
25194206Ssimon
26160814Ssimon#ifdef KERNEL
27194206Ssimon
28194206Ssimon/* BIOS id */
29160814Ssimon#ifdef PC98
30298998Sjkim#define APM_BIOS		0x9a
31298998Sjkim#define SYSTEM_BIOS		0x1f
32298998Sjkim#else
33298998Sjkim#define APM_BIOS		0x53
34298998Sjkim#define SYSTEM_BIOS		0x15
35298998Sjkim#endif
36298998Sjkim
37298998Sjkim/* APM flags */
38298998Sjkim#define APM_16BIT_SUPPORT	0x01
39194206Ssimon#define APM_32BIT_SUPPORT	0x02
40194206Ssimon#define APM_CPUIDLE_SLOW	0x04
41194206Ssimon#define APM_DISABLED		0x08
42194206Ssimon#define APM_DISENGAGED		0x10
43194206Ssimon
44194206Ssimon/* APM initializer physical address */
45194206Ssimon#define APM_OURADDR		0x00080000
46194206Ssimon
47194206Ssimon/* Error code of APM initializer */
48194206Ssimon#define APMINI_CANTFIND		0xffffffff
49194206Ssimon#define APMINI_NOT32BIT		0xfffffffe
50194206Ssimon#define APMINI_CONNECTERR	0xfffffffd
51160814Ssimon
52160814Ssimon/* APM functions */
53194206Ssimon#define APM_INSTCHECK		0x00
54194206Ssimon#define APM_REALCONNECT		0x01
55194206Ssimon#define APM_PROT16CONNECT	0x02
56194206Ssimon#define APM_PROT32CONNECT	0x03
57160814Ssimon#define APM_DISCONNECT		0x04
58160814Ssimon#define APM_CPUIDLE		0x05
59160814Ssimon#define APM_CPUBUSY		0x06
60194206Ssimon#define APM_SETPWSTATE		0x07
61194206Ssimon#define APM_ENABLEDISABLEPM	0x08
62194206Ssimon#define APM_RESTOREDEFAULT	0x09
63194206Ssimon#define	APM_GETPWSTATUS		0x0a
64160814Ssimon#define APM_GETPMEVENT		0x0b
65160814Ssimon#define APM_GETPWSTATE		0x0c
66194206Ssimon#define APM_ENABLEDISABLEDPM	0x0d
67160814Ssimon#define APM_DRVVERSION		0x0e
68160814Ssimon#define APM_ENGAGEDISENGAGEPM	0x0f
69160814Ssimon#define APM_OEMFUNC		0x80
70160814Ssimon
71160814Ssimon/* error code */
72160814Ssimon#define APME_OK			0x00
73160814Ssimon#define APME_PMDISABLED		0x01
74160814Ssimon#define APME_REALESTABLISHED	0x02
75160814Ssimon#define APME_NOTCONNECTED	0x03
76160814Ssimon#define APME_PROT16ESTABLISHED	0x05
77160814Ssimon#define APME_PROT16NOTSUPPORTED	0x06
78160814Ssimon#define APME_PROT32ESTABLISHED	0x07
79160814Ssimon#define APME_PROT32NOTDUPPORTED	0x08
80160814Ssimon#define APME_UNKNOWNDEVICEID	0x09
81160814Ssimon#define APME_OUTOFRANGE		0x0a
82160814Ssimon#define APME_NOTENGAGED		0x0b
83160814Ssimon#define APME_CANTENTERSTATE	0x60
84194206Ssimon#define APME_NOPMEVENT		0x80
85160814Ssimon#define APME_NOAPMPRESENT	0x86
86160814Ssimon
87160814Ssimon
88160814Ssimon/* device code */
89160814Ssimon#define PMDV_APMBIOS		0x0000
90160814Ssimon#define PMDV_ALLDEV		0x0001
91160814Ssimon#define PMDV_DISP0		0x0100
92205128Ssimon#define PMDV_DISP1		0x0101
93160814Ssimon#define PMDV_2NDSTORAGE0	0x0200
94160814Ssimon#define PMDV_2NDSTORAGE1	0x0201
95160814Ssimon#define PMDV_2NDSTORAGE2	0x0202
96194206Ssimon#define PMDV_2NDSTORAGE3	0x0203
97194206Ssimon#define PMDV_PARALLEL0		0x0300
98160814Ssimon#define PMDV_PARALLEL1		0x0301
99160814Ssimon#define PMDV_SERIAL0		0x0400
100238405Sjkim#define PMDV_SERIAL1		0x0401
101238405Sjkim#define PMDV_SERIAL2		0x0402
102261037Sjkim#define PMDV_SERIAL3		0x0403
103261037Sjkim#define PMDV_SERIAL4		0x0404
104261037Sjkim#define PMDV_SERIAL5		0x0405
105261037Sjkim#define PMDV_SERIAL6		0x0406
106261037Sjkim#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_DISPLAY		_IOW('P', 9, int)
197
198#endif /* !ASSEMBLER && !INITIALIZER */
199
200#endif /* !_MACHINE_APM_BIOS_H_ */
201