Deleted Added
full compact
acpivar.h (84575) acpivar.h (85556)
1/*-
2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000 BSDi
5 * All rights reserved.
6 *
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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000 BSDi
5 * All rights reserved.
6 *
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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/acpica/acpivar.h 84575 2001-10-06 04:09:26Z peter $
28 * $FreeBSD: head/sys/dev/acpica/acpivar.h 85556 2001-10-26 17:43:05Z iwasaki $
29 */
30
31#include "bus_if.h"
32#include <sys/eventhandler.h>
33#include <sys/sysctl.h>
34
35#include <machine/bus.h>
36#include <machine/resource.h>
37
38extern devclass_t acpi_devclass;
39
40struct acpi_softc {
41 device_t acpi_dev;
42 dev_t acpi_dev_t;
43
44 struct resource *acpi_irq;
45 int acpi_irq_rid;
46 void *acpi_irq_handle;
47
48 int acpi_enabled;
49 int acpi_sstate;
50
51 struct sysctl_ctx_list acpi_sysctl_ctx;
52 struct sysctl_oid *acpi_sysctl_tree;
53#define ACPI_POWER_BUTTON_DEFAULT_SX ACPI_STATE_S5;
54#define ACPI_SLEEP_BUTTON_DEFAULT_SX ACPI_STATE_S1;
55#define ACPI_LID_SWITCH_DEFAULT_SX ACPI_STATE_S1;
56 int acpi_power_button_sx;
57 int acpi_sleep_button_sx;
58 int acpi_lid_switch_sx;
59
29 */
30
31#include "bus_if.h"
32#include <sys/eventhandler.h>
33#include <sys/sysctl.h>
34
35#include <machine/bus.h>
36#include <machine/resource.h>
37
38extern devclass_t acpi_devclass;
39
40struct acpi_softc {
41 device_t acpi_dev;
42 dev_t acpi_dev_t;
43
44 struct resource *acpi_irq;
45 int acpi_irq_rid;
46 void *acpi_irq_handle;
47
48 int acpi_enabled;
49 int acpi_sstate;
50
51 struct sysctl_ctx_list acpi_sysctl_ctx;
52 struct sysctl_oid *acpi_sysctl_tree;
53#define ACPI_POWER_BUTTON_DEFAULT_SX ACPI_STATE_S5;
54#define ACPI_SLEEP_BUTTON_DEFAULT_SX ACPI_STATE_S1;
55#define ACPI_LID_SWITCH_DEFAULT_SX ACPI_STATE_S1;
56 int acpi_power_button_sx;
57 int acpi_sleep_button_sx;
58 int acpi_lid_switch_sx;
59
60 int acpi_standby_sx;
61 int acpi_suspend_sx;
62
60 bus_dma_tag_t acpi_waketag;
61 bus_dmamap_t acpi_wakemap;
62 vm_offset_t acpi_wakeaddr;
63 vm_offset_t acpi_wakephys;
64
65 struct sysctl_ctx_list acpi_battery_sysctl_ctx;
66 struct sysctl_oid *acpi_battery_sysctl_tree;
67};
68
69struct acpi_device {
70 /* ACPI ivars */
71 ACPI_HANDLE ad_handle;
72 int ad_magic;
73 void *ad_private;
74
75 /* resources */
76 struct resource_list ad_rl;
77
78};
79
80/*
81 * The ACPI subsystem lives under a single mutex. You *must*
82 * acquire this mutex before calling any of the acpi_ or Acpi* functions.
83 *
84 * XXX the ACPI_MSLEEP macro should go away once locking is resolved
85 */
86extern struct mtx acpi_mutex;
87#if 0
88# define ACPI_LOCK mtx_lock(&acpi_mutex)
89# define ACPI_UNLOCK mtx_unlock(&acpi_mutex)
90# define ACPI_ASSERTLOCK mtx_assert(&acpi_mutex, MA_OWNED)
91# define ACPI_MSLEEP(a, b, c, d, e) msleep(a, b, c, d, e)
92#else
93# define ACPI_LOCK
94# define ACPI_UNLOCK
95# define ACPI_ASSERTLOCK
96# define ACPI_MSLEEP(a, b, c, d, e) tsleep(a, c, d, e)
97#endif
98
99/*
100 * This is a cheap and nasty way to get around the horrid counted list
101 * argument format that AcpiEvalateObject uses.
102 */
103#define ACPI_OBJECTLIST_MAX 16
104struct acpi_object_list {
105 UINT32 count;
106 ACPI_OBJECT *pointer[ACPI_OBJECTLIST_MAX];
107 ACPI_OBJECT object[ACPI_OBJECTLIST_MAX];
108};
109
110static __inline struct acpi_object_list *
111acpi_AllocObjectList(int nobj)
112{
113 struct acpi_object_list *l;
114 int i;
115
116 if (nobj > ACPI_OBJECTLIST_MAX)
117 return(NULL);
118 if ((l = AcpiOsAllocate(sizeof(*l))) == NULL)
119 return(NULL);
120 bzero(l, sizeof(*l));
121 for (i = 0; i < ACPI_OBJECTLIST_MAX; i++)
122 l->pointer[i] = &l->object[i];
123 l->count = nobj;
124 return(l);
125}
126
127/*
128 * Note that the low ivar values are reserved to provide
129 * interface compatibility with ISA drivers which can also
130 * attach to ACPI.
131 */
132#define ACPI_IVAR_HANDLE 0x100
133#define ACPI_IVAR_MAGIC 0x101
134#define ACPI_IVAR_PRIVATE 0x102
135
136static __inline ACPI_HANDLE
137acpi_get_handle(device_t dev)
138{
139 uintptr_t up;
140 ACPI_HANDLE h;
141
142 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, &up))
143 return(NULL);
144 h = (ACPI_HANDLE)up;
145 return(h);
146}
147
148static __inline int
149acpi_set_handle(device_t dev, ACPI_HANDLE h)
150{
151 uintptr_t up;
152
153 up = (uintptr_t)h;
154 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, up));
155}
156
157static __inline int
158acpi_get_magic(device_t dev)
159{
160 uintptr_t up;
161 int m;
162
163 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, &up))
164 return(0);
165 m = (int)up;
166 return(m);
167}
168
169static __inline int
170acpi_set_magic(device_t dev, int m)
171{
172 uintptr_t up;
173
174 up = (uintptr_t)m;
175 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, up));
176}
177
178static __inline void *
179acpi_get_private(device_t dev)
180{
181 uintptr_t up;
182 void *p;
183
184 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, &up))
185 return(NULL);
186 p = (void *)up;
187 return(p);
188}
189
190static __inline int
191acpi_set_private(device_t dev, void *p)
192{
193 uintptr_t up;
194
195 up = (uintptr_t)p;
196 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, up));
197}
198
199static __inline ACPI_OBJECT_TYPE
200acpi_get_type(device_t dev)
201{
202 ACPI_HANDLE h;
203 ACPI_OBJECT_TYPE t;
204
205 if ((h = acpi_get_handle(dev)) == NULL)
206 return(ACPI_TYPE_NOT_FOUND);
207 if (AcpiGetType(h, &t) != AE_OK)
208 return(ACPI_TYPE_NOT_FOUND);
209 return(t);
210}
211
212#ifdef ENABLE_DEBUGGER
213extern void acpi_EnterDebugger(void);
214#endif
215
216#ifdef ACPI_DEBUG
217#include <sys/cons.h>
218#define STEP(x) do {printf x, printf("\n"); cngetc();} while (0)
219#else
220#define STEP(x)
221#endif
222
223extern BOOLEAN acpi_DeviceIsPresent(device_t dev);
224extern BOOLEAN acpi_MatchHid(device_t dev, char *hid);
225extern ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result);
226extern ACPI_BUFFER *acpi_AllocBuffer(int size);
227extern ACPI_STATUS acpi_GetIntoBuffer(ACPI_HANDLE handle,
228 ACPI_STATUS (*func)(ACPI_HANDLE, ACPI_BUFFER *),
229 ACPI_BUFFER *buf);
230extern ACPI_STATUS acpi_GetTableIntoBuffer(ACPI_TABLE_TYPE table, UINT32 instance, ACPI_BUFFER *buf);
231extern ACPI_STATUS acpi_EvaluateIntoBuffer(ACPI_HANDLE object, ACPI_STRING pathname,
232 ACPI_OBJECT_LIST *params, ACPI_BUFFER *buf);
233extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number);
234extern ACPI_STATUS acpi_ForeachPackageObject(ACPI_OBJECT *obj,
235 void (* func)(ACPI_OBJECT *comp, void *arg),
236 void *arg);
237extern ACPI_STATUS acpi_FindIndexedResource(ACPI_BUFFER *buf, int index, ACPI_RESOURCE **resp);
238extern ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res);
239
240extern ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state);
241extern ACPI_STATUS acpi_Enable(struct acpi_softc *sc);
242extern ACPI_STATUS acpi_Disable(struct acpi_softc *sc);
243
244struct acpi_parse_resource_set {
245 void (* set_init)(device_t dev, void **context);
246 void (* set_done)(device_t dev, void *context);
247 void (* set_ioport)(device_t dev, void *context, u_int32_t base, u_int32_t length);
248 void (* set_iorange)(device_t dev, void *context, u_int32_t low, u_int32_t high,
249 u_int32_t length, u_int32_t align);
250 void (* set_memory)(device_t dev, void *context, u_int32_t base, u_int32_t length);
251 void (* set_memoryrange)(device_t dev, void *context, u_int32_t low, u_int32_t high,
252 u_int32_t length, u_int32_t align);
253 void (* set_irq)(device_t dev, void *context, u_int32_t irq);
254 void (* set_drq)(device_t dev, void *context, u_int32_t drq);
255 void (* set_start_dependant)(device_t dev, void *context, int preference);
256 void (* set_end_dependant)(device_t dev, void *context);
257};
258
259extern struct acpi_parse_resource_set acpi_res_parse_set;
260extern ACPI_STATUS acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
261 struct acpi_parse_resource_set *set);
262/* XXX until Intel fix this in their headers, based on NEXT_RESOURCE */
263#define ACPI_RESOURCE_NEXT(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length)
264
265/*
266 * ACPI event handling
267 */
268extern UINT32 acpi_eventhandler_power_button_for_sleep(void *context);
269extern UINT32 acpi_eventhandler_power_button_for_wakeup(void *context);
270extern UINT32 acpi_eventhandler_sleep_button_for_sleep(void *context);
271extern UINT32 acpi_eventhandler_sleep_button_for_wakeup(void *context);
272
273#define ACPI_EVENT_PRI_FIRST 0
274#define ACPI_EVENT_PRI_DEFAULT 10000
275#define ACPI_EVENT_PRI_LAST 20000
276
277typedef void (*acpi_event_handler_t) __P((void *, int));
278
279EVENTHANDLER_DECLARE(acpi_sleep_event, acpi_event_handler_t);
280EVENTHANDLER_DECLARE(acpi_wakeup_event, acpi_event_handler_t);
281
282/*
283 * Device power control.
284 */
285extern ACPI_STATUS acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state);
286
287/*
288 * Misc.
289 */
290static __inline struct acpi_softc *
291acpi_device_get_parent_softc(device_t child)
292{
293 device_t parent;
294
295 parent = device_get_parent(child);
296 if (parent == NULL) {
297 return(NULL);
298 }
299 return(device_get_softc(parent));
300}
301
302extern char *acpi_name(ACPI_HANDLE handle);
303extern int acpi_avoid(ACPI_HANDLE handle);
304extern int acpi_disabled(char *subsys);
305
63 bus_dma_tag_t acpi_waketag;
64 bus_dmamap_t acpi_wakemap;
65 vm_offset_t acpi_wakeaddr;
66 vm_offset_t acpi_wakephys;
67
68 struct sysctl_ctx_list acpi_battery_sysctl_ctx;
69 struct sysctl_oid *acpi_battery_sysctl_tree;
70};
71
72struct acpi_device {
73 /* ACPI ivars */
74 ACPI_HANDLE ad_handle;
75 int ad_magic;
76 void *ad_private;
77
78 /* resources */
79 struct resource_list ad_rl;
80
81};
82
83/*
84 * The ACPI subsystem lives under a single mutex. You *must*
85 * acquire this mutex before calling any of the acpi_ or Acpi* functions.
86 *
87 * XXX the ACPI_MSLEEP macro should go away once locking is resolved
88 */
89extern struct mtx acpi_mutex;
90#if 0
91# define ACPI_LOCK mtx_lock(&acpi_mutex)
92# define ACPI_UNLOCK mtx_unlock(&acpi_mutex)
93# define ACPI_ASSERTLOCK mtx_assert(&acpi_mutex, MA_OWNED)
94# define ACPI_MSLEEP(a, b, c, d, e) msleep(a, b, c, d, e)
95#else
96# define ACPI_LOCK
97# define ACPI_UNLOCK
98# define ACPI_ASSERTLOCK
99# define ACPI_MSLEEP(a, b, c, d, e) tsleep(a, c, d, e)
100#endif
101
102/*
103 * This is a cheap and nasty way to get around the horrid counted list
104 * argument format that AcpiEvalateObject uses.
105 */
106#define ACPI_OBJECTLIST_MAX 16
107struct acpi_object_list {
108 UINT32 count;
109 ACPI_OBJECT *pointer[ACPI_OBJECTLIST_MAX];
110 ACPI_OBJECT object[ACPI_OBJECTLIST_MAX];
111};
112
113static __inline struct acpi_object_list *
114acpi_AllocObjectList(int nobj)
115{
116 struct acpi_object_list *l;
117 int i;
118
119 if (nobj > ACPI_OBJECTLIST_MAX)
120 return(NULL);
121 if ((l = AcpiOsAllocate(sizeof(*l))) == NULL)
122 return(NULL);
123 bzero(l, sizeof(*l));
124 for (i = 0; i < ACPI_OBJECTLIST_MAX; i++)
125 l->pointer[i] = &l->object[i];
126 l->count = nobj;
127 return(l);
128}
129
130/*
131 * Note that the low ivar values are reserved to provide
132 * interface compatibility with ISA drivers which can also
133 * attach to ACPI.
134 */
135#define ACPI_IVAR_HANDLE 0x100
136#define ACPI_IVAR_MAGIC 0x101
137#define ACPI_IVAR_PRIVATE 0x102
138
139static __inline ACPI_HANDLE
140acpi_get_handle(device_t dev)
141{
142 uintptr_t up;
143 ACPI_HANDLE h;
144
145 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, &up))
146 return(NULL);
147 h = (ACPI_HANDLE)up;
148 return(h);
149}
150
151static __inline int
152acpi_set_handle(device_t dev, ACPI_HANDLE h)
153{
154 uintptr_t up;
155
156 up = (uintptr_t)h;
157 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, up));
158}
159
160static __inline int
161acpi_get_magic(device_t dev)
162{
163 uintptr_t up;
164 int m;
165
166 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, &up))
167 return(0);
168 m = (int)up;
169 return(m);
170}
171
172static __inline int
173acpi_set_magic(device_t dev, int m)
174{
175 uintptr_t up;
176
177 up = (uintptr_t)m;
178 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, up));
179}
180
181static __inline void *
182acpi_get_private(device_t dev)
183{
184 uintptr_t up;
185 void *p;
186
187 if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, &up))
188 return(NULL);
189 p = (void *)up;
190 return(p);
191}
192
193static __inline int
194acpi_set_private(device_t dev, void *p)
195{
196 uintptr_t up;
197
198 up = (uintptr_t)p;
199 return(BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, up));
200}
201
202static __inline ACPI_OBJECT_TYPE
203acpi_get_type(device_t dev)
204{
205 ACPI_HANDLE h;
206 ACPI_OBJECT_TYPE t;
207
208 if ((h = acpi_get_handle(dev)) == NULL)
209 return(ACPI_TYPE_NOT_FOUND);
210 if (AcpiGetType(h, &t) != AE_OK)
211 return(ACPI_TYPE_NOT_FOUND);
212 return(t);
213}
214
215#ifdef ENABLE_DEBUGGER
216extern void acpi_EnterDebugger(void);
217#endif
218
219#ifdef ACPI_DEBUG
220#include <sys/cons.h>
221#define STEP(x) do {printf x, printf("\n"); cngetc();} while (0)
222#else
223#define STEP(x)
224#endif
225
226extern BOOLEAN acpi_DeviceIsPresent(device_t dev);
227extern BOOLEAN acpi_MatchHid(device_t dev, char *hid);
228extern ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result);
229extern ACPI_BUFFER *acpi_AllocBuffer(int size);
230extern ACPI_STATUS acpi_GetIntoBuffer(ACPI_HANDLE handle,
231 ACPI_STATUS (*func)(ACPI_HANDLE, ACPI_BUFFER *),
232 ACPI_BUFFER *buf);
233extern ACPI_STATUS acpi_GetTableIntoBuffer(ACPI_TABLE_TYPE table, UINT32 instance, ACPI_BUFFER *buf);
234extern ACPI_STATUS acpi_EvaluateIntoBuffer(ACPI_HANDLE object, ACPI_STRING pathname,
235 ACPI_OBJECT_LIST *params, ACPI_BUFFER *buf);
236extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number);
237extern ACPI_STATUS acpi_ForeachPackageObject(ACPI_OBJECT *obj,
238 void (* func)(ACPI_OBJECT *comp, void *arg),
239 void *arg);
240extern ACPI_STATUS acpi_FindIndexedResource(ACPI_BUFFER *buf, int index, ACPI_RESOURCE **resp);
241extern ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res);
242
243extern ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state);
244extern ACPI_STATUS acpi_Enable(struct acpi_softc *sc);
245extern ACPI_STATUS acpi_Disable(struct acpi_softc *sc);
246
247struct acpi_parse_resource_set {
248 void (* set_init)(device_t dev, void **context);
249 void (* set_done)(device_t dev, void *context);
250 void (* set_ioport)(device_t dev, void *context, u_int32_t base, u_int32_t length);
251 void (* set_iorange)(device_t dev, void *context, u_int32_t low, u_int32_t high,
252 u_int32_t length, u_int32_t align);
253 void (* set_memory)(device_t dev, void *context, u_int32_t base, u_int32_t length);
254 void (* set_memoryrange)(device_t dev, void *context, u_int32_t low, u_int32_t high,
255 u_int32_t length, u_int32_t align);
256 void (* set_irq)(device_t dev, void *context, u_int32_t irq);
257 void (* set_drq)(device_t dev, void *context, u_int32_t drq);
258 void (* set_start_dependant)(device_t dev, void *context, int preference);
259 void (* set_end_dependant)(device_t dev, void *context);
260};
261
262extern struct acpi_parse_resource_set acpi_res_parse_set;
263extern ACPI_STATUS acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
264 struct acpi_parse_resource_set *set);
265/* XXX until Intel fix this in their headers, based on NEXT_RESOURCE */
266#define ACPI_RESOURCE_NEXT(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length)
267
268/*
269 * ACPI event handling
270 */
271extern UINT32 acpi_eventhandler_power_button_for_sleep(void *context);
272extern UINT32 acpi_eventhandler_power_button_for_wakeup(void *context);
273extern UINT32 acpi_eventhandler_sleep_button_for_sleep(void *context);
274extern UINT32 acpi_eventhandler_sleep_button_for_wakeup(void *context);
275
276#define ACPI_EVENT_PRI_FIRST 0
277#define ACPI_EVENT_PRI_DEFAULT 10000
278#define ACPI_EVENT_PRI_LAST 20000
279
280typedef void (*acpi_event_handler_t) __P((void *, int));
281
282EVENTHANDLER_DECLARE(acpi_sleep_event, acpi_event_handler_t);
283EVENTHANDLER_DECLARE(acpi_wakeup_event, acpi_event_handler_t);
284
285/*
286 * Device power control.
287 */
288extern ACPI_STATUS acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state);
289
290/*
291 * Misc.
292 */
293static __inline struct acpi_softc *
294acpi_device_get_parent_softc(device_t child)
295{
296 device_t parent;
297
298 parent = device_get_parent(child);
299 if (parent == NULL) {
300 return(NULL);
301 }
302 return(device_get_softc(parent));
303}
304
305extern char *acpi_name(ACPI_HANDLE handle);
306extern int acpi_avoid(ACPI_HANDLE handle);
307extern int acpi_disabled(char *subsys);
308
309extern int acpi_machdep_init(device_t dev);
306extern void acpi_install_wakeup_handler(struct acpi_softc *sc);
307extern int acpi_sleep_machdep(struct acpi_softc *sc, int state);
308
309/*
310 * Battery Abstruction.
311 */
312struct acpi_battinfo;
310extern void acpi_install_wakeup_handler(struct acpi_softc *sc);
311extern int acpi_sleep_machdep(struct acpi_softc *sc, int state);
312
313/*
314 * Battery Abstruction.
315 */
316struct acpi_battinfo;
317struct acpi_battdesc;
313
314extern int acpi_battery_register(int, int);
318
319extern int acpi_battery_register(int, int);
320extern int acpi_battery_get_battinfo(int, struct acpi_battinfo *);
321extern int acpi_battery_get_units(void);
322extern int acpi_battery_get_battdesc(int, struct acpi_battdesc *);
323
315extern int acpi_cmbat_get_battinfo(int, struct acpi_battinfo *);
316
317/*
324extern int acpi_cmbat_get_battinfo(int, struct acpi_battinfo *);
325
326/*
327 * AC adapter interface.
328 */
329
330extern int acpi_acad_get_acline(int *);
331
332/*
318 * System power API.
319 *
320 * XXX should this be further generalised?
321 *
322 */
323#define POWERPROFILE_PERFORMANCE 0
324#define POWERPROFILE_ECONOMY 1
325
326extern int powerprofile_get_state(void);
327extern void powerprofile_set_state(int state);
328
329typedef void (*powerprofile_change_hook)(void *);
330EVENTHANDLER_DECLARE(powerprofile_change, powerprofile_change_hook);
333 * System power API.
334 *
335 * XXX should this be further generalised?
336 *
337 */
338#define POWERPROFILE_PERFORMANCE 0
339#define POWERPROFILE_ECONOMY 1
340
341extern int powerprofile_get_state(void);
342extern void powerprofile_set_state(int state);
343
344typedef void (*powerprofile_change_hook)(void *);
345EVENTHANDLER_DECLARE(powerprofile_change, powerprofile_change_hook);