diff options
Diffstat (limited to 'sys/contrib/dev/acpica/evmisc.c')
-rw-r--r-- | sys/contrib/dev/acpica/evmisc.c | 210 |
1 files changed, 149 insertions, 61 deletions
diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c index 7e1ecda..05aac5e 100644 --- a/sys/contrib/dev/acpica/evmisc.c +++ b/sys/contrib/dev/acpica/evmisc.c @@ -2,7 +2,7 @@ * * Module Name: evmisc - ACPI device notification handler dispatch * and ACPI Global Lock support - * $Revision: 36 $ + * $Revision: 46 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -122,7 +122,61 @@ #include "achware.h" #define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evmisc") + ACPI_MODULE_NAME ("evmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeRegisterIndex + * + * PARAMETERS: GpeNumber - Raw GPE number + * + * RETURN: None. + * + * DESCRIPTION: Returns the register index (index into the GPE register info + * table) associated with this GPE. + * + ******************************************************************************/ + +UINT32 +AcpiEvGetGpeRegisterIndex ( + UINT32 GpeNumber) +{ + + if (GpeNumber > AcpiGbl_GpeNumberMax) + { + return (ACPI_GPE_INVALID); + } + + return (ACPI_DIV_8 (AcpiGbl_GpeNumberToIndex[GpeNumber].NumberIndex)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeNumberIndex + * + * PARAMETERS: GpeNumber - Raw GPE number + * + * RETURN: None. + * + * DESCRIPTION: Returns the number index (index into the GPE number info table) + * associated with this GPE. + * + ******************************************************************************/ + +UINT32 +AcpiEvGetGpeNumberIndex ( + UINT32 GpeNumber) +{ + + if (GpeNumber > AcpiGbl_GpeNumberMax) + { + return (ACPI_GPE_INVALID); + } + + return (AcpiGbl_GpeNumberToIndex[GpeNumber].NumberIndex); +} /******************************************************************************* @@ -149,7 +203,7 @@ AcpiEvQueueNotifyRequest ( ACPI_STATUS Status = AE_OK; - PROC_NAME ("EvQueueNotifyRequest"); + ACPI_FUNCTION_NAME ("EvQueueNotifyRequest"); /* @@ -184,20 +238,19 @@ AcpiEvQueueNotifyRequest ( break; } - /* * Get the notify object attached to the device Node */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { - /* We have the notify object, Get the right handler */ switch (Node->Type) { case ACPI_TYPE_DEVICE: - if (NotifyValue <= MAX_SYS_NOTIFY) + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { HandlerObj = ObjDesc->Device.SysHandler; } @@ -207,8 +260,10 @@ AcpiEvQueueNotifyRequest ( } break; + case ACPI_TYPE_THERMAL: - if (NotifyValue <= MAX_SYS_NOTIFY) + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { HandlerObj = ObjDesc->ThermalZone.SysHandler; } @@ -222,11 +277,10 @@ AcpiEvQueueNotifyRequest ( /* If there is any handler to run, schedule the dispatcher */ - if ((AcpiGbl_SysNotify.Handler && (NotifyValue <= MAX_SYS_NOTIFY)) || - (AcpiGbl_DrvNotify.Handler && (NotifyValue > MAX_SYS_NOTIFY)) || + if ((AcpiGbl_SysNotify.Handler && (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || + (AcpiGbl_DrvNotify.Handler && (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || HandlerObj) { - NotifyInfo = AcpiUtCreateGenericState (); if (!NotifyInfo) { @@ -280,14 +334,14 @@ AcpiEvNotifyDispatch ( ACPI_OPERAND_OBJECT *HandlerObj; - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); /* * We will invoke a global notify handler if installed. * This is done _before_ we invoke the per-device handler attached to the device. */ - if (NotifyInfo->Notify.Value <= MAX_SYS_NOTIFY) + if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) { /* Global system notification handler */ @@ -376,7 +430,6 @@ AcpiEvGlobalLockHandler ( void *Context) { BOOLEAN Acquired = FALSE; - void *GlobalLock; /* @@ -384,8 +437,7 @@ AcpiEvGlobalLockHandler ( * If we don't get it now, it will be marked pending and we will * take another interrupt when it becomes free. */ - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); if (Acquired) { /* Got the lock, now wake all threads waiting for it */ @@ -398,7 +450,7 @@ AcpiEvGlobalLockHandler ( Context); } - return (INTERRUPT_HANDLED); + return (ACPI_INTERRUPT_HANDLED); } @@ -418,7 +470,7 @@ AcpiEvInitGlobalLockHandler (void) ACPI_STATUS Status; - FUNCTION_TRACE ("EvInitGlobalLockHandler"); + ACPI_FUNCTION_TRACE ("EvInitGlobalLockHandler"); AcpiGbl_GlobalLockPresent = TRUE; @@ -427,7 +479,7 @@ AcpiEvInitGlobalLockHandler (void) /* * If the global lock does not exist on this platform, the attempt - * to enable GBL_STS will fail (the GBL_EN bit will not stick) + * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) * Map to AE_OK, but mark global lock as not present. * Any attempt to actually use the global lock will be flagged * with an error. @@ -453,14 +505,15 @@ AcpiEvInitGlobalLockHandler (void) *****************************************************************************/ ACPI_STATUS -AcpiEvAcquireGlobalLock(void) +AcpiEvAcquireGlobalLock ( + UINT32 Timeout) { ACPI_STATUS Status = AE_OK; BOOLEAN Acquired = FALSE; - void *GlobalLock; - FUNCTION_TRACE ("EvAcquireGlobalLock"); + ACPI_FUNCTION_TRACE ("EvAcquireGlobalLock"); + /* Make sure that we actually have a global lock */ @@ -473,29 +526,21 @@ AcpiEvAcquireGlobalLock(void) AcpiGbl_GlobalLockThreadCount++; - /* If we (OS side) have the hardware lock already, we are done */ + /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */ if (AcpiGbl_GlobalLockAcquired) { return_ACPI_STATUS (AE_OK); } - /* Only if the FACS is valid */ - - if (!AcpiGbl_FACS) - { - return_ACPI_STATUS (AE_OK); - } - /* We must acquire the actual hardware lock */ - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); if (Acquired) { /* We got the lock */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the Global Lock\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the HW Global Lock\n")); AcpiGbl_GlobalLockAcquired = TRUE; return_ACPI_STATUS (AE_OK); @@ -507,12 +552,12 @@ AcpiEvAcquireGlobalLock(void) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for the HW Global Lock\n")); - /* - * Acquire the global lock semaphore first. - * Since this wait will block, we must release the interpreter - */ + /* + * Acquire the global lock semaphore first. + * Since this wait will block, we must release the interpreter + */ Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, - ACPI_UINT32_MAX); + Timeout); return_ACPI_STATUS (Status); } @@ -529,44 +574,87 @@ void AcpiEvReleaseGlobalLock (void) { BOOLEAN Pending = FALSE; - void *GlobalLock; - FUNCTION_TRACE ("EvReleaseGlobalLock"); + ACPI_FUNCTION_TRACE ("EvReleaseGlobalLock"); if (!AcpiGbl_GlobalLockThreadCount) { - REPORT_WARNING(("Global Lock has not be acquired, cannot release\n")); + ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); return_VOID; } - /* One fewer thread has the global lock */ + /* One fewer thread has the global lock */ AcpiGbl_GlobalLockThreadCount--; + if (AcpiGbl_GlobalLockThreadCount) + { + /* There are still some threads holding the lock, cannot release */ - /* Have all threads released the lock? */ + return_VOID; + } - if (!AcpiGbl_GlobalLockThreadCount) + /* + * No more threads holding lock, we can do the actual hardware + * release + */ + ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Pending); + AcpiGbl_GlobalLockAcquired = FALSE; + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) { - /* - * No more threads holding lock, we can do the actual hardware - * release - */ - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_RELEASE_GLOBAL_LOCK (GlobalLock, Pending); - AcpiGbl_GlobalLockAcquired = FALSE; - - /* - * If the pending bit was set, we must write GBL_RLS to the control - * register - */ - if (Pending) - { - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, - GBL_RLS, 1); - } + AcpiHwBitRegisterWrite (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK); + } + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate (void) +{ + + ACPI_FUNCTION_TRACE ("EvTerminate"); + + + /* + * Free global tables, etc. + */ + if (AcpiGbl_GpeRegisterInfo) + { + ACPI_MEM_FREE (AcpiGbl_GpeRegisterInfo); + AcpiGbl_GpeRegisterInfo = NULL; + } + + if (AcpiGbl_GpeNumberInfo) + { + ACPI_MEM_FREE (AcpiGbl_GpeNumberInfo); + AcpiGbl_GpeNumberInfo = NULL; + } + + if (AcpiGbl_GpeNumberToIndex) + { + ACPI_MEM_FREE (AcpiGbl_GpeNumberToIndex); + AcpiGbl_GpeNumberToIndex = NULL; } return_VOID; } + |