From 7996f19f432a6f4cf9a62d6121b95f412a9828bb Mon Sep 17 00:00:00 2001 From: msmith Date: Tue, 29 May 2001 20:13:42 +0000 Subject: - Updates for new constant naming in the ACPI CA 20010518 update. - Use __func__ instead of __FUNCTION. - Support power-off to S3 or S5 (takawata) - Enable ACPI debugging earlier (with a sysinit) - Fix a deadlock in the EC code (takawata) - Improve arithmetic and reduce the risk of spurious wakeup in AcpiOsSleep. - Add AcpiOsGetThreadId. - Simplify mutex code (still disabled). --- sys/dev/acpica/Osd/OsdBusMgr.c | 16 +++++------ sys/dev/acpica/Osd/OsdInterrupt.c | 6 ++-- sys/dev/acpica/Osd/OsdSchedule.c | 24 +++++++++++----- sys/dev/acpica/Osd/OsdSynch.c | 22 +++++---------- sys/dev/acpica/acpi.c | 59 +++++++++++++++++++-------------------- sys/dev/acpica/acpi_acad.c | 5 ++++ sys/dev/acpica/acpi_button.c | 10 +++---- sys/dev/acpica/acpi_cmbat.c | 6 ++++ sys/dev/acpica/acpi_ec.c | 42 +++++++++++++--------------- sys/dev/acpica/acpi_isa.c | 10 +++---- sys/dev/acpica/acpi_lid.c | 8 +++--- sys/dev/acpica/acpi_pcib.c | 6 ++-- sys/dev/acpica/acpi_pcib_acpi.c | 6 ++-- sys/dev/acpica/acpi_processor.c | 16 +++++------ sys/dev/acpica/acpi_resource.c | 38 ++++++++++++------------- sys/dev/acpica/acpi_thermal.c | 10 +++---- sys/dev/acpica/acpi_timer.c | 6 ++-- sys/dev/acpica/acpivar.h | 7 +++++ 18 files changed, 157 insertions(+), 140 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/acpica/Osd/OsdBusMgr.c b/sys/dev/acpica/Osd/OsdBusMgr.c index 3d8e125..0ffdef3 100644 --- a/sys/dev/acpica/Osd/OsdBusMgr.c +++ b/sys/dev/acpica/Osd/OsdBusMgr.c @@ -37,7 +37,7 @@ #include #include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("BUSMGR") struct osd_eventhandle { @@ -56,7 +56,7 @@ osd_idlehandler(void *arg, int junk) { struct osd_eventhandle *oh = (struct osd_eventhandle *)arg; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); oh->Function(oh->Context); return_VOID(); @@ -67,7 +67,7 @@ osd_shutdownhandler(void *arg, int howto) { struct osd_eventhandle *oh = (struct osd_eventhandle *)arg; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); oh->Function(oh->Context); return_VOID(); @@ -78,7 +78,7 @@ AcpiOsInstallIdleHandler(OSD_IDLE_HANDLER Function, void *Context) { int i; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Function == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -99,7 +99,7 @@ AcpiOsRemoveIdleHandler(OSD_IDLE_HANDLER Function) { int i; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Function == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -122,7 +122,7 @@ AcpiOsInstallShutdownHandler(OSD_SHUTDOWN_HANDLER Function, void *Context) { int i; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Function == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -143,7 +143,7 @@ AcpiOsRemoveShutdownHandler(OSD_SHUTDOWN_HANDLER Function) { int i; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Function == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -160,7 +160,7 @@ AcpiOsRemoveShutdownHandler(OSD_SHUTDOWN_HANDLER Function) ACPI_STATUS AcpiOsShutdown (void) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); shutdown_nice(0); return_VOID(); diff --git a/sys/dev/acpica/Osd/OsdInterrupt.c b/sys/dev/acpica/Osd/OsdInterrupt.c index f7eefab..fd94ad1 100644 --- a/sys/dev/acpica/Osd/OsdInterrupt.c +++ b/sys/dev/acpica/Osd/OsdInterrupt.c @@ -40,7 +40,7 @@ #include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("INTERRUPT") /* @@ -52,7 +52,7 @@ AcpiOsInstallInterruptHandler(UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine { struct acpi_softc *sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if ((InterruptNumber < 0) || (InterruptNumber > 255)) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -93,7 +93,7 @@ AcpiOsRemoveInterruptHandler (UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine { struct acpi_softc *sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if ((InterruptNumber < 0) || (InterruptNumber > 255)) return_ACPI_STATUS(AE_BAD_PARAMETER); diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index f838580..6089031 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -38,7 +38,7 @@ #include #include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("SCHEDULE") /* @@ -64,7 +64,7 @@ AcpiOsQueueForExecution(UINT32 Priority, OSD_EXECUTION_CALLBACK Function, void * { struct acpi_task *at; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Function == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -107,7 +107,7 @@ AcpiOsExecuteQueue(void *arg, int pending) OSD_EXECUTION_CALLBACK Function; void *Context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); Function = (OSD_EXECUTION_CALLBACK)at->at_function; Context = at->at_context; @@ -126,20 +126,21 @@ void AcpiOsSleep (UINT32 Seconds, UINT32 Milliseconds) { int timo; + static int dummy; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); - timo = (Seconds * hz) + Milliseconds / (1000 * hz); + timo = (Seconds * hz) + Milliseconds * hz / 1000; if (timo == 0) timo = 1; - tsleep(NULL, PZERO, "acpislp", timo); + tsleep(&dummy, 0, "acpislp", timo); return_VOID; } void AcpiOsSleepUsec (UINT32 Microseconds) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (Microseconds > 1000) { /* long enough to be worth the overhead of sleeping */ AcpiOsSleep(0, Microseconds / 1000); @@ -148,3 +149,12 @@ AcpiOsSleepUsec (UINT32 Microseconds) } return_VOID; } + +UINT32 +AcpiOsGetThreadId (void) +{ + /* XXX do not add FUNCTION_TRACE here, results in recursive call */ + + KASSERT(curproc != NULL, (__func__ ": curproc is NULL!")); + return(curproc->p_pid + 1); /* can't return 0 */ +} diff --git a/sys/dev/acpica/Osd/OsdSynch.c b/sys/dev/acpica/Osd/OsdSynch.c index 84773de..85068c0 100644 --- a/sys/dev/acpica/Osd/OsdSynch.c +++ b/sys/dev/acpica/Osd/OsdSynch.c @@ -37,8 +37,9 @@ #include #include #include +#include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("SYNCH") static MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore"); @@ -54,7 +55,6 @@ struct acpi_semaphore { struct mtx as_mtx; UINT32 as_units; UINT32 as_maxunits; - char *as_name; }; ACPI_STATUS @@ -63,7 +63,7 @@ AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHand #ifndef ACPI_NO_SEMAPHORES struct acpi_semaphore *as; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (OutHandle == NULL) return(AE_BAD_PARAMETER); @@ -76,8 +76,6 @@ AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHand mtx_init(&as->as_mtx, "ACPI semaphore", MTX_DEF); as->as_units = InitialUnits; as->as_maxunits = MaxUnits; - as->as_name = malloc(strlen(name) + 1, M_ACPISEM, M_NOWAIT); - strcpy(as->as_name, name); DEBUG_PRINT(TRACE_MUTEX, ("created semaphore %p max %d, initial %d\n", as, InitialUnits, MaxUnits)); @@ -96,15 +94,10 @@ AcpiOsDeleteSemaphore (ACPI_HANDLE Handle) #ifndef ACPI_NO_SEMAPHORES struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); -#ifdef ACPI_TRACK_SEMAPHORE - printf("destroyed semaphore '%s' @ %p\n", as->as_name, as); -#else DEBUG_PRINT(TRACE_MUTEX, ("destroyed semaphore %p\n", as)); -#endif mtx_destroy(&as->as_mtx); - free(as->as_name, M_ACPISEM); free(Handle, M_ACPISEM); return_ACPI_STATUS(AE_OK); #else @@ -125,7 +118,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout) ACPI_STATUS result; int rv, tmo; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (as == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); @@ -135,7 +128,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout) tmo = 0; } else { /* compute timeout using microseconds per tick */ - tmo = (Timeout * 1000) / (1000000 / hz) + tmo = (Timeout * 1000) / (1000000 / hz); if (tmo <= 0) tmo = 1; } @@ -155,7 +148,6 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout) } DEBUG_PRINT(TRACE_MUTEX, ("semaphore blocked, calling msleep(%p, %p, %d, \"acpisem\", %d)\n", as, as->as_mtx, 0, tmo)); - for (;;) ; rv = msleep(as, &as->as_mtx, 0, "acpisem", tmo); DEBUG_PRINT(TRACE_MUTEX, ("msleep returned %d\n", rv)); @@ -178,7 +170,7 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units) #ifndef ACPI_NO_SEMAPHORES struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (as == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 93464e4..436f5f0 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -57,7 +57,7 @@ MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices"); /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("ACPI") /* @@ -88,6 +88,9 @@ static struct cdevsw acpi_cdevsw = { static const char* sleep_state_names[] = { "S0", "S1", "S2", "S3", "S4", "S4B", "S5" }; +/* this has to be static, as the softc is gone when we need it */ +static int acpi_off_state = ACPI_STATE_S5; + static void acpi_identify(driver_t *driver, device_t parent); static int acpi_probe(device_t dev); static int acpi_attach(device_t dev); @@ -113,10 +116,6 @@ static void acpi_shutdown_final(void *arg, int howto); static void acpi_enable_fixed_events(struct acpi_softc *sc); -#ifdef ACPI_DEBUG -static void acpi_set_debugging(void); -#endif - static void acpi_system_eventhandler_sleep(void *arg, int state); static void acpi_system_eventhandler_wakeup(void *arg, int state); static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); @@ -173,7 +172,7 @@ acpi_identify(driver_t *driver, device_t parent) char *debugpoint = getenv("debug.acpi.debugger"); #endif - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if(!cold){ printf("Don't load this driver from userland!!\n"); @@ -185,13 +184,9 @@ acpi_identify(driver_t *driver, device_t parent) */ if (device_find_child(parent, "acpi", 0) != NULL) return_VOID; - -#ifdef ACPI_DEBUG - acpi_set_debugging(); -#endif /* - * Start up ACPICA + * Start up the ACPI CA subsystem. */ #ifdef ENABLE_DEBUGGER if (debugpoint && !strcmp(debugpoint, "init")) @@ -230,7 +225,7 @@ acpi_probe(device_t dev) char buf[20]; int error; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if ((error = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th)) != AE_OK) { device_printf(dev, "couldn't get XSDT header: %s\n", acpi_strerror(error)); @@ -251,7 +246,7 @@ acpi_attach(device_t dev) char *debugpoint = getenv("debug.acpi.debugger"); #endif - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); bzero(sc, sizeof(*sc)); @@ -266,21 +261,21 @@ acpi_attach(device_t dev) * Install the default address space handlers. */ if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemMemory handler: %s\n", acpi_strerror(error)); return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemIO handler: %s\n", acpi_strerror(error)); return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise PciConfig handler: %s\n", acpi_strerror(error)); @@ -574,7 +569,7 @@ acpi_probe_children(device_t bus) static char *scopes[] = {"\\_TZ_", "\\_SI", "\\_SB_", NULL}; int i; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Create any static children by calling device identify methods. @@ -622,7 +617,7 @@ 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__); + FUNCTION_TRACE(__func__); /* * Skip this device if we think we'll have trouble with it. @@ -673,7 +668,7 @@ acpi_shutdown_final(void *arg, int howto) if (howto & RB_POWEROFF) { printf("Power system off using ACPI...\n"); - if ((status = AcpiEnterSleepState(ACPI_STATE_S5)) != AE_OK) { + if ((status = AcpiEnterSleepState(acpi_off_state)) != AE_OK) { printf("ACPI power-off failed - %s\n", acpi_strerror(status)); } else { DELAY(1000000); @@ -776,7 +771,7 @@ acpi_wakeup(UINT8 state) ACPI_OBJECT Objects[3]; /* package plus 2 number objects */ ACPI_BUFFER ReturnBuffer; - FUNCTION_TRACE_U32(__FUNCTION__, state); + FUNCTION_TRACE_U32(__func__, state); /* wait for the WAK_STS bit */ Count = 0; @@ -862,7 +857,7 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) { ACPI_STATUS status = AE_OK; - FUNCTION_TRACE_U32(__FUNCTION__, state); + FUNCTION_TRACE_U32(__func__, state); switch (state) { case ACPI_STATE_S0: /* XXX only for testing */ @@ -899,6 +894,9 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) acpi_enable_fixed_events(sc); break; + case ACPI_STATE_S3: + acpi_off_state = ACPI_STATE_S3; + /* FALLTHROUGH */ case ACPI_STATE_S5: /* * Shut down cleanly and power off. This will call us back through the @@ -923,7 +921,7 @@ acpi_Enable(struct acpi_softc *sc) ACPI_STATUS status; u_int32_t flags; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); flags = ACPI_NO_ADDRESS_SPACE_INIT | ACPI_NO_HARDWARE_INIT | ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; @@ -942,7 +940,7 @@ acpi_Disable(struct acpi_softc *sc) { ACPI_STATUS status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (sc->acpi_enabled) { status = AcpiDisable(); @@ -1008,7 +1006,7 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number) static void acpi_system_eventhandler_sleep(void *arg, int state) { - FUNCTION_TRACE_U32(__FUNCTION__, state); + FUNCTION_TRACE_U32(__func__, state); if (state >= ACPI_STATE_S0 && state <= ACPI_STATE_S5) acpi_SetSleepState((struct acpi_softc *)arg, state); @@ -1018,7 +1016,7 @@ acpi_system_eventhandler_sleep(void *arg, int state) static void acpi_system_eventhandler_wakeup(void *arg, int state) { - FUNCTION_TRACE_U32(__FUNCTION__, state); + FUNCTION_TRACE_U32(__func__, state); /* Well, what to do? :-) */ @@ -1033,7 +1031,7 @@ acpi_eventhandler_power_button_for_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); EVENTHANDLER_INVOKE(acpi_sleep_event, sc->acpi_power_button_sx); @@ -1045,7 +1043,7 @@ acpi_eventhandler_power_button_for_wakeup(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); EVENTHANDLER_INVOKE(acpi_wakeup_event, sc->acpi_power_button_sx); @@ -1057,7 +1055,7 @@ acpi_eventhandler_sleep_button_for_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); EVENTHANDLER_INVOKE(acpi_sleep_event, sc->acpi_sleep_button_sx); @@ -1069,7 +1067,7 @@ acpi_eventhandler_sleep_button_for_wakeup(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); EVENTHANDLER_INVOKE(acpi_wakeup_event, sc->acpi_sleep_button_sx); @@ -1448,7 +1446,7 @@ acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag) } static void -acpi_set_debugging(void) +acpi_set_debugging(void *junk) { char *cp; @@ -1461,4 +1459,5 @@ acpi_set_debugging(void) printf("ACPI debug layer 0x%x debug level 0x%x\n", AcpiDbgLayer, AcpiDbgLevel); } +SYSINIT(acpi_debugging, SI_SUB_TUNABLES, SI_ORDER_ANY, acpi_set_debugging, NULL); #endif diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c index a668048..d67d8cf 100644 --- a/sys/dev/acpica/acpi_acad.c +++ b/sys/dev/acpica/acpi_acad.c @@ -42,6 +42,11 @@ #include #include +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT ACPI_AC_ADAPTER +MODULE_NAME("AC_ADAPTER") #define ACPI_DEVICE_CHECK_PNP 0x00 #define ACPI_DEVICE_CHECK_EXISTENCE 0x01 diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c index 70cad56..c69d7e0 100644 --- a/sys/dev/acpica/acpi_button.c +++ b/sys/dev/acpica/acpi_button.c @@ -40,7 +40,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_BUTTON MODULE_NAME("BUTTON") struct acpi_button_softc { @@ -103,7 +103,7 @@ acpi_button_attach(device_t dev) struct acpi_button_softc *sc; ACPI_STATUS status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->button_dev = dev; @@ -123,7 +123,7 @@ acpi_button_notify_pressed_for_sleep(void *arg) struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = (struct acpi_button_softc *)arg; acpi_sc = acpi_device_get_parent_softc(sc->button_dev); @@ -150,7 +150,7 @@ acpi_button_notify_pressed_for_wakeup(void *arg) struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = (struct acpi_button_softc *)arg; acpi_sc = acpi_device_get_parent_softc(sc->button_dev); @@ -180,7 +180,7 @@ 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); + FUNCTION_TRACE_U32(__func__, notify); switch (notify) { case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP: diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c index 4c26305..f85ddd5 100644 --- a/sys/dev/acpica/acpi_cmbat.c +++ b/sys/dev/acpica/acpi_cmbat.c @@ -44,6 +44,12 @@ #include #include +/* + * Hooks for the ACPI CA debugging infrastructure + */ +#define _COMPONENT ACPI_BATTERY +MODULE_NAME("BATTERY") + static void acpi_cmbat_get_bst(void *); static void acpi_cmbat_get_bif(void *); static void acpi_cmbat_notify_handler(ACPI_HANDLE, UINT32, void *); diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index a0833e9..3c6401e 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -152,7 +152,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT EMBEDDED_CONTROLLER +#define _COMPONENT ACPI_EMBEDDED_CONTROLLER MODULE_NAME("EC") struct acpi_ec_softc { @@ -251,7 +251,7 @@ DRIVER_MODULE(acpi_ec, acpi, acpi_ec_driver, acpi_ec_devclass, 0, 0); static void acpi_ec_identify(driver_t driver, device_t bus) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* XXX implement - need an ACPI 2.0 system to test this */ @@ -286,7 +286,7 @@ acpi_ec_attach(device_t dev) struct acpi_ec_softc *sc; ACPI_STATUS Status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Fetch/initialise softc @@ -353,7 +353,7 @@ acpi_ec_attach(device_t dev) * Install address space handler */ DEBUG_PRINT(TRACE_RESOURCES, ("attaching address space handler\n")); - if ((Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ADDRESS_SPACE_EC, + if ((Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, sc)) != AE_OK) { device_printf(dev, "can't install address space handler - %s\n", acpi_strerror(Status)); return_VALUE(ENXIO); @@ -371,7 +371,7 @@ EcGpeQueryHandler(void *Context) ACPI_STATUS Status; char qxx[5]; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); for (;;) { @@ -455,7 +455,7 @@ static ACPI_STATUS EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context, void **RegionContext) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Just pass the context through, there's nothing to do here. @@ -474,22 +474,21 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN EC_REQUEST EcRequest; int i; - FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Address); + FUNCTION_TRACE_U32(__func__, (UINT32)Address); if ((Address > 0xFF) || (width % 8 != 0) || (Value == NULL) || (Context == NULL)) return_ACPI_STATUS(AE_BAD_PARAMETER); switch (Function) { - case ADDRESS_SPACE_READ: + case ACPI_READ_ADR_SPACE: EcRequest.Command = EC_COMMAND_READ; EcRequest.Address = Address; - EcRequest.Data = 0; + (*Value) = 0; break; - case ADDRESS_SPACE_WRITE: + case ACPI_WRITE_ADR_SPACE: EcRequest.Command = EC_COMMAND_WRITE; EcRequest.Address = Address; - EcRequest.Data = (UINT8)(*Value); break; default: @@ -500,9 +499,8 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN /* * Perform the transaction. */ - (*Value) = 0; for (i = 0; i < width; i += 8) { - if (Function == ADDRESS_SPACE_READ) + if (Function == ACPI_READ_ADR_SPACE) EcRequest.Data = 0; else EcRequest.Data = (UINT8)((*Value) >> i); @@ -512,9 +510,9 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN if (++EcRequest.Address == 0) return_ACPI_STATUS(AE_BAD_PARAMETER); } - return_ACPI_STATUS(Status); } + static ACPI_STATUS EcWaitEventIntr(struct acpi_ec_softc *sc, EC_EVENT Event) { @@ -569,9 +567,9 @@ EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event) * Wait For Event: * --------------- * Poll the EC status register to detect completion of the last - * command. Wait up to 10ms (in 100us chunks) for this to occur. + * command. Wait up to 10ms (in 10us chunks) for this to occur. */ - for (i = 0; i < 100; i++) { + for (i = 0; i < 1000; i++) { EcStatus = EC_GET_CSR(sc); if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && @@ -582,7 +580,7 @@ EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event) !(EcStatus & EC_FLAG_INPUT_BUFFER)) return(AE_OK); - AcpiOsSleepUsec(100); + AcpiOsSleepUsec(10); } return(AE_ERROR); @@ -638,6 +636,11 @@ EcTransaction(struct acpi_ec_softc *sc, EC_REQUEST *EcRequest) } /* + * Unlock the EC + */ + EcUnlock(sc); + + /* * Clear & Re-Enable the EC GPE: * ----------------------------- * 'Consume' any EC GPE events that we generated while performing @@ -658,11 +661,6 @@ EcTransaction(struct acpi_ec_softc *sc, EC_REQUEST *EcRequest) if (AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE) != AE_OK) device_printf(sc->ec_dev, "EcRequest: Unable to re-enable the EC GPE.\n"); - /* - * Unlock the EC - */ - EcUnlock(sc); - return(Status); } diff --git a/sys/dev/acpica/acpi_isa.c b/sys/dev/acpica/acpi_isa.c index 977cf52..6670927 100644 --- a/sys/dev/acpica/acpi_isa.c +++ b/sys/dev/acpica/acpi_isa.c @@ -46,7 +46,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("ISA") #define PNP_HEXTONUM(c) ((c) >= 'a' \ @@ -142,7 +142,7 @@ acpi_isa_identify(driver_t *driver, device_t bus) ACPI_HANDLE parent; ACPI_STATUS status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (acpi_disabled("isa")) return_VOID; @@ -188,7 +188,7 @@ 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__); + FUNCTION_TRACE(__func__); /* * Skip this node if it's on the 'avoid' list. @@ -260,7 +260,7 @@ acpi_isa_set_init(device_t dev, void **context) { struct acpi_isa_context *cp; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); cp = malloc(sizeof(*cp), M_DEVBUF, M_NOWAIT); bzero(cp, sizeof(*cp)); @@ -278,7 +278,7 @@ acpi_isa_set_done(device_t dev, void *context) device_t parent; int i, j; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (cp == NULL) return_VOID; diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c index 551ec18..fc0cb74 100644 --- a/sys/dev/acpica/acpi_lid.c +++ b/sys/dev/acpica/acpi_lid.c @@ -44,7 +44,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_BUTTON MODULE_NAME("LID") struct acpi_lid_softc { @@ -92,7 +92,7 @@ acpi_lid_attach(device_t dev) { struct acpi_lid_softc *sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->lid_dev = dev; @@ -111,7 +111,7 @@ acpi_lid_notify_status_changed(void *arg) struct acpi_lid_softc *sc; struct acpi_softc *acpi_sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = (struct acpi_lid_softc *)arg; @@ -146,7 +146,7 @@ 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); + FUNCTION_TRACE_U32(__func__, notify); switch (notify) { case ACPI_NOTIFY_STATUS_CHANGED: diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c index 60f1708..6fc5e2b 100644 --- a/sys/dev/acpica/acpi_pcib.c +++ b/sys/dev/acpica/acpi_pcib.c @@ -42,8 +42,8 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER -MODULE_NAME("PCIB") +#define _COMPONENT ACPI_BUS_MANAGER +MODULE_NAME("PCI") struct acpi_pcib_softc { device_t ap_dev; @@ -125,7 +125,7 @@ acpi_pcib_attach(device_t dev) ACPI_STATUS status; int result; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->ap_dev = dev; diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index 60f1708..6fc5e2b 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -42,8 +42,8 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER -MODULE_NAME("PCIB") +#define _COMPONENT ACPI_BUS_MANAGER +MODULE_NAME("PCI") struct acpi_pcib_softc { device_t ap_dev; @@ -125,7 +125,7 @@ acpi_pcib_attach(device_t dev) ACPI_STATUS status; int result; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->ap_dev = dev; diff --git a/sys/dev/acpica/acpi_processor.c b/sys/dev/acpica/acpi_processor.c index 14e7d52..1898602 100644 --- a/sys/dev/acpica/acpi_processor.c +++ b/sys/dev/acpica/acpi_processor.c @@ -157,7 +157,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT PROCESSOR_CONTROL +#define _COMPONENT ACPI_PROCESSOR_CONTROL MODULE_NAME("PROCESSOR") #define PR_MAX_POWER_STATES 4 @@ -303,7 +303,7 @@ acpi_pr_identify(driver_t *driver, device_t bus) { ACPI_HANDLE handle; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (!acpi_disabled("processor") && (AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_PR_", &handle) == AE_OK)) @@ -322,7 +322,7 @@ acpi_pr_identify_cpu(ACPI_HANDLE handle, UINT32 level, void *context, void **sta device_t child; PROCESSOR_APIC lapic; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); acpi_pr_FindLapic(bus, handle, &lapic); @@ -352,7 +352,7 @@ acpi_pr_attach(device_t dev) { struct acpi_pr_softc *sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->pr_dev = dev; @@ -466,7 +466,7 @@ acpi_pr_CalculatePowerStates(struct acpi_pr_softc *sc) u_int32_t StateCount = 0; u_int32_t i = 0; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Set Latency Defaults: @@ -516,7 +516,7 @@ acpi_pr_CalculatePerformanceStates(struct acpi_pr_softc *sc) { ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* TODO... */ @@ -532,7 +532,7 @@ acpi_pr_CalculateThrottlingStates(struct acpi_pr_softc *sc) u_int32_t StateCount = 0; u_int32_t i = 0; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Get Throttling States: @@ -568,7 +568,7 @@ acpi_pr_PolicyInitialize(struct acpi_pr_softc *sc) { ACPI_STATUS Status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); 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)); diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c index 6b848bc..9fb1509 100644 --- a/sys/dev/acpica/acpi_resource.c +++ b/sys/dev/acpica/acpi_resource.c @@ -41,7 +41,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("RESOURCE") /* @@ -54,13 +54,13 @@ ACPI_STATUS acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resource_set *set) { ACPI_BUFFER buf; - RESOURCE *res; + ACPI_RESOURCE *res; char *curr, *last; ACPI_STATUS status; int i; void *context; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); /* * Fetch the device resources @@ -79,24 +79,24 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc curr = buf.Pointer; last = (char *)buf.Pointer + buf.Length; while (curr < last) { - res = (RESOURCE *)curr; + res = (ACPI_RESOURCE *)curr; curr += res->Length; /* * Handle the individual resource types */ switch(res->Id) { - case EndTag: + case ACPI_RSTYPE_END_TAG: DEBUG_PRINT(TRACE_RESOURCES, ("EndTag\n")); curr = last; break; - case FixedIo: + case ACPI_RSTYPE_FIXED_IO: 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: + case ACPI_RSTYPE_IO: if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) { 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); @@ -108,14 +108,14 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc } break; - case FixedMemory32: + case ACPI_RSTYPE_FIXED_MEM32: 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: + case ACPI_RSTYPE_MEM32: if (res->Data.Memory32.MinBaseAddress == res->Data.Memory32.MaxBaseAddress) { DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress, res->Data.Memory32.RangeLength)); @@ -128,7 +128,7 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc } break; - case Memory24: + case ACPI_RSTYPE_MEM24: if (res->Data.Memory24.MinBaseAddress == res->Data.Memory24.MaxBaseAddress) { DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress, res->Data.Memory24.RangeLength)); @@ -141,43 +141,43 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resourc } break; - case Irq: + case ACPI_RSTYPE_IRQ: for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) { 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: + case ACPI_RSTYPE_DMA: for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) { 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: + case ACPI_RSTYPE_START_DPF: DEBUG_PRINT(TRACE_RESOURCES, ("start dependant functions")); - set->set_start_dependant(dev, context, res->Data.StartDependentFunctions.CompatibilityPriority); + set->set_start_dependant(dev, context, res->Data.StartDpf.CompatibilityPriority); break; - case EndDependentFunctions: + case ACPI_RSTYPE_END_DPF: DEBUG_PRINT(TRACE_RESOURCES, ("end dependant functions")); set->set_end_dependant(dev, context); break; - case Address32: + case ACPI_RSTYPE_ADDRESS32: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address32 resource\n")); break; - case Address16: + case ACPI_RSTYPE_ADDRESS16: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address16 resource\n")); break; - case ExtendedIrq: + case ACPI_RSTYPE_EXT_IRQ: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented ExtendedIrq resource\n")); break; - case VendorSpecific: + case ACPI_RSTYPE_VENDOR: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented VendorSpecific resource\n")); break; default: diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index 694419e..0475d28 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -39,7 +39,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT THERMAL_CONTROL +#define _COMPONENT ACPI_THERMAL_ZONE MODULE_NAME("THERMAL") #define TZ_ZEROC 2732 @@ -76,7 +76,7 @@ static int acpi_tz_probe(device_t dev) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if ((acpi_get_type(dev) == ACPI_TYPE_THERMAL) && !acpi_disabled("thermal")) { @@ -92,7 +92,7 @@ acpi_tz_attach(device_t dev) struct acpi_tz_softc *sc; ACPI_STATUS status; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->tz_dev = dev; @@ -116,7 +116,7 @@ acpi_tz_check_tripping_point(void *context) ACPI_STATUS status; int tp; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); if ((status = acpi_EvaluateInteger(sc->tz_handle, "_TMP", &tp)) != AE_OK) { @@ -133,7 +133,7 @@ acpi_tz_check_tripping_point(void *context) static void acpi_tz_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) { - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); switch(notify){ case ACPI_TZ_STATUS_CHANGE: diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index 5efae58..9581dae 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -39,7 +39,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_SYSTEM MODULE_NAME("TIMER") #define ACPITIMER_MAGIC 0x524d4954 /* "TIMR" */ @@ -76,7 +76,7 @@ acpi_timer_identify(driver_t *driver, device_t parent) device_t dev; char desc[40]; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); if (acpi_disabled("timer")) return_VOID; @@ -112,7 +112,7 @@ acpi_timer_attach(device_t dev) { struct acpi_timer_softc *sc; - FUNCTION_TRACE(__FUNCTION__); + FUNCTION_TRACE(__func__); sc = device_get_softc(dev); sc->tm_dev = dev; diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 6bc6cbe..ebefafb 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -154,6 +154,13 @@ acpi_get_type(device_t dev) { extern void acpi_EnterDebugger(void); #endif +#ifdef ACPI_DEBUG +#include +#define STEP(x) do {printf x, printf("\n"); cngetc();} while (0) +#else +#define STEP(x) +#endif + extern BOOLEAN acpi_MatchHid(device_t dev, char *hid); extern ACPI_STATUS acpi_GetIntoBuffer(ACPI_HANDLE handle, ACPI_STATUS (*func)(ACPI_HANDLE, ACPI_BUFFER *), -- cgit v1.1