xref: /netbsd/sys/arch/macppc/include/apmvar.h (revision c4a72b64)
1 /*	$NetBSD: apmvar.h,v 1.1 2002/06/18 05:22:51 itojun Exp $	*/
2 /*	$OpenBSD: apmvar.h,v 1.2 2001/10/03 20:06:01 drahn Exp $	*/
3 
4 /*
5  *  Copyright (c) 2001 Alexander Guy
6  *  Copyright (c) 1995 John T. Kohl
7  *  All rights reserved.
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *  1. Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *  2. Redistributions in binary form must reproduce the above copyright
15  *     notice, this list of conditions and the following disclaimer in the
16  *     documentation and/or other materials provided with the distribution.
17  *  3. The name of the author may not be used to endorse or promote products
18  *     derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 #ifndef _MACPPC_APMVAR_H_
34 #define _MACPPC_APMVAR_H_
35 
36 #include <sys/ioccom.h>
37 
38 /* Advanced Power Management (v1.0 and v1.1 specification)
39  * functions/defines/etc.
40  */
41 
42 /* These definitions make up the heart of the user-land interface
43  * to the APM devices.
44  */
45 
46 #define		APM_AC_OFF		0x00
47 #define		APM_AC_ON		0x01
48 #define		APM_AC_BACKUP		0x02
49 #define		APM_AC_UNKNOWN		0xff
50 #define		APM_BATT_HIGH		0x00
51 #define		APM_BATT_LOW		0x01
52 #define		APM_BATT_CRITICAL	0x02
53 #define		APM_BATT_CHARGING	0x03
54 #define		APM_BATT_ABSENT		0x04 /* Software only--not in spec! */
55 #define		APM_BATT_UNKNOWN	0xff
56 #define		APM_BATT_LIFE_UNKNOWN	0xff
57 
58 #define		APM_NOEVENT		0x0000
59 #define		APM_STANDBY_REQ		0x0001
60 #define		APM_SUSPEND_REQ		0x0002
61 #define		APM_NORMAL_RESUME	0x0003
62 #define		APM_CRIT_RESUME		0x0004 /* suspend/resume happened
63 						  without us */
64 #define		APM_BATTERY_LOW		0x0005
65 #define		APM_POWER_CHANGE	0x0006
66 #define		APM_UPDATE_TIME		0x0007
67 #define		APM_CRIT_SUSPEND_REQ	0x0008
68 #define		APM_USER_STANDBY_REQ	0x0009
69 #define		APM_USER_SUSPEND_REQ	0x000A
70 #define		APM_SYS_STANDBY_RESUME	0x000B
71 #define		APM_CAPABILITY_CHANGE	0x000C	/* apm v1.2 */
72 #define		APM_EVENT_MASK		0xffff
73 
74 #define	APM_EVENT_COMPOSE(t,i)	((((i) & 0x7fff) << 16)|((t) & APM_EVENT_MASK))
75 #define	APM_EVENT_TYPE(e)	((e) & APM_EVENT_MASK)
76 #define	APM_EVENT_INDEX(e)	((e) >> 16)
77 
78 /*
79  * LP (Laptop Package)
80  *
81  * Copyright (C) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp>
82  *
83  * This software may be used, modified, copied, and distributed, in
84  * both source and binary form provided that the above copyright and
85  * these terms are retained. Under no circumstances is the author
86  * responsible for the proper functioning of this software, nor does
87  * the author assume any responsibility for damages incurred with its
88  * use.
89  *
90  * Sep., 1994	Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
91  */
92 
93 struct apm_connect_info {
94 	u_int apm_code32_seg_base;	/* real-mode style segment selector */
95 	u_int apm_code16_seg_base;
96 	u_int apm_data_seg_base;
97 	u_int apm_entrypt;
98 	u_short	apm_segsel;		/* segment selector for APM */
99 	u_short _pad1;
100 	u_int apm_code32_seg_len;
101 	u_int apm_code16_seg_len;
102 	u_int apm_data_seg_len;
103 	u_int apm_detail;
104 };
105 
106 struct apm_event_info {
107 	u_int type;
108 	u_int index;
109 	u_int spare[8];
110 };
111 
112 #define APM_BATTERY_ABSENT 4
113 
114 struct apm_power_info {
115 	u_char battery_state;
116 	u_char ac_state;
117 	u_char battery_life;
118 	u_char spare1;
119 	u_int minutes_left;		/* estimate */
120 	u_int nbattery;
121 	u_int batteryid;
122 	u_int spare2[4];
123 };
124 
125 struct apm_ctl {
126 	u_int dev;
127 	u_int mode;
128 };
129 
130 #define	APM_IOC_REJECT	_IOW('A', 0, struct apm_event_info) /* reject request # */
131 #define	APM_IOC_STANDBY	_IO('A', 1)	/* put system into standby */
132 #define	APM_IOC_SUSPEND	_IO('A', 2)	/* put system into suspend */
133 #define	APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
134 #define	APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */
135 #define	APM_IOC_DEV_CTL	_IOW('A', 5, struct apm_ctl) /* put device into mode */
136 #define APM_IOC_PRN_CTL _IOW('A', 6, int ) /* driver power status msg */
137 #define		APM_PRINT_ON	0	/* driver power status displayed */
138 #define		APM_PRINT_OFF	1	/* driver power status not displayed */
139 #define		APM_PRINT_PCT	2	/* driver power status only displayed
140 					   if the percentage changes */
141 
142 #endif /* _MACPPC_APMVAR_H_ */
143