diff options
Diffstat (limited to 'sys/contrib/dev/acpica/dsmthdat.c')
-rw-r--r-- | sys/contrib/dev/acpica/dsmthdat.c | 359 |
1 files changed, 116 insertions, 243 deletions
diff --git a/sys/contrib/dev/acpica/dsmthdat.c b/sys/contrib/dev/acpica/dsmthdat.c index e44829def13d..e597976ff12a 100644 --- a/sys/contrib/dev/acpica/dsmthdat.c +++ b/sys/contrib/dev/acpica/dsmthdat.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 49 $ + * $Revision: 53 $ * ******************************************************************************/ @@ -141,6 +141,12 @@ * This allows RefOf and DeRefOf to work properly for these * special data types. * + * NOTES: WalkState fields are initialized to zero by the + * ACPI_MEM_CALLOCATE(). + * + * A pseudo-Namespace Node is assigned to each argument and local + * so that RefOf() can return a pointer to the Node. + * ******************************************************************************/ ACPI_STATUS @@ -152,13 +158,6 @@ AcpiDsMethodDataInit ( FUNCTION_TRACE ("DsMethodDataInit"); - /* - * WalkState fields are initialized to zero by the - * ACPI_MEM_CALLOCATE(). - * - * An Node is assigned to each argument and local so - * that RefOf() can return a pointer to the Node. - */ /* Init the method arguments */ @@ -207,52 +206,38 @@ AcpiDsMethodDataDeleteAll ( ACPI_WALK_STATE *WalkState) { UINT32 Index; - ACPI_OPERAND_OBJECT *Object; FUNCTION_TRACE ("DsMethodDataDeleteAll"); - /* Delete the locals */ - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting local variables in %p\n", WalkState)); + /* Detach the locals */ for (Index = 0; Index < MTH_NUM_LOCALS; Index++) { - Object = WalkState->LocalVariables[Index].Object; - if (Object) + if (WalkState->LocalVariables[Index].Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", Index, Object)); - - /* Remove first */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + Index, WalkState->LocalVariables[Index].Object)); - WalkState->LocalVariables[Index].Object = NULL; + /* Detach object (if present) and remove a reference */ - /* Was given a ref when stored */ - - AcpiUtRemoveReference (Object); + AcpiNsDetachObject (&WalkState->LocalVariables[Index]); } } - - /* Delete the arguments */ - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting arguments in %p\n", WalkState)); + /* Detach the arguments */ for (Index = 0; Index < MTH_NUM_ARGS; Index++) { - Object = WalkState->Arguments[Index].Object; - if (Object) + if (WalkState->Arguments[Index].Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", Index, Object)); - - /* Remove first */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + Index, WalkState->Arguments[Index].Object)); - WalkState->Arguments[Index].Object = NULL; + /* Detach object (if present) and remove a reference */ - /* Was given a ref when stored */ - - AcpiUtRemoveReference (Object); + AcpiNsDetachObject (&WalkState->Arguments[Index]); } } @@ -270,7 +255,9 @@ AcpiDsMethodDataDeleteAll ( * * RETURN: Status * - * DESCRIPTION: Initialize arguments for a method + * DESCRIPTION: Initialize arguments for a method. The parameter list is a list + * of ACPI operand objects, either null terminated or whose length + * is defined by MaxParamCount. * ******************************************************************************/ @@ -281,8 +268,7 @@ AcpiDsMethodDataInitArgs ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - UINT32 Mindex; - UINT32 Pindex; + UINT32 Index = 0; FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); @@ -296,85 +282,68 @@ AcpiDsMethodDataInitArgs ( /* Copy passed parameters into the new method stack frame */ - for (Pindex = Mindex = 0; - (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); - Mindex++) + while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) { - if (Params[Pindex]) + /* + * A valid parameter. + * Store the argument in the method/walk descriptor + */ + Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index], + WalkState); + if (ACPI_FAILURE (Status)) { - /* - * A valid parameter. - * Set the current method argument to the - * Params[Pindex++] argument object descriptor - */ - Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Mindex, - Params[Pindex], WalkState); - if (ACPI_FAILURE (Status)) - { - break; - } - - Pindex++; + return_ACPI_STATUS (Status); } - else - { - break; - } + Index++; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Pindex)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiDsMethodDataGetEntry + * FUNCTION: AcpiDsMethodDataGetNode * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument to get - * Entry - Pointer to where a pointer to the stack - * entry is returned. + * Index - Which localVar or argument whose type + * to get * WalkState - Current walk state object * - * RETURN: Status - * - * DESCRIPTION: Get the address of the object entry given by Opcode:Index + * RETURN: Get the Node associated with a local or arg. * ******************************************************************************/ ACPI_STATUS -AcpiDsMethodDataGetEntry ( +AcpiDsMethodDataGetNode ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT ***Entry) + ACPI_NAMESPACE_NODE **Node) { - - FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); + FUNCTION_TRACE ("DsMethodDataGetNode"); /* - * Get the requested object. - * The stack "Opcode" is either a LocalVariable or an Argument + * Method Locals and Arguments are supported */ switch (Opcode) { - case AML_LOCAL_OP: if (Index > MTH_MAX_LOCAL) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "LocalVar index %d is invalid (max %d)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", Index, MTH_MAX_LOCAL)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); } - *Entry = (ACPI_OPERAND_OBJECT **) - &WalkState->LocalVariables[Index].Object; - break; + /* Return a pointer to the pseudo-node */ + *Node = &WalkState->LocalVariables[Index]; + break; case AML_ARG_OP: @@ -382,27 +351,27 @@ AcpiDsMethodDataGetEntry ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", Index, MTH_MAX_ARG)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); } - *Entry = (ACPI_OPERAND_OBJECT **) - &WalkState->Arguments[Index].Object; - break; + /* Return a pointer to the pseudo-node */ + *Node = &WalkState->Arguments[Index]; + break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + break; } - return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiDsMethodDataSetEntry + * FUNCTION: AcpiDsMethodDataSetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to get @@ -416,22 +385,22 @@ AcpiDsMethodDataGetEntry ( ******************************************************************************/ ACPI_STATUS -AcpiDsMethodDataSetEntry ( +AcpiDsMethodDataSetValue ( UINT16 Opcode, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Entry; + ACPI_NAMESPACE_NODE *Node; - FUNCTION_TRACE ("DsMethodDataSetEntry"); + FUNCTION_TRACE ("DsMethodDataSetValue"); - /* Get a pointer to the stack entry to set */ + /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -443,8 +412,7 @@ AcpiDsMethodDataSetEntry ( /* Install the object into the stack entry */ - *Entry = Object; - + Node->Object = Object; return_ACPI_STATUS (AE_OK); } @@ -458,8 +426,7 @@ AcpiDsMethodDataSetEntry ( * to get * WalkState - Current walk state object * - * RETURN: Data type of selected Arg or Local - * Used only in ExecMonadic2()/TypeOp. + * RETURN: Data type of current value of the selected Arg or Local * ******************************************************************************/ @@ -470,98 +437,34 @@ AcpiDsMethodDataGetType ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Entry; + ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; FUNCTION_TRACE ("DsMethodDataGetType"); - /* Get a pointer to the requested stack entry */ + /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_VALUE ((ACPI_TYPE_NOT_FOUND)); } - /* Get the object from the method stack */ - - Object = *Entry; - - /* Get the object type */ + /* Get the object */ + Object = AcpiNsGetAttachedObject (Node); if (!Object) { - /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ - return_VALUE (ACPI_TYPE_ANY); - } - - return_VALUE (Object->Common.Type); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsMethodDataGetNode - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument whose type - * to get - * WalkState - Current walk state object - * - * RETURN: Get the Node associated with a local or arg. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiDsMethodDataGetNode ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_NAMESPACE_NODE *Node = NULL; - - - FUNCTION_TRACE ("DsMethodDataGetNode"); - - - switch (Opcode) - { - - case AML_LOCAL_OP: - - if (Index > MTH_MAX_LOCAL) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", - Index, MTH_MAX_LOCAL)); - return_PTR (Node); - } - - Node = &WalkState->LocalVariables[Index]; - break; - - - case AML_ARG_OP: - - if (Index > MTH_MAX_ARG) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", - Index, MTH_MAX_ARG)); - return_PTR (Node); - } - - Node = &WalkState->Arguments[Index]; - break; - + /* Uninitialized local/arg, return TYPE_ANY */ - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); - break; + return_VALUE (ACPI_TYPE_ANY); } + /* Get the object type */ - return_PTR (Node); + return_VALUE (Object->Common.Type); } @@ -591,7 +494,7 @@ AcpiDsMethodDataGetValue ( ACPI_OPERAND_OBJECT **DestDesc) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Entry; + ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; @@ -606,26 +509,24 @@ AcpiDsMethodDataGetValue ( return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Get the namespace node for the arg/local */ - /* Get a pointer to the requested method stack entry */ - - Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* Get the object from the method stack */ - - Object = *Entry; + /* Get the object from the node */ + Object = Node->Object; /* Examine the returned object, it must be valid. */ if (!Object) { /* - * Index points to uninitialized object stack value. + * Index points to uninitialized object. * This means that either 1) The expected argument was * not passed to the method, or 2) A local variable * was referenced by the method (via the ASL) @@ -635,25 +536,24 @@ AcpiDsMethodDataGetValue ( { case AML_ARG_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n", - Index, Entry)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", + Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); break; case AML_LOCAL_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n", - Index, Entry)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", + Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); break; } } - /* - * Index points to initialized and valid object stack value. + * The Index points to an initialized and valid object. * Return an additional reference to the object */ *DestDesc = Object; @@ -685,39 +585,39 @@ AcpiDsMethodDataDeleteValue ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Entry; + ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; FUNCTION_TRACE ("DsMethodDataDeleteValue"); - /* Get a pointer to the requested entry */ + /* Get the namespace node for the arg/local */ - Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* Get the current entry in this slot k */ + /* Get the associated object */ - Object = *Entry; + Object = AcpiNsGetAttachedObject (Node); /* * Undefine the Arg or Local by setting its descriptor * pointer to NULL. Locals/Args can contain both * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs */ - *Entry = NULL; + Node->Object = NULL; if ((Object) && (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) { /* - * There is a valid object in this slot + * There is a valid object. * Decrement the reference count by one to balance the - * increment when the object was stored in the slot. + * increment when the object was stored. */ AcpiUtRemoveReference (Object); } @@ -732,14 +632,14 @@ AcpiDsMethodDataDeleteValue ( * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to set - * SrcDesc - Value to be stored + * ObjDesc - Value to be stored * WalkState - Current walk state * * RETURN: Status * - * DESCRIPTION: Store a value in an Arg or Local. The SrcDesc is installed + * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed * as the new value for the Arg or Local and the reference count - * for SrcDesc is incremented. + * for ObjDesc is incremented. * ******************************************************************************/ @@ -747,48 +647,48 @@ ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT16 Opcode, UINT32 Index, - ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Entry; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *CurrentObjDesc; - FUNCTION_TRACE ("DsMethodDataSetValue"); + FUNCTION_TRACE ("DsStoreObjectToLocal"); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", - Opcode, Index, SrcDesc)); + Opcode, Index, ObjDesc)); /* Parameter validation */ - if (!SrcDesc) + if (!ObjDesc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Get the namespace node for the arg/local */ - /* Get a pointer to the requested method stack entry */ - - Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { - goto Cleanup; + return_ACPI_STATUS (Status); } - if (*Entry == SrcDesc) + CurrentObjDesc = AcpiNsGetAttachedObject (Node); + if (CurrentObjDesc == ObjDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", SrcDesc)); - goto Cleanup; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc)); + return_ACPI_STATUS (Status); } - /* * If there is an object already in this slot, we either * have to delete it, or if this is an argument and there * is an object reference stored there, we have to do * an indirect store! */ - if (*Entry) + if (CurrentObjDesc) { /* * Check for an indirect store if an argument @@ -807,38 +707,25 @@ AcpiDsStoreObjectToLocal ( * Weird, but true. */ if ((Opcode == AML_ARG_OP) && - (VALID_DESCRIPTOR_TYPE (*Entry, ACPI_DESC_TYPE_NAMED))) + (VALID_DESCRIPTOR_TYPE (CurrentObjDesc, ACPI_DESC_TYPE_NAMED))) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Arg (%p) is an ObjRef(Node), storing in %p\n", - SrcDesc, *Entry)); + "Arg (%p) is an ObjRef(Node), storing in node %p\n", + ObjDesc, CurrentObjDesc)); /* Detach an existing object from the Node */ - AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) *Entry); + AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc); /* * Store this object into the Node - * (do the indirect store) + * (perform the indirect store) */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) *Entry, SrcDesc, - SrcDesc->Common.Type); + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc, + ObjDesc, ObjDesc->Common.Type); return_ACPI_STATUS (Status); } - -#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION - /* - * Perform "Implicit conversion" of the new object to the type of the - * existing object - */ - Status = AcpiExConvertToTargetType ((*Entry)->Common.Type, &SrcDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } -#endif - /* * Delete the existing object * before storing the new one @@ -846,28 +733,14 @@ AcpiDsStoreObjectToLocal ( AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); } - /* - * Install the ObjStack descriptor (*SrcDesc) into + * Install the ObjStack descriptor (*ObjDesc) into * the descriptor for the Arg or Local. * Install the new object in the stack entry * (increments the object reference count by one) */ - Status = AcpiDsMethodDataSetEntry (Opcode, Index, SrcDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Normal exit */ - - return_ACPI_STATUS (AE_OK); - - - /* Error exit */ - -Cleanup: - + Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState); return_ACPI_STATUS (Status); } + |