acpi.c revision 1.4.4.6 1 1.4.4.6 nathanw /* $NetBSD: acpi.c,v 1.4.4.6 2002/06/20 03:43:25 nathanw Exp $ */
2 1.4.4.2 nathanw
3 1.4.4.2 nathanw /*
4 1.4.4.2 nathanw * Copyright 2001 Wasabi Systems, Inc.
5 1.4.4.2 nathanw * All rights reserved.
6 1.4.4.2 nathanw *
7 1.4.4.2 nathanw * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.4.4.2 nathanw *
9 1.4.4.2 nathanw * Redistribution and use in source and binary forms, with or without
10 1.4.4.2 nathanw * modification, are permitted provided that the following conditions
11 1.4.4.2 nathanw * are met:
12 1.4.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
13 1.4.4.2 nathanw * notice, this list of conditions and the following disclaimer.
14 1.4.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
15 1.4.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
16 1.4.4.2 nathanw * documentation and/or other materials provided with the distribution.
17 1.4.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
18 1.4.4.2 nathanw * must display the following acknowledgement:
19 1.4.4.2 nathanw * This product includes software developed for the NetBSD Project by
20 1.4.4.2 nathanw * Wasabi Systems, Inc.
21 1.4.4.2 nathanw * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.4.4.2 nathanw * or promote products derived from this software without specific prior
23 1.4.4.2 nathanw * written permission.
24 1.4.4.2 nathanw *
25 1.4.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.4.4.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.4.4.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.4.4.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.4.4.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.4.4.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.4.4.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.4.4.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.4.4.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.4.4.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.4.4.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
36 1.4.4.2 nathanw */
37 1.4.4.2 nathanw
38 1.4.4.2 nathanw /*
39 1.4.4.2 nathanw * Autoconfiguration support for the Intel ACPI Component Architecture
40 1.4.4.2 nathanw * ACPI reference implementation.
41 1.4.4.2 nathanw */
42 1.4.4.2 nathanw
43 1.4.4.3 nathanw #include <sys/cdefs.h>
44 1.4.4.6 nathanw __KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.4.4.6 2002/06/20 03:43:25 nathanw Exp $");
45 1.4.4.3 nathanw
46 1.4.4.2 nathanw #include <sys/param.h>
47 1.4.4.2 nathanw #include <sys/systm.h>
48 1.4.4.2 nathanw #include <sys/device.h>
49 1.4.4.2 nathanw #include <sys/malloc.h>
50 1.4.4.2 nathanw
51 1.4.4.2 nathanw #include <dev/acpi/acpica.h>
52 1.4.4.2 nathanw #include <dev/acpi/acpireg.h>
53 1.4.4.2 nathanw #include <dev/acpi/acpivar.h>
54 1.4.4.2 nathanw #include <dev/acpi/acpi_osd.h>
55 1.4.4.2 nathanw
56 1.4.4.6 nathanw #include <machine/acpi_machdep.h>
57 1.4.4.6 nathanw
58 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
59 1.4.4.2 nathanw #define ACPI_DBGR_INIT 0x01
60 1.4.4.2 nathanw #define ACPI_DBGR_TABLES 0x02
61 1.4.4.2 nathanw #define ACPI_DBGR_ENABLE 0x04
62 1.4.4.2 nathanw #define ACPI_DBGR_PROBE 0x08
63 1.4.4.2 nathanw #define ACPI_DBGR_RUNNING 0x10
64 1.4.4.2 nathanw
65 1.4.4.2 nathanw int acpi_dbgr = 0x00;
66 1.4.4.2 nathanw #endif
67 1.4.4.2 nathanw
68 1.4.4.2 nathanw int acpi_match(struct device *, struct cfdata *, void *);
69 1.4.4.2 nathanw void acpi_attach(struct device *, struct device *, void *);
70 1.4.4.2 nathanw
71 1.4.4.2 nathanw int acpi_print(void *aux, const char *);
72 1.4.4.2 nathanw
73 1.4.4.2 nathanw extern struct cfdriver acpi_cd;
74 1.4.4.2 nathanw
75 1.4.4.2 nathanw struct cfattach acpi_ca = {
76 1.4.4.2 nathanw sizeof(struct acpi_softc), acpi_match, acpi_attach,
77 1.4.4.2 nathanw };
78 1.4.4.2 nathanw
79 1.4.4.2 nathanw /*
80 1.4.4.2 nathanw * This is a flag we set when the ACPI subsystem is active. Machine
81 1.4.4.2 nathanw * dependent code may wish to skip other steps (such as attaching
82 1.4.4.2 nathanw * subsystems that ACPI supercedes) when ACPI is active.
83 1.4.4.2 nathanw */
84 1.4.4.2 nathanw int acpi_active;
85 1.4.4.2 nathanw
86 1.4.4.2 nathanw /*
87 1.4.4.2 nathanw * Pointer to the ACPI subsystem's state. There can be only
88 1.4.4.2 nathanw * one ACPI instance.
89 1.4.4.2 nathanw */
90 1.4.4.2 nathanw struct acpi_softc *acpi_softc;
91 1.4.4.2 nathanw
92 1.4.4.2 nathanw void acpi_shutdown(void *);
93 1.4.4.2 nathanw ACPI_STATUS acpi_disable(struct acpi_softc *sc);
94 1.4.4.2 nathanw void acpi_build_tree(struct acpi_softc *);
95 1.4.4.2 nathanw ACPI_STATUS acpi_make_devnode(ACPI_HANDLE, UINT32, void *, void **);
96 1.4.4.2 nathanw
97 1.4.4.2 nathanw void acpi_enable_fixed_events(struct acpi_softc *);
98 1.4.4.2 nathanw
99 1.4.4.2 nathanw /*
100 1.4.4.2 nathanw * acpi_probe:
101 1.4.4.2 nathanw *
102 1.4.4.2 nathanw * Probe for ACPI support. This is called by the
103 1.4.4.2 nathanw * machine-dependent ACPI front-end. All of the
104 1.4.4.2 nathanw * actual work is done by ACPICA.
105 1.4.4.2 nathanw *
106 1.4.4.2 nathanw * NOTE: This is not an autoconfiguration interface function.
107 1.4.4.2 nathanw */
108 1.4.4.2 nathanw int
109 1.4.4.2 nathanw acpi_probe(void)
110 1.4.4.2 nathanw {
111 1.4.4.2 nathanw static int beenhere;
112 1.4.4.2 nathanw ACPI_STATUS rv;
113 1.4.4.2 nathanw
114 1.4.4.2 nathanw if (beenhere != 0)
115 1.4.4.2 nathanw panic("acpi_probe: ACPI has already been probed");
116 1.4.4.2 nathanw beenhere = 1;
117 1.4.4.2 nathanw
118 1.4.4.2 nathanw /*
119 1.4.4.2 nathanw * Start up ACPICA.
120 1.4.4.2 nathanw */
121 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
122 1.4.4.2 nathanw if (acpi_dbgr & ACPI_DBGR_INIT)
123 1.4.4.2 nathanw acpi_osd_debugger();
124 1.4.4.2 nathanw #endif
125 1.4.4.2 nathanw
126 1.4.4.2 nathanw rv = AcpiInitializeSubsystem();
127 1.4.4.2 nathanw if (rv != AE_OK) {
128 1.4.4.2 nathanw printf("ACPI: unable to initialize ACPICA: %d\n", rv);
129 1.4.4.2 nathanw return (0);
130 1.4.4.2 nathanw }
131 1.4.4.2 nathanw
132 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
133 1.4.4.2 nathanw if (acpi_dbgr & ACPI_DBGR_TABLES)
134 1.4.4.2 nathanw acpi_osd_debugger();
135 1.4.4.2 nathanw #endif
136 1.4.4.2 nathanw
137 1.4.4.2 nathanw rv = AcpiLoadTables();
138 1.4.4.2 nathanw if (rv != AE_OK) {
139 1.4.4.2 nathanw printf("ACPI: unable to load tables: %d\n", rv);
140 1.4.4.2 nathanw return (0);
141 1.4.4.2 nathanw }
142 1.4.4.2 nathanw
143 1.4.4.2 nathanw /*
144 1.4.4.2 nathanw * Looks like we have ACPI!
145 1.4.4.2 nathanw */
146 1.4.4.2 nathanw
147 1.4.4.2 nathanw return (1);
148 1.4.4.2 nathanw }
149 1.4.4.2 nathanw
150 1.4.4.2 nathanw /*
151 1.4.4.2 nathanw * acpi_match:
152 1.4.4.2 nathanw *
153 1.4.4.2 nathanw * Autoconfiguration `match' routine.
154 1.4.4.2 nathanw */
155 1.4.4.2 nathanw int
156 1.4.4.2 nathanw acpi_match(struct device *parent, struct cfdata *match, void *aux)
157 1.4.4.2 nathanw {
158 1.4.4.2 nathanw struct acpibus_attach_args *aa = aux;
159 1.4.4.2 nathanw
160 1.4.4.2 nathanw if (strcmp(aa->aa_busname, acpi_cd.cd_name) != 0)
161 1.4.4.2 nathanw return (0);
162 1.4.4.2 nathanw
163 1.4.4.2 nathanw /*
164 1.4.4.2 nathanw * XXX Check other locators? Hard to know -- machine
165 1.4.4.2 nathanw * dependent code has already checked for the presence
166 1.4.4.2 nathanw * of ACPI by calling acpi_probe(), so I suppose we
167 1.4.4.2 nathanw * don't really have to do anything else.
168 1.4.4.2 nathanw */
169 1.4.4.2 nathanw return (1);
170 1.4.4.2 nathanw }
171 1.4.4.2 nathanw
172 1.4.4.2 nathanw /*
173 1.4.4.2 nathanw * acpi_attach:
174 1.4.4.2 nathanw *
175 1.4.4.2 nathanw * Autoconfiguration `attach' routine. Finish initializing
176 1.4.4.2 nathanw * ACPICA (some initialization was done in acpi_probe(),
177 1.4.4.2 nathanw * which was required to check for the presence of ACPI),
178 1.4.4.2 nathanw * and enable the ACPI subsystem.
179 1.4.4.2 nathanw */
180 1.4.4.2 nathanw void
181 1.4.4.2 nathanw acpi_attach(struct device *parent, struct device *self, void *aux)
182 1.4.4.2 nathanw {
183 1.4.4.2 nathanw struct acpi_softc *sc = (void *) self;
184 1.4.4.2 nathanw struct acpibus_attach_args *aa = aux;
185 1.4.4.2 nathanw ACPI_STATUS rv;
186 1.4.4.2 nathanw
187 1.4.4.2 nathanw printf("\n");
188 1.4.4.2 nathanw
189 1.4.4.2 nathanw if (acpi_softc != NULL)
190 1.4.4.2 nathanw panic("acpi_attach: ACPI has already been attached");
191 1.4.4.2 nathanw
192 1.4.4.2 nathanw sc->sc_iot = aa->aa_iot;
193 1.4.4.2 nathanw sc->sc_memt = aa->aa_memt;
194 1.4.4.2 nathanw sc->sc_pc = aa->aa_pc;
195 1.4.4.2 nathanw sc->sc_pciflags = aa->aa_pciflags;
196 1.4.4.2 nathanw
197 1.4.4.2 nathanw acpi_softc = sc;
198 1.4.4.2 nathanw
199 1.4.4.2 nathanw /*
200 1.4.4.2 nathanw * Install the default address space handlers.
201 1.4.4.2 nathanw */
202 1.4.4.2 nathanw
203 1.4.4.2 nathanw rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
204 1.4.4.2 nathanw ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
205 1.4.4.2 nathanw if (rv != AE_OK) {
206 1.4.4.2 nathanw printf("%s: unable to install SYSTEM MEMORY handler: %d\n",
207 1.4.4.2 nathanw sc->sc_dev.dv_xname, rv);
208 1.4.4.2 nathanw return;
209 1.4.4.2 nathanw }
210 1.4.4.2 nathanw
211 1.4.4.2 nathanw rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
212 1.4.4.2 nathanw ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL);
213 1.4.4.2 nathanw if (rv != AE_OK) {
214 1.4.4.2 nathanw printf("%s: unable to install SYSTEM IO handler: %d\n",
215 1.4.4.2 nathanw sc->sc_dev.dv_xname, rv);
216 1.4.4.2 nathanw return;
217 1.4.4.2 nathanw }
218 1.4.4.2 nathanw
219 1.4.4.2 nathanw rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
220 1.4.4.2 nathanw ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
221 1.4.4.2 nathanw if (rv != AE_OK) {
222 1.4.4.2 nathanw printf("%s: unable to install PCI CONFIG handler: %d\n",
223 1.4.4.2 nathanw sc->sc_dev.dv_xname, rv);
224 1.4.4.2 nathanw return;
225 1.4.4.2 nathanw }
226 1.4.4.2 nathanw
227 1.4.4.2 nathanw /*
228 1.4.4.2 nathanw * Bring ACPI on-line.
229 1.4.4.2 nathanw *
230 1.4.4.2 nathanw * Note that we request that _STA (device init) and _INI (object init)
231 1.4.4.2 nathanw * methods not be run.
232 1.4.4.2 nathanw *
233 1.4.4.2 nathanw * XXX We need to arrange for the object init pass after we have
234 1.4.4.2 nathanw * XXX attached all of our children.
235 1.4.4.2 nathanw */
236 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
237 1.4.4.2 nathanw if (acpi_dbgr & ACPI_DBGR_ENABLE)
238 1.4.4.2 nathanw acpi_osd_debugger();
239 1.4.4.2 nathanw #endif
240 1.4.4.2 nathanw rv = AcpiEnableSubsystem(ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
241 1.4.4.2 nathanw if (rv != AE_OK) {
242 1.4.4.2 nathanw printf("%s: unable to enable ACPI: %d\n",
243 1.4.4.2 nathanw sc->sc_dev.dv_xname, rv);
244 1.4.4.2 nathanw return;
245 1.4.4.2 nathanw }
246 1.4.4.2 nathanw acpi_active = 1;
247 1.4.4.2 nathanw
248 1.4.4.2 nathanw /*
249 1.4.4.2 nathanw * Set up the default sleep state to enter when various
250 1.4.4.2 nathanw * switches are activated.
251 1.4.4.2 nathanw */
252 1.4.4.2 nathanw sc->sc_switch_sleep[ACPI_SWITCH_POWERBUTTON] = ACPI_STATE_S5;
253 1.4.4.2 nathanw sc->sc_switch_sleep[ACPI_SWITCH_SLEEPBUTTON] = ACPI_STATE_S1;
254 1.4.4.2 nathanw sc->sc_switch_sleep[ACPI_SWITCH_LID] = ACPI_STATE_S1;
255 1.4.4.2 nathanw
256 1.4.4.2 nathanw /* Our current state is "awake". */
257 1.4.4.2 nathanw sc->sc_sleepstate = ACPI_STATE_S0;
258 1.4.4.2 nathanw
259 1.4.4.6 nathanw /* Show SCI interrupt. */
260 1.4.4.6 nathanw if (AcpiGbl_FADT != NULL)
261 1.4.4.6 nathanw printf("%s: SCI interrupting at irq %d\n",
262 1.4.4.6 nathanw sc->sc_dev.dv_xname, AcpiGbl_FADT->SciInt);
263 1.4.4.2 nathanw /*
264 1.4.4.2 nathanw * Check for fixed-hardware features.
265 1.4.4.2 nathanw */
266 1.4.4.2 nathanw acpi_enable_fixed_events(sc);
267 1.4.4.2 nathanw
268 1.4.4.2 nathanw /*
269 1.4.4.2 nathanw * Scan the namespace and build our device tree.
270 1.4.4.2 nathanw */
271 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
272 1.4.4.2 nathanw if (acpi_dbgr & ACPI_DBGR_PROBE)
273 1.4.4.2 nathanw acpi_osd_debugger();
274 1.4.4.2 nathanw #endif
275 1.4.4.2 nathanw acpi_build_tree(sc);
276 1.4.4.2 nathanw
277 1.4.4.2 nathanw /*
278 1.4.4.2 nathanw * Register a shutdown hook that disables certain ACPI
279 1.4.4.2 nathanw * events that might happen and confuse us while we're
280 1.4.4.2 nathanw * trying to shut down.
281 1.4.4.2 nathanw */
282 1.4.4.2 nathanw sc->sc_sdhook = shutdownhook_establish(acpi_shutdown, sc);
283 1.4.4.2 nathanw if (sc->sc_sdhook == NULL)
284 1.4.4.2 nathanw printf("%s: WARNING: unable to register shutdown hook\n",
285 1.4.4.2 nathanw sc->sc_dev.dv_xname);
286 1.4.4.2 nathanw
287 1.4.4.2 nathanw #ifdef ENABLE_DEBUGGER
288 1.4.4.2 nathanw if (acpi_dbgr & ACPI_DBGR_RUNNING)
289 1.4.4.2 nathanw acpi_osd_debugger();
290 1.4.4.2 nathanw #endif
291 1.4.4.2 nathanw }
292 1.4.4.2 nathanw
293 1.4.4.2 nathanw /*
294 1.4.4.2 nathanw * acpi_shutdown:
295 1.4.4.2 nathanw *
296 1.4.4.2 nathanw * Shutdown hook for ACPI -- disable some events that
297 1.4.4.2 nathanw * might confuse us.
298 1.4.4.2 nathanw */
299 1.4.4.2 nathanw void
300 1.4.4.2 nathanw acpi_shutdown(void *arg)
301 1.4.4.2 nathanw {
302 1.4.4.2 nathanw struct acpi_softc *sc = arg;
303 1.4.4.2 nathanw
304 1.4.4.2 nathanw if (acpi_disable(sc) != AE_OK)
305 1.4.4.2 nathanw printf("%s: WARNING: unable to disable ACPI\n",
306 1.4.4.2 nathanw sc->sc_dev.dv_xname);
307 1.4.4.2 nathanw }
308 1.4.4.2 nathanw
309 1.4.4.2 nathanw /*
310 1.4.4.2 nathanw * acpi_disable:
311 1.4.4.2 nathanw *
312 1.4.4.2 nathanw * Disable ACPI.
313 1.4.4.2 nathanw */
314 1.4.4.2 nathanw ACPI_STATUS
315 1.4.4.2 nathanw acpi_disable(struct acpi_softc *sc)
316 1.4.4.2 nathanw {
317 1.4.4.2 nathanw ACPI_STATUS rv = AE_OK;
318 1.4.4.2 nathanw
319 1.4.4.2 nathanw if (acpi_active) {
320 1.4.4.2 nathanw rv = AcpiDisable();
321 1.4.4.2 nathanw if (rv == AE_OK)
322 1.4.4.2 nathanw acpi_active = 0;
323 1.4.4.2 nathanw }
324 1.4.4.2 nathanw return (rv);
325 1.4.4.2 nathanw }
326 1.4.4.2 nathanw
327 1.4.4.2 nathanw struct acpi_make_devnode_state {
328 1.4.4.2 nathanw struct acpi_softc *softc;
329 1.4.4.2 nathanw struct acpi_scope *scope;
330 1.4.4.2 nathanw };
331 1.4.4.2 nathanw
332 1.4.4.2 nathanw /*
333 1.4.4.2 nathanw * acpi_build_tree:
334 1.4.4.2 nathanw *
335 1.4.4.2 nathanw * Scan relevant portions of the ACPI namespace and attach
336 1.4.4.2 nathanw * child devices.
337 1.4.4.2 nathanw */
338 1.4.4.2 nathanw void
339 1.4.4.2 nathanw acpi_build_tree(struct acpi_softc *sc)
340 1.4.4.2 nathanw {
341 1.4.4.2 nathanw static const char *scopes[] = {
342 1.4.4.2 nathanw "\\_PR_", /* ACPI 1.0 processor namespace */
343 1.4.4.2 nathanw "\\_SB_", /* system bus namespace */
344 1.4.4.2 nathanw "\\_SI_", /* system idicator namespace */
345 1.4.4.2 nathanw "\\_TZ_", /* ACPI 1.0 thermal zone namespace */
346 1.4.4.2 nathanw NULL,
347 1.4.4.2 nathanw };
348 1.4.4.2 nathanw struct acpi_attach_args aa;
349 1.4.4.2 nathanw struct acpi_make_devnode_state state;
350 1.4.4.2 nathanw struct acpi_scope *as;
351 1.4.4.2 nathanw struct acpi_devnode *ad;
352 1.4.4.2 nathanw ACPI_HANDLE parent;
353 1.4.4.2 nathanw int i;
354 1.4.4.2 nathanw
355 1.4.4.2 nathanw TAILQ_INIT(&sc->sc_scopes);
356 1.4.4.2 nathanw
357 1.4.4.2 nathanw state.softc = sc;
358 1.4.4.2 nathanw
359 1.4.4.2 nathanw /*
360 1.4.4.2 nathanw * Scan the namespace and build our tree.
361 1.4.4.2 nathanw */
362 1.4.4.2 nathanw for (i = 0; scopes[i] != NULL; i++) {
363 1.4.4.2 nathanw as = malloc(sizeof(*as), M_DEVBUF, M_WAITOK);
364 1.4.4.2 nathanw as->as_name = scopes[i];
365 1.4.4.2 nathanw TAILQ_INIT(&as->as_devnodes);
366 1.4.4.2 nathanw
367 1.4.4.2 nathanw TAILQ_INSERT_TAIL(&sc->sc_scopes, as, as_list);
368 1.4.4.2 nathanw
369 1.4.4.2 nathanw state.scope = as;
370 1.4.4.2 nathanw
371 1.4.4.2 nathanw if (AcpiGetHandle(ACPI_ROOT_OBJECT, (char *) scopes[i],
372 1.4.4.2 nathanw &parent) == AE_OK) {
373 1.4.4.2 nathanw AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100,
374 1.4.4.2 nathanw acpi_make_devnode, &state, NULL);
375 1.4.4.2 nathanw }
376 1.4.4.2 nathanw
377 1.4.4.2 nathanw /* Now, for this namespace, try and attach the devices. */
378 1.4.4.2 nathanw TAILQ_FOREACH(ad, &as->as_devnodes, ad_list) {
379 1.4.4.2 nathanw aa.aa_node = ad;
380 1.4.4.2 nathanw aa.aa_iot = sc->sc_iot;
381 1.4.4.2 nathanw aa.aa_memt = sc->sc_memt;
382 1.4.4.2 nathanw aa.aa_pc = sc->sc_pc;
383 1.4.4.2 nathanw aa.aa_pciflags = sc->sc_pciflags;
384 1.4.4.2 nathanw
385 1.4.4.2 nathanw /*
386 1.4.4.2 nathanw * XXX We only attach devices which are:
387 1.4.4.2 nathanw *
388 1.4.4.2 nathanw * - present
389 1.4.4.2 nathanw * - enabled
390 1.4.4.2 nathanw * - functioning properly
391 1.4.4.2 nathanw *
392 1.4.4.2 nathanw * However, if enabled, it's decoding resources,
393 1.4.4.2 nathanw * so we should claim them, if possible. Requires
394 1.4.4.2 nathanw * changes to bus_space(9).
395 1.4.4.2 nathanw */
396 1.4.4.2 nathanw if ((ad->ad_devinfo.CurrentStatus &
397 1.4.4.2 nathanw (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
398 1.4.4.6 nathanw ACPI_STA_DEV_OK)) !=
399 1.4.4.2 nathanw (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
400 1.4.4.6 nathanw ACPI_STA_DEV_OK))
401 1.4.4.2 nathanw continue;
402 1.4.4.2 nathanw
403 1.4.4.2 nathanw /*
404 1.4.4.2 nathanw * XXX Same problem as above...
405 1.4.4.2 nathanw */
406 1.4.4.2 nathanw if ((ad->ad_devinfo.Valid & ACPI_VALID_HID) == 0)
407 1.4.4.2 nathanw continue;
408 1.4.4.2 nathanw
409 1.4.4.2 nathanw ad->ad_device = config_found(&sc->sc_dev,
410 1.4.4.2 nathanw &aa, acpi_print);
411 1.4.4.2 nathanw }
412 1.4.4.2 nathanw }
413 1.4.4.2 nathanw }
414 1.4.4.2 nathanw
415 1.4.4.2 nathanw /*
416 1.4.4.2 nathanw * acpi_make_devnode:
417 1.4.4.2 nathanw *
418 1.4.4.2 nathanw * Make an ACPI devnode.
419 1.4.4.2 nathanw */
420 1.4.4.2 nathanw ACPI_STATUS
421 1.4.4.2 nathanw acpi_make_devnode(ACPI_HANDLE handle, UINT32 level, void *context,
422 1.4.4.2 nathanw void **status)
423 1.4.4.2 nathanw {
424 1.4.4.2 nathanw struct acpi_make_devnode_state *state = context;
425 1.4.4.2 nathanw #ifdef ACPI_DEBUG
426 1.4.4.2 nathanw struct acpi_softc *sc = state->softc;
427 1.4.4.2 nathanw #endif
428 1.4.4.2 nathanw struct acpi_scope *as = state->scope;
429 1.4.4.2 nathanw struct acpi_devnode *ad;
430 1.4.4.2 nathanw ACPI_OBJECT_TYPE type;
431 1.4.4.2 nathanw ACPI_STATUS rv;
432 1.4.4.2 nathanw
433 1.4.4.2 nathanw if (AcpiGetType(handle, &type) == AE_OK) {
434 1.4.4.2 nathanw switch (type) {
435 1.4.4.2 nathanw case ACPI_TYPE_DEVICE:
436 1.4.4.2 nathanw case ACPI_TYPE_PROCESSOR:
437 1.4.4.2 nathanw case ACPI_TYPE_THERMAL:
438 1.4.4.2 nathanw case ACPI_TYPE_POWER:
439 1.4.4.4 nathanw ad = malloc(sizeof(*ad), M_DEVBUF, M_NOWAIT|M_ZERO);
440 1.4.4.2 nathanw if (ad == NULL)
441 1.4.4.2 nathanw return (AE_NO_MEMORY);
442 1.4.4.2 nathanw
443 1.4.4.2 nathanw ad->ad_handle = handle;
444 1.4.4.2 nathanw ad->ad_level = level;
445 1.4.4.2 nathanw ad->ad_scope = as;
446 1.4.4.2 nathanw ad->ad_type = type;
447 1.4.4.2 nathanw
448 1.4.4.2 nathanw TAILQ_INSERT_TAIL(&as->as_devnodes, ad, ad_list);
449 1.4.4.2 nathanw
450 1.4.4.2 nathanw rv = AcpiGetObjectInfo(handle, &ad->ad_devinfo);
451 1.4.4.2 nathanw if (rv != AE_OK)
452 1.4.4.2 nathanw goto out;
453 1.4.4.2 nathanw
454 1.4.4.2 nathanw if ((ad->ad_devinfo.Valid & ACPI_VALID_HID) == 0)
455 1.4.4.2 nathanw goto out;
456 1.4.4.2 nathanw
457 1.4.4.2 nathanw #ifdef ACPI_DEBUG
458 1.4.4.2 nathanw printf("%s: HID %s found in scope %s level %d\n",
459 1.4.4.2 nathanw sc->sc_dev.dv_xname, ad->ad_devinfo.HardwareId,
460 1.4.4.2 nathanw as->as_name, ad->ad_level);
461 1.4.4.2 nathanw if (ad->ad_devinfo.Valid & ACPI_VALID_UID)
462 1.4.4.2 nathanw printf(" UID %s\n",
463 1.4.4.2 nathanw ad->ad_devinfo.UniqueId);
464 1.4.4.2 nathanw if (ad->ad_devinfo.Valid & ACPI_VALID_ADR)
465 1.4.4.2 nathanw printf(" ADR 0x%016qx\n",
466 1.4.4.2 nathanw ad->ad_devinfo.Address);
467 1.4.4.2 nathanw if (ad->ad_devinfo.Valid & ACPI_VALID_STA)
468 1.4.4.2 nathanw printf(" STA 0x%08x\n",
469 1.4.4.2 nathanw ad->ad_devinfo.CurrentStatus);
470 1.4.4.2 nathanw #endif
471 1.4.4.2 nathanw }
472 1.4.4.2 nathanw }
473 1.4.4.2 nathanw out:
474 1.4.4.2 nathanw return (AE_OK);
475 1.4.4.2 nathanw }
476 1.4.4.2 nathanw
477 1.4.4.2 nathanw /*
478 1.4.4.2 nathanw * acpi_print:
479 1.4.4.2 nathanw *
480 1.4.4.2 nathanw * Autoconfiguration print routine.
481 1.4.4.2 nathanw */
482 1.4.4.2 nathanw int
483 1.4.4.2 nathanw acpi_print(void *aux, const char *pnp)
484 1.4.4.2 nathanw {
485 1.4.4.2 nathanw struct acpi_attach_args *aa = aux;
486 1.4.4.5 nathanw #if 0
487 1.4.4.2 nathanw char *str;
488 1.4.4.5 nathanw #endif
489 1.4.4.2 nathanw
490 1.4.4.2 nathanw if (pnp) {
491 1.4.4.2 nathanw printf("%s ", aa->aa_node->ad_devinfo.HardwareId);
492 1.4.4.5 nathanw #if 0 /* Not until we fix acpi_eval_string */
493 1.4.4.2 nathanw if (acpi_eval_string(aa->aa_node->ad_handle,
494 1.4.4.2 nathanw "_STR", &str) == AE_OK) {
495 1.4.4.2 nathanw printf("[%s] ", str);
496 1.4.4.2 nathanw AcpiOsFree(str);
497 1.4.4.2 nathanw }
498 1.4.4.5 nathanw #endif
499 1.4.4.2 nathanw printf("at %s", pnp);
500 1.4.4.2 nathanw }
501 1.4.4.2 nathanw
502 1.4.4.2 nathanw return (UNCONF);
503 1.4.4.2 nathanw }
504 1.4.4.2 nathanw
505 1.4.4.2 nathanw /*****************************************************************************
506 1.4.4.2 nathanw * ACPI fixed-hardware feature handlers
507 1.4.4.2 nathanw *****************************************************************************/
508 1.4.4.2 nathanw
509 1.4.4.2 nathanw UINT32 acpi_fixed_power_button_handler(void *);
510 1.4.4.2 nathanw UINT32 acpi_fixed_sleep_button_handler(void *);
511 1.4.4.2 nathanw
512 1.4.4.2 nathanw /*
513 1.4.4.2 nathanw * acpi_enable_fixed_events:
514 1.4.4.2 nathanw *
515 1.4.4.2 nathanw * Enable any fixed-hardware feature handlers.
516 1.4.4.2 nathanw */
517 1.4.4.2 nathanw void
518 1.4.4.2 nathanw acpi_enable_fixed_events(struct acpi_softc *sc)
519 1.4.4.2 nathanw {
520 1.4.4.2 nathanw static int beenhere;
521 1.4.4.2 nathanw ACPI_STATUS rv;
522 1.4.4.2 nathanw
523 1.4.4.2 nathanw /*
524 1.4.4.2 nathanw * Check for fixed-hardware buttons.
525 1.4.4.2 nathanw */
526 1.4.4.2 nathanw
527 1.4.4.2 nathanw if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->PwrButton == 0) {
528 1.4.4.2 nathanw if (beenhere == 0)
529 1.4.4.2 nathanw printf("%s: fixed-feature power button present\n",
530 1.4.4.2 nathanw sc->sc_dev.dv_xname);
531 1.4.4.2 nathanw rv = AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON,
532 1.4.4.2 nathanw acpi_fixed_power_button_handler, sc);
533 1.4.4.2 nathanw if (rv != AE_OK)
534 1.4.4.2 nathanw printf("%s: unable to install handler for fixed "
535 1.4.4.2 nathanw "power button: %d\n", sc->sc_dev.dv_xname, rv);
536 1.4.4.2 nathanw }
537 1.4.4.2 nathanw
538 1.4.4.2 nathanw if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->SleepButton == 0) {
539 1.4.4.2 nathanw if (beenhere == 0)
540 1.4.4.2 nathanw printf("%s: fixed-feature sleep button present\n",
541 1.4.4.2 nathanw sc->sc_dev.dv_xname);
542 1.4.4.2 nathanw rv = AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON,
543 1.4.4.2 nathanw acpi_fixed_sleep_button_handler, sc);
544 1.4.4.2 nathanw if (rv != AE_OK)
545 1.4.4.2 nathanw printf("%s: unable to install handler for fixed "
546 1.4.4.2 nathanw "power button: %d\n", sc->sc_dev.dv_xname, rv);
547 1.4.4.2 nathanw }
548 1.4.4.2 nathanw
549 1.4.4.2 nathanw beenhere = 1;
550 1.4.4.2 nathanw }
551 1.4.4.2 nathanw
552 1.4.4.2 nathanw /*
553 1.4.4.2 nathanw * acpi_fixed_power_button_handler:
554 1.4.4.2 nathanw *
555 1.4.4.2 nathanw * Fixed event handler for the power button.
556 1.4.4.2 nathanw */
557 1.4.4.2 nathanw UINT32
558 1.4.4.2 nathanw acpi_fixed_power_button_handler(void *context)
559 1.4.4.2 nathanw {
560 1.4.4.2 nathanw struct acpi_softc *sc = context;
561 1.4.4.2 nathanw
562 1.4.4.2 nathanw /* XXX XXX XXX */
563 1.4.4.2 nathanw
564 1.4.4.2 nathanw printf("%s: fixed power button pressed\n", sc->sc_dev.dv_xname);
565 1.4.4.2 nathanw
566 1.4.4.6 nathanw return (ACPI_INTERRUPT_HANDLED);
567 1.4.4.2 nathanw }
568 1.4.4.2 nathanw
569 1.4.4.2 nathanw /*
570 1.4.4.2 nathanw * acpi_fixed_sleep_button_handler:
571 1.4.4.2 nathanw *
572 1.4.4.2 nathanw * Fixed event handler for the sleep button.
573 1.4.4.2 nathanw */
574 1.4.4.2 nathanw UINT32
575 1.4.4.2 nathanw acpi_fixed_sleep_button_handler(void *context)
576 1.4.4.2 nathanw {
577 1.4.4.2 nathanw struct acpi_softc *sc = context;
578 1.4.4.2 nathanw
579 1.4.4.2 nathanw /* XXX XXX XXX */
580 1.4.4.2 nathanw
581 1.4.4.2 nathanw printf("%s: fixed sleep button pressed\n", sc->sc_dev.dv_xname);
582 1.4.4.2 nathanw
583 1.4.4.6 nathanw return (ACPI_INTERRUPT_HANDLED);
584 1.4.4.2 nathanw }
585 1.4.4.2 nathanw
586 1.4.4.2 nathanw /*****************************************************************************
587 1.4.4.2 nathanw * ACPI utility routines.
588 1.4.4.2 nathanw *****************************************************************************/
589 1.4.4.2 nathanw
590 1.4.4.2 nathanw /*
591 1.4.4.2 nathanw * acpi_eval_integer:
592 1.4.4.2 nathanw *
593 1.4.4.2 nathanw * Evaluate an integer object.
594 1.4.4.2 nathanw */
595 1.4.4.2 nathanw ACPI_STATUS
596 1.4.4.2 nathanw acpi_eval_integer(ACPI_HANDLE handle, char *path, int *valp)
597 1.4.4.2 nathanw {
598 1.4.4.2 nathanw ACPI_STATUS rv;
599 1.4.4.2 nathanw ACPI_BUFFER buf;
600 1.4.4.2 nathanw ACPI_OBJECT param;
601 1.4.4.2 nathanw
602 1.4.4.2 nathanw if (handle == NULL)
603 1.4.4.2 nathanw handle = ACPI_ROOT_OBJECT;
604 1.4.4.2 nathanw
605 1.4.4.2 nathanw buf.Pointer = ¶m;
606 1.4.4.2 nathanw buf.Length = sizeof(param);
607 1.4.4.2 nathanw
608 1.4.4.2 nathanw rv = AcpiEvaluateObject(handle, path, NULL, &buf);
609 1.4.4.2 nathanw if (rv == AE_OK) {
610 1.4.4.2 nathanw if (param.Type == ACPI_TYPE_INTEGER)
611 1.4.4.2 nathanw *valp = param.Integer.Value;
612 1.4.4.2 nathanw else
613 1.4.4.2 nathanw rv = AE_TYPE;
614 1.4.4.2 nathanw }
615 1.4.4.2 nathanw
616 1.4.4.2 nathanw return (rv);
617 1.4.4.2 nathanw }
618 1.4.4.2 nathanw
619 1.4.4.5 nathanw #if 0
620 1.4.4.2 nathanw /*
621 1.4.4.2 nathanw * acpi_eval_string:
622 1.4.4.2 nathanw *
623 1.4.4.5 nathanw * Evaluate a (Unicode) string object.
624 1.4.4.5 nathanw * XXX current API may leak memory, so don't use this.
625 1.4.4.2 nathanw */
626 1.4.4.2 nathanw ACPI_STATUS
627 1.4.4.2 nathanw acpi_eval_string(ACPI_HANDLE handle, char *path, char **stringp)
628 1.4.4.2 nathanw {
629 1.4.4.2 nathanw ACPI_STATUS rv;
630 1.4.4.2 nathanw ACPI_BUFFER buf;
631 1.4.4.5 nathanw ACPI_OBJECT *param;
632 1.4.4.2 nathanw
633 1.4.4.2 nathanw if (handle == NULL)
634 1.4.4.2 nathanw handle = ACPI_ROOT_OBJECT;
635 1.4.4.2 nathanw
636 1.4.4.2 nathanw buf.Pointer = NULL;
637 1.4.4.2 nathanw buf.Length = 0;
638 1.4.4.2 nathanw
639 1.4.4.2 nathanw rv = AcpiEvaluateObject(handle, path, NULL, &buf);
640 1.4.4.2 nathanw if (rv != AE_BUFFER_OVERFLOW)
641 1.4.4.2 nathanw return (rv);
642 1.4.4.2 nathanw
643 1.4.4.2 nathanw buf.Pointer = AcpiOsAllocate(buf.Length);
644 1.4.4.2 nathanw if (buf.Pointer == NULL)
645 1.4.4.2 nathanw return (AE_NO_MEMORY);
646 1.4.4.2 nathanw
647 1.4.4.2 nathanw rv = AcpiEvaluateObject(handle, path, NULL, &buf);
648 1.4.4.5 nathanw param = (ACPI_OBJECT *)buf.Pointer;
649 1.4.4.2 nathanw if (rv == AE_OK) {
650 1.4.4.5 nathanw if (param->Type == ACPI_TYPE_STRING) {
651 1.4.4.5 nathanw /* XXX may leak buf.Pointer!! */
652 1.4.4.5 nathanw *stringp = param->String.Pointer;
653 1.4.4.2 nathanw return (AE_OK);
654 1.4.4.2 nathanw }
655 1.4.4.2 nathanw rv = AE_TYPE;
656 1.4.4.2 nathanw }
657 1.4.4.2 nathanw
658 1.4.4.2 nathanw AcpiOsFree(buf.Pointer);
659 1.4.4.2 nathanw return (rv);
660 1.4.4.2 nathanw }
661 1.4.4.5 nathanw #endif
662 1.4.4.5 nathanw
663 1.4.4.5 nathanw
664 1.4.4.5 nathanw /*
665 1.4.4.5 nathanw * acpi_eval_struct:
666 1.4.4.5 nathanw *
667 1.4.4.5 nathanw * Evaluate a more complex structure. Caller must free buf.Pointer.
668 1.4.4.5 nathanw */
669 1.4.4.5 nathanw ACPI_STATUS
670 1.4.4.5 nathanw acpi_eval_struct(ACPI_HANDLE handle, char *path, ACPI_BUFFER *bufp)
671 1.4.4.5 nathanw {
672 1.4.4.5 nathanw ACPI_STATUS rv;
673 1.4.4.5 nathanw
674 1.4.4.5 nathanw if (handle == NULL)
675 1.4.4.5 nathanw handle = ACPI_ROOT_OBJECT;
676 1.4.4.5 nathanw
677 1.4.4.5 nathanw bufp->Pointer = NULL;
678 1.4.4.5 nathanw bufp->Length = 0;
679 1.4.4.5 nathanw
680 1.4.4.5 nathanw rv = AcpiEvaluateObject(handle, path, NULL, bufp);
681 1.4.4.5 nathanw if (rv != AE_BUFFER_OVERFLOW)
682 1.4.4.5 nathanw return (rv);
683 1.4.4.5 nathanw
684 1.4.4.5 nathanw bufp->Pointer = AcpiOsAllocate(bufp->Length);
685 1.4.4.5 nathanw if (bufp->Pointer == NULL)
686 1.4.4.5 nathanw return (AE_NO_MEMORY);
687 1.4.4.5 nathanw
688 1.4.4.5 nathanw rv = AcpiEvaluateObject(handle, path, NULL, bufp);
689 1.4.4.5 nathanw
690 1.4.4.5 nathanw return (rv);
691 1.4.4.5 nathanw }
692 1.4.4.2 nathanw
693 1.4.4.2 nathanw /*
694 1.4.4.2 nathanw * acpi_get:
695 1.4.4.2 nathanw *
696 1.4.4.2 nathanw * Fetch data info the specified (empty) ACPI buffer.
697 1.4.4.2 nathanw */
698 1.4.4.2 nathanw ACPI_STATUS
699 1.4.4.2 nathanw acpi_get(ACPI_HANDLE handle, ACPI_BUFFER *buf,
700 1.4.4.2 nathanw ACPI_STATUS (*getit)(ACPI_HANDLE, ACPI_BUFFER *))
701 1.4.4.2 nathanw {
702 1.4.4.2 nathanw ACPI_STATUS rv;
703 1.4.4.2 nathanw
704 1.4.4.2 nathanw buf->Pointer = NULL;
705 1.4.4.2 nathanw buf->Length = 0;
706 1.4.4.2 nathanw
707 1.4.4.2 nathanw rv = (*getit)(handle, buf);
708 1.4.4.2 nathanw if (rv != AE_BUFFER_OVERFLOW)
709 1.4.4.2 nathanw return (rv);
710 1.4.4.2 nathanw
711 1.4.4.6 nathanw buf->Pointer = AcpiOsAllocate(buf->Length);
712 1.4.4.2 nathanw if (buf->Pointer == NULL)
713 1.4.4.2 nathanw return (AE_NO_MEMORY);
714 1.4.4.6 nathanw memset(buf->Pointer, 0, buf->Length);
715 1.4.4.2 nathanw
716 1.4.4.2 nathanw return ((*getit)(handle, buf));
717 1.4.4.2 nathanw }
718 1.4.4.6 nathanw
719 1.4.4.6 nathanw
720 1.4.4.6 nathanw /*****************************************************************************
721 1.4.4.6 nathanw * ACPI sleep support.
722 1.4.4.6 nathanw *****************************************************************************/
723 1.4.4.6 nathanw
724 1.4.4.6 nathanw static int
725 1.4.4.6 nathanw is_available_state(struct acpi_softc *sc, int state)
726 1.4.4.6 nathanw {
727 1.4.4.6 nathanw UINT8 type_a, type_b;
728 1.4.4.6 nathanw
729 1.4.4.6 nathanw return (ACPI_SUCCESS(AcpiGetSleepTypeData((UINT8)state,
730 1.4.4.6 nathanw &type_a, &type_b)));
731 1.4.4.6 nathanw }
732 1.4.4.6 nathanw
733 1.4.4.6 nathanw /*
734 1.4.4.6 nathanw * acpi_enter_sleep_state:
735 1.4.4.6 nathanw *
736 1.4.4.6 nathanw * enter to the specified sleep state.
737 1.4.4.6 nathanw */
738 1.4.4.6 nathanw
739 1.4.4.6 nathanw ACPI_STATUS
740 1.4.4.6 nathanw acpi_enter_sleep_state(struct acpi_softc *sc, int state)
741 1.4.4.6 nathanw {
742 1.4.4.6 nathanw int s;
743 1.4.4.6 nathanw ACPI_STATUS ret = AE_OK;
744 1.4.4.6 nathanw
745 1.4.4.6 nathanw switch (state) {
746 1.4.4.6 nathanw case ACPI_STATE_S0:
747 1.4.4.6 nathanw break;
748 1.4.4.6 nathanw case ACPI_STATE_S1:
749 1.4.4.6 nathanw case ACPI_STATE_S2:
750 1.4.4.6 nathanw case ACPI_STATE_S3:
751 1.4.4.6 nathanw case ACPI_STATE_S4:
752 1.4.4.6 nathanw if (!is_available_state(sc, state)) {
753 1.4.4.6 nathanw printf("acpi: cannot enter the sleep state (%d).\n",
754 1.4.4.6 nathanw state);
755 1.4.4.6 nathanw break;
756 1.4.4.6 nathanw }
757 1.4.4.6 nathanw ret = AcpiEnterSleepStatePrep(state);
758 1.4.4.6 nathanw if (ACPI_FAILURE(ret)) {
759 1.4.4.6 nathanw printf("acpi: failed preparing to sleep (%s)\n",
760 1.4.4.6 nathanw AcpiFormatException(ret));
761 1.4.4.6 nathanw break;
762 1.4.4.6 nathanw }
763 1.4.4.6 nathanw if (state==ACPI_STATE_S1) {
764 1.4.4.6 nathanw /* just enter the state */
765 1.4.4.6 nathanw AcpiEnterSleepState((UINT8)state);
766 1.4.4.6 nathanw AcpiUtReleaseMutex(ACPI_MTX_HARDWARE);
767 1.4.4.6 nathanw } else {
768 1.4.4.6 nathanw /* XXX: powerhooks(9) framework is too poor to
769 1.4.4.6 nathanw * support ACPI sleep state...
770 1.4.4.6 nathanw */
771 1.4.4.6 nathanw dopowerhooks(PWR_SOFTSUSPEND);
772 1.4.4.6 nathanw s = splhigh();
773 1.4.4.6 nathanw dopowerhooks(PWR_SUSPEND);
774 1.4.4.6 nathanw acpi_md_sleep(state);
775 1.4.4.6 nathanw dopowerhooks(PWR_RESUME);
776 1.4.4.6 nathanw splx(s);
777 1.4.4.6 nathanw dopowerhooks(PWR_SOFTRESUME);
778 1.4.4.6 nathanw if (state==ACPI_STATE_S4)
779 1.4.4.6 nathanw AcpiEnable();
780 1.4.4.6 nathanw }
781 1.4.4.6 nathanw AcpiLeaveSleepState((UINT8)state);
782 1.4.4.6 nathanw break;
783 1.4.4.6 nathanw case ACPI_STATE_S5:
784 1.4.4.6 nathanw AcpiEnterSleepStatePrep(ACPI_STATE_S5);
785 1.4.4.6 nathanw AcpiEnterSleepState(ACPI_STATE_S5);
786 1.4.4.6 nathanw printf("WARNING: powerdown failed!\n");
787 1.4.4.6 nathanw break;
788 1.4.4.6 nathanw }
789 1.4.4.6 nathanw
790 1.4.4.6 nathanw return (ret);
791 1.4.4.6 nathanw }
792