Deleted Added
sdiff udiff text old ( 126080 ) new ( 126517 )
full compact
1/*-
2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2000, 2001 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/sys/dev/acpica/acpi.c 126080 2004-02-21 21:10:55Z phk $
30 */
31
32#include "opt_acpi.h"
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/proc.h>
36#include <sys/fcntl.h>
37#include <sys/malloc.h>

--- 42 unchanged lines hidden (view full) ---

80
81/* this has to be static, as the softc is gone when we need it */
82static int acpi_off_state = ACPI_STATE_S5;
83
84#if __FreeBSD_version >= 500000
85struct mtx acpi_mutex;
86#endif
87
88static int acpi_modevent(struct module *mod, int event, void *junk);
89static void acpi_identify(driver_t *driver, device_t parent);
90static int acpi_probe(device_t dev);
91static int acpi_attach(device_t dev);
92static device_t acpi_add_child(device_t bus, int order, const char *name,
93 int unit);
94static int acpi_print_child(device_t bus, device_t child);
95static int acpi_read_ivar(device_t dev, device_t child, int index,
96 uintptr_t *result);
97static int acpi_write_ivar(device_t dev, device_t child, int index,
98 uintptr_t value);
99static int acpi_set_resource(device_t dev, device_t child, int type,

--- 102 unchanged lines hidden (view full) ---

202#ifdef ACPI_DEBUGGER
203 char *debugpoint;
204#endif
205 static int error, started = 0;
206
207 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
208
209 if (started)
210 return_VALUE(error);
211 started = 1;
212
213#if __FreeBSD_version >= 500000
214 /* Initialise the ACPI mutex */
215 mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
216#endif
217
218 /* Start up the ACPI CA subsystem. */
219#ifdef ACPI_DEBUGGER
220 debugpoint = getenv("debug.acpi.debugger");
221 if (debugpoint) {
222 if (!strcmp(debugpoint, "init"))
223 acpi_EnterDebugger();
224 freeenv(debugpoint);
225 }
226#endif
227 if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) {
228 printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error));
229 return_VALUE(error);
230 }
231#ifdef ACPI_DEBUGGER
232 debugpoint = getenv("debug.acpi.debugger");
233 if (debugpoint) {
234 if (!strcmp(debugpoint, "tables"))
235 acpi_EnterDebugger();
236 freeenv(debugpoint);
237 }
238#endif
239
240 if (ACPI_FAILURE(error = AcpiLoadTables())) {
241 printf("ACPI: table load failed: %s\n", AcpiFormatException(error));
242 return_VALUE(error);
243 }
244 return_VALUE(AE_OK);
245}
246
247/*
248 * Detect ACPI, perform early initialisation
249 */
250static void
251acpi_identify(driver_t *driver, device_t parent)
252{

--- 295 unchanged lines hidden (view full) ---

548
549 error = 0;
550
551 out:
552 ACPI_UNLOCK;
553 return_VALUE (error);
554}
555
556/*
557 * Handle a new device being added
558 */
559static device_t
560acpi_add_child(device_t bus, int order, const char *name, int unit)
561{
562 struct acpi_device *ad;
563 device_t child;

--- 21 unchanged lines hidden (view full) ---

585 retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
586 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
587 retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%ld");
588 retval += bus_print_child_footer(bus, child);
589
590 return (retval);
591}
592
593
594/*
595 * Handle per-device ivars
596 */
597static int
598acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
599{
600 struct acpi_device *ad;
601

--- 1225 unchanged lines hidden (view full) ---

1827 * Debugging/bug-avoidance. Disable ACPI subsystem components.
1828 */
1829int
1830acpi_disabled(char *subsys)
1831{
1832 char *cp, *env;
1833 int len;
1834
1835 if ((env = getenv("debug.acpi.disable")) == NULL)
1836 return (0);
1837 if (!strcmp(env, "all")) {
1838 freeenv(env);
1839 return (1);
1840 }
1841
1842 /* scan the disable list checking for a match */
1843 cp = env;
1844 for (;;) {
1845 while ((*cp != 0) && isspace(*cp))
1846 cp++;
1847 if (*cp == 0)
1848 break;
1849 len = 0;
1850 while ((cp[len] != 0) && !isspace(cp[len]))
1851 len++;
1852 if (!strncmp(cp, subsys, len)) {
1853 freeenv(env);
1854 return (1);
1855 }
1856 cp += len;
1857 }
1858 freeenv(env);
1859
1860 return (0);

--- 345 unchanged lines hidden (view full) ---

2206 {"ACPI_DISPATCHER", ACPI_DISPATCHER},
2207 {"ACPI_EXECUTER", ACPI_EXECUTER},
2208 {"ACPI_RESOURCES", ACPI_RESOURCES},
2209 {"ACPI_CA_DEBUGGER", ACPI_CA_DEBUGGER},
2210 {"ACPI_OS_SERVICES", ACPI_OS_SERVICES},
2211 {"ACPI_CA_DISASSEMBLER", ACPI_CA_DISASSEMBLER},
2212 {"ACPI_ALL_COMPONENTS", ACPI_ALL_COMPONENTS},
2213
2214 {"ACPI_BUS", ACPI_BUS},
2215 {"ACPI_SYSTEM", ACPI_SYSTEM},
2216 {"ACPI_POWER", ACPI_POWER},
2217 {"ACPI_EC", ACPI_EC},
2218 {"ACPI_AC_ADAPTER", ACPI_AC_ADAPTER},
2219 {"ACPI_BATTERY", ACPI_BATTERY},
2220 {"ACPI_BUTTON", ACPI_BUTTON},
2221 {"ACPI_PROCESSOR", ACPI_PROCESSOR},
2222 {"ACPI_THERMAL", ACPI_THERMAL},
2223 {"ACPI_FAN", ACPI_FAN},
2224 {"ACPI_ALL_DRIVERS", ACPI_ALL_DRIVERS},
2225 {NULL, 0}
2226};
2227
2228static struct debugtag dbg_level[] = {
2229 {"ACPI_LV_ERROR", ACPI_LV_ERROR},
2230 {"ACPI_LV_WARN", ACPI_LV_WARN},
2231 {"ACPI_LV_INIT", ACPI_LV_INIT},

--- 212 unchanged lines hidden ---