apm_bios.h revision 3263
1/*
2 * Advanced Power Management (APM) BIOS driver for laptop PCs.
3 *
4 * Copyright (c) 1994 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
16#ifndef _MACHINE_APM_BIOS_H_
17#define _MACHINE_APM_BIOS_H_	1
18
19#ifdef KERNEL
20
21/* BIOS id */
22#define APM_BIOS		0x53
23#define SYSTEM_BIOS		0x15
24
25/* APM flags */
26#define APM_16BIT_SUPPORT	0x01
27#define APM_32BIT_SUPPORT	0x02
28#define APM_CPUIDLE_SLOW	0x04
29#define APM_DISABLED		0x08
30#define APM_DISENGAGED		0x10
31
32/* APM initializer physical address */
33#define APM_OURADDR		0x00080000
34
35/* Error code of APM initializer */
36#define APMINI_CANTFIND		0xffffffff
37#define APMINI_NOT32BIT		0xfffffffe
38#define APMINI_CONNECTERR	0xfffffffd
39
40/* APM functions */
41#define APM_INSTCHECK		0x00
42#define APM_REALCONNECT		0x01
43#define APM_PROT16CONNECT	0x02
44#define APM_PROT32CONNECT	0x03
45#define APM_DISCONNECT		0x04
46#define APM_CPUIDLE		0x05
47#define APM_CPUBUSY		0x06
48#define APM_SETPWSTATE		0x07
49#define APM_ENABLEDISABLEPM	0x08
50#define APM_RESTOREDEFAULT	0x09
51#define	APM_GETPWSTATUS		0x0a
52#define APM_GETPMEVENT		0x0b
53#define APM_GETPWSTATE		0x0c
54#define APM_ENABLEDISABLEDPM	0x0d
55#define APM_DRVVERSION		0x0e
56#define APM_ENGAGEDISENGAGEPM	0x0f
57#define APM_OEMFUNC		0x80
58
59/* error code */
60#define APME_OK			0x00
61#define APME_PMDISABLED		0x01
62#define APME_REALESTABLISHED	0x02
63#define APME_NOTCONNECTED	0x03
64#define APME_PROT16ESTABLISHED	0x05
65#define APME_PROT16NOTSUPPORTED	0x06
66#define APME_PROT32ESTABLISHED	0x07
67#define APME_PROT32NOTDUPPORTED	0x08
68#define APME_UNKNOWNDEVICEID	0x09
69#define APME_OUTOFRANGE		0x0a
70#define APME_NOTENGAGED		0x0b
71#define APME_CANTENTERSTATE	0x60
72#define APME_NOPMEVENT		0x80
73#define APME_NOAPMPRESENT	0x86
74
75
76/* device code */
77#define PMDV_APMBIOS		0x0000
78#define PMDV_ALLDEV		0x0001
79#define PMDV_DISP0		0x0100
80#define PMDV_DISP1		0x0101
81#define PMDV_2NDSTORAGE0	0x0200
82#define PMDV_2NDSTORAGE1	0x0201
83#define PMDV_2NDSTORAGE2	0x0202
84#define PMDV_2NDSTORAGE3	0x0203
85#define PMDV_PARALLEL0		0x0300
86#define PMDV_PARALLEL1		0x0301
87#define PMDV_SERIAL0		0x0400
88#define PMDV_SERIAL1		0x0401
89#define PMDV_SERIAL2		0x0402
90#define PMDV_SERIAL3		0x0403
91#define PMDV_SERIAL4		0x0404
92#define PMDV_SERIAL5		0x0405
93#define PMDV_SERIAL6		0x0406
94#define PMDV_SERIAL7		0x0407
95#define PMDV_NET0		0x0500
96#define PMDV_NET1		0x0501
97#define PMDV_NET2		0x0502
98#define PMDV_NET3		0x0503
99#define PMDV_PCMCIA0		0x0600
100#define PMDV_PCMCIA1		0x0601
101#define PMDV_PCMCIA2		0x0602
102#define PMDV_PCMCIA3		0x0603
103/* 0x0700 - 0xdfff	Reserved			*/
104/* 0xe000 - 0xefff	OEM-defined power device IDs	*/
105/* 0xf000 - 0xffff	Reserved			*/
106
107/* Power state */
108#define PMST_APMENABLED		0x0000
109#define PMST_STANDBY		0x0001
110#define PMST_SUSPEND		0x0002
111#define PMST_OFF		0x0003
112#define PMST_LASTREQNOTIFY	0x0004
113#define PMST_LASTREQREJECT	0x0005
114/* 0x0006 - 0x001f	Reserved system states		*/
115/* 0x0020 - 0x003f	OEM-defined system states	*/
116/* 0x0040 - 0x007f	OEM-defined device states	*/
117/* 0x0080 - 0xffff	Reserved device states		*/
118
119#if !defined(ASM) && !defined(INITIALIZER)
120
121/* C definitions */
122typedef struct apm_hook_func {
123	struct apm_hook_func	*next;		/* Linked list */
124	int			(*func)(void);
125	const char		*name;
126	int			order;
127} *apm_hook_func_t;
128
129apm_hook_func_t apm_resume_hook_init(int (*func)(void), char *name, int order);
130void apm_resume_hook_delete(apm_hook_func_t delete_func);
131apm_hook_func_t apm_suspend_hook_init(int (*func)(void), char *name, int order);
132void apm_suspend_hook_delete(apm_hook_func_t delete_func);
133void apm_suspend_resume(void);
134void apm_cpu_idle(void);
135void apm_cpu_busy(void);
136
137#endif /* !ASM && !INITIALIZER */
138
139#define APM_MIN_ORDER		0x00
140#define APM_MID_ORDER		0x80
141#define APM_MAX_ORDER		0xff
142
143#endif /* KERNEL */
144
145/* power management event code */
146#define PMEV_NOEVENT		0x0000
147#define PMEV_STANDBYREQ		0x0001
148#define PMEV_SUSPENDREQ		0x0002
149#define PMEV_NORMRESUME		0x0003
150#define PMEV_CRITRESUME		0x0004
151#define PMEV_BATTERYLOW		0x0005
152#define PMEV_POWERSTATECHANGE	0x0006
153#define PMEV_UPDATETIME		0x0007
154#define PMEV_CRITSUSPEND	0x0008
155#define PMEV_USERSTANDBYREQ	0x0009
156#define PMEV_USERSUSPENDREQ	0x000a
157#define PMEV_STANDBYRESUME	0x000b
158/* 0x000c - 0x00ff	Reserved system events	*/
159/* 0x0100 - 0x01ff	Reserved device events	*/
160/* 0x0200 - 0x02ff	OEM-defined APM events	*/
161/* 0x0300 - 0xffff	Reserved		*/
162#define PMEV_DEFAULT		0xffffffff	/* used for customization */
163
164#if !defined(ASM) && !defined(INITIALIZER)
165
166typedef struct apm_info {
167	u_int	ai_major;	/* APM major version */
168	u_int	ai_minor;	/* APM minor version */
169	u_int	ai_acline;	/* AC line status */
170	u_int	ai_batt_stat;	/* Battery status */
171	u_int	ai_batt_life;	/* Remaining battery life */
172} *apm_info_t;
173
174typedef struct apm_eqv_event {
175	u_int	aee_event;	/* Event ID */
176	u_int	aee_equiv;	/* Equivalent event ID */
177	u_int	aee_resume;	/* Equivalent event ID when system resumes */
178} *apm_eqv_event_t;
179
180#define APMIO_SUSPEND		_IO('P', 1)
181#define APMIO_GETINFO		_IOR('P', 2, struct apm_info)
182#define APMIO_DEFEQV		_IOW('P', 3, struct apm_eqv_event)
183#define APMIO_FLUSHEQV		_IO('P', 4)
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
189#define APM_MAX_EQUIV_EVENTS	16
190
191#endif /* !ASM && !INITIALIZER */
192
193#endif /* _MACHINE_APM_BIOS_H_ */
194