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 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
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
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);
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)
228 return_VALUE (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));
247 return_VALUE (error);
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 }
262
263 /* Set up any quirks we have for this XSDT. */
264 acpi_quirks_set();
265
266 return_VALUE (AE_OK);
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
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
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
1896 if ((env = getenv("debug.acpi.disabled")) == NULL)
1897 return (0);
1898 if (strcmp(env, "all") == 0) {
1899 freeenv(env);
1900 return (1);
1901 }
1902
1903 /* Scan the disable list, checking for a match. */
1904 cp = env;
1905 for (;;) {
1906 while (*cp != '\0' && isspace(*cp))
1907 cp++;
1908 if (*cp == '\0')
1909 break;
1910 len = 0;
1911 while (cp[len] != '\0' && !isspace(cp[len]))
1912 len++;
1913 if (strncmp(cp, subsys, len) == 0) {
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
2275 {"ACPI_AC_ADAPTER", ACPI_AC_ADAPTER},
2276 {"ACPI_BATTERY", ACPI_BATTERY},
2277 {"ACPI_BUS", ACPI_BUS},
2278 {"ACPI_BUTTON", ACPI_BUTTON},
2279 {"ACPI_EC", ACPI_EC},
2280 {"ACPI_FAN", ACPI_FAN},
2281 {"ACPI_POWERRES", ACPI_POWERRES},
2282 {"ACPI_PROCESSOR", ACPI_PROCESSOR},
2283 {"ACPI_THERMAL", ACPI_THERMAL},
2284 {"ACPI_TIMER", ACPI_TIMER},
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 ---