Deleted Added
full compact
acpi.c (126080) acpi.c (126517)
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 *
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 $
29 * $FreeBSD: head/sys/dev/acpica/acpi.c 126517 2004-03-03 03:02:17Z njl $
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
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
88struct acpi_quirks {
89 char *OemId;
90 uint32_t OemRevision;
91 char *value;
92};
93
94#define ACPI_OEM_REV_ANY 0
95
96static struct acpi_quirks acpi_quirks_table[] = {
97#ifdef notyet
98 /* Bad PCI routing table. Used on some SuperMicro boards. */
99 { "PTLTD ", 0x06040000, "pci_link" },
100#endif
101
102 { NULL, 0, NULL }
103};
104
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);
105static int acpi_modevent(struct module *mod, int event, void *junk);
106static void acpi_identify(driver_t *driver, device_t parent);
107static int acpi_probe(device_t dev);
108static int acpi_attach(device_t dev);
109static void acpi_quirks_set(void);
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)
110static device_t acpi_add_child(device_t bus, int order, const char *name,
111 int unit);
112static int acpi_print_child(device_t bus, device_t child);
113static int acpi_read_ivar(device_t dev, device_t child, int index,
114 uintptr_t *result);
115static int acpi_write_ivar(device_t dev, device_t child, int index,
116 uintptr_t value);
117static int acpi_set_resource(device_t dev, device_t child, int type,

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

220#ifdef ACPI_DEBUGGER
221 char *debugpoint;
222#endif
223 static int error, started = 0;
224
225 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
226
227 if (started)
210 return_VALUE(error);
228 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 started = 1;
230
231#if __FreeBSD_version >= 500000
232 /* Initialise the ACPI mutex */
233 mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
234#endif
235
236 /* Start up the ACPI CA subsystem. */
237#ifdef ACPI_DEBUGGER
238 debugpoint = getenv("debug.acpi.debugger");
239 if (debugpoint) {
240 if (!strcmp(debugpoint, "init"))
241 acpi_EnterDebugger();
242 freeenv(debugpoint);
243 }
244#endif
245 if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) {
246 printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error));
229 return_VALUE(error);
247 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 }
248 }
249#ifdef ACPI_DEBUGGER
250 debugpoint = getenv("debug.acpi.debugger");
251 if (debugpoint) {
252 if (!strcmp(debugpoint, "tables"))
253 acpi_EnterDebugger();
254 freeenv(debugpoint);
255 }
256#endif
257
258 if (ACPI_FAILURE(error = AcpiLoadTables())) {
259 printf("ACPI: table load failed: %s\n", AcpiFormatException(error));
260 return_VALUE(error);
261 }
244 return_VALUE(AE_OK);
262
263 /* Set up any quirks we have for this XSDT. */
264 acpi_quirks_set();
265
266 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
267}
268
269/*
270 * Detect ACPI, perform early initialisation
271 */
272static void
273acpi_identify(driver_t *driver, device_t parent)
274{

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

570
571 error = 0;
572
573 out:
574 ACPI_UNLOCK;
575 return_VALUE (error);
576}
577
578static void
579acpi_quirks_set()
580{
581 XSDT_DESCRIPTOR *xsdt;
582 struct acpi_quirks *quirk;
583 char *env, *tmp;
584 int len;
585
586 /* If the user specifies "noquirks", leave the settings alone. */
587 len = 0;
588 if ((env = getenv("debug.acpi.disabled")) != NULL) {
589 if (strstr("noquirks", env) != NULL)
590 goto out;
591 len = strlen(env);
592 }
593
594 /*
595 * Search through our quirk table and concatenate the disabled
596 * values with whatever we find.
597 */
598 xsdt = AcpiGbl_XSDT;
599 for (quirk = acpi_quirks_table; quirk->OemId; quirk++) {
600 if (!strncmp(xsdt->OemId, quirk->OemId, strlen(quirk->OemId)) &&
601 (xsdt->OemRevision == quirk->OemRevision ||
602 quirk->OemRevision == ACPI_OEM_REV_ANY)) {
603 len += strlen(quirk->value) + 2;
604 if ((tmp = malloc(len, M_TEMP, M_NOWAIT)) == NULL)
605 goto out;
606 sprintf(tmp, "%s %s", env ? env : "", quirk->value);
607 setenv("debug.acpi.disabled", tmp);
608 free(tmp, M_TEMP);
609 break;
610 }
611 }
612
613out:
614 if (env)
615 freeenv(env);
616}
617
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
618/*
619 * Handle a new device being added
620 */
621static device_t
622acpi_add_child(device_t bus, int order, const char *name, int unit)
623{
624 struct acpi_device *ad;
625 device_t child;

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

647 retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
648 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
649 retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%ld");
650 retval += bus_print_child_footer(bus, child);
651
652 return (retval);
653}
654
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
655/*
656 * Handle per-device ivars
657 */
658static int
659acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
660{
661 struct acpi_device *ad;
662

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

1888 * Debugging/bug-avoidance. Disable ACPI subsystem components.
1889 */
1890int
1891acpi_disabled(char *subsys)
1892{
1893 char *cp, *env;
1894 int len;
1895
1835 if ((env = getenv("debug.acpi.disable")) == NULL)
1896 if ((env = getenv("debug.acpi.disabled")) == NULL)
1836 return (0);
1897 return (0);
1837 if (!strcmp(env, "all")) {
1898 if (strcmp(env, "all") == 0) {
1838 freeenv(env);
1839 return (1);
1840 }
1841
1899 freeenv(env);
1900 return (1);
1901 }
1902
1842 /* scan the disable list checking for a match */
1903 /* Scan the disable list, checking for a match. */
1843 cp = env;
1844 for (;;) {
1904 cp = env;
1905 for (;;) {
1845 while ((*cp != 0) && isspace(*cp))
1906 while (*cp != '\0' && isspace(*cp))
1846 cp++;
1907 cp++;
1847 if (*cp == 0)
1908 if (*cp == '\0')
1848 break;
1849 len = 0;
1909 break;
1910 len = 0;
1850 while ((cp[len] != 0) && !isspace(cp[len]))
1911 while (cp[len] != '\0' && !isspace(cp[len]))
1851 len++;
1912 len++;
1852 if (!strncmp(cp, subsys, len)) {
1913 if (strncmp(cp, subsys, len) == 0) {
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
1914 freeenv(env);
1915 return (1);
1916 }
1917 cp += len;
1918 }
1919 freeenv(env);
1920
1921 return (0);

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

2267 {"ACPI_DISPATCHER", ACPI_DISPATCHER},
2268 {"ACPI_EXECUTER", ACPI_EXECUTER},
2269 {"ACPI_RESOURCES", ACPI_RESOURCES},
2270 {"ACPI_CA_DEBUGGER", ACPI_CA_DEBUGGER},
2271 {"ACPI_OS_SERVICES", ACPI_OS_SERVICES},
2272 {"ACPI_CA_DISASSEMBLER", ACPI_CA_DISASSEMBLER},
2273 {"ACPI_ALL_COMPONENTS", ACPI_ALL_COMPONENTS},
2274
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},
2275 {"ACPI_AC_ADAPTER", ACPI_AC_ADAPTER},
2276 {"ACPI_BATTERY", ACPI_BATTERY},
2277 {"ACPI_BUS", ACPI_BUS},
2220 {"ACPI_BUTTON", ACPI_BUTTON},
2278 {"ACPI_BUTTON", ACPI_BUTTON},
2279 {"ACPI_EC", ACPI_EC},
2280 {"ACPI_FAN", ACPI_FAN},
2281 {"ACPI_POWERRES", ACPI_POWERRES},
2221 {"ACPI_PROCESSOR", ACPI_PROCESSOR},
2222 {"ACPI_THERMAL", ACPI_THERMAL},
2282 {"ACPI_PROCESSOR", ACPI_PROCESSOR},
2283 {"ACPI_THERMAL", ACPI_THERMAL},
2223 {"ACPI_FAN", ACPI_FAN},
2284 {"ACPI_TIMER", ACPI_TIMER},
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 ---
2285 {"ACPI_ALL_DRIVERS", ACPI_ALL_DRIVERS},
2286 {NULL, 0}
2287};
2288
2289static struct debugtag dbg_level[] = {
2290 {"ACPI_LV_ERROR", ACPI_LV_ERROR},
2291 {"ACPI_LV_WARN", ACPI_LV_WARN},
2292 {"ACPI_LV_INIT", ACPI_LV_INIT},

--- 212 unchanged lines hidden ---