acpivar.h revision 1.1 1 /* $NetBSD: acpivar.h,v 1.1 2001/09/28 02:09:24 thorpej Exp $ */
2
3 /*
4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
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. 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
23 * written permission.
24 *
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.
36 */
37
38 /*
39 * This file defines the ACPI interface provided to the rest of the
40 * kernel, as well as the autoconfiguration structures for ACPI
41 * support.
42 */
43
44 #include <machine/bus.h>
45 #include <dev/pci/pcivar.h>
46
47 #include <dev/acpi/acpica.h>
48
49 /*
50 * acpibus_attach_args:
51 *
52 * This structure is used to attach the ACPI "bus".
53 */
54 struct acpibus_attach_args {
55 const char *aa_busname; /* XXX should be common */
56 bus_space_tag_t aa_iot; /* PCI I/O space tag */
57 bus_space_tag_t aa_memt; /* PCI MEM space tag */
58 pci_chipset_tag_t aa_pc; /* PCI chipset */
59 int aa_pciflags; /* PCI bus flags */
60 };
61
62 /*
63 * Types of switches that ACPI understands.
64 */
65 #define ACPI_SWITCH_POWERBUTTON 0
66 #define ACPI_SWITCH_SLEEPBUTTON 1
67 #define ACPI_SWITCH_LID 2
68 #define ACPI_NSWITCHES 3
69
70 /*
71 * acpi_devnode:
72 *
73 * An ACPI device node.
74 */
75 struct acpi_devnode {
76 TAILQ_ENTRY(acpi_devnode) ad_list;
77 ACPI_HANDLE ad_handle; /* our ACPI handle */
78 u_int32_t ad_level; /* ACPI level */
79 u_int32_t ad_type; /* ACPI object type */
80 ACPI_DEVICE_INFO ad_devinfo; /* our ACPI device info */
81 struct acpi_scope *ad_scope; /* backpointer to scope */
82 struct device *ad_device; /* pointer to configured device */
83 };
84
85 /*
86 * acpi_scope:
87 *
88 * Description of an ACPI scope.
89 */
90 struct acpi_scope {
91 TAILQ_ENTRY(acpi_scope) as_list;
92 const char *as_name; /* scope name */
93 /*
94 * Device nodes we manage.
95 */
96 TAILQ_HEAD(, acpi_devnode) as_devnodes;
97 };
98
99 /*
100 * acpi_softc:
101 *
102 * Software state of the ACPI subsystem.
103 */
104 struct acpi_softc {
105 struct device sc_dev; /* base device info */
106 bus_space_tag_t sc_iot; /* PCI I/O space tag */
107 bus_space_tag_t sc_memt; /* PCI MEM space tag */
108 pci_chipset_tag_t sc_pc; /* PCI chipset tag */
109 int sc_pciflags; /* PCI bus flags */
110
111 void *sc_sdhook; /* shutdown hook */
112
113 /*
114 * Sleep state to transition to when a given
115 * switch is activated.
116 */
117 int sc_switch_sleep[ACPI_NSWITCHES];
118
119 int sc_sleepstate; /* current sleep state */
120
121 /*
122 * Scopes we manage.
123 */
124 TAILQ_HEAD(, acpi_scope) sc_scopes;
125 };
126
127 struct acpi_attach_args {
128 struct acpi_devnode *aa_node; /* ACPI device node */
129 bus_space_tag_t aa_iot; /* PCI I/O space tag */
130 bus_space_tag_t aa_memt; /* PCI MEM space tag */
131 pci_chipset_tag_t aa_pc; /* PCI chipset tag */
132 int aa_pciflags; /* PCI bus flags */
133 };
134
135 extern struct acpi_softc *acpi_softc;
136 extern int acpi_active;
137
138 int acpi_probe(void);
139
140 ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, char *, int *);
141