diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exutils.c')
-rw-r--r-- | sys/contrib/dev/acpica/exutils.c | 205 |
1 files changed, 139 insertions, 66 deletions
diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c index f22f959..2ce75bb 100644 --- a/sys/contrib/dev/acpica/exutils.c +++ b/sys/contrib/dev/acpica/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * $Revision: 1.118 $ + * $Revision: 1.129 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -156,51 +156,81 @@ AcpiExDigitsNeeded ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Enter the interpreter execution region. Failure to enter - * the interpreter region is a fatal system error + * DESCRIPTION: Enter the interpreter execution region. Failure to enter + * the interpreter region is a fatal system error. Used in + * conjunction with ExitInterpreter. * ******************************************************************************/ -ACPI_STATUS +void AcpiExEnterInterpreter ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExEnterInterpreter"); + + ACPI_FUNCTION_TRACE (ExEnterInterpreter); - Status = AcpiUtAcquireMutex (ACPI_MTX_EXECUTE); + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n")); + ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); } - return_ACPI_STATUS (Status); + return_VOID; } /******************************************************************************* * - * FUNCTION: AcpiExExitInterpreter + * FUNCTION: AcpiExReacquireInterpreter * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Exit the interpreter execution region + * DESCRIPTION: Reacquire the interpreter execution region from within the + * interpreter code. Failure to enter the interpreter region is a + * fatal system error. Used in conjuction with + * RelinquishInterpreter * - * Cases where the interpreter is unlocked: - * 1) Completion of the execution of a control method - * 2) Method blocked on a Sleep() AML opcode - * 3) Method blocked on an Acquire() AML opcode - * 4) Method blocked on a Wait() AML opcode - * 5) Method blocked to acquire the global lock - * 6) Method blocked to execute a serialized control method that is - * already executing - * 7) About to invoke a user-installed opregion handler + ******************************************************************************/ + +void +AcpiExReacquireInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExReacquireInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter, + * since it was not actually released by AcpiExRelinquishInterpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExEnterInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExitInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region. This is the top level + * routine used to exit the interpreter when all processing has + * been completed. * ******************************************************************************/ @@ -211,13 +241,56 @@ AcpiExExitInterpreter ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExExitInterpreter"); + ACPI_FUNCTION_TRACE (ExExitInterpreter); - Status = AcpiUtReleaseMutex (ACPI_MTX_EXECUTE); + Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not release interpreter mutex\n")); + ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRelinquishInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region, from within the + * interpreter - before attempting an operation that will possibly + * block the running thread. + * + * Cases where the interpreter is unlocked internally + * 1) Method to be blocked on a Sleep() AML opcode + * 2) Method to be blocked on an Acquire() AML opcode + * 3) Method to be blocked on a Wait() AML opcode + * 4) Method to be blocked to acquire the global lock + * 5) Method to be blocked waiting to execute a serialized control method + * that is currently executing + * 6) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiExRelinquishInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExExitInterpreter (); } return_VOID; @@ -232,8 +305,8 @@ AcpiExExitInterpreter ( * * RETURN: none * - * DESCRIPTION: Truncate a number to 32-bits if the currently executing method - * belongs to a 32-bit ACPI table. + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is + * 32-bit, as determined by the revision of the DSDT. * ******************************************************************************/ @@ -247,9 +320,10 @@ AcpiExTruncateFor32bitTable ( /* * Object must be a valid number and we must be executing - * a control method + * a control method. NS node could be there for AML_INT_NAMEPATH_OP. */ if ((!ObjDesc) || + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) { return; @@ -273,45 +347,42 @@ AcpiExTruncateFor32bitTable ( * PARAMETERS: FieldFlags - Flags with Lock rule: * AlwaysLock or NeverLock * - * RETURN: TRUE/FALSE indicating whether the lock was actually acquired + * RETURN: None * - * DESCRIPTION: Obtain the global lock and keep track of this fact via two - * methods. A global variable keeps the state of the lock, and - * the state is returned to the caller. + * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field + * flags specifiy that it is to be obtained before field access. * ******************************************************************************/ -BOOLEAN +void AcpiExAcquireGlobalLock ( UINT32 FieldFlags) { - BOOLEAN Locked = FALSE; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExAcquireGlobalLock"); + ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); - /* Only attempt lock if the AlwaysLock bit is set */ + /* Only use the lock if the AlwaysLock bit is set */ - if (FieldFlags & AML_FIELD_LOCK_RULE_MASK) + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Attempt to get the global lock, wait forever */ + + Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_FAILURE (Status)) { - /* We should attempt to get the lock, wait forever */ - - Status = AcpiEvAcquireGlobalLock (ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (Status)) - { - Locked = TRUE; - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not acquire Global Lock, %s\n", - AcpiFormatException (Status))); - } + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not acquire Global Lock")); } - return_UINT8 (Locked); + return_VOID; } @@ -319,39 +390,41 @@ AcpiExAcquireGlobalLock ( * * FUNCTION: AcpiExReleaseGlobalLock * - * PARAMETERS: LockedByMe - Return value from corresponding call to - * AcquireGlobalLock. + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock * * RETURN: None * - * DESCRIPTION: Release the global lock if it is locked. + * DESCRIPTION: Release the ACPI hardware Global Lock * ******************************************************************************/ void AcpiExReleaseGlobalLock ( - BOOLEAN LockedByMe) + UINT32 FieldFlags) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExReleaseGlobalLock"); + ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); - /* Only attempt unlock if the caller locked it */ + /* Only use the lock if the AlwaysLock bit is set */ - if (LockedByMe) + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) { - /* OK, now release the lock */ + return_VOID; + } + + /* Release the global lock */ - Status = AcpiEvReleaseGlobalLock (); - if (ACPI_FAILURE (Status)) - { - /* Report the error, but there isn't much else we can do */ + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + if (ACPI_FAILURE (Status)) + { + /* Report the error, but there isn't much else we can do */ - ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n", - AcpiFormatException (Status))); - } + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not release Global Lock")); } return_VOID; @@ -381,7 +454,7 @@ AcpiExDigitsNeeded ( ACPI_INTEGER CurrentValue; - ACPI_FUNCTION_TRACE ("ExDigitsNeeded"); + ACPI_FUNCTION_TRACE (ExDigitsNeeded); /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ |