diff options
Diffstat (limited to 'sys/contrib/dev/acpica/nseval.c')
-rw-r--r-- | sys/contrib/dev/acpica/nseval.c | 185 |
1 files changed, 73 insertions, 112 deletions
diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index d863fac..725b4f3 100644 --- a/sys/contrib/dev/acpica/nseval.c +++ b/sys/contrib/dev/acpica/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 104 $ + * $Revision: 109 $ * ******************************************************************************/ @@ -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 @@ -126,7 +126,7 @@ #define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nseval") + ACPI_MODULE_NAME ("nseval") /******************************************************************************* @@ -165,7 +165,7 @@ AcpiNsEvaluateRelative ( ACPI_GENERIC_STATE ScopeInfo; - FUNCTION_TRACE ("NsEvaluateRelative"); + ACPI_FUNCTION_TRACE ("NsEvaluateRelative"); /* @@ -186,12 +186,16 @@ AcpiNsEvaluateRelative ( /* Get the prefix handle and Node */ - AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } PrefixNode = AcpiNsMapHandleToNode (Handle); if (!PrefixNode) { - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AE_BAD_PARAMETER; goto Cleanup; } @@ -200,10 +204,10 @@ AcpiNsEvaluateRelative ( ScopeInfo.Scope.Node = PrefixNode; Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { @@ -262,7 +266,7 @@ AcpiNsEvaluateByName ( NATIVE_CHAR *InternalPath = NULL; - FUNCTION_TRACE ("NsEvaluateByName"); + ACPI_FUNCTION_TRACE ("NsEvaluateByName"); /* Build an internal name string for the method */ @@ -273,15 +277,19 @@ AcpiNsEvaluateByName ( return_ACPI_STATUS (Status); } - AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Lookup the name in the namespace */ Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { @@ -346,7 +354,7 @@ AcpiNsEvaluateByHandle ( ACPI_OPERAND_OBJECT *LocalReturnObject; - FUNCTION_TRACE ("NsEvaluateByHandle"); + ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); /* Check if namespace has been initialized */ @@ -372,12 +380,16 @@ AcpiNsEvaluateByHandle ( /* Get the prefix handle and Node */ - AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -477,7 +489,7 @@ AcpiNsExecuteControlMethod ( ACPI_OPERAND_OBJECT *ObjDesc; - FUNCTION_TRACE ("NsExecuteControlMethod"); + ACPI_FUNCTION_TRACE ("NsExecuteControlMethod"); /* Verify that there is a method associated with this object */ @@ -487,7 +499,7 @@ AcpiNsExecuteControlMethod ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_NULL_OBJECT); } @@ -495,7 +507,7 @@ AcpiNsExecuteControlMethod ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Control method at Offset %p Length %x]\n", ObjDesc->Method.AmlStart + 1, ObjDesc->Method.AmlLength - 1)); - DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", + ACPI_DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", ACPI_LV_NAMES, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "At offset %p\n", @@ -509,7 +521,11 @@ AcpiNsExecuteControlMethod ( * interpreter locks to ensure that no thread is using the portion of the * namespace that is being deleted. */ - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* * Execute the method via the interpreter. The interpreter is locked @@ -538,7 +554,7 @@ AcpiNsExecuteControlMethod ( * * DESCRIPTION: Return the current value of the object * - * MUTEX: Assumes namespace is locked + * MUTEX: Assumes namespace is locked, leaves namespace unlocked * ******************************************************************************/ @@ -549,117 +565,62 @@ AcpiNsGetObjectValue ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *SourceDesc; - FUNCTION_TRACE ("NsGetObjectValue"); + ACPI_FUNCTION_TRACE ("NsGetObjectValue"); /* - * We take the value from certain objects directly + * Objects require additional resolution steps (e.g., the + * Node may be a field that must be read, etc.) -- we can't just grab + * the object out of the node. */ - if ((Node->Type == ACPI_TYPE_PROCESSOR) || - (Node->Type == ACPI_TYPE_POWER)) - { - /* - * Create a Reference object to contain the object - */ - ObjDesc = AcpiUtCreateInternalObject (Node->Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* - * Get the attached object - */ - SourceDesc = AcpiNsGetAttachedObject (Node); - if (!SourceDesc) - { - Status = AE_NULL_OBJECT; - goto UnlockAndExit; - } - - /* - * Just copy from the original to the return object - * - * TBD: [Future] - need a low-level object copy that handles - * the reference count automatically. (Don't want to copy it) - */ - MEMCPY (ObjDesc, SourceDesc, sizeof (ACPI_OPERAND_OBJECT)); - ObjDesc->Common.ReferenceCount = 1; - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - } - + ObjDesc = (ACPI_OPERAND_OBJECT *) Node; /* - * Other objects require a reference object wrapper which we - * then attempt to resolve. + * Use ResolveNodeToValue() to get the associated value. This call + * always deletes ObjDesc (allocated above). + * + * NOTE: we can get away with passing in NULL for a walk state + * because ObjDesc is guaranteed to not be a reference to either + * a method local or a method argument (because this interface can only be + * called from the AcpiEvaluate external interface, never called from + * a running control method.) + * + * Even though we do not directly invoke the interpreter + * for this, we must enter it because we could access an opregion. + * The opregion access code assumes that the interpreter + * is locked. + * + * We must release the namespace lock before entering the + * intepreter. */ - else + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) { - /* Create an Reference object to contain the object */ - - ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Construct a descriptor pointing to the name */ - - ObjDesc->Reference.Opcode = (UINT8) AML_NAME_OP; - ObjDesc->Reference.Object = (void *) Node; + return_ACPI_STATUS (Status); + } + Status = AcpiExEnterInterpreter (); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExResolveNodeToValue ((ACPI_NAMESPACE_NODE **) &ObjDesc, NULL); /* - * Use ResolveToValue() to get the associated value. This call - * always deletes ObjDesc (allocated above). - * - * NOTE: we can get away with passing in NULL for a walk state - * because ObjDesc is guaranteed to not be a reference to either - * a method local or a method argument - * - * Even though we do not directly invoke the interpreter - * for this, we must enter it because we could access an opregion. - * The opregion access code assumes that the interpreter - * is locked. - * - * We must release the namespace lock before entering the - * intepreter. + * If AcpiExResolveNodeToValue() succeeded, the return value was + * placed in ObjDesc. */ - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - Status = AcpiExEnterInterpreter (); + AcpiExExitInterpreter (); + if (ACPI_SUCCESS (Status)) { - Status = AcpiExResolveToValue (&ObjDesc, NULL); - - AcpiExExitInterpreter (); + Status = AE_CTRL_RETURN_VALUE; + *ReturnObjDesc = ObjDesc; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Returning obj %p\n", *ReturnObjDesc)); } } - /* - * If AcpiExResolveToValue() succeeded, the return value was - * placed in ObjDesc. - */ - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_RETURN_VALUE; - - *ReturnObjDesc = ObjDesc; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Returning obj %p\n", *ReturnObjDesc)); - } - /* Namespace is unlocked */ return_ACPI_STATUS (Status); - - -UnlockAndExit: - - /* Unlock the namespace */ - - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); } + |