diff options
author | msmith <msmith@FreeBSD.org> | 2000-12-08 09:16:20 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2000-12-08 09:16:20 +0000 |
commit | 3d96e58d420f86cc9ab2fab8c58a17921833e586 (patch) | |
tree | 13559703e4a964e10c5a092763cd63d3b6d8de56 /sys/dev/acpica | |
parent | 601ec8e1853accdb6afea835eff3e1a5d42b2390 (diff) | |
download | FreeBSD-src-3d96e58d420f86cc9ab2fab8c58a17921833e586.zip FreeBSD-src-3d96e58d420f86cc9ab2fab8c58a17921833e586.tar.gz |
- Convert a lot of homebrew debugging output to use the ACPI CA debugging
infrastructure. It's not perfect, but it's a lot better than what
we've been using so far. The following rules apply to this:
o BSD component names should be capitalised
o Layer names should be taken from the non-CA set for now. We
may elect to add some new BSD-specific layers later.
- Make it possible to turn off selective debugging flags or layers
by listing them in debug.acpi.layer or debug.acpi.level prefixed
with !.
- Fully implement support for avoiding nodes in the ACPI namespace.
Nodes may be listed in the debug.acpi.avoid environment variable;
these nodes and all their children will be ignored (although still
scanned over) by ACPI functions which scan the namespace. Multiple
nodes can be specified, separated by whitespace.
- Implement support for selectively disabling ACPI subsystem components
via the debug.acpi.disable environment variable. The following
components can be disabled:
o bus creation/scanning of the ACPI 'bus'
o children attachment of children to the ACPI 'bus'
o button the acpi_button control-method button driver
o ec the acpi_ec embedded-controller driver
o isa acpi replacement of PnP BIOS for ISA device discovery
o lid the control-method lid switch driver
o pci pci root-bus discovery
o processor CPU power/speed management
o thermal system temperature detection and control
o timer ACPI timecounter
Multiple components may be disabled by specifying their name(s)
separated by whitespace.
- Add support for ioctl registration. ACPI subsystem components may
register ioctl handlers with the /dev/acpi generic ioctl handler,
allowing us to avoid the need for a multitude of /dev/acpi* control
devices, etc.
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r-- | sys/dev/acpica/acpi.c | 267 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_button.c | 52 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_ec.c | 47 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_isa.c | 70 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_lid.c | 26 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_pcib.c | 23 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_pcib_acpi.c | 23 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_processor.c | 50 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_resource.c | 89 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_thermal.c | 24 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_timer.c | 25 | ||||
-rw-r--r-- | sys/dev/acpica/acpiio.h | 7 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 5 |
13 files changed, 512 insertions, 196 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 5095c54..3bb3a9b 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -52,6 +52,12 @@ MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices"); /* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT BUS_MANAGER +MODULE_NAME("ACPI") + +/* * Character device */ @@ -159,6 +165,8 @@ acpi_identify(driver_t *driver, device_t parent) char *debugpoint = getenv("debug.acpi.debugger"); #endif + FUNCTION_TRACE(__FUNCTION__); + if(!cold){ printf("Don't load this driver from userland!!\n"); return ; @@ -168,7 +176,7 @@ acpi_identify(driver_t *driver, device_t parent) * Make sure we're not being doubly invoked. */ if (device_find_child(parent, "acpi", 0) != NULL) - return; + return_VOID; #ifdef ACPI_DEBUG acpi_set_debugging(); @@ -183,7 +191,7 @@ acpi_identify(driver_t *driver, device_t parent) #endif if ((error = AcpiInitializeSubsystem()) != AE_OK) { printf("ACPI: initialisation failed: %s\n", acpi_strerror(error)); - return; + return_VOID; } #ifdef ENABLE_DEBUGGER if (debugpoint && !strcmp(debugpoint, "tables")) @@ -192,7 +200,7 @@ acpi_identify(driver_t *driver, device_t parent) if (((error = AcpiFindRootPointer(&rsdp)) != AE_OK) || ((error = AcpiLoadTables(rsdp)) != AE_OK)) { printf("ACPI: table load failed: %s\n", acpi_strerror(error)); - return; + return_VOID; } /* @@ -200,7 +208,7 @@ acpi_identify(driver_t *driver, device_t parent) */ if ((child = BUS_ADD_CHILD(parent, 0, "acpi", 0)) == NULL) { device_printf(parent, "ACPI: could not attach\n"); - return; + return_VOID; } } @@ -214,14 +222,16 @@ acpi_probe(device_t dev) char buf[20]; int error; + FUNCTION_TRACE(__FUNCTION__); + if ((error = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th)) != AE_OK) { device_printf(dev, "couldn't get XSDT header: %s\n", acpi_strerror(error)); - return(ENXIO); + return_VALUE(ENXIO); } sprintf(buf, "%.6s %.8s", th.OemId, th.OemTableId); device_set_desc_copy(dev, buf); - return(0); + return_VALUE(0); } static int @@ -233,6 +243,7 @@ acpi_attach(device_t dev) char *debugpoint = getenv("debug.acpi.debugger"); #endif + FUNCTION_TRACE(__FUNCTION__); sc = device_get_softc(dev); bzero(sc, sizeof(*sc)); @@ -251,21 +262,21 @@ acpi_attach(device_t dev) ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemMemory handler: %s\n", acpi_strerror(error)); - return(ENXIO); + return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ADDRESS_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemIO handler: %s\n", acpi_strerror(error)); - return(ENXIO); + return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ADDRESS_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise PciConfig handler: %s\n", acpi_strerror(error)); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -283,7 +294,7 @@ acpi_attach(device_t dev) #endif if ((error = AcpiEnableSubsystem(ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT)) != AE_OK) { device_printf(dev, "could not enable ACPI: %s\n", acpi_strerror(error)); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -315,7 +326,8 @@ acpi_attach(device_t dev) if (debugpoint && !strcmp(debugpoint, "probe")) acpi_EnterDebugger(); #endif - acpi_probe_children(dev); + if (!acpi_disabled("bus")) + acpi_probe_children(dev); /* * Register our shutdown handlers @@ -346,7 +358,7 @@ acpi_attach(device_t dev) if (debugpoint && !strcmp(debugpoint, "running")) acpi_EnterDebugger(); #endif - return(0); + return_VALUE(0); } /* @@ -547,9 +559,12 @@ acpi_probe_children(device_t bus) static char *scopes[] = {"\\_TZ_", "\\_SI", "\\_SB_", NULL}; int i; + FUNCTION_TRACE(__FUNCTION__); + /* * Create any static children by calling device identify methods. */ + DEBUG_PRINT(TRACE_OBJECTS, ("device identify routines\n")); bus_generic_probe(bus); /* @@ -561,6 +576,7 @@ acpi_probe_children(device_t bus) * present. (This assumes that we don't want to create/remove devices as they * appear, which might be smarter.) */ + DEBUG_PRINT(TRACE_OBJECTS, ("namespace scan\n")); for (i = 0; scopes[i] != NULL; i++) if ((AcpiGetHandle(ACPI_ROOT_OBJECT, scopes[i], &parent)) == AE_OK) AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100, acpi_probe_child, bus, NULL); @@ -568,13 +584,17 @@ acpi_probe_children(device_t bus) /* * Scan all of the child devices we have created and let them probe/attach. */ + DEBUG_PRINT(TRACE_OBJECTS, ("first bus_generic_attach\n")); bus_generic_attach(bus); /* * Some of these children may have attached others as part of their attach * process (eg. the root PCI bus driver), so rescan. */ + DEBUG_PRINT(TRACE_OBJECTS, ("second bus_generic_attach\n")); bus_generic_attach(bus); + + return_VOID; } /* @@ -587,28 +607,41 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) ACPI_OBJECT_TYPE type; device_t child, bus = (device_t)context; + FUNCTION_TRACE(__FUNCTION__); + + /* + * Skip this device if we think we'll have trouble with it. + */ + if (acpi_avoid(handle)) + return_ACPI_STATUS(AE_OK); + if (AcpiGetType(handle, &type) == AE_OK) { switch(type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: case ACPI_TYPE_POWER: + if (acpi_disabled("children")) + break; /* * Create a placeholder device for this node. Sort the placeholder * so that the probe/attach passes will run breadth-first. */ + DEBUG_PRINT(TRACE_OBJECTS, ("scanning '%s'\n", acpi_name(handle))) child = BUS_ADD_CHILD(bus, level * 10, NULL, -1); acpi_set_handle(child, handle); + DEBUG_EXEC(device_probe_and_attach(child)); + break; } } - return(AE_OK); + return_ACPI_STATUS(AE_OK); } static void acpi_shutdown_pre_sync(void *arg, int howto) { /* - * disable all of ACPI events before soft off, otherwise the system + * Disable all ACPI events before soft off, otherwise the system * will be turned on again on some laptops. * * XXX this should probably be restricted to masking some events just @@ -643,7 +676,7 @@ acpi_MatchHid(device_t dev, char *hid) ACPI_HANDLE h; ACPI_DEVICE_INFO devinfo; ACPI_STATUS error; - + if (hid == NULL) return(FALSE); if ((h = acpi_get_handle(dev)) == NULL) @@ -699,6 +732,8 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) { ACPI_STATUS status = AE_OK; + FUNCTION_TRACE_U32(__FUNCTION__, state); + switch (state) { case ACPI_STATE_S0: /* XXX only for testing */ status = AcpiSetSystemSleepState((UINT8)state); @@ -720,7 +755,7 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) * current bus interface does not provide for this. */ DEVICE_RESUME(root_bus); - return(AE_ERROR); + return_ACPI_STATUS(AE_ERROR); } sc->acpi_sstate = state; status = AcpiSetSystemSleepState((UINT8)state); @@ -743,7 +778,7 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) status = AE_BAD_PARAMETER; break; } - return(status); + return_ACPI_STATUS(status); } /* @@ -755,6 +790,8 @@ acpi_Enable(struct acpi_softc *sc) ACPI_STATUS status; u_int32_t flags; + FUNCTION_TRACE(__FUNCTION__); + flags = ACPI_NO_ADDRESS_SPACE_INIT | ACPI_NO_HARDWARE_INIT | ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; if (!sc->acpi_enabled) { @@ -764,7 +801,7 @@ acpi_Enable(struct acpi_softc *sc) } if (status == AE_OK) sc->acpi_enabled = 1; - return(status); + return_ACPI_STATUS(status); } ACPI_STATUS @@ -772,6 +809,8 @@ acpi_Disable(struct acpi_softc *sc) { ACPI_STATUS status; + FUNCTION_TRACE(__FUNCTION__); + if (sc->acpi_enabled) { status = AcpiDisable(); } else { @@ -779,7 +818,7 @@ acpi_Disable(struct acpi_softc *sc) } if (status == AE_OK) sc->acpi_enabled = 0; - return(status); + return_ACPI_STATUS(status); } /* @@ -836,18 +875,21 @@ acpi_EvaluateNumber(ACPI_HANDLE handle, char *path, int *number) static void acpi_system_eventhandler_sleep(void *arg, int state) { - if (state < ACPI_STATE_S0 || state > ACPI_STATE_S5) { - return; - } + FUNCTION_TRACE_U32(__FUNCTION__, state); - acpi_SetSleepState((struct acpi_softc *)arg, state); + if (state >= ACPI_STATE_S0 && state <= ACPI_STATE_S5) + acpi_SetSleepState((struct acpi_softc *)arg, state); + return_VOID; } - static void acpi_system_eventhandler_wakeup(void *arg, int state) { + FUNCTION_TRACE_U32(__FUNCTION__, state); + /* Well, what to do? :-) */ + + return_VOID; } /* @@ -858,8 +900,11 @@ acpi_eventhandler_power_button_for_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; + FUNCTION_TRACE(__FUNCTION__); + EVENTHANDLER_INVOKE(acpi_sleep_event, sc->acpi_power_button_sx); - return(INTERRUPT_HANDLED); + + return_VALUE(INTERRUPT_HANDLED); } UINT32 @@ -867,8 +912,11 @@ acpi_eventhandler_power_button_for_wakeup(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; + FUNCTION_TRACE(__FUNCTION__); + EVENTHANDLER_INVOKE(acpi_wakeup_event, sc->acpi_power_button_sx); - return(INTERRUPT_HANDLED); + + return_VALUE(INTERRUPT_HANDLED); } UINT32 @@ -876,8 +924,11 @@ acpi_eventhandler_sleep_button_for_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; + FUNCTION_TRACE(__FUNCTION__); + EVENTHANDLER_INVOKE(acpi_sleep_event, sc->acpi_sleep_button_sx); - return(INTERRUPT_HANDLED); + + return_VALUE(INTERRUPT_HANDLED); } UINT32 @@ -885,8 +936,11 @@ acpi_eventhandler_sleep_button_for_wakeup(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; + FUNCTION_TRACE(__FUNCTION__); + EVENTHANDLER_INVOKE(acpi_wakeup_event, sc->acpi_sleep_button_sx); - return(INTERRUPT_HANDLED); + + return_VALUE(INTERRUPT_HANDLED); } /* @@ -949,7 +1003,39 @@ acpi_avoid(ACPI_HANDLE handle) while ((cp[len] != 0) && !isspace(cp[len])) len++; if (!strncmp(cp, np, len)) { - printf("avoiding '%s'\n", np); + DEBUG_PRINT(TRACE_OBJECTS, ("avoiding '%s'\n", np)); + return(1); + } + cp += len; + } + return(0); +} + +/* + * Debugging/bug-avoidance. Disable ACPI subsystem components. + */ +int +acpi_disabled(char *subsys) +{ + char *cp; + int len; + + if ((cp = getenv("debug.acpi.disable")) == NULL) + return(0); + if (!strcmp(cp, "all")) + return(1); + + /* scan the disable list checking for a match */ + for (;;) { + while ((*cp != 0) && isspace(*cp)) + cp++; + if (*cp == 0) + break; + len = 0; + while ((cp[len] != 0) && !isspace(cp[len])) + len++; + if (!strncmp(cp, subsys, len)) { + DEBUG_PRINT(TRACE_OBJECTS, ("disabled '%s'\n", subsys)); return(1); } cp += len; @@ -960,42 +1046,107 @@ acpi_avoid(ACPI_HANDLE handle) /* * Control interface. * - * XXX this is provided as a temporary measure for - * backwards compatibility for now. A better - * interface will probably use sysctl or similar. + * We multiplex ioctls for all participating ACPI devices here. Individual + * drivers wanting to be accessible via /dev/acpi should use the register/deregister + * interface to make their handlers visible. */ +struct acpi_ioctl_hook +{ + TAILQ_ENTRY(acpi_ioctl_hook) link; + u_long cmd; + int (* fn)(u_long cmd, caddr_t addr, void *arg); + void *arg; +}; + +static TAILQ_HEAD(,acpi_ioctl_hook) acpi_ioctl_hooks; +static int acpi_ioctl_hooks_initted; + +/* + * Register an ioctl handler. + */ +int +acpi_register_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg), void *arg) +{ + struct acpi_ioctl_hook *hp; + + if ((hp = malloc(sizeof(*hp), M_ACPIDEV, M_NOWAIT)) == NULL) + return(ENOMEM); + hp->cmd = cmd; + hp->fn = fn; + hp->arg = arg; + if (acpi_ioctl_hooks_initted == 0) { + TAILQ_INIT(&acpi_ioctl_hooks); + acpi_ioctl_hooks_initted = 1; + } + TAILQ_INSERT_TAIL(&acpi_ioctl_hooks, hp, link); + return(0); +} + +/* + * Deregister an ioctl handler. + */ +void +acpi_deregister_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg)) +{ + struct acpi_ioctl_hook *hp; + + TAILQ_FOREACH(hp, &acpi_ioctl_hooks, link) + if ((hp->cmd == cmd) && (hp->fn == fn)) + break; + + if (hp != NULL) { + TAILQ_REMOVE(&acpi_ioctl_hooks, hp, link); + free(hp, M_ACPIDEV); + } +} + static int -acpiopen(dev_t dev, int flag, int fmt, struct proc * p) +acpiopen(dev_t dev, int flag, int fmt, struct proc *p) { return(0); } static int -acpiclose(dev_t dev, int flag, int fmt, struct proc * p) +acpiclose(dev_t dev, int flag, int fmt, struct proc *p) { return(0); } static int -acpiioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc * p) +acpiioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { - int error, state; - struct acpi_softc *sc; + struct acpi_softc *sc; + struct acpi_ioctl_hook *hp; + int error, xerror, state; error = state = 0; sc = dev->si_drv1; + /* + * Scan the list of registered ioctls, looking for handlers. + */ + if (acpi_ioctl_hooks_initted) { + TAILQ_FOREACH(hp, &acpi_ioctl_hooks, link) { + if (hp->cmd == cmd) { + xerror = hp->fn(cmd, addr, hp->arg); + if (xerror != 0) + error = xerror; + } + } + } + + /* + * Core system ioctls. + */ switch (cmd) { case ACPIIO_ENABLE: - if (ACPI_FAILURE(acpi_Enable(sc))) { + if (ACPI_FAILURE(acpi_Enable(sc))) error = ENXIO; - } break; case ACPIIO_DISABLE: - if (ACPI_FAILURE(acpi_Disable(sc))) { + if (ACPI_FAILURE(acpi_Disable(sc))) error = ENXIO; - } break; case ACPIIO_SETSLPSTATE: @@ -1009,18 +1160,25 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc * p) } else { error = EINVAL; } - break; default: - error = EINVAL; + if (error == 0) + error = EINVAL; break; } - return(error); } #ifdef ACPI_DEBUG +/* + * Support for parsing debug options from the kernel environment. + * + * Bits may be set in the AcpiDbgLayer and AcpiDbgLevel debug registers + * by specifying the names of the bits in the debug.acpi.layer and + * debug.acpi.level environment variables. Bits may be unset by + * prefixing the bit name with !. + */ struct debugtag { char *name; @@ -1093,6 +1251,7 @@ acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag) { char *ep; int i, l; + int set; while (*cp) { if (isspace(*cp)) { @@ -1102,10 +1261,22 @@ acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag) ep = cp; while (*ep && !isspace(*ep)) ep++; + if (*cp == '!') { + set = 0; + cp++; + if (cp == ep) + continue; + } else { + set = 1; + } l = ep - cp; for (i = 0; tag[i].name != NULL; i++) { if (!strncmp(cp, tag[i].name, l)) { - *flag |= tag[i].value; + if (set) { + *flag |= tag[i].value; + } else { + *flag &= ~tag[i].value; + } printf("ACPI_DEBUG: set '%s'\n", tag[i].name); } } @@ -1117,10 +1288,14 @@ static void acpi_set_debugging(void) { char *cp; - + + AcpiDbgLayer = 0; + AcpiDbgLevel = 0; if ((cp = getenv("debug.acpi.layer")) != NULL) acpi_parse_debug(cp, &dbg_layer[0], &AcpiDbgLayer); if ((cp = getenv("debug.acpi.level")) != NULL) acpi_parse_debug(cp, &dbg_level[0], &AcpiDbgLevel); + + printf("ACPI debug layer 0x%x debug level 0x%x\n", AcpiDbgLayer, AcpiDbgLevel); } #endif diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c index cc6b4c2..70cad56 100644 --- a/sys/dev/acpica/acpi_button.c +++ b/sys/dev/acpica/acpi_button.c @@ -37,6 +37,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT SYSTEM_CONTROL +MODULE_NAME("BUTTON") + struct acpi_button_softc { device_t button_dev; ACPI_HANDLE button_handle; @@ -75,17 +81,18 @@ acpi_button_probe(device_t dev) sc = device_get_softc(dev); if (acpi_get_type(dev) == ACPI_TYPE_DEVICE) { - if (acpi_MatchHid(dev, "PNP0C0C")) { - device_set_desc(dev, "Control Method Power Button Device"); - sc->button_type = ACPI_POWER_BUTTON; - return(0); + if (!acpi_disabled("button")) { + if (acpi_MatchHid(dev, "PNP0C0C")) { + device_set_desc(dev, "Control Method Power Button Device"); + sc->button_type = ACPI_POWER_BUTTON; + return(0); + } + if (acpi_MatchHid(dev, "PNP0C0E")) { + device_set_desc(dev, "Control Method Sleep Button Device"); + sc->button_type = ACPI_SLEEP_BUTTON; + return(0); + } } - if (acpi_MatchHid(dev, "PNP0C0E")) { - device_set_desc(dev, "Control Method Sleep Button Device"); - sc->button_type = ACPI_SLEEP_BUTTON; - return(0); - } - return(ENXIO); } return(ENXIO); } @@ -96,6 +103,8 @@ acpi_button_attach(device_t dev) struct acpi_button_softc *sc; ACPI_STATUS status; + FUNCTION_TRACE(__FUNCTION__); + sc = device_get_softc(dev); sc->button_dev = dev; sc->button_handle = acpi_get_handle(dev); @@ -103,9 +112,9 @@ acpi_button_attach(device_t dev) if ((status = AcpiInstallNotifyHandler(sc->button_handle, ACPI_DEVICE_NOTIFY, acpi_button_notify_handler, sc)) != AE_OK) { device_printf(sc->button_dev, "couldn't install Notify handler - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } - return(0); + return_VALUE(0); } static void @@ -114,10 +123,12 @@ acpi_button_notify_pressed_for_sleep(void *arg) struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; + FUNCTION_TRACE(__FUNCTION__); + sc = (struct acpi_button_softc *)arg; acpi_sc = acpi_device_get_parent_softc(sc->button_dev); if (acpi_sc == NULL) { - return; + return_VOID; } switch (sc->button_type) { @@ -128,8 +139,9 @@ acpi_button_notify_pressed_for_sleep(void *arg) acpi_eventhandler_sleep_button_for_sleep((void *)acpi_sc); break; default: - return; /* unknown button type */ + break; /* unknown button type */ } + return_VOID; } static void @@ -138,10 +150,12 @@ acpi_button_notify_pressed_for_wakeup(void *arg) struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; + FUNCTION_TRACE(__FUNCTION__); + sc = (struct acpi_button_softc *)arg; acpi_sc = acpi_device_get_parent_softc(sc->button_dev); if (acpi_sc == NULL) { - return; + return_VOID; } switch (sc->button_type) { @@ -152,8 +166,9 @@ acpi_button_notify_pressed_for_wakeup(void *arg) acpi_eventhandler_sleep_button_for_wakeup((void *)acpi_sc); break; default: - return; /* unknown button type */ + break; /* unknown button type */ } + return_VOID; } /* XXX maybe not here */ @@ -165,6 +180,8 @@ acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) { struct acpi_button_softc *sc = (struct acpi_button_softc *)context; + FUNCTION_TRACE_U32(__FUNCTION__, notify); + switch (notify) { case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP: AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_button_notify_pressed_for_sleep, sc); @@ -175,8 +192,9 @@ acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) device_printf(sc->button_dev, "pressed for wakeup, button type: %d\n", sc->button_type); break; default: - return; /* unknown notification value */ + break; /* unknown notification value */ } + return_VOID; } diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index ea895a2..aa90c87 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -149,6 +149,12 @@ #include <dev/acpica/acpivar.h> #include <dev/acpica/acpi_ecreg.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT EMBEDDED_CONTROLLER +MODULE_NAME("EC") + struct acpi_ec_softc { device_t ec_dev; ACPI_HANDLE ec_handle; @@ -246,9 +252,11 @@ DRIVER_MODULE(acpi_ec, acpi, acpi_ec_driver, acpi_ec_devclass, 0, 0); static void acpi_ec_identify(driver_t driver, device_t bus) { - ACPI_STATUS Status; + FUNCTION_TRACE(__FUNCTION__); /* XXX implement - need an ACPI 2.0 system to test this */ + + return_VOID; } /* @@ -258,7 +266,9 @@ acpi_ec_identify(driver_t driver, device_t bus) static int acpi_ec_probe(device_t dev) { + if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && + !acpi_disabled("ec") && acpi_MatchHid(dev, "PNP0C09")) { /* @@ -280,6 +290,8 @@ acpi_ec_attach(device_t dev) ACPI_STATUS Status; struct acpi_object_list *args; + FUNCTION_TRACE(__FUNCTION__); + /* * Fetch/initialise softc */ @@ -299,7 +311,7 @@ acpi_ec_attach(device_t dev) if ((sc->ec_data_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_data_rid, 0, ~0, 1, RF_ACTIVE)) == NULL) { device_printf(dev, "can't allocate data port\n"); - return(ENXIO); + return_VALUE(ENXIO); } sc->ec_data_tag = rman_get_bustag(sc->ec_data_res); sc->ec_data_handle = rman_get_bushandle(sc->ec_data_res); @@ -308,7 +320,7 @@ acpi_ec_attach(device_t dev) if ((sc->ec_csr_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_csr_rid, 0, ~0, 1, RF_ACTIVE)) == NULL) { device_printf(dev, "can't allocate command/status port\n"); - return(ENXIO); + return_VALUE(ENXIO); } sc->ec_csr_tag = rman_get_bustag(sc->ec_csr_res); sc->ec_csr_handle = rman_get_bushandle(sc->ec_csr_res); @@ -318,7 +330,7 @@ acpi_ec_attach(device_t dev) */ if ((Status = AcpiOsCreateSemaphore(1, 1, &sc->ec_semaphore)) != AE_OK) { device_printf(dev, "can't create semaphore - %s\n", acpi_strerror(Status)); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -328,15 +340,15 @@ acpi_ec_attach(device_t dev) * status (SCI). */ if ((bufp = acpi_AllocBuffer(16)) == NULL) - return(ENOMEM); + return_VALUE(ENOMEM); if ((Status = AcpiEvaluateObject(sc->ec_handle, "_GPE", NULL, bufp)) != AE_OK) { device_printf(dev, "can't evaluate _GPE method - %s\n", acpi_strerror(Status)); - return(ENXIO); + return_VALUE(ENXIO); } param = (UINT32 *)bufp->Pointer; if (param[0] != ACPI_TYPE_NUMBER) { device_printf(dev, "_GPE method returned bad result\n"); - return(ENXIO); + return_VALUE(ENXIO); } sc->ec_gpebit = param[1]; AcpiOsFree(bufp); @@ -352,7 +364,7 @@ acpi_ec_attach(device_t dev) if ((Status = AcpiInstallGpeHandler(sc->ec_gpebit, ACPI_EVENT_LEVEL_TRIGGERED | ACPI_EVENT_EDGE_TRIGGERED, EcGpeHandler, sc)) != AE_OK) { device_printf(dev, "can't install GPE handler - %s\n", acpi_strerror(Status)); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -361,14 +373,14 @@ acpi_ec_attach(device_t dev) if ((Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ADDRESS_SPACE_EC, &EcSpaceHandler, &EcSpaceSetup, sc)) != AE_OK) { device_printf(dev, "can't install address space handler - %s\n", acpi_strerror(Status)); - return(ENXIO); + return_VALUE(ENXIO); } /* * Evaluate _REG to indicate that the region is now available. */ if ((args = acpi_AllocObjectList(2)) == NULL) - return(ENOMEM); + return_VALUE(ENOMEM); args->object[0].Type = ACPI_TYPE_NUMBER; args->object[0].Number.Value = ADDRESS_SPACE_EC; args->object[1].Type = ACPI_TYPE_NUMBER; @@ -381,10 +393,10 @@ acpi_ec_attach(device_t dev) */ if ((Status != AE_OK) && (Status != AE_NOT_FOUND)) { device_printf(dev, "can't evaluate _REG method - %s\n", acpi_strerror(Status)); - return(ENXIO); + return_VALUE(ENXIO); } - return(0); + return_VALUE(0); } static void @@ -395,6 +407,8 @@ EcGpeHandler(void *Context) ACPI_STATUS Status; char qxx[5]; + FUNCTION_TRACE(__FUNCTION__); + for (;;) { /* @@ -434,6 +448,7 @@ EcGpeHandler(void *Context) qxx, acpi_strerror(Status)); } } + return_VOID; } static ACPI_STATUS @@ -455,8 +470,10 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN ACPI_STATUS Status = AE_OK; EC_REQUEST EcRequest; + FUNCTION_TRACE_U32(__FUNCTION__, Address); + if ((Address > 0xFF) || (width != 8) || (Value == NULL) || (Context == NULL)) - return(AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); switch (Function) { case ADDRESS_SPACE_READ: @@ -473,7 +490,7 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN default: device_printf(sc->ec_dev, "invalid Address Space function %d\n", Function); - return(AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -482,7 +499,7 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN if ((Status = EcTransaction(sc, &EcRequest)) == AE_OK) (*Value) = (UINT32)EcRequest.Data; - return(Status); + return_ACPI_STATUS(Status); } static ACPI_STATUS diff --git a/sys/dev/acpica/acpi_isa.c b/sys/dev/acpica/acpi_isa.c index 19d7b5f..977cf52 100644 --- a/sys/dev/acpica/acpi_isa.c +++ b/sys/dev/acpica/acpi_isa.c @@ -43,6 +43,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT BUS_MANAGER +MODULE_NAME("ISA") + #define PNP_HEXTONUM(c) ((c) >= 'a' \ ? (c) - 'a' + 10 \ : ((c) >= 'A' \ @@ -136,10 +142,18 @@ acpi_isa_identify(driver_t *driver, device_t bus) ACPI_HANDLE parent; ACPI_STATUS status; - /*If this driver is loaded from userland ,just ignore*/ - if(!cold){ - return; - } + FUNCTION_TRACE(__FUNCTION__); + + if (acpi_disabled("isa")) + return_VOID; + + /* + * If this driver is loaded from userland, we can assume that + * the ISA bus has already been detected, and we should not + * interfere. + */ + if (!cold) + return_VOID; /* * Look for the _SB_ scope, which will contain all the devices @@ -147,13 +161,13 @@ acpi_isa_identify(driver_t *driver, device_t bus) */ if ((status = AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &parent)) != AE_OK) { device_printf(bus, "no ACPI _SB_ scope - %s\n", acpi_strerror(status)); - return; + return_VOID; } - if ((status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, parent, 100, acpi_isa_identify_child, bus, NULL)) != AE_OK) { + if ((status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, parent, 100, acpi_isa_identify_child, bus, NULL)) != AE_OK) device_printf(bus, "AcpiWalkNamespace on _SB_ failed - %s\n", acpi_strerror(status)); - return; - } + + return_VOID; } /* @@ -174,17 +188,25 @@ acpi_isa_identify_child(ACPI_HANDLE handle, UINT32 level, void *context, void ** device_t child, bus = (device_t)context; u_int32_t devid; + FUNCTION_TRACE(__FUNCTION__); + + /* + * Skip this node if it's on the 'avoid' list. + */ + if (acpi_avoid(handle)) + return_ACPI_STATUS(AE_OK); + /* - * Try to get information about the device + * Try to get information about the device. */ if (AcpiGetObjectInfo(handle, &devinfo) != AE_OK) - return(AE_OK); + return_ACPI_STATUS(AE_OK); /* * Reformat the _HID value into 32 bits. */ if (!(devinfo.Valid & ACPI_VALID_HID)) - return(AE_OK); + return_ACPI_STATUS(AE_OK); /* * XXX Try to avoid passing stuff to ISA that it just isn't interested @@ -195,7 +217,7 @@ acpi_isa_identify_child(ACPI_HANDLE handle, UINT32 level, void *context, void ** * this is very difficult. Maybe we need a device_configure method? */ if (!(strncmp(devinfo.HardwareId, "PNP0C", 5))) - return(AE_OK); + return_ACPI_STATUS(AE_OK); devid = PNP_EISAID(devinfo.HardwareId); @@ -210,7 +232,7 @@ acpi_isa_identify_child(ACPI_HANDLE handle, UINT32 level, void *context, void ** * point as well. */ if (acpi_GetIntoBuffer(handle, AcpiGetCurrentResources, &buf) != AE_OK) - return(AE_OK); + return_ACPI_STATUS(AE_OK); /* * Add the device and parse our resources @@ -225,10 +247,12 @@ acpi_isa_identify_child(ACPI_HANDLE handle, UINT32 level, void *context, void ** if (!device_get_desc(child)) device_set_desc_copy(child, devinfo.HardwareId); + DEBUG_PRINT(TRACE_OBJECTS, ("added ISA PnP info for %s\n", acpi_name(handle))); + /* * XXX Parse configuration data and _CID list to find compatible IDs */ - return(AE_OK); + return_ACPI_STATUS(AE_OK); } static void @@ -236,10 +260,14 @@ acpi_isa_set_init(device_t dev, void **context) { struct acpi_isa_context *cp; + FUNCTION_TRACE(__FUNCTION__); + cp = malloc(sizeof(*cp), M_DEVBUF, M_NOWAIT); bzero(cp, sizeof(*cp)); cp->ai_nconfigs = 1; *context = cp; + + return_VOID; } static void @@ -250,8 +278,10 @@ acpi_isa_set_done(device_t dev, void *context) device_t parent; int i, j; + FUNCTION_TRACE(__FUNCTION__); + if (cp == NULL) - return; + return_VOID; parent = device_get_parent(dev); /* simple config without dependants */ @@ -268,7 +298,7 @@ acpi_isa_set_done(device_t dev, void *context) if (config->ic_nmem == ISA_NMEM) { device_printf(parent, "too many memory ranges\n"); free(configs, M_DEVBUF); - return; + return_VOID; } config->ic_mem[config->ic_nmem] = configs[0].ic_mem[j]; config->ic_nmem++; @@ -277,7 +307,7 @@ acpi_isa_set_done(device_t dev, void *context) if (config->ic_nport == ISA_NPORT) { device_printf(parent, "too many port ranges\n"); free(configs, M_DEVBUF); - return; + return_VOID; } config->ic_port[config->ic_nport] = configs[0].ic_port[j]; config->ic_nport++; @@ -286,7 +316,7 @@ acpi_isa_set_done(device_t dev, void *context) if (config->ic_nirq == ISA_NIRQ) { device_printf(parent, "too many irq ranges\n"); free(configs, M_DEVBUF); - return; + return_VOID; } config->ic_irqmask[config->ic_nirq] = configs[0].ic_irqmask[j]; config->ic_nirq++; @@ -295,7 +325,7 @@ acpi_isa_set_done(device_t dev, void *context) if (config->ic_ndrq == ISA_NDRQ) { device_printf(parent, "too many drq ranges\n"); free(configs, M_DEVBUF); - return; + return_VOID; } config->ic_drqmask[config->ic_ndrq] = configs[0].ic_drqmask[j]; config->ic_ndrq++; @@ -305,6 +335,8 @@ acpi_isa_set_done(device_t dev, void *context) done: free(cp, M_DEVBUF); + + return_VOID; } static void diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c index b32cdc6..b93913f 100644 --- a/sys/dev/acpica/acpi_lid.c +++ b/sys/dev/acpica/acpi_lid.c @@ -38,6 +38,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT SYSTEM_CONTROL +MODULE_NAME("LID") + struct acpi_lid_softc { device_t lid_dev; ACPI_HANDLE lid_handle; @@ -70,6 +76,7 @@ static int acpi_lid_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && + !acpi_disabled("lid") && acpi_MatchHid(dev, "PNP0C0D")) { device_set_desc(dev, "Control Method Lid Switch"); return(0); @@ -82,6 +89,8 @@ acpi_lid_attach(device_t dev) { struct acpi_lid_softc *sc; + FUNCTION_TRACE(__FUNCTION__); + sc = device_get_softc(dev); sc->lid_dev = dev; sc->lid_handle = acpi_get_handle(dev); @@ -90,7 +99,7 @@ acpi_lid_attach(device_t dev) * Install notification handler */ AcpiInstallNotifyHandler(sc->lid_handle, ACPI_DEVICE_NOTIFY, acpi_lid_notify_handler, sc); - return(0); + return_VALUE(0); } static void @@ -101,6 +110,8 @@ acpi_lid_notify_status_changed(void *arg) ACPI_BUFFER Buffer; ACPI_OBJECT Object; + FUNCTION_TRACE(__FUNCTION__); + sc = (struct acpi_lid_softc *)arg; /* @@ -111,9 +122,9 @@ acpi_lid_notify_status_changed(void *arg) Buffer.Length = sizeof(Object); Buffer.Pointer = &Object; if (AcpiEvaluateObject(sc->lid_handle, "_LID", NULL, &Buffer) != AE_OK) - return; + return_VOID; if (Object.Type != ACPI_TYPE_NUMBER) - return; + return_VOID; /* * Update lid status @@ -123,7 +134,7 @@ acpi_lid_notify_status_changed(void *arg) acpi_sc = acpi_device_get_parent_softc(sc->lid_dev); if (acpi_sc == NULL) { - return; + return_VOID; } if (sc->lid_status == 0) { @@ -131,6 +142,8 @@ acpi_lid_notify_status_changed(void *arg) } else { EVENTHANDLER_INVOKE(acpi_wakeup_event, acpi_sc->acpi_lid_switch_sx); } + + return_VOID; } /* XXX maybe not here */ @@ -141,12 +154,15 @@ acpi_lid_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) { struct acpi_lid_softc *sc = (struct acpi_lid_softc *)context; + FUNCTION_TRACE_U32(__FUNCTION__, notify); + switch (notify) { case ACPI_NOTIFY_STATUS_CHANGED: AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_lid_notify_status_changed, sc); break; default: - return; /* unknown notification value */ + break; /* unknown notification value */ } + return_VOID; } diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c index 1e7ef6e..19df2a7 100644 --- a/sys/dev/acpica/acpi_pcib.c +++ b/sys/dev/acpica/acpi_pcib.c @@ -39,6 +39,12 @@ #include <pci/pcivar.h> #include "pcib_if.h" +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT BUS_MANAGER +MODULE_NAME("PCIB") + struct acpi_pcib_softc { device_t ap_dev; ACPI_HANDLE ap_handle; @@ -99,6 +105,7 @@ acpi_pcib_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && + !acpi_disabled("pci") && acpi_MatchHid(dev, "PNP0A03")) { /* @@ -116,6 +123,9 @@ acpi_pcib_attach(device_t dev) struct acpi_pcib_softc *sc; device_t child; ACPI_STATUS status; + int result; + + FUNCTION_TRACE(__FUNCTION__); sc = device_get_softc(dev); sc->ap_dev = dev; @@ -128,7 +138,7 @@ acpi_pcib_attach(device_t dev) * on a hot-plug docking station, etc. */ if (!acpi_DeviceIsPresent(dev)) - return(ENXIO); + return_VALUE(ENXIO); /* * Get our segment number by evaluating _SEG @@ -137,7 +147,7 @@ acpi_pcib_attach(device_t dev) if ((status = acpi_EvaluateNumber(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) { if (status != AE_NOT_FOUND) { device_printf(dev, "could not evaluate _SEG - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } /* if it's not found, assume 0 */ sc->ap_segment = 0; @@ -159,7 +169,7 @@ acpi_pcib_attach(device_t dev) if ((status = acpi_EvaluateNumber(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) { if (status != AE_NOT_FOUND) { device_printf(dev, "could not evaluate _BBN - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } /* if it's not found, assume 0 */ sc->ap_bus = 0; @@ -170,14 +180,14 @@ acpi_pcib_attach(device_t dev) * (should we complain here?). */ if (devclass_get_device(devclass_find("pci"), sc->ap_bus) != NULL) - return(0); + return_VALUE(0); /* * Attach the PCI bus proper. */ if ((child = device_add_child(dev, "pci", sc->ap_bus)) == NULL) { device_printf(device_get_parent(dev), "couldn't attach pci bus"); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -186,7 +196,8 @@ acpi_pcib_attach(device_t dev) * XXX It would be nice to defer this and count on the nexus getting it * after the first pass, but this does not seem to be reliable. */ - return(bus_generic_attach(dev)); + result = bus_generic_attach(dev); + return_VALUE(result); } static int diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index 1e7ef6e..19df2a7 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -39,6 +39,12 @@ #include <pci/pcivar.h> #include "pcib_if.h" +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT BUS_MANAGER +MODULE_NAME("PCIB") + struct acpi_pcib_softc { device_t ap_dev; ACPI_HANDLE ap_handle; @@ -99,6 +105,7 @@ acpi_pcib_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && + !acpi_disabled("pci") && acpi_MatchHid(dev, "PNP0A03")) { /* @@ -116,6 +123,9 @@ acpi_pcib_attach(device_t dev) struct acpi_pcib_softc *sc; device_t child; ACPI_STATUS status; + int result; + + FUNCTION_TRACE(__FUNCTION__); sc = device_get_softc(dev); sc->ap_dev = dev; @@ -128,7 +138,7 @@ acpi_pcib_attach(device_t dev) * on a hot-plug docking station, etc. */ if (!acpi_DeviceIsPresent(dev)) - return(ENXIO); + return_VALUE(ENXIO); /* * Get our segment number by evaluating _SEG @@ -137,7 +147,7 @@ acpi_pcib_attach(device_t dev) if ((status = acpi_EvaluateNumber(sc->ap_handle, "_SEG", &sc->ap_segment)) != AE_OK) { if (status != AE_NOT_FOUND) { device_printf(dev, "could not evaluate _SEG - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } /* if it's not found, assume 0 */ sc->ap_segment = 0; @@ -159,7 +169,7 @@ acpi_pcib_attach(device_t dev) if ((status = acpi_EvaluateNumber(sc->ap_handle, "_BBN", &sc->ap_bus)) != AE_OK) { if (status != AE_NOT_FOUND) { device_printf(dev, "could not evaluate _BBN - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } /* if it's not found, assume 0 */ sc->ap_bus = 0; @@ -170,14 +180,14 @@ acpi_pcib_attach(device_t dev) * (should we complain here?). */ if (devclass_get_device(devclass_find("pci"), sc->ap_bus) != NULL) - return(0); + return_VALUE(0); /* * Attach the PCI bus proper. */ if ((child = device_add_child(dev, "pci", sc->ap_bus)) == NULL) { device_printf(device_get_parent(dev), "couldn't attach pci bus"); - return(ENXIO); + return_VALUE(ENXIO); } /* @@ -186,7 +196,8 @@ acpi_pcib_attach(device_t dev) * XXX It would be nice to defer this and count on the nexus getting it * after the first pass, but this does not seem to be reliable. */ - return(bus_generic_attach(dev)); + result = bus_generic_attach(dev); + return_VALUE(result); } static int diff --git a/sys/dev/acpica/acpi_processor.c b/sys/dev/acpica/acpi_processor.c index a355248..cdd13ef 100644 --- a/sys/dev/acpica/acpi_processor.c +++ b/sys/dev/acpica/acpi_processor.c @@ -154,6 +154,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT PROCESSOR_CONTROL +MODULE_NAME("PROCESSOR") + #define PR_MAX_POWER_STATES 4 #define PR_MAX_PERFORMANCE_STATES 8 #define PR_MAX_THROTTLING_STATES 8 @@ -297,8 +303,13 @@ acpi_pr_identify(driver_t *driver, device_t bus) { ACPI_HANDLE handle; - if (AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_PR_", &handle) == AE_OK) + FUNCTION_TRACE(__FUNCTION__); + + if (!acpi_disabled("processor") && + (AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_PR_", &handle) == AE_OK)) AcpiWalkNamespace(ACPI_TYPE_PROCESSOR, handle, 2, acpi_pr_identify_cpu, bus, NULL); + + return_VOID; } /* @@ -311,20 +322,21 @@ acpi_pr_identify_cpu(ACPI_HANDLE handle, UINT32 level, void *context, void **sta device_t child; PROCESSOR_APIC lapic; + FUNCTION_TRACE(__FUNCTION__); acpi_pr_FindLapic(bus, handle, &lapic); if (lapic.ProcessorEnabled) { if ((child = BUS_ADD_CHILD(bus, 0, "acpi_pr", -1)) == NULL) { device_printf(bus, "could not create CPU device\n"); - return(AE_OK); + return_ACPI_STATUS(AE_OK); } acpi_set_handle(child, handle); acpi_set_magic(child, PR_MAGIC); device_set_desc(child, "processor device"); } - return(AE_OK); + return_ACPI_STATUS(AE_OK); } static int @@ -340,6 +352,8 @@ acpi_pr_attach(device_t dev) { struct acpi_pr_softc *sc; + FUNCTION_TRACE(__FUNCTION__); + sc = device_get_softc(dev); sc->pr_dev = dev; sc->pr_handle = acpi_get_handle(dev); @@ -362,7 +376,7 @@ acpi_pr_attach(device_t dev) /* XXX call MD cpu-identification here? */ - return(0); + return_VALUE(0); } /* @@ -447,6 +461,8 @@ acpi_pr_CalculatePowerStates(struct acpi_pr_softc *sc) u_int32_t StateCount = 0; u_int32_t i = 0; + FUNCTION_TRACE(__FUNCTION__); + /* * Set Latency Defaults: * --------------------- @@ -467,7 +483,7 @@ acpi_pr_CalculatePowerStates(struct acpi_pr_softc *sc) Status = acpi_GetIntoBuffer(sc->pr_handle, AcpiGetProcessorCxInfo, &Buffer); if (Status != AE_OK) { device_printf(sc->pr_dev, "could not fetch ProcessorCxInfo - %s\n", acpi_strerror(Status)); - return(Status); + return_ACPI_STATUS(Status); } State = (ACPI_CX_STATE*)(Buffer.Pointer); @@ -487,7 +503,7 @@ acpi_pr_CalculatePowerStates(struct acpi_pr_softc *sc) sc->pr_PowerStates.ActiveState = PR_POWER_STATE_C1; AcpiOsFree(Buffer.Pointer); - return(Status); + return_ACPI_STATUS(Status); } static ACPI_STATUS @@ -495,9 +511,11 @@ acpi_pr_CalculatePerformanceStates(struct acpi_pr_softc *sc) { ACPI_STATUS Status = AE_OK; + FUNCTION_TRACE(__FUNCTION__); + /* TODO... */ - return(Status); + return_ACPI_STATUS(Status); } static ACPI_STATUS @@ -509,6 +527,8 @@ acpi_pr_CalculateThrottlingStates(struct acpi_pr_softc *sc) u_int32_t StateCount = 0; u_int32_t i = 0; + FUNCTION_TRACE(__FUNCTION__); + /* * Get Throttling States: * ---------------------- @@ -516,7 +536,7 @@ acpi_pr_CalculateThrottlingStates(struct acpi_pr_softc *sc) Status = acpi_GetIntoBuffer(sc->pr_handle, AcpiGetProcessorThrottlingInfo, &Buffer); if (Status != AE_OK) { device_printf(sc->pr_dev, "could not fetch ThrottlingInfo - %s\n", acpi_strerror(Status)); - return(Status); + return_ACPI_STATUS(Status); } State = (ACPI_CPU_THROTTLING_STATE*)(Buffer.Pointer); @@ -535,22 +555,24 @@ acpi_pr_CalculateThrottlingStates(struct acpi_pr_softc *sc) } AcpiOsFree(Buffer.Pointer); - return(Status); + return_ACPI_STATUS(Status); } static ACPI_STATUS acpi_pr_PolicyInitialize(struct acpi_pr_softc *sc) { - ACPI_STATUS status; + ACPI_STATUS Status; + + FUNCTION_TRACE(__FUNCTION__); - if ((status = AcpiSetProcessorSleepState(sc->pr_handle, sc->pr_PowerStates.ActiveState)) != AE_OK) { - device_printf(sc->pr_dev, "could not set Active sleep state - %s\n", acpi_strerror(status)); - return(status); + if ((Status = AcpiSetProcessorSleepState(sc->pr_handle, sc->pr_PowerStates.ActiveState)) != AE_OK) { + device_printf(sc->pr_dev, "could not set Active sleep state - %s\n", acpi_strerror(Status)); + return_ACPI_STATUS(Status); } /* XXX need to hook ourselves to be called when things go idle */ /* sc->pr_idleevent = EVENTHANDLER_FAST_REGISTER(idle_event, acpi_pr_IdleHandler, sc, IDLE_PRI_FIRST); */ - return(AE_OK); + return_ACPI_STATUS(AE_OK); } static void diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c index 3581ff7..6b848bc 100644 --- a/sys/dev/acpica/acpi_resource.c +++ b/sys/dev/acpica/acpi_resource.c @@ -39,6 +39,12 @@ #include <dev/acpica/acpivar.h> /* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT BUS_MANAGER +MODULE_NAME("RESOURCE") + +/* * Fetch a device's resources and associate them with the device. * * Note that it might be nice to also locate ACPI-specific resource items, such @@ -54,18 +60,17 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc int i; void *context; + FUNCTION_TRACE(__FUNCTION__); + /* * Fetch the device resources */ if (((status = acpi_GetIntoBuffer(handle, AcpiGetPossibleResources, &buf)) != AE_OK) && ((status = acpi_GetIntoBuffer(handle, AcpiGetCurrentResources, &buf)) != AE_OK)) { device_printf(dev, "can't fetch ACPI resources - %s\n", acpi_strerror(status)); - return(status); + return_ACPI_STATUS(status); } - -#ifdef ACPI_RES_DEBUG - device_printf(dev, "got %d bytes of resources\n", buf.Length); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("got %d bytes of resources\n", buf.Length)); set->set_init(dev, &context); /* @@ -82,56 +87,42 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc */ switch(res->Id) { case EndTag: -#ifdef ACPI_RES_DEBUG - device_printf(dev, "EndTag\n"); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("EndTag\n")); curr = last; break; case FixedIo: -#ifdef ACPI_RES_DEBUG - device_printf(dev, "FixedIo 0x%x/%d\n", res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("FixedIo 0x%x/%d\n", res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength)); set->set_ioport(dev, context, res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength); break; case Io: if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Io 0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Io 0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength)); set->set_ioport(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength); } else { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Io 0x%x-0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress, - res->Data.Io.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Io 0x%x-0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress, + res->Data.Io.RangeLength)); set->set_iorange(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress, res->Data.Io.RangeLength, res->Data.Io.Alignment); } break; case FixedMemory32: -#ifdef ACPI_RES_DEBUG - device_printf(dev, "FixedMemory32 0x%x/%d\n", res->Data.FixedMemory32.RangeBaseAddress, - res->Data.FixedMemory32.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("FixedMemory32 0x%x/%d\n", res->Data.FixedMemory32.RangeBaseAddress, + res->Data.FixedMemory32.RangeLength)); set->set_memory(dev, context, res->Data.FixedMemory32.RangeBaseAddress, res->Data.FixedMemory32.RangeLength); break; case Memory32: if (res->Data.Memory32.MinBaseAddress == res->Data.Memory32.MaxBaseAddress) { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress, - res->Data.Memory32.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress, + res->Data.Memory32.RangeLength)); set->set_memory(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.RangeLength); } else { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Memory32 0x%x-0x%x/%d\n", res->Data.Memory32.MinBaseAddress, - res->Data.Memory32.MaxBaseAddress, res->Data.Memory32.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x-0x%x/%d\n", res->Data.Memory32.MinBaseAddress, + res->Data.Memory32.MaxBaseAddress, res->Data.Memory32.RangeLength)); set->set_memoryrange(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.MaxBaseAddress, res->Data.Memory32.RangeLength, res->Data.Memory32.Alignment); } @@ -139,16 +130,12 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc case Memory24: if (res->Data.Memory24.MinBaseAddress == res->Data.Memory24.MaxBaseAddress) { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress, - res->Data.Memory24.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress, + res->Data.Memory24.RangeLength)); set->set_memory(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.RangeLength); } else { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Memory24 0x%x-0x%x/%d\n", res->Data.Memory24.MinBaseAddress, - res->Data.Memory24.MaxBaseAddress, res->Data.Memory24.RangeLength); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x-0x%x/%d\n", res->Data.Memory24.MinBaseAddress, + res->Data.Memory24.MaxBaseAddress, res->Data.Memory24.RangeLength)); set->set_memoryrange(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.MaxBaseAddress, res->Data.Memory24.RangeLength, res->Data.Memory24.Alignment); } @@ -156,50 +143,42 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc case Irq: for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Irq %d\n", res->Data.Irq.Interrupts[i]); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Irq %d\n", res->Data.Irq.Interrupts[i])); set->set_irq(dev, context, res->Data.Irq.Interrupts[i]); } break; case Dma: for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) { -#ifdef ACPI_RES_DEBUG - device_printf(dev, "Drq %d\n", res->Data.Dma.Channels[i]); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("Drq %d\n", res->Data.Dma.Channels[i])); set->set_drq(dev, context, res->Data.Dma.Channels[i]); } break; case StartDependentFunctions: -#ifdef ACPI_RES_DEBUG - device_printf(dev, "start dependant functions"); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("start dependant functions")); set->set_start_dependant(dev, context, res->Data.StartDependentFunctions.CompatibilityPriority); break; case EndDependentFunctions: -#ifdef ACPI_RES_DEBUG - device_printf(dev, "end dependant functions"); -#endif + DEBUG_PRINT(TRACE_RESOURCES, ("end dependant functions")); set->set_end_dependant(dev, context); break; case Address32: - device_printf(dev, "unimplemented Address32 resource\n"); + DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address32 resource\n")); break; case Address16: - device_printf(dev, "unimplemented Address16 resource\n"); + DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address16 resource\n")); break; case ExtendedIrq: - device_printf(dev, "unimplemented ExtendedIrq resource\n"); + DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented ExtendedIrq resource\n")); break; case VendorSpecific: - device_printf(dev, "unimplemented VendorSpecific resource\n"); + DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented VendorSpecific resource\n")); break; default: break; @@ -207,7 +186,7 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc } AcpiOsFree(buf.Pointer); set->set_done(dev, context); - return(AE_OK); + return_ACPI_STATUS(AE_OK); } static void acpi_res_set_init(device_t dev, void **context); diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index 45398fe..273729c 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -36,6 +36,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT THERMAL_CONTROL +MODULE_NAME("THERMAL") + #define TZ_KELVTOC(x) (((x) - 2732) / 10), (((x) - 2732) % 10) struct acpi_tz_softc { @@ -66,11 +72,15 @@ DRIVER_MODULE(acpi_tz, acpi, acpi_tz_driver, acpi_tz_devclass, 0, 0); static int acpi_tz_probe(device_t dev) { - if (acpi_get_type(dev) == ACPI_TYPE_THERMAL) { + + FUNCTION_TRACE(__FUNCTION__); + + if ((acpi_get_type(dev) == ACPI_TYPE_THERMAL) && + !acpi_disabled("thermal")) { device_set_desc(dev, "thermal zone"); - return(0); + return_VALUE(0); } - return(ENXIO); + return_VALUE(ENXIO); } static int @@ -81,6 +91,8 @@ acpi_tz_attach(device_t dev) ACPI_BUFFER buf; ACPI_STATUS status; + FUNCTION_TRACE(__FUNCTION__); + sc = device_get_softc(dev); sc->tz_dev = dev; sc->tz_handle = acpi_get_handle(dev); @@ -89,14 +101,14 @@ acpi_tz_attach(device_t dev) buf.Length = sizeof(param); if ((status = AcpiEvaluateObject(sc->tz_handle, "_TMP", NULL, &buf)) != AE_OK) { device_printf(sc->tz_dev, "can't fetch temperature - %s\n", acpi_strerror(status)); - return(ENXIO); + return_VALUE(ENXIO); } if (param[0] != ACPI_TYPE_NUMBER) { device_printf(sc->tz_dev, "%s._TMP does not evaluate to ACPI_TYPE_NUMBER\n", acpi_name(sc->tz_handle)); - return(ENXIO); + return_VALUE(ENXIO); } device_printf(sc->tz_dev, "current temperature %d.%dC\n", TZ_KELVTOC(param[1])); - return(0); + return_VALUE(0); } diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index e586aae..19ebcc0 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -36,6 +36,12 @@ #include <dev/acpica/acpivar.h> +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT SYSTEM_CONTROL +MODULE_NAME("TIMER") + #define ACPITIMER_MAGIC 0x524d4954 /* "TIMR" */ struct acpi_timer_softc { @@ -73,28 +79,35 @@ acpi_timer_identify(driver_t *driver, device_t parent) device_t dev; char desc[40]; + FUNCTION_TRACE(__FUNCTION__); + + if (acpi_disabled("timer")) + return_VOID; + buf.Pointer = &fadt; buf.Length = sizeof(fadt); if ((status = AcpiGetTable(ACPI_TABLE_FADT, 1, &buf)) != AE_OK) { device_printf(parent, "can't locate FADT - %s\n", acpi_strerror(status)); - return; + return_VOID; } if (buf.Length != sizeof(fadt)) { device_printf(parent, "invalid FADT\n"); - return; + return_VOID; } if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) { device_printf(parent, "could not add acpi_timer0\n"); - return; + return_VOID; } if (acpi_set_magic(dev, ACPITIMER_MAGIC)) { device_printf(dev, "could not set magic\n"); - return; + return_VOID; } sprintf(desc, "%d-bit timer at 3.579545MHz", fadt.TmrValExt ? 32 : 24); device_set_desc_copy(dev, desc); + + return_VOID; } static int @@ -110,8 +123,10 @@ acpi_timer_attach(device_t dev) { struct acpi_timer_softc *sc; + FUNCTION_TRACE(__FUNCTION__); + sc = device_get_softc(dev); sc->tm_dev = dev; - return(0); + return_VALUE(0); } diff --git a/sys/dev/acpica/acpiio.h b/sys/dev/acpica/acpiio.h index 75c59fc..2e1fb12 100644 --- a/sys/dev/acpica/acpiio.h +++ b/sys/dev/acpica/acpiio.h @@ -27,7 +27,14 @@ * $FreeBSD$ */ +/* + * Core ACPI subsystem ioctls + */ #define ACPIIO_ENABLE _IO('P', 1) #define ACPIIO_DISABLE _IO('P', 2) #define ACPIIO_SETSLPSTATE _IOW('P', 3, int) +#ifdef _KERNEL +extern int acpi_register_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg), void *arg); +extern void acpi_deregister_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg)); +#endif diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index f415bae..960d175 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -216,6 +216,7 @@ acpi_device_get_parent_softc(device_t child) return(device_get_softc(parent)); } -extern char *acpi_name(ACPI_HANDLE handle); -extern int acpi_avoid(ACPI_HANDLE handle); +extern char *acpi_name(ACPI_HANDLE handle); +extern int acpi_avoid(ACPI_HANDLE handle); +extern int acpi_disabled(char *subsys); |