Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / hpc / include / config_hook.h
blobfb7a2653ddf46fcf5e6579fb21607afa1711f132
1 /* $NetBSD: config_hook.h,v 1.6 2005/12/11 12:17:25 christos Exp $ */
3 /*-
4 * Copyright (c) 1999-2001
5 * Shin Takemura and PocketBSD Project. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the PocketBSD project
18 * and its contributors.
19 * 4. Neither the name of the project nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
37 #ifndef _CONFIG_HOOK_H_
38 #define _CONFIG_HOOK_H_
40 enum config_hook_mode {
41 CONFIG_HOOK_SHARE,
42 CONFIG_HOOK_REPLACE,
43 CONFIG_HOOK_EXCLUSIVE,
46 typedef void *config_hook_tag;
47 typedef void *config_call_tag;
49 void config_hook_init(void);
50 config_hook_tag config_hook(int, long, enum config_hook_mode,
51 int (*func)(void *, int, long, void *), void *);
52 void config_unhook(config_hook_tag);
53 int __config_hook_call(int, long, void *, int);
54 config_call_tag config_connect(int, long);
55 void config_disconnect(config_call_tag crx);
56 int config_connected_call(config_call_tag, void *);
58 static __inline int
59 config_hook_call(int type, long id, void *msg)
61 return __config_hook_call(type, id, msg, 0);
64 static __inline int
65 config_hook_call_reverse(int type, long id, void *msg)
67 return __config_hook_call(type, id, msg, 1);
71 * hook types and IDs
73 /* apm releted events */
74 #define CONFIG_HOOK_PMEVENT 0
75 #define CONFIG_HOOK_PMEVENT_STANDBYREQ 0
76 #define CONFIG_HOOK_PMEVENT_SUSPENDREQ 1
77 #define CONFIG_HOOK_PMEVENT_HARDPOWER 2
78 #define CONFIG_HOOK_PMEVENT_BATTERY 3
79 #define CONFIG_HOOK_PMEVENT_AC 4
82 /* get value */
83 #define CONFIG_HOOK_GET 1
84 /* set value and send event */
85 #define CONFIG_HOOK_SET 2
86 /* external event */
87 #define CONFIG_HOOK_EVENT CONFIG_HOOK_SET
90 /* CONFIG_HOOK_GET/CONFIG_HOOK_SET/CONFIG_HOOK_EVENT event id's */
91 #define CONFIG_HOOK_POWER_COM0 0
92 #define CONFIG_HOOK_POWER_COM1 1
93 #define CONFIG_HOOK_POWER_COM2 2
94 #define CONFIG_HOOK_POWER_COM3 3
95 #define CONFIG_HOOK_POWER_LCDLIGHT 4
96 #define CONFIG_HOOK_POWER_LCD 5
97 #define CONFIG_HOOK_POWER_SPEAKER 6
98 #define CONFIG_HOOK_BUTTON_POWER 7
99 #define CONFIG_HOOK_BUTTON_OK 8
100 #define CONFIG_HOOK_BUTTON_CANCEL 9
101 #define CONFIG_HOOK_BUTTON_UP 10
102 #define CONFIG_HOOK_BUTTON_DOWN 11
103 #define CONFIG_HOOK_BUTTON_REC 12
104 #define CONFIG_HOOK_BUTTON_COVER 13
105 #define CONFIG_HOOK_BUTTON_LIGHT 14
106 #define CONFIG_HOOK_BUTTON_CONTRAST 15
107 #define CONFIG_HOOK_BUTTON_APP0 16
108 #define CONFIG_HOOK_BUTTON_APP1 17
109 #define CONFIG_HOOK_BUTTON_APP2 18
110 #define CONFIG_HOOK_BUTTON_APP3 19
111 #define CONFIG_HOOK_BUTTON_LEFT 20
112 #define CONFIG_HOOK_BUTTON_RIGHT 21
113 #define CONFIG_HOOK_BUTTON_CONTRAST_UP 22
114 #define CONFIG_HOOK_BUTTON_CONTRAST_DOWN 23
115 #define CONFIG_HOOK_BUTTON_LIGHT_UP 24
116 #define CONFIG_HOOK_BUTTON_LIGHT_DOWN 25
117 #define CONFIG_HOOK_LED 26
118 #define CONFIG_HOOK_LED_MAX 27
119 #define CONFIG_HOOK_CONTRAST 28
120 #define CONFIG_HOOK_CONTRAST_MAX 29
121 #define CONFIG_HOOK_BRIGHTNESS 30
122 #define CONFIG_HOOK_BRIGHTNESS_MAX 31
123 #define CONFIG_HOOK_COM0_CTS 32
124 #define CONFIG_HOOK_COM1_CTS 33
125 #define CONFIG_HOOK_COM2_CTS 34
126 #define CONFIG_HOOK_COM3_CTS 35
127 #define CONFIG_HOOK_COM0_DCD 36
128 #define CONFIG_HOOK_COM1_DCD 37
129 #define CONFIG_HOOK_COM2_DCD 38
130 #define CONFIG_HOOK_COM3_DCD 39
131 #define CONFIG_HOOK_COM0_RTS 40
132 #define CONFIG_HOOK_COM1_RTS 41
133 #define CONFIG_HOOK_COM2_RTS 42
134 #define CONFIG_HOOK_COM3_RTS 43
135 #define CONFIG_HOOK_COM0_DTR 44
136 #define CONFIG_HOOK_COM1_DTR 45
137 #define CONFIG_HOOK_COM2_DTR 46
138 #define CONFIG_HOOK_COM3_DTR 47
139 #define CONFIG_HOOK_BATTERYVAL 48
140 #define CONFIG_HOOK_ACADAPTER 49
141 #define CONFIG_HOOK_CHARGE 50
143 /* power control type */
144 #define CONFIG_HOOK_POWERCONTROL 3
145 #define CONFIG_HOOK_POWERCONTROL_COM0 CONFIG_HOOK_POWER_COM0
146 #define CONFIG_HOOK_POWERCONTROL_COM1 CONFIG_HOOK_POWER_COM1
147 #define CONFIG_HOOK_POWERCONTROL_COM2 CONFIG_HOOK_POWER_COM2
148 #define CONFIG_HOOK_POWERCONTROL_COM3 CONFIG_HOOK_POWER_COM3
149 #define CONFIG_HOOK_POWERCONTROL_LCDLIGHT CONFIG_HOOK_POWER_LCDLIGHT
150 #define CONFIG_HOOK_POWERCONTROL_LCD CONFIG_HOOK_POWER_LCD
151 #define CONFIG_HOOK_POWERCONTROL_SPEAKER CONFIG_HOOK_POWER_SPEAKER
152 #define CONFIG_HOOK_POWERCONTROL_LED CONFIG_HOOK_LED
154 /* button event type */
155 #define CONFIG_HOOK_BUTTONEVENT 4
156 #define CONFIG_HOOK_BUTTONEVENT_POWER CONFIG_HOOK_BUTTON_POWER
157 #define CONFIG_HOOK_BUTTONEVENT_OK CONFIG_HOOK_BUTTON_OK
158 #define CONFIG_HOOK_BUTTONEVENT_CANCEL CONFIG_HOOK_BUTTON_CANCEL
159 #define CONFIG_HOOK_BUTTONEVENT_UP CONFIG_HOOK_BUTTON_UP
160 #define CONFIG_HOOK_BUTTONEVENT_DOWN CONFIG_HOOK_BUTTON_DOWN
161 #define CONFIG_HOOK_BUTTONEVENT_REC CONFIG_HOOK_BUTTON_REC
162 #define CONFIG_HOOK_BUTTONEVENT_COVER CONFIG_HOOK_BUTTON_COVER
163 #define CONFIG_HOOK_BUTTONEVENT_LIGHT CONFIG_HOOK_BUTTON_LIGHT
164 #define CONFIG_HOOK_BUTTONEVENT_CONTRAST CONFIG_HOOK_BUTTON_CONTRAST
165 #define CONFIG_HOOK_BUTTONEVENT_APP0 CONFIG_HOOK_BUTTON_APP0
166 #define CONFIG_HOOK_BUTTONEVENT_APP1 CONFIG_HOOK_BUTTON_APP1
167 #define CONFIG_HOOK_BUTTONEVENT_APP2 CONFIG_HOOK_BUTTON_APP2
168 #define CONFIG_HOOK_BUTTONEVENT_APP3 CONFIG_HOOK_BUTTON_APP3
169 #define CONFIG_HOOK_BUTTONEVENT_LEFT CONFIG_HOOK_BUTTON_LEFT
170 #define CONFIG_HOOK_BUTTONEVENT_RIGHT CONFIG_HOOK_BUTTON_RIGHT
171 #define CONFIG_HOOK_BUTTONEVENT_CONTRAST_UP CONFIG_HOOK_BUTTON_CONTRAST_UP
172 #define CONFIG_HOOK_BUTTONEVENT_CONTRAST_DOWN CONFIG_HOOK_BUTTON_CONTRAST_DOWN
173 #define CONFIG_HOOK_BUTTONEVENT_LIGHT_UP CONFIG_HOOK_BUTTON_LIGHT_UP
174 #define CONFIG_HOOK_BUTTONEVENT_LIGHT_DOWN CONFIG_HOOK_BUTTON_LIGHT_DOWN
176 /* PCI interrupt type */
177 #define CONFIG_HOOK_PCIINTR 5
178 #define CONFIG_HOOK_PCIINTR_ID(bus, dev, func) \
179 (((bus) << 16) | ((dev) << 11) | ((func) << 8))
180 #define CONFIG_HOOK_PCIINTR_BUS(id) (((id) >> 16) & 0xff)
181 #define CONFIG_HOOK_PCIINTR_DEVICE(id) (((id) >> 11) & 0x1f)
182 #define CONFIG_HOOK_PCIINTR_FUNCTION(id) (((id) >> 8) & 0x07)
184 #define CONFIG_HOOK_NTYPES 6
187 * nicknames for including from configuration file.
189 #ifdef CONFIG_HOOK_DEFINE_NICKNAME
190 /* type nicknames */
191 #define PMEVENT CONFIG_HOOK_PMEVENT
192 #define SET CONFIG_HOOK_SET
193 #define EVENT CONFIG_HOOK_EVENT
194 #define GET CONFIG_HOOK_GET
195 #define POWER CONFIG_HOOK_POWERCONTROL
196 #define BUTTON CONFIG_HOOK_BUTTONEVENT
197 #define PCIINTR CONFIG_HOOK_PCIINTR
199 /* ID nicknames */
200 /* power contorol */
201 #define PWCTL_COM0 CONFIG_HOOK_POWER_COM0
202 #define PWCTL_COM1 CONFIG_HOOK_POWER_COM1
203 #define PWCTL_COM2 CONFIG_HOOK_POWER_COM2
204 #define PWCTL_COM3 CONFIG_HOOK_POWER_COM3
205 #define PWCTL_LCDLIGHT CONFIG_HOOK_POWER_LCDLIGHT
206 #define PWCTL_LCD CONFIG_HOOK_POWER_LCD
207 #define PWCTL_SPEAKER CONFIG_HOOK_POWER_SPEAKER
208 #define PWCTL_LED CONFIG_HOOK_LED
209 /* buttons */
210 #define BTN_POWER CONFIG_HOOK_BUTTON_POWER
211 #define BTN_OK CONFIG_HOOK_BUTTON_OK
212 #define BTN_CANCEL CONFIG_HOOK_BUTTON_CANCEL
213 #define BTN_UP CONFIG_HOOK_BUTTON_UP
214 #define BTN_DOWN CONFIG_HOOK_BUTTON_DOWN
215 #define BTN_REC CONFIG_HOOK_BUTTON_REC
216 #define BTN_COVER CONFIG_HOOK_BUTTON_COVER
217 #define BTN_LIGHT CONFIG_HOOK_BUTTON_LIGHT
218 #define BTN_CONTRAST CONFIG_HOOK_BUTTON_CONTRAST
219 #define BTN_APP0 CONFIG_HOOK_BUTTON_APP0
220 #define BTN_APP1 CONFIG_HOOK_BUTTON_APP1
221 #define BTN_APP2 CONFIG_HOOK_BUTTON_APP2
222 #define BTN_APP3 CONFIG_HOOK_BUTTON_APP3
223 #define BTN_LEFT CONFIG_HOOK_BUTTON_LEFT
224 #define BTN_RIGHT CONFIG_HOOK_BUTTON_RIGHT
225 #define BTN_CONTRAST_UP CONFIG_HOOK_BUTTON_CONTRAST_UP
226 #define BTN_CONTRAST_DN CONFIG_HOOK_BUTTON_CONTRAST_DOWN
227 #define BTN_LIGHT_UP CONFIG_HOOK_BUTTON_LIGHT_UP
228 #define BTN_LIGHT_DN CONFIG_HOOK_BUTTON_LIGHT_DOWN
229 /* PMEVENT */
230 #define PME_STANBY CONFIG_HOOK_PMEVENT_STANDBYREQ
231 #define PME_SUSPEND CONFIG_HOOK_PMEVENT_SUSPENDREQ
232 #define PME_HARDPOWER CONFIG_HOOK_PMEVENT_HARDPOWER
233 #define PME_BATTERY CONFIG_HOOK_PMEVENT_BATTERY
234 #define PME_AC CONFIG_HOOK_PMEVENT_AC
235 /* set/get */
236 #define POWER_COM0 CONFIG_HOOK_POWER_COM0
237 #define POWER_COM1 CONFIG_HOOK_POWER_COM1
238 #define POWER_COM2 CONFIG_HOOK_POWER_COM2
239 #define POWER_COM3 CONFIG_HOOK_POWER_COM3
240 #define POWER_LCDLIGHT CONFIG_HOOK_POWER_LCDLIGHT
241 #define POWER_LCD CONFIG_HOOK_POWER_LCD
242 #define POWER_SPEAKER CONFIG_HOOK_POWER_SPEAKER
243 #define BUTTON_POWER CONFIG_HOOK_BUTTON_POWER
244 #define BUTTON_OK CONFIG_HOOK_BUTTON_OK
245 #define BUTTON_CANCEL CONFIG_HOOK_BUTTON_CANCEL
246 #define BUTTON_UP CONFIG_HOOK_BUTTON_UP
247 #define BUTTON_DOWN CONFIG_HOOK_BUTTON_DOWN
248 #define BUTTON_REC CONFIG_HOOK_BUTTON_REC
249 #define BUTTON_COVER CONFIG_HOOK_BUTTON_COVER
250 #define BUTTON_LIGHT CONFIG_HOOK_BUTTON_LIGHT
251 #define BUTTON_CONTRAST CONFIG_HOOK_BUTTON_CONTRAST
252 #define BUTTON_APP0 CONFIG_HOOK_BUTTON_APP0
253 #define BUTTON_APP1 CONFIG_HOOK_BUTTON_APP1
254 #define BUTTON_APP2 CONFIG_HOOK_BUTTON_APP2
255 #define BUTTON_APP3 CONFIG_HOOK_BUTTON_APP3
256 #define BUTTON_LEFT CONFIG_HOOK_BUTTON_LEFT
257 #define BUTTON_RIGHT CONFIG_HOOK_BUTTON_RIGHT
258 #define BUTTON_CONTRAST_UP CONFIG_HOOK_BUTTON_CONTRAST_UP
259 #define BUTTON_CONTRAST_DOWN CONFIG_HOOK_BUTTON_CONTRAST_DOWN
260 #define BUTTON_LIFHT_UP CONFIG_HOOK_BUTTON_LIGHT_UP
261 #define BUTTON_LIFHT_DOWN CONFIG_HOOK_BUTTON_LIGHT_DOWN
262 #define LED CONFIG_HOOK_LED
263 #define LED_MAX CONFIG_HOOK_LED_MAX
264 #define CONTRAST CONFIG_HOOK_CONTRAST
265 #define CONTRAST_MAX CONFIG_HOOK_CONTRAST_MAX
266 #define BRIGHTNESS CONFIG_HOOK_BRIGHTNESS
267 #define BRIGHTNESS_MAX CONFIG_HOOK_BRIGHTNESS_MAX
268 #define COM0_CTS CONFIG_HOOK_COM0_CTS
269 #define COM1_CTS CONFIG_HOOK_COM1_CTS
270 #define COM2_CTS CONFIG_HOOK_COM2_CTS
271 #define COM3_CTS CONFIG_HOOK_COM3_CTS
272 #define COM0_DCD CONFIG_HOOK_COM0_DCD
273 #define COM1_DCD CONFIG_HOOK_COM1_DCD
274 #define COM2_DCD CONFIG_HOOK_COM2_DCD
275 #define COM3_DCD CONFIG_HOOK_COM3_DCD
276 #define COM0_RTS CONFIG_HOOK_COM0_RTS
277 #define COM1_RTS CONFIG_HOOK_COM1_RTS
278 #define COM2_RTS CONFIG_HOOK_COM2_RTS
279 #define COM3_RTS CONFIG_HOOK_COM3_RTS
280 #define COM0_DTR CONFIG_HOOK_COM0_DTR
281 #define COM1_DTR CONFIG_HOOK_COM1_DTR
282 #define COM2_DTR CONFIG_HOOK_COM2_DTR
283 #define COM3_DTR CONFIG_HOOK_COM3_DTR
284 #define BATTERYVAL CONFIG_HOOK_BATTERYVAL
285 #define ACADAPTER CONFIG_HOOK_ACADAPTER
286 #define CHARGE CONFIG_HOOK_CHARGE
287 /* PCI interrupt */
288 #define PCIINTR_ID(bus, dev, func) CONFIG_HOOK_PCIINTR_ID(bus, dev, func)
289 #define PCIINTR_00_00_00 PCIINTR_ID(0, 0, 0)
290 #define PCIINTR_00_00_01 PCIINTR_ID(0, 0, 1)
291 #define PCIINTR_00_01_00 PCIINTR_ID(0, 1, 0)
292 #define PCIINTR_00_12_00 PCIINTR_ID(0, 12, 0)
293 #define PCIINTR_00_12_02 PCIINTR_ID(0, 12, 2)
294 #define PCIINTR_00_16_00 PCIINTR_ID(0, 16, 0)
295 #define PCIINTR_00_19_00 PCIINTR_ID(0, 19, 0)
296 #define PCIINTR_00_19_02 PCIINTR_ID(0, 19, 2)
297 #endif /* CONFIG_HOOK_DEFINE_NICKNAME */
300 * POWERCONTROL value
302 #define PWCTL_ON ((void *)1)
303 #define PWCTL_OFF ((void *)0)
305 /* CONFIG_HOOK typical value */
306 #define CONFIG_HOOK_ON 1
307 #define CONFIG_HOOK_OFF 0
310 * CONFIG_HOOK_LED value
312 #define CONFIG_HOOK_LED_ON 0
313 #define CONFIG_HOOK_LED_OFF 1
314 #define CONFIG_HOOK_LED_FLASH 2 /* flash 100msec */
315 #define CONFIG_HOOK_LED_FLASH2 3 /* flash 200msec */
316 #define CONFIG_HOOK_LED_FLASH5 4 /* flash 500msec */
317 #define CONFIG_HOOK_LED_BLINK 5 /* blink 1sec interval */
318 #define CONFIG_HOOK_LED_BLINK2 6 /* blink 2sec interval */
321 * CONFIG_HOOK_AC event value
323 #define CONFIG_HOOK_AC_OFF 0
324 #define CONFIG_HOOK_AC_ON_CHARGE 1
325 #define CONFIG_HOOK_AC_ON_NOCHARGE 2
326 #define CONFIG_HOOK_AC_UNKNOWN 3
329 * CONFIG_HOOK_BATTERY event value
331 #define CONFIG_HOOK_BATT_CRITICAL 0
332 #define CONFIG_HOOK_BATT_10P 1
333 #define CONFIG_HOOK_BATT_20P 2
334 #define CONFIG_HOOK_BATT_30P 3
335 #define CONFIG_HOOK_BATT_LOW 4
336 #define CONFIG_HOOK_BATT_40P 5
337 #define CONFIG_HOOK_BATT_50P 6
338 #define CONFIG_HOOK_BATT_60P 7
339 #define CONFIG_HOOK_BATT_70P 8
340 #define CONFIG_HOOK_BATT_HIGH 9
341 #define CONFIG_HOOK_BATT_80P 10
342 #define CONFIG_HOOK_BATT_90P 11
343 #define CONFIG_HOOK_BATT_100P 12
344 #define CONFIG_HOOK_BATT_UNKNOWN 13
345 #define CONFIG_HOOK_BATT_NO_SYSTEM_BATTERY 14
347 #define CONFIG_HOOK_MAXVALUE 14 /* max value, check in this file */
348 #define CONFIG_HOOK_VALUEP(p) \
349 ((int)(p) >= 0 && (int)(p) <= CONFIG_HOOK_MAXVALUE)
350 #define CONFIG_HOOK_PTRP(p) (!CONFIG_HOOK_VALUEP(p))
352 #endif /* _CONFIG_HOOK_H_ */