1 /* $NetBSD: acpivar.h,v 1.37 2009/11/28 17:02:14 cegger Exp $ */
4 * Copyright 2001 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * This file defines the ACPI interface provided to the rest of the
40 * kernel, as well as the autoconfiguration structures for ACPI
45 #include <dev/pci/pcivar.h>
46 #include <dev/isa/isavar.h>
48 #include <dev/acpi/acpica.h>
50 #include <dev/sysmon/sysmonvar.h>
53 * acpibus_attach_args:
55 * This structure is used to attach the ACPI "bus".
57 struct acpibus_attach_args
{
58 bus_space_tag_t aa_iot
; /* PCI I/O space tag */
59 bus_space_tag_t aa_memt
; /* PCI MEM space tag */
60 pci_chipset_tag_t aa_pc
; /* PCI chipset */
61 int aa_pciflags
; /* PCI bus flags */
62 isa_chipset_tag_t aa_ic
; /* ISA chipset */
66 * Types of switches that ACPI understands.
68 #define ACPI_SWITCH_POWERBUTTON 0
69 #define ACPI_SWITCH_SLEEPBUTTON 1
70 #define ACPI_SWITCH_LID 2
71 #define ACPI_NSWITCHES 3
76 * An ACPI device node.
79 TAILQ_ENTRY(acpi_devnode
) ad_list
;
80 ACPI_HANDLE ad_handle
; /* our ACPI handle */
81 uint32_t ad_level
; /* ACPI level */
82 uint32_t ad_type
; /* ACPI object type */
83 ACPI_DEVICE_INFO
*ad_devinfo
; /* our ACPI device info */
84 struct acpi_scope
*ad_scope
; /* backpointer to scope */
85 device_t ad_device
; /* pointer to configured device */
86 char ad_name
[5]; /* Human-readable device name */
92 * Description of an ACPI scope.
95 TAILQ_ENTRY(acpi_scope
) as_list
;
96 const char *as_name
; /* scope name */
98 * Device nodes we manage.
100 TAILQ_HEAD(, acpi_devnode
) as_devnodes
;
106 * Software state of the ACPI subsystem.
109 device_t sc_dev
; /* base device info */
110 bus_space_tag_t sc_iot
; /* PCI I/O space tag */
111 bus_space_tag_t sc_memt
; /* PCI MEM space tag */
112 pci_chipset_tag_t sc_pc
; /* PCI chipset tag */
113 int sc_pciflags
; /* PCI bus flags */
114 int sc_pci_bus
; /* internal PCI fixup */
115 isa_chipset_tag_t sc_ic
; /* ISA chipset tag */
117 void *sc_sdhook
; /* shutdown hook */
120 * Power switch handlers for fixed-feature buttons.
122 struct sysmon_pswitch sc_smpsw_power
;
123 struct sysmon_pswitch sc_smpsw_sleep
;
126 * Sleep state to transition to when a given
127 * switch is activated.
129 int sc_switch_sleep
[ACPI_NSWITCHES
];
131 int sc_sleepstate
; /* current sleep state */
138 TAILQ_HEAD(, acpi_scope
) sc_scopes
;
145 * Used to attach a device instance to the acpi "bus".
147 struct acpi_attach_args
{
148 struct acpi_devnode
*aa_node
; /* ACPI device node */
149 bus_space_tag_t aa_iot
; /* PCI I/O space tag */
150 bus_space_tag_t aa_memt
; /* PCI MEM space tag */
151 pci_chipset_tag_t aa_pc
; /* PCI chipset tag */
152 int aa_pciflags
; /* PCI bus flags */
153 isa_chipset_tag_t aa_ic
; /* ISA chipset */
160 * acpi_iorange I/O port range
161 * acpi_mem memory region
162 * acpi_memrange memory range
163 * acpi_irq Interrupt Request
164 * acpi_drq DMA request
168 SIMPLEQ_ENTRY(acpi_io
) ar_list
;
174 struct acpi_iorange
{
175 SIMPLEQ_ENTRY(acpi_iorange
) ar_list
;
184 SIMPLEQ_ENTRY(acpi_mem
) ar_list
;
190 struct acpi_memrange
{
191 SIMPLEQ_ENTRY(acpi_memrange
) ar_list
;
200 SIMPLEQ_ENTRY(acpi_irq
) ar_list
;
207 SIMPLEQ_ENTRY(acpi_drq
) ar_list
;
212 struct acpi_resources
{
213 SIMPLEQ_HEAD(, acpi_io
) ar_io
;
216 SIMPLEQ_HEAD(, acpi_iorange
) ar_iorange
;
219 SIMPLEQ_HEAD(, acpi_mem
) ar_mem
;
222 SIMPLEQ_HEAD(, acpi_memrange
) ar_memrange
;
225 SIMPLEQ_HEAD(, acpi_irq
) ar_irq
;
228 SIMPLEQ_HEAD(, acpi_drq
) ar_drq
;
233 * acpi_resource_parse_ops:
235 * The client of ACPI resources specifies these operations
236 * when the resources are parsed.
238 struct acpi_resource_parse_ops
{
239 void (*init
)(device_t
, void *, void **);
240 void (*fini
)(device_t
, void *);
242 void (*ioport
)(device_t
, void *, uint32_t, uint32_t);
243 void (*iorange
)(device_t
, void *, uint32_t, uint32_t,
246 void (*memory
)(device_t
, void *, uint32_t, uint32_t);
247 void (*memrange
)(device_t
, void *, uint32_t, uint32_t,
250 void (*irq
)(device_t
, void *, uint32_t, uint32_t);
251 void (*drq
)(device_t
, void *, uint32_t);
253 void (*start_dep
)(device_t
, void *, int);
254 void (*end_dep
)(device_t
, void *);
257 extern struct acpi_softc
*acpi_softc
;
258 extern int acpi_active
;
260 extern const struct acpi_resource_parse_ops acpi_resource_parse_ops_default
;
262 int acpi_check(device_t
, const char *);
263 int acpi_probe(void);
264 ACPI_PHYSICAL_ADDRESS
acpi_OsGetRootPointer(void);
265 int acpi_match_hid(ACPI_DEVICE_INFO
*, const char * const *);
266 void acpi_set_wake_gpe(ACPI_HANDLE
);
267 void acpi_clear_wake_gpe(ACPI_HANDLE
);
269 ACPI_STATUS
acpi_eval_integer(ACPI_HANDLE
, const char *, ACPI_INTEGER
*);
270 ACPI_STATUS
acpi_eval_set_integer(ACPI_HANDLE handle
, const char *path
,
272 ACPI_STATUS
acpi_eval_string(ACPI_HANDLE
, const char *, char **);
273 ACPI_STATUS
acpi_eval_struct(ACPI_HANDLE
, const char *, ACPI_BUFFER
*);
275 ACPI_STATUS
acpi_foreach_package_object(ACPI_OBJECT
*,
276 ACPI_STATUS (*)(ACPI_OBJECT
*, void *), void *);
277 ACPI_STATUS
acpi_get(ACPI_HANDLE
, ACPI_BUFFER
*,
278 ACPI_STATUS (*)(ACPI_HANDLE
, ACPI_BUFFER
*));
279 const char* acpi_name(ACPI_HANDLE
);
281 ACPI_STATUS
acpi_resource_parse(device_t
, ACPI_HANDLE
, const char *,
282 void *, const struct acpi_resource_parse_ops
*);
283 void acpi_resource_print(device_t
, struct acpi_resources
*);
284 void acpi_resource_cleanup(struct acpi_resources
*);
285 ACPI_STATUS
acpi_allocate_resources(ACPI_HANDLE
);
287 ACPI_STATUS
acpi_pwr_switch_consumer(ACPI_HANDLE
, int);
289 void * acpi_pci_link_devbyhandle(ACPI_HANDLE
);
290 void acpi_pci_link_add_reference(void *, int, int, int, int);
291 int acpi_pci_link_route_interrupt(void *, int, int *, int *, int *);
292 char * acpi_pci_link_name(void *);
293 ACPI_HANDLE
acpi_pci_link_handle(void *);
294 void acpi_pci_link_state(void);
295 void acpi_pci_link_resume(void);
297 struct acpi_io
*acpi_res_io(struct acpi_resources
*, int);
298 struct acpi_iorange
*acpi_res_iorange(struct acpi_resources
*, int);
299 struct acpi_mem
*acpi_res_mem(struct acpi_resources
*, int);
300 struct acpi_memrange
*acpi_res_memrange(struct acpi_resources
*, int);
301 struct acpi_irq
*acpi_res_irq(struct acpi_resources
*, int);
302 struct acpi_drq
*acpi_res_drq(struct acpi_resources
*, int);
305 * power state transition
307 ACPI_STATUS
acpi_enter_sleep_state(struct acpi_softc
*, int);
313 const char *aq_tabletype
; /* what type of table (FADT, DSDT, etc) */
314 const char *aq_oemid
; /* compared against the table OemId */
315 int aq_oemrev
; /* compared against the table OemRev */
316 int aq_cmpop
; /* how to compare the oemrev number */
317 const char *aq_tabid
; /* compared against the table TableId */
318 int aq_quirks
; /* the actual quirks */
321 #define AQ_GT 0 /* > */
322 #define AQ_LT 1 /* < */
323 #define AQ_GTE 2 /* >= */
324 #define AQ_LTE 3 /* <= */
325 #define AQ_EQ 4 /* == */
327 #define ACPI_QUIRK_BROKEN 0x00000001 /* totally broken */
328 #define ACPI_QUIRK_BADPCI 0x00000002 /* bad PCI hierarchy */
329 #define ACPI_QUIRK_BADBBN 0x00000004 /* _BBN broken */
330 #define ACPI_QUIRK_IRQ0 0x00000008 /* bad 0->2 irq override */
332 int acpi_find_quirks(void);