dsmthdat.c revision 87031
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dsmthdat - control method arguments and local variables 487031Smsmith * $Revision: 53 $ 567754Smsmith * 667754Smsmith ******************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 1271867Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith#define __DSMTHDAT_C__ 11867754Smsmith 11967754Smsmith#include "acpi.h" 12067754Smsmith#include "acparser.h" 12167754Smsmith#include "acdispat.h" 12267754Smsmith#include "acinterp.h" 12367754Smsmith#include "amlcode.h" 12467754Smsmith#include "acnamesp.h" 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_DISPATCHER 12867754Smsmith MODULE_NAME ("dsmthdat") 12967754Smsmith 13067754Smsmith 13167754Smsmith/******************************************************************************* 13267754Smsmith * 13367754Smsmith * FUNCTION: AcpiDsMethodDataInit 13467754Smsmith * 13571867Smsmith * PARAMETERS: WalkState - Current walk state object 13667754Smsmith * 13767754Smsmith * RETURN: Status 13867754Smsmith * 13967754Smsmith * DESCRIPTION: Initialize the data structures that hold the method's arguments 14067754Smsmith * and locals. The data struct is an array of NTEs for each. 14167754Smsmith * This allows RefOf and DeRefOf to work properly for these 14267754Smsmith * special data types. 14367754Smsmith * 14487031Smsmith * NOTES: WalkState fields are initialized to zero by the 14587031Smsmith * ACPI_MEM_CALLOCATE(). 14687031Smsmith * 14787031Smsmith * A pseudo-Namespace Node is assigned to each argument and local 14887031Smsmith * so that RefOf() can return a pointer to the Node. 14987031Smsmith * 15067754Smsmith ******************************************************************************/ 15167754Smsmith 15267754SmsmithACPI_STATUS 15367754SmsmithAcpiDsMethodDataInit ( 15467754Smsmith ACPI_WALK_STATE *WalkState) 15567754Smsmith{ 15667754Smsmith UINT32 i; 15767754Smsmith 15867754Smsmith 15967754Smsmith FUNCTION_TRACE ("DsMethodDataInit"); 16067754Smsmith 16167754Smsmith 16267754Smsmith /* Init the method arguments */ 16367754Smsmith 16467754Smsmith for (i = 0; i < MTH_NUM_ARGS; i++) 16567754Smsmith { 16667754Smsmith MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, 16767754Smsmith NAMEOF_ARG_NTE); 16867754Smsmith WalkState->Arguments[i].Name |= (i << 24); 16967754Smsmith WalkState->Arguments[i].DataType = ACPI_DESC_TYPE_NAMED; 17069746Smsmith WalkState->Arguments[i].Type = ACPI_TYPE_ANY; 17169746Smsmith WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; 17267754Smsmith } 17367754Smsmith 17467754Smsmith /* Init the method locals */ 17567754Smsmith 17667754Smsmith for (i = 0; i < MTH_NUM_LOCALS; i++) 17767754Smsmith { 17867754Smsmith MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, 17967754Smsmith NAMEOF_LOCAL_NTE); 18067754Smsmith 18167754Smsmith WalkState->LocalVariables[i].Name |= (i << 24); 18267754Smsmith WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED; 18369746Smsmith WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; 18469746Smsmith WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; 18567754Smsmith } 18667754Smsmith 18767754Smsmith return_ACPI_STATUS (AE_OK); 18867754Smsmith} 18967754Smsmith 19067754Smsmith 19167754Smsmith/******************************************************************************* 19267754Smsmith * 19367754Smsmith * FUNCTION: AcpiDsMethodDataDeleteAll 19467754Smsmith * 19571867Smsmith * PARAMETERS: WalkState - Current walk state object 19667754Smsmith * 19767754Smsmith * RETURN: Status 19867754Smsmith * 19967754Smsmith * DESCRIPTION: Delete method locals and arguments. Arguments are only 20067754Smsmith * deleted if this method was called from another method. 20167754Smsmith * 20267754Smsmith ******************************************************************************/ 20367754Smsmith 20467754SmsmithACPI_STATUS 20567754SmsmithAcpiDsMethodDataDeleteAll ( 20667754Smsmith ACPI_WALK_STATE *WalkState) 20767754Smsmith{ 20867754Smsmith UINT32 Index; 20967754Smsmith 21067754Smsmith 21167754Smsmith FUNCTION_TRACE ("DsMethodDataDeleteAll"); 21267754Smsmith 21367754Smsmith 21487031Smsmith /* Detach the locals */ 21567754Smsmith 21667754Smsmith for (Index = 0; Index < MTH_NUM_LOCALS; Index++) 21767754Smsmith { 21887031Smsmith if (WalkState->LocalVariables[Index].Object) 21967754Smsmith { 22087031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", 22187031Smsmith Index, WalkState->LocalVariables[Index].Object)); 22267754Smsmith 22387031Smsmith /* Detach object (if present) and remove a reference */ 22467754Smsmith 22587031Smsmith AcpiNsDetachObject (&WalkState->LocalVariables[Index]); 22667754Smsmith } 22767754Smsmith } 22867754Smsmith 22987031Smsmith /* Detach the arguments */ 23067754Smsmith 23167754Smsmith for (Index = 0; Index < MTH_NUM_ARGS; Index++) 23267754Smsmith { 23387031Smsmith if (WalkState->Arguments[Index].Object) 23467754Smsmith { 23587031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", 23687031Smsmith Index, WalkState->Arguments[Index].Object)); 23767754Smsmith 23887031Smsmith /* Detach object (if present) and remove a reference */ 23967754Smsmith 24087031Smsmith AcpiNsDetachObject (&WalkState->Arguments[Index]); 24167754Smsmith } 24267754Smsmith } 24367754Smsmith 24467754Smsmith return_ACPI_STATUS (AE_OK); 24567754Smsmith} 24667754Smsmith 24767754Smsmith 24867754Smsmith/******************************************************************************* 24967754Smsmith * 25067754Smsmith * FUNCTION: AcpiDsMethodDataInitArgs 25167754Smsmith * 25271867Smsmith * PARAMETERS: *Params - Pointer to a parameter list for the method 25371867Smsmith * MaxParamCount - The arg count for this method 25471867Smsmith * WalkState - Current walk state object 25567754Smsmith * 25667754Smsmith * RETURN: Status 25767754Smsmith * 25887031Smsmith * DESCRIPTION: Initialize arguments for a method. The parameter list is a list 25987031Smsmith * of ACPI operand objects, either null terminated or whose length 26087031Smsmith * is defined by MaxParamCount. 26167754Smsmith * 26267754Smsmith ******************************************************************************/ 26367754Smsmith 26467754SmsmithACPI_STATUS 26567754SmsmithAcpiDsMethodDataInitArgs ( 26667754Smsmith ACPI_OPERAND_OBJECT **Params, 26767754Smsmith UINT32 MaxParamCount, 26867754Smsmith ACPI_WALK_STATE *WalkState) 26967754Smsmith{ 27067754Smsmith ACPI_STATUS Status; 27187031Smsmith UINT32 Index = 0; 27267754Smsmith 27367754Smsmith 27467754Smsmith FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); 27567754Smsmith 27667754Smsmith 27767754Smsmith if (!Params) 27867754Smsmith { 27982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); 28067754Smsmith return_ACPI_STATUS (AE_OK); 28167754Smsmith } 28267754Smsmith 28367754Smsmith /* Copy passed parameters into the new method stack frame */ 28467754Smsmith 28587031Smsmith while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) 28667754Smsmith { 28787031Smsmith /* 28887031Smsmith * A valid parameter. 28987031Smsmith * Store the argument in the method/walk descriptor 29087031Smsmith */ 29187031Smsmith Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index], 29287031Smsmith WalkState); 29387031Smsmith if (ACPI_FAILURE (Status)) 29467754Smsmith { 29587031Smsmith return_ACPI_STATUS (Status); 29667754Smsmith } 29767754Smsmith 29887031Smsmith Index++; 29967754Smsmith } 30067754Smsmith 30187031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); 30267754Smsmith return_ACPI_STATUS (AE_OK); 30367754Smsmith} 30467754Smsmith 30567754Smsmith 30667754Smsmith/******************************************************************************* 30767754Smsmith * 30887031Smsmith * FUNCTION: AcpiDsMethodDataGetNode 30967754Smsmith * 31077424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 31187031Smsmith * Index - Which localVar or argument whose type 31287031Smsmith * to get 31371867Smsmith * WalkState - Current walk state object 31467754Smsmith * 31587031Smsmith * RETURN: Get the Node associated with a local or arg. 31667754Smsmith * 31767754Smsmith ******************************************************************************/ 31867754Smsmith 31967754SmsmithACPI_STATUS 32087031SmsmithAcpiDsMethodDataGetNode ( 32177424Smsmith UINT16 Opcode, 32267754Smsmith UINT32 Index, 32367754Smsmith ACPI_WALK_STATE *WalkState, 32487031Smsmith ACPI_NAMESPACE_NODE **Node) 32567754Smsmith{ 32687031Smsmith FUNCTION_TRACE ("DsMethodDataGetNode"); 32767754Smsmith 32867754Smsmith 32967754Smsmith /* 33087031Smsmith * Method Locals and Arguments are supported 33167754Smsmith */ 33277424Smsmith switch (Opcode) 33367754Smsmith { 33477424Smsmith case AML_LOCAL_OP: 33567754Smsmith 33667754Smsmith if (Index > MTH_MAX_LOCAL) 33767754Smsmith { 33887031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", 33967754Smsmith Index, MTH_MAX_LOCAL)); 34087031Smsmith return_ACPI_STATUS (AE_AML_INVALID_INDEX); 34167754Smsmith } 34267754Smsmith 34387031Smsmith /* Return a pointer to the pseudo-node */ 34487031Smsmith 34587031Smsmith *Node = &WalkState->LocalVariables[Index]; 34667754Smsmith break; 34767754Smsmith 34877424Smsmith case AML_ARG_OP: 34967754Smsmith 35067754Smsmith if (Index > MTH_MAX_ARG) 35167754Smsmith { 35282367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 35367754Smsmith Index, MTH_MAX_ARG)); 35487031Smsmith return_ACPI_STATUS (AE_AML_INVALID_INDEX); 35567754Smsmith } 35667754Smsmith 35787031Smsmith /* Return a pointer to the pseudo-node */ 35887031Smsmith 35987031Smsmith *Node = &WalkState->Arguments[Index]; 36067754Smsmith break; 36167754Smsmith 36267754Smsmith default: 36382367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); 36487031Smsmith return_ACPI_STATUS (AE_AML_BAD_OPCODE); 36587031Smsmith break; 36667754Smsmith } 36767754Smsmith 36867754Smsmith return_ACPI_STATUS (AE_OK); 36967754Smsmith} 37067754Smsmith 37167754Smsmith 37267754Smsmith/******************************************************************************* 37367754Smsmith * 37487031Smsmith * FUNCTION: AcpiDsMethodDataSetValue 37567754Smsmith * 37677424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 37767754Smsmith * Index - Which localVar or argument to get 37867754Smsmith * Object - Object to be inserted into the stack entry 37971867Smsmith * WalkState - Current walk state object 38067754Smsmith * 38167754Smsmith * RETURN: Status 38267754Smsmith * 38377424Smsmith * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. 38467754Smsmith * 38567754Smsmith ******************************************************************************/ 38667754Smsmith 38767754SmsmithACPI_STATUS 38887031SmsmithAcpiDsMethodDataSetValue ( 38977424Smsmith UINT16 Opcode, 39067754Smsmith UINT32 Index, 39167754Smsmith ACPI_OPERAND_OBJECT *Object, 39267754Smsmith ACPI_WALK_STATE *WalkState) 39367754Smsmith{ 39467754Smsmith ACPI_STATUS Status; 39587031Smsmith ACPI_NAMESPACE_NODE *Node; 39667754Smsmith 39767754Smsmith 39887031Smsmith FUNCTION_TRACE ("DsMethodDataSetValue"); 39967754Smsmith 40083174Smsmith 40187031Smsmith /* Get the namespace node for the arg/local */ 40267754Smsmith 40387031Smsmith Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 40467754Smsmith if (ACPI_FAILURE (Status)) 40567754Smsmith { 40667754Smsmith return_ACPI_STATUS (Status); 40767754Smsmith } 40867754Smsmith 40967754Smsmith /* Increment ref count so object can't be deleted while installed */ 41067754Smsmith 41177424Smsmith AcpiUtAddReference (Object); 41267754Smsmith 41367754Smsmith /* Install the object into the stack entry */ 41467754Smsmith 41587031Smsmith Node->Object = Object; 41667754Smsmith return_ACPI_STATUS (AE_OK); 41767754Smsmith} 41867754Smsmith 41967754Smsmith 42067754Smsmith/******************************************************************************* 42167754Smsmith * 42267754Smsmith * FUNCTION: AcpiDsMethodDataGetType 42367754Smsmith * 42477424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 42567754Smsmith * Index - Which localVar or argument whose type 42667754Smsmith * to get 42771867Smsmith * WalkState - Current walk state object 42867754Smsmith * 42987031Smsmith * RETURN: Data type of current value of the selected Arg or Local 43067754Smsmith * 43167754Smsmith ******************************************************************************/ 43267754Smsmith 43377424SmsmithACPI_OBJECT_TYPE8 43467754SmsmithAcpiDsMethodDataGetType ( 43577424Smsmith UINT16 Opcode, 43667754Smsmith UINT32 Index, 43767754Smsmith ACPI_WALK_STATE *WalkState) 43867754Smsmith{ 43967754Smsmith ACPI_STATUS Status; 44087031Smsmith ACPI_NAMESPACE_NODE *Node; 44167754Smsmith ACPI_OPERAND_OBJECT *Object; 44267754Smsmith 44367754Smsmith 44467754Smsmith FUNCTION_TRACE ("DsMethodDataGetType"); 44567754Smsmith 44667754Smsmith 44787031Smsmith /* Get the namespace node for the arg/local */ 44867754Smsmith 44987031Smsmith Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 45067754Smsmith if (ACPI_FAILURE (Status)) 45167754Smsmith { 45267754Smsmith return_VALUE ((ACPI_TYPE_NOT_FOUND)); 45367754Smsmith } 45467754Smsmith 45587031Smsmith /* Get the object */ 45667754Smsmith 45787031Smsmith Object = AcpiNsGetAttachedObject (Node); 45867754Smsmith if (!Object) 45967754Smsmith { 46087031Smsmith /* Uninitialized local/arg, return TYPE_ANY */ 46187031Smsmith 46267754Smsmith return_VALUE (ACPI_TYPE_ANY); 46367754Smsmith } 46467754Smsmith 46587031Smsmith /* Get the object type */ 46687031Smsmith 46767754Smsmith return_VALUE (Object->Common.Type); 46867754Smsmith} 46967754Smsmith 47067754Smsmith 47167754Smsmith/******************************************************************************* 47267754Smsmith * 47367754Smsmith * FUNCTION: AcpiDsMethodDataGetValue 47467754Smsmith * 47577424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 47667754Smsmith * Index - Which localVar or argument to get 47771867Smsmith * WalkState - Current walk state object 47871867Smsmith * *DestDesc - Ptr to Descriptor into which selected Arg 47967754Smsmith * or Local value should be copied 48067754Smsmith * 48167754Smsmith * RETURN: Status 48267754Smsmith * 48367754Smsmith * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame 48467754Smsmith * at the current top of the method stack. 48577424Smsmith * Used only in AcpiExResolveToValue(). 48667754Smsmith * 48767754Smsmith ******************************************************************************/ 48867754Smsmith 48967754SmsmithACPI_STATUS 49067754SmsmithAcpiDsMethodDataGetValue ( 49177424Smsmith UINT16 Opcode, 49267754Smsmith UINT32 Index, 49367754Smsmith ACPI_WALK_STATE *WalkState, 49467754Smsmith ACPI_OPERAND_OBJECT **DestDesc) 49567754Smsmith{ 49667754Smsmith ACPI_STATUS Status; 49787031Smsmith ACPI_NAMESPACE_NODE *Node; 49867754Smsmith ACPI_OPERAND_OBJECT *Object; 49967754Smsmith 50067754Smsmith 50167754Smsmith FUNCTION_TRACE ("DsMethodDataGetValue"); 50267754Smsmith 50367754Smsmith 50467754Smsmith /* Validate the object descriptor */ 50567754Smsmith 50667754Smsmith if (!DestDesc) 50767754Smsmith { 50882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); 50967754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 51067754Smsmith } 51167754Smsmith 51287031Smsmith /* Get the namespace node for the arg/local */ 51367754Smsmith 51487031Smsmith Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 51567754Smsmith if (ACPI_FAILURE (Status)) 51667754Smsmith { 51767754Smsmith return_ACPI_STATUS (Status); 51867754Smsmith } 51967754Smsmith 52087031Smsmith /* Get the object from the node */ 52167754Smsmith 52287031Smsmith Object = Node->Object; 52367754Smsmith 52467754Smsmith /* Examine the returned object, it must be valid. */ 52567754Smsmith 52667754Smsmith if (!Object) 52767754Smsmith { 52867754Smsmith /* 52987031Smsmith * Index points to uninitialized object. 53067754Smsmith * This means that either 1) The expected argument was 53167754Smsmith * not passed to the method, or 2) A local variable 53267754Smsmith * was referenced by the method (via the ASL) 53367754Smsmith * before it was initialized. Either case is an error. 53467754Smsmith */ 53577424Smsmith switch (Opcode) 53667754Smsmith { 53777424Smsmith case AML_ARG_OP: 53871867Smsmith 53987031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", 54087031Smsmith Index, Node)); 54171867Smsmith 54267754Smsmith return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 54367754Smsmith break; 54467754Smsmith 54577424Smsmith case AML_LOCAL_OP: 54671867Smsmith 54787031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", 54887031Smsmith Index, Node)); 54971867Smsmith 55067754Smsmith return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 55167754Smsmith break; 55267754Smsmith } 55367754Smsmith } 55467754Smsmith 55567754Smsmith /* 55687031Smsmith * The Index points to an initialized and valid object. 55767754Smsmith * Return an additional reference to the object 55867754Smsmith */ 55967754Smsmith *DestDesc = Object; 56077424Smsmith AcpiUtAddReference (Object); 56167754Smsmith 56267754Smsmith return_ACPI_STATUS (AE_OK); 56367754Smsmith} 56467754Smsmith 56567754Smsmith 56667754Smsmith/******************************************************************************* 56767754Smsmith * 56867754Smsmith * FUNCTION: AcpiDsMethodDataDeleteValue 56967754Smsmith * 57077424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 57167754Smsmith * Index - Which localVar or argument to delete 57271867Smsmith * WalkState - Current walk state object 57367754Smsmith * 57467754Smsmith * RETURN: Status 57567754Smsmith * 57677424Smsmith * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts 57767754Smsmith * a null into the stack slot after the object is deleted. 57867754Smsmith * 57967754Smsmith ******************************************************************************/ 58067754Smsmith 58167754SmsmithACPI_STATUS 58267754SmsmithAcpiDsMethodDataDeleteValue ( 58377424Smsmith UINT16 Opcode, 58467754Smsmith UINT32 Index, 58567754Smsmith ACPI_WALK_STATE *WalkState) 58667754Smsmith{ 58767754Smsmith ACPI_STATUS Status; 58887031Smsmith ACPI_NAMESPACE_NODE *Node; 58967754Smsmith ACPI_OPERAND_OBJECT *Object; 59067754Smsmith 59167754Smsmith 59267754Smsmith FUNCTION_TRACE ("DsMethodDataDeleteValue"); 59367754Smsmith 59467754Smsmith 59587031Smsmith /* Get the namespace node for the arg/local */ 59667754Smsmith 59787031Smsmith Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 59867754Smsmith if (ACPI_FAILURE (Status)) 59967754Smsmith { 60067754Smsmith return_ACPI_STATUS (Status); 60167754Smsmith } 60267754Smsmith 60387031Smsmith /* Get the associated object */ 60467754Smsmith 60587031Smsmith Object = AcpiNsGetAttachedObject (Node); 60667754Smsmith 60767754Smsmith /* 60867754Smsmith * Undefine the Arg or Local by setting its descriptor 60967754Smsmith * pointer to NULL. Locals/Args can contain both 61067754Smsmith * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs 61167754Smsmith */ 61287031Smsmith Node->Object = NULL; 61367754Smsmith 61467754Smsmith if ((Object) && 61567754Smsmith (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) 61667754Smsmith { 61767754Smsmith /* 61887031Smsmith * There is a valid object. 61967754Smsmith * Decrement the reference count by one to balance the 62087031Smsmith * increment when the object was stored. 62167754Smsmith */ 62277424Smsmith AcpiUtRemoveReference (Object); 62367754Smsmith } 62467754Smsmith 62567754Smsmith return_ACPI_STATUS (AE_OK); 62667754Smsmith} 62767754Smsmith 62867754Smsmith 62967754Smsmith/******************************************************************************* 63067754Smsmith * 63177424Smsmith * FUNCTION: AcpiDsStoreObjectToLocal 63267754Smsmith * 63377424Smsmith * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 63467754Smsmith * Index - Which localVar or argument to set 63587031Smsmith * ObjDesc - Value to be stored 63671867Smsmith * WalkState - Current walk state 63767754Smsmith * 63867754Smsmith * RETURN: Status 63967754Smsmith * 64087031Smsmith * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed 64167754Smsmith * as the new value for the Arg or Local and the reference count 64287031Smsmith * for ObjDesc is incremented. 64367754Smsmith * 64467754Smsmith ******************************************************************************/ 64567754Smsmith 64667754SmsmithACPI_STATUS 64777424SmsmithAcpiDsStoreObjectToLocal ( 64877424Smsmith UINT16 Opcode, 64967754Smsmith UINT32 Index, 65087031Smsmith ACPI_OPERAND_OBJECT *ObjDesc, 65167754Smsmith ACPI_WALK_STATE *WalkState) 65267754Smsmith{ 65367754Smsmith ACPI_STATUS Status; 65487031Smsmith ACPI_NAMESPACE_NODE *Node; 65587031Smsmith ACPI_OPERAND_OBJECT *CurrentObjDesc; 65667754Smsmith 65767754Smsmith 65887031Smsmith FUNCTION_TRACE ("DsStoreObjectToLocal"); 65982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", 66087031Smsmith Opcode, Index, ObjDesc)); 66167754Smsmith 66267754Smsmith 66367754Smsmith /* Parameter validation */ 66467754Smsmith 66587031Smsmith if (!ObjDesc) 66667754Smsmith { 66767754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 66867754Smsmith } 66967754Smsmith 67087031Smsmith /* Get the namespace node for the arg/local */ 67167754Smsmith 67287031Smsmith Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 67367754Smsmith if (ACPI_FAILURE (Status)) 67467754Smsmith { 67587031Smsmith return_ACPI_STATUS (Status); 67667754Smsmith } 67767754Smsmith 67887031Smsmith CurrentObjDesc = AcpiNsGetAttachedObject (Node); 67987031Smsmith if (CurrentObjDesc == ObjDesc) 68067754Smsmith { 68187031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc)); 68287031Smsmith return_ACPI_STATUS (Status); 68367754Smsmith } 68467754Smsmith 68567754Smsmith /* 68667754Smsmith * If there is an object already in this slot, we either 68767754Smsmith * have to delete it, or if this is an argument and there 68867754Smsmith * is an object reference stored there, we have to do 68967754Smsmith * an indirect store! 69067754Smsmith */ 69187031Smsmith if (CurrentObjDesc) 69267754Smsmith { 69367754Smsmith /* 69467754Smsmith * Check for an indirect store if an argument 69567754Smsmith * contains an object reference (stored as an Node). 69667754Smsmith * We don't allow this automatic dereferencing for 69767754Smsmith * locals, since a store to a local should overwrite 69867754Smsmith * anything there, including an object reference. 69967754Smsmith * 70067754Smsmith * If both Arg0 and Local0 contain RefOf (Local4): 70167754Smsmith * 70267754Smsmith * Store (1, Arg0) - Causes indirect store to local4 70367754Smsmith * Store (1, Local0) - Stores 1 in local0, overwriting 70467754Smsmith * the reference to local4 70567754Smsmith * Store (1, DeRefof (Local0)) - Causes indirect store to local4 70667754Smsmith * 70767754Smsmith * Weird, but true. 70867754Smsmith */ 70977424Smsmith if ((Opcode == AML_ARG_OP) && 71087031Smsmith (VALID_DESCRIPTOR_TYPE (CurrentObjDesc, ACPI_DESC_TYPE_NAMED))) 71167754Smsmith { 71282367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 71387031Smsmith "Arg (%p) is an ObjRef(Node), storing in node %p\n", 71487031Smsmith ObjDesc, CurrentObjDesc)); 71567754Smsmith 71667754Smsmith /* Detach an existing object from the Node */ 71767754Smsmith 71887031Smsmith AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc); 71967754Smsmith 72067754Smsmith /* 72167754Smsmith * Store this object into the Node 72287031Smsmith * (perform the indirect store) 72367754Smsmith */ 72487031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc, 72587031Smsmith ObjDesc, ObjDesc->Common.Type); 72667754Smsmith return_ACPI_STATUS (Status); 72767754Smsmith } 72867754Smsmith 72967754Smsmith /* 73071867Smsmith * Delete the existing object 73167754Smsmith * before storing the new one 73267754Smsmith */ 73377424Smsmith AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); 73467754Smsmith } 73567754Smsmith 73667754Smsmith /* 73787031Smsmith * Install the ObjStack descriptor (*ObjDesc) into 73867754Smsmith * the descriptor for the Arg or Local. 73967754Smsmith * Install the new object in the stack entry 74067754Smsmith * (increments the object reference count by one) 74167754Smsmith */ 74287031Smsmith Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState); 74367754Smsmith return_ACPI_STATUS (Status); 74467754Smsmith} 74567754Smsmith 74687031Smsmith 747