dsmthdat.c revision 77424
165557Sjasone/******************************************************************************* 265557Sjasone * 365557Sjasone * Module Name: dsmthdat - control method arguments and local variables 465557Sjasone * $Revision: 46 $ 565557Sjasone * 665557Sjasone ******************************************************************************/ 765557Sjasone 865557Sjasone/****************************************************************************** 965557Sjasone * 1065557Sjasone * 1. Copyright Notice 1165557Sjasone * 1265557Sjasone * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 1365557Sjasone * All rights reserved. 1465557Sjasone * 1565557Sjasone * 2. License 1665557Sjasone * 1765557Sjasone * 2.1. This is your license from Intel Corp. under its intellectual property 1865557Sjasone * rights. You may have additional license terms from the party that provided 1965557Sjasone * you this software, covering your right to use that party's intellectual 2065557Sjasone * property rights. 2165557Sjasone * 2265557Sjasone * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2365557Sjasone * copy of the source code appearing in this file ("Covered Code") an 2465557Sjasone * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2565557Sjasone * base code distributed originally by Intel ("Original Intel Code") to copy, 2665557Sjasone * make derivatives, distribute, use and display any portion of the Covered 2765557Sjasone * Code in any form, with the right to sublicense such rights; and 2865557Sjasone * 2967352Sjhb * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3065557Sjasone * license (with the right to sublicense), under only those claims of Intel 3165557Sjasone * patents that are infringed by the Original Intel Code, to make, use, sell, 3265557Sjasone * offer to sell, and import the Covered Code and derivative works thereof 3365557Sjasone * solely to the minimum extent necessary to exercise the above copyright 3474912Sjhb * license, and in no event shall the patent license extend to any additions 3574912Sjhb * to or modifications of the Original Intel Code. No other license or right 3674912Sjhb * is granted directly or by implication, estoppel or otherwise; 3772200Sbmilekic * 3872200Sbmilekic * The above copyright and patent license is granted only if the following 3972200Sbmilekic * conditions are met: 4065557Sjasone * 4165557Sjasone * 3. Conditions 4265557Sjasone * 4365557Sjasone * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4465557Sjasone * Redistribution of source code of any substantial portion of the Covered 4565557Sjasone * Code or modification with rights to further distribute source must include 4665557Sjasone * the above Copyright Notice, the above License, this list of Conditions, 4765557Sjasone * and the following Disclaimer and Export Compliance provision. In addition, 4865557Sjasone * Licensee must cause all Covered Code to which Licensee contributes to 4965557Sjasone * contain a file documenting the changes Licensee made to create that Covered 5065557Sjasone * Code and the date of any change. Licensee must include in that file the 5165557Sjasone * documentation of any changes made by any predecessor Licensee. Licensee 5265557Sjasone * must include a prominent statement that the modification is derived, 5365557Sjasone * directly or indirectly, from Original Intel Code. 5465557Sjasone * 5565557Sjasone * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5665557Sjasone * Redistribution of source code of any substantial portion of the Covered 5765557Sjasone * Code or modification without rights to further distribute source must 5865557Sjasone * include the following Disclaimer and Export Compliance provision in the 59111881Sjhb * documentation and/or other materials provided with distribution. In 60111881Sjhb * addition, Licensee may not authorize further sublicense of source of any 61111881Sjhb * portion of the Covered Code, and must include terms to the effect that the 62111881Sjhb * license from Licensee to its licensee is limited to the intellectual 63111881Sjhb * property embodied in the software Licensee provides to its licensee, and 64111881Sjhb * not to intellectual property embodied in modifications its licensee may 65111881Sjhb * make. 66111881Sjhb * 67111881Sjhb * 3.3. Redistribution of Executable. Redistribution in executable form of any 68111881Sjhb * substantial portion of the Covered Code or modification must reproduce the 69111881Sjhb * above Copyright Notice, and the following Disclaimer and Export Compliance 70111881Sjhb * provision in the documentation and/or other materials provided with the 71111881Sjhb * distribution. 72111881Sjhb * 73111881Sjhb * 3.4. Intel retains all right, title, and interest in and to the Original 74111881Sjhb * Intel Code. 75111881Sjhb * 76111881Sjhb * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77111881Sjhb * Intel shall be used in advertising or otherwise to promote the sale, use or 78111881Sjhb * other dealings in products derived from or relating to the Covered Code 79111881Sjhb * without prior written authorization from Intel. 80111881Sjhb * 81111881Sjhb * 4. Disclaimer and Export Compliance 82111881Sjhb * 83111881Sjhb * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84111881Sjhb * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8568790Sjhb * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667676Sjhb * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767676Sjhb * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8865557Sjasone * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967352Sjhb * PARTICULAR PURPOSE. 9067352Sjhb * 9174912Sjhb * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9274912Sjhb * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367352Sjhb * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9474912Sjhb * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9565557Sjasone * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667676Sjhb * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9765557Sjasone * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9865557Sjasone * LIMITED REMEDY. 9968790Sjhb * 10068790Sjhb * 4.3. Licensee shall not export, either directly or indirectly, any of this 101111881Sjhb * software or system incorporating such software without first obtaining any 102111881Sjhb * required license or other approval from the U. S. Department of Commerce or 103105508Sphk * any other agency or department of the United States Government. In the 104105508Sphk * event Licensee exports any such software from the United States or 105105508Sphk * re-exports any such software from a foreign destination, Licensee shall 10674912Sjhb * ensure that the distribution and export/re-export of the software is in 10774912Sjhb * compliance with all laws, regulations, orders, or other restrictions of the 10865557Sjasone * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10983798Sjhb * any of its subsidiaries will export/re-export any technical data, process, 11074912Sjhb * software, or service, directly or indirectly, to any country for which the 11174912Sjhb * United States government or any agency thereof requires an export license, 11267352Sjhb * other governmental approval, or letter of assurance, without first obtaining 11374912Sjhb * such license, approval or letter. 11471352Sjasone * 11574912Sjhb *****************************************************************************/ 11671352Sjasone 11774912Sjhb#define __DSMTHDAT_C__ 11871352Sjasone 11974912Sjhb#include "acpi.h" 12074912Sjhb#include "acparser.h" 12174912Sjhb#include "acdispat.h" 12274912Sjhb#include "acinterp.h" 12374912Sjhb#include "amlcode.h" 12474912Sjhb#include "acnamesp.h" 12574912Sjhb 12674912Sjhb 12774912Sjhb#define _COMPONENT ACPI_DISPATCHER 12874912Sjhb MODULE_NAME ("dsmthdat") 12974912Sjhb 13074912Sjhb 13174912Sjhb/******************************************************************************* 13274912Sjhb * 13371352Sjasone * FUNCTION: AcpiDsMethodDataInit 13474912Sjhb * 13574912Sjhb * PARAMETERS: WalkState - Current walk state object 13674912Sjhb * 13774912Sjhb * RETURN: Status 13874912Sjhb * 13971352Sjasone * DESCRIPTION: Initialize the data structures that hold the method's arguments 14074912Sjhb * and locals. The data struct is an array of NTEs for each. 14171352Sjasone * This allows RefOf and DeRefOf to work properly for these 142105508Sphk * special data types. 14374912Sjhb * 14474912Sjhb ******************************************************************************/ 14574912Sjhb 14674912SjhbACPI_STATUS 147105508SphkAcpiDsMethodDataInit ( 14871352Sjasone ACPI_WALK_STATE *WalkState) 14974912Sjhb{ 15074912Sjhb UINT32 i; 15174912Sjhb 15274912Sjhb 15371352Sjasone FUNCTION_TRACE ("DsMethodDataInit"); 15474912Sjhb 15574912Sjhb /* 15674912Sjhb * WalkState fields are initialized to zero by the 15774912Sjhb * AcpiUtCallocate(). 15874912Sjhb * 15974912Sjhb * An Node is assigned to each argument and local so 160105508Sphk * that RefOf() can return a pointer to the Node. 16174912Sjhb */ 162105508Sphk 16374912Sjhb /* Init the method arguments */ 16474912Sjhb 16574912Sjhb for (i = 0; i < MTH_NUM_ARGS; i++) 16674912Sjhb { 16774912Sjhb MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, 16874912Sjhb NAMEOF_ARG_NTE); 16974912Sjhb WalkState->Arguments[i].Name |= (i << 24); 17074912Sjhb WalkState->Arguments[i].DataType = ACPI_DESC_TYPE_NAMED; 17174912Sjhb WalkState->Arguments[i].Type = ACPI_TYPE_ANY; 17274912Sjhb WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; 17376272Sjhb } 17476272Sjhb 175111881Sjhb /* Init the method locals */ 176111881Sjhb 177100011Smp for (i = 0; i < MTH_NUM_LOCALS; i++) 178100011Smp { 179100011Smp MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, 180100011Smp NAMEOF_LOCAL_NTE); 181100011Smp 18272200Sbmilekic WalkState->LocalVariables[i].Name |= (i << 24); 18374912Sjhb WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED; 18472200Sbmilekic WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; 18577843Speter WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; 18677900Speter } 18774912Sjhb 18871352Sjasone return_ACPI_STATUS (AE_OK); 18967352Sjhb} 19072200Sbmilekic 19167676Sjhb 19265557Sjasone/******************************************************************************* 19365557Sjasone * 19465557Sjasone * FUNCTION: AcpiDsMethodDataDeleteAll 19565557Sjasone * 19667676Sjhb * PARAMETERS: WalkState - Current walk state object 19777843Speter * 19867676Sjhb * RETURN: Status 19977843Speter * 20065557Sjasone * DESCRIPTION: Delete method locals and arguments. Arguments are only 20177900Speter * deleted if this method was called from another method. 20267676Sjhb * 203110779Speter ******************************************************************************/ 204110779Speter 205110779SpeterACPI_STATUS 206110779SpeterAcpiDsMethodDataDeleteAll ( 207110779Speter ACPI_WALK_STATE *WalkState) 208110779Speter{ 209110779Speter UINT32 Index; 210110779Speter ACPI_OPERAND_OBJECT *Object; 211110779Speter 212110779Speter 21367676Sjhb FUNCTION_TRACE ("DsMethodDataDeleteAll"); 21465557Sjasone 21567676Sjhb 21677843Speter /* Delete the locals */ 21767676Sjhb 21877843Speter DEBUG_PRINTP (ACPI_INFO, ("Deleting local variables in %p\n", WalkState)); 21965557Sjasone 22077900Speter for (Index = 0; Index < MTH_NUM_LOCALS; Index++) 22167676Sjhb { 22267676Sjhb Object = WalkState->LocalVariables[Index].Object; 22365557Sjasone if (Object) 22474912Sjhb { 22574912Sjhb DEBUG_PRINTP (TRACE_EXEC, ("Deleting Local%d=%p\n", Index, Object)); 22674912Sjhb 22774912Sjhb /* Remove first */ 22874912Sjhb 22974912Sjhb WalkState->LocalVariables[Index].Object = NULL; 23074912Sjhb 23174912Sjhb /* Was given a ref when stored */ 23265557Sjasone 23374912Sjhb AcpiUtRemoveReference (Object); 23474912Sjhb } 23574912Sjhb } 23665557Sjasone 23774912Sjhb 23874912Sjhb /* Delete the arguments */ 23974912Sjhb 24074912Sjhb DEBUG_PRINTP (ACPI_INFO, ("Deleting arguments in %p\n", WalkState)); 241108184Skris 242108184Skris for (Index = 0; Index < MTH_NUM_ARGS; Index++) 24396122Salfred { 24491140Stanimura Object = WalkState->Arguments[Index].Object; 24574912Sjhb if (Object) 24691140Stanimura { 24774912Sjhb DEBUG_PRINTP (TRACE_EXEC, ("Deleting Arg%d=%p\n", Index, Object)); 24874912Sjhb 24974912Sjhb /* Remove first */ 25075464Sjhb 25175464Sjhb WalkState->Arguments[Index].Object = NULL; 25275464Sjhb 25384331Sjhb /* Was given a ref when stored */ 25484331Sjhb 25584331Sjhb AcpiUtRemoveReference (Object); 25674912Sjhb } 25772224Sjhb } 25884331Sjhb 25974912Sjhb return_ACPI_STATUS (AE_OK); 26072224Sjhb} 26174912Sjhb 26272224Sjhb 263103091Sjake/******************************************************************************* 264109015Sjake * 26574912Sjhb * FUNCTION: AcpiDsMethodDataInitArgs 26674912Sjhb * 26774912Sjhb * PARAMETERS: *Params - Pointer to a parameter list for the method 26874912Sjhb * MaxParamCount - The arg count for this method 26974912Sjhb * WalkState - Current walk state object 27065557Sjasone * 27165557Sjasone * RETURN: Status 27265557Sjasone * 27390278Sjhb * DESCRIPTION: Initialize arguments for a method 27499416Salc * 27588322Sjhb ******************************************************************************/ 27672224Sjhb 27774912SjhbACPI_STATUS 27899862SpeterAcpiDsMethodDataInitArgs ( 27999862Speter ACPI_OPERAND_OBJECT **Params, 28072224Sjhb UINT32 MaxParamCount, 281108187Sjake ACPI_WALK_STATE *WalkState) 282108187Sjake{ 28399862Speter ACPI_STATUS Status; 284108187Sjake UINT32 Mindex; 28578785Sjhb UINT32 Pindex; 28695473Sdes 287111028Sjeff 288103786Sjeff FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); 289104951Speter 290104951Speter 291104951Speter if (!Params) 292111068Speter { 293111068Speter DEBUG_PRINTP (TRACE_EXEC, ("No param list passed to method\n")); 294111068Speter return_ACPI_STATUS (AE_OK); 29574912Sjhb } 29674912Sjhb 29765557Sjasone /* Copy passed parameters into the new method stack frame */ 29865557Sjasone 299105508Sphk for (Pindex = Mindex = 0; 30065557Sjasone (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); 30165557Sjasone Mindex++) 30265557Sjasone { 30365557Sjasone if (Params[Pindex]) 30465856Sjhb { 30565557Sjasone /* 30672200Sbmilekic * A valid parameter. 30772200Sbmilekic * Set the current method argument to the 308105508Sphk * Params[Pindex++] argument object descriptor 30965557Sjasone */ 31074912Sjhb Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Mindex, 31174912Sjhb Params[Pindex], WalkState); 31274912Sjhb if (ACPI_FAILURE (Status)) 31397963Sjhb { 31474912Sjhb break; 31574912Sjhb } 31674912Sjhb 31774912Sjhb Pindex++; 31893811Sjhb } 31974912Sjhb 32097963Sjhb else 32174912Sjhb { 32274912Sjhb break; 32374912Sjhb } 32474912Sjhb } 32574912Sjhb 32674912Sjhb DEBUG_PRINTP (TRACE_EXEC, ("%d args passed to method\n", Pindex)); 32774912Sjhb return_ACPI_STATUS (AE_OK); 32874912Sjhb} 32974912Sjhb 33074912Sjhb 33174912Sjhb/******************************************************************************* 33274912Sjhb * 33374912Sjhb * FUNCTION: AcpiDsMethodDataGetEntry 33474912Sjhb * 33574912Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 33674912Sjhb * Index - Which localVar or argument to get 33774912Sjhb * Entry - Pointer to where a pointer to the stack 33874912Sjhb * entry is returned. 33974912Sjhb * WalkState - Current walk state object 34074912Sjhb * 34171352Sjasone * RETURN: Status 34274912Sjhb * 34365557Sjasone * DESCRIPTION: Get the address of the object entry given by Opcode:Index 34474912Sjhb * 34574912Sjhb ******************************************************************************/ 34674912Sjhb 34774912SjhbACPI_STATUS 34865557SjasoneAcpiDsMethodDataGetEntry ( 34974912Sjhb UINT16 Opcode, 35074912Sjhb UINT32 Index, 35174912Sjhb ACPI_WALK_STATE *WalkState, 35274912Sjhb ACPI_OPERAND_OBJECT ***Entry) 35374912Sjhb{ 35474912Sjhb 35574912Sjhb FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); 35687593Sobrien 35797963Sjhb 35893811Sjhb /* 35993811Sjhb * Get the requested object. 36074912Sjhb * The stack "Opcode" is either a LocalVariable or an Argument 36174912Sjhb */ 36274912Sjhb 36374912Sjhb switch (Opcode) 36474912Sjhb { 36574912Sjhb 36674912Sjhb case AML_LOCAL_OP: 36774912Sjhb 36874912Sjhb if (Index > MTH_MAX_LOCAL) 36974912Sjhb { 37075569Sjhb DEBUG_PRINTP (ACPI_ERROR, ("LocalVar index %d is invalid (max %d)\n", 37175569Sjhb Index, MTH_MAX_LOCAL)); 37274912Sjhb return_ACPI_STATUS (AE_BAD_PARAMETER); 37374912Sjhb } 37474912Sjhb 37575569Sjhb *Entry = (ACPI_OPERAND_OBJECT **) 37675569Sjhb &WalkState->LocalVariables[Index].Object; 37774912Sjhb break; 37874912Sjhb 37974912Sjhb 38065557Sjasone case AML_ARG_OP: 38165557Sjasone 38265557Sjasone if (Index > MTH_MAX_ARG) 38374912Sjhb { 38474912Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Arg index %d is invalid (max %d)\n", 38597963Sjhb Index, MTH_MAX_ARG)); 38674912Sjhb return_ACPI_STATUS (AE_BAD_PARAMETER); 38793811Sjhb } 38874912Sjhb 38974912Sjhb *Entry = (ACPI_OPERAND_OBJECT **) 39074912Sjhb &WalkState->Arguments[Index].Object; 39174912Sjhb break; 39274912Sjhb 39374912Sjhb 39474912Sjhb default: 39574912Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Opcode %d is invalid\n", Opcode)); 39674912Sjhb return_ACPI_STATUS (AE_BAD_PARAMETER); 39774912Sjhb } 39865557Sjasone 39974912Sjhb 40065557Sjasone return_ACPI_STATUS (AE_OK); 40174912Sjhb} 40274912Sjhb 40374912Sjhb 40474912Sjhb/******************************************************************************* 40574912Sjhb * 40674912Sjhb * FUNCTION: AcpiDsMethodDataSetEntry 40774912Sjhb * 40882284Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 40974912Sjhb * Index - Which localVar or argument to get 41074912Sjhb * Object - Object to be inserted into the stack entry 41174912Sjhb * WalkState - Current walk state object 41282284Sjhb * 41374912Sjhb * RETURN: Status 41474912Sjhb * 41574912Sjhb * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. 41682284Sjhb * 41774912Sjhb ******************************************************************************/ 41882244Sjhb 41982244SjhbACPI_STATUS 42082284SjhbAcpiDsMethodDataSetEntry ( 42182244Sjhb UINT16 Opcode, 42282244Sjhb UINT32 Index, 42374912Sjhb ACPI_OPERAND_OBJECT *Object, 42497963Sjhb ACPI_WALK_STATE *WalkState) 42574912Sjhb{ 42674912Sjhb ACPI_STATUS Status; 42774912Sjhb ACPI_OPERAND_OBJECT **Entry; 42874912Sjhb 42974912Sjhb 43080747Sjhb FUNCTION_TRACE ("DsMethodDataSetEntry"); 43174912Sjhb 43293811Sjhb /* Get a pointer to the stack entry to set */ 43374912Sjhb 43474912Sjhb Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); 43574912Sjhb if (ACPI_FAILURE (Status)) 43674912Sjhb { 43774912Sjhb return_ACPI_STATUS (Status); 43874912Sjhb } 43974912Sjhb 44075362Sjhb /* Increment ref count so object can't be deleted while installed */ 44174912Sjhb 44274912Sjhb AcpiUtAddReference (Object); 44374912Sjhb 44474912Sjhb /* Install the object into the stack entry */ 44574912Sjhb 44682284Sjhb *Entry = Object; 44774912Sjhb 44874912Sjhb return_ACPI_STATUS (AE_OK); 44976272Sjhb} 45075362Sjhb 45175362Sjhb 45275362Sjhb/******************************************************************************* 45397948Sjhb * 45475362Sjhb * FUNCTION: AcpiDsMethodDataGetType 45575362Sjhb * 45675362Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 45775362Sjhb * Index - Which localVar or argument whose type 45874912Sjhb * to get 45974912Sjhb * WalkState - Current walk state object 46097963Sjhb * 46180055Sjhb * RETURN: Data type of selected Arg or Local 46274912Sjhb * Used only in ExecMonadic2()/TypeOp. 46374912Sjhb * 46474912Sjhb ******************************************************************************/ 465100011Smp 46671352SjasoneACPI_OBJECT_TYPE8 46774912SjhbAcpiDsMethodDataGetType ( 46874912Sjhb UINT16 Opcode, 46971352Sjasone UINT32 Index, 47071352Sjasone ACPI_WALK_STATE *WalkState) 47174912Sjhb{ 47271352Sjasone ACPI_STATUS Status; 47374912Sjhb ACPI_OPERAND_OBJECT **Entry; 47474912Sjhb ACPI_OPERAND_OBJECT *Object; 47571352Sjasone 47674912Sjhb 47774912Sjhb FUNCTION_TRACE ("DsMethodDataGetType"); 47874912Sjhb 47974912Sjhb 48071352Sjasone /* Get a pointer to the requested stack entry */ 48174912Sjhb 48271352Sjasone Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); 48374912Sjhb if (ACPI_FAILURE (Status)) 48471352Sjasone { 48571352Sjasone return_VALUE ((ACPI_TYPE_NOT_FOUND)); 48671352Sjasone } 48771352Sjasone 48871352Sjasone /* Get the object from the method stack */ 48971352Sjasone 49074912Sjhb Object = *Entry; 49172224Sjhb 49274912Sjhb /* Get the object type */ 49374912Sjhb 49474912Sjhb if (!Object) 49574912Sjhb { 49674912Sjhb /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ 49782284Sjhb return_VALUE (ACPI_TYPE_ANY); 49874912Sjhb } 49974912Sjhb 50072224Sjhb return_VALUE (Object->Common.Type); 50174930Sjhb} 50274912Sjhb 50374912Sjhb 50474912Sjhb/******************************************************************************* 50574912Sjhb * 50674912Sjhb * FUNCTION: AcpiDsMethodDataGetNode 50774912Sjhb * 50874930Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 50972224Sjhb * Index - Which localVar or argument whose type 51074912Sjhb * to get 51174912Sjhb * WalkState - Current walk state object 51272224Sjhb * 51372224Sjhb * RETURN: Get the Node associated with a local or arg. 51474930Sjhb * 51572224Sjhb ******************************************************************************/ 51674912Sjhb 51774912SjhbACPI_NAMESPACE_NODE * 51897948SjhbAcpiDsMethodDataGetNode ( 51971352Sjasone UINT16 Opcode, 52074912Sjhb UINT32 Index, 52171352Sjasone ACPI_WALK_STATE *WalkState) 52271352Sjasone{ 523100011Smp ACPI_NAMESPACE_NODE *Node = NULL; 52471352Sjasone 52565557Sjasone 52674912Sjhb FUNCTION_TRACE ("DsMethodDataGetNode"); 52765557Sjasone 52874912Sjhb 52976272Sjhb switch (Opcode) 53074912Sjhb { 53165856Sjhb 53283366Sjulian case AML_LOCAL_OP: 53374912Sjhb 53467676Sjhb if (Index > MTH_MAX_LOCAL) 53567676Sjhb { 53667676Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Local index %d is invalid (max %d)\n", 53765557Sjasone Index, MTH_MAX_LOCAL)); 53874912Sjhb return_PTR (Node); 53980747Sjhb } 54071320Sjasone 54174912Sjhb Node = &WalkState->LocalVariables[Index]; 54274912Sjhb break; 54383366Sjulian 54465557Sjasone 54574912Sjhb case AML_ARG_OP: 54693676Sjhb 54793676Sjhb if (Index > MTH_MAX_ARG) 54893676Sjhb { 54993676Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Arg index %d is invalid (max %d)\n", 55093676Sjhb Index, MTH_MAX_ARG)); 55188899Sjhb return_PTR (Node); 55274912Sjhb } 55374912Sjhb 55483366Sjulian Node = &WalkState->Arguments[Index]; 55588899Sjhb break; 55688899Sjhb 55765557Sjasone 55876772Sjhb default: 55976772Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Opcode %d is invalid\n", Opcode)); 56076772Sjhb break; 56176772Sjhb } 56276772Sjhb 56374912Sjhb 56465557Sjasone return_PTR (Node); 56565557Sjasone} 56665557Sjasone 56774912Sjhb 56874912Sjhb/******************************************************************************* 56965557Sjasone * 57074912Sjhb * FUNCTION: AcpiDsMethodDataGetValue 57165557Sjasone * 57265557Sjasone * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 57374912Sjhb * Index - Which localVar or argument to get 57476272Sjhb * WalkState - Current walk state object 57576272Sjhb * *DestDesc - Ptr to Descriptor into which selected Arg 57676272Sjhb * or Local value should be copied 57776272Sjhb * 57876272Sjhb * RETURN: Status 57976272Sjhb * 58076272Sjhb * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame 58176272Sjhb * at the current top of the method stack. 58276272Sjhb * Used only in AcpiExResolveToValue(). 58376272Sjhb * 58476272Sjhb ******************************************************************************/ 58576272Sjhb 58676272SjhbACPI_STATUS 58776272SjhbAcpiDsMethodDataGetValue ( 58876272Sjhb UINT16 Opcode, 58976272Sjhb UINT32 Index, 59076272Sjhb ACPI_WALK_STATE *WalkState, 59176272Sjhb ACPI_OPERAND_OBJECT **DestDesc) 59276272Sjhb{ 59376272Sjhb ACPI_STATUS Status; 59476272Sjhb ACPI_OPERAND_OBJECT **Entry; 59576272Sjhb ACPI_OPERAND_OBJECT *Object; 59676272Sjhb 59776272Sjhb 59876272Sjhb FUNCTION_TRACE ("DsMethodDataGetValue"); 59976272Sjhb 60076272Sjhb 60176272Sjhb /* Validate the object descriptor */ 60276272Sjhb 60387593Sobrien if (!DestDesc) 60484680Sjhb { 60578785Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Null object descriptor pointer\n")); 60676272Sjhb return_ACPI_STATUS (AE_BAD_PARAMETER); 60776272Sjhb } 60876272Sjhb 60976272Sjhb 61076272Sjhb /* Get a pointer to the requested method stack entry */ 61176272Sjhb 61274912Sjhb Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); 61374912Sjhb if (ACPI_FAILURE (Status)) 61474912Sjhb { 61574912Sjhb return_ACPI_STATUS (Status); 61676272Sjhb } 61776272Sjhb 61874912Sjhb /* Get the object from the method stack */ 61993273Sjeff 62065557Sjasone Object = *Entry; 62165557Sjasone 62275755Sjhb 62393811Sjhb /* Examine the returned object, it must be valid. */ 62493811Sjhb 62593811Sjhb if (!Object) 62693811Sjhb { 62767676Sjhb /* 62867676Sjhb * Index points to uninitialized object stack value. 62967676Sjhb * This means that either 1) The expected argument was 63065557Sjasone * not passed to the method, or 2) A local variable 63165557Sjasone * was referenced by the method (via the ASL) 63265557Sjasone * before it was initialized. Either case is an error. 63374912Sjhb */ 63465557Sjasone 63565557Sjasone switch (Opcode) 63665557Sjasone { 63765557Sjasone case AML_ARG_OP: 63874912Sjhb 63965557Sjasone DEBUG_PRINTP (ACPI_ERROR, ("Uninitialized Arg[%d] at entry %p\n", 64065557Sjasone Index, Entry)); 641111881Sjhb 642111881Sjhb return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 643111881Sjhb break; 644111881Sjhb 645111881Sjhb case AML_LOCAL_OP: 64674912Sjhb 64774912Sjhb DEBUG_PRINTP (ACPI_ERROR, ("Uninitialized Local[%d] at entry %p\n", 64865557Sjasone Index, Entry)); 64965557Sjasone 65074912Sjhb return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 65174912Sjhb break; 65265557Sjasone } 65374912Sjhb } 65476272Sjhb 65576272Sjhb 65674912Sjhb /* 65774912Sjhb * Index points to initialized and valid object stack value. 65874912Sjhb * Return an additional reference to the object 65974912Sjhb */ 66074912Sjhb 66174912Sjhb *DestDesc = Object; 66276272Sjhb AcpiUtAddReference (Object); 66374912Sjhb 66474912Sjhb return_ACPI_STATUS (AE_OK); 66574912Sjhb} 66676272Sjhb 667111881Sjhb 66876272Sjhb/******************************************************************************* 66976272Sjhb * 670111881Sjhb * FUNCTION: AcpiDsMethodDataDeleteValue 67176272Sjhb * 67276272Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 67393690Sjhb * Index - Which localVar or argument to delete 67493690Sjhb * WalkState - Current walk state object 675111881Sjhb * 67693690Sjhb * RETURN: Status 677111881Sjhb * 678111887Sjhb * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts 679111881Sjhb * a null into the stack slot after the object is deleted. 680111881Sjhb * 681111881Sjhb ******************************************************************************/ 682111881Sjhb 683111881SjhbACPI_STATUS 684111881SjhbAcpiDsMethodDataDeleteValue ( 685111881Sjhb UINT16 Opcode, 68693690Sjhb UINT32 Index, 687111881Sjhb ACPI_WALK_STATE *WalkState) 688111881Sjhb{ 689111881Sjhb ACPI_STATUS Status; 690111881Sjhb ACPI_OPERAND_OBJECT **Entry; 691111881Sjhb ACPI_OPERAND_OBJECT *Object; 69274912Sjhb 69374912Sjhb 69474912Sjhb FUNCTION_TRACE ("DsMethodDataDeleteValue"); 69574912Sjhb 69674912Sjhb 69774912Sjhb /* Get a pointer to the requested entry */ 698105508Sphk 69965557Sjasone Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); 70065557Sjasone if (ACPI_FAILURE (Status)) 701105508Sphk { 70276272Sjhb return_ACPI_STATUS (Status); 70365557Sjasone } 70465557Sjasone 70565557Sjasone /* Get the current entry in this slot k */ 70665557Sjasone 70765557Sjasone Object = *Entry; 70865557Sjasone 70965557Sjasone /* 71065557Sjasone * Undefine the Arg or Local by setting its descriptor 71165557Sjasone * pointer to NULL. Locals/Args can contain both 71265557Sjasone * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs 71374912Sjhb */ 71474912Sjhb *Entry = NULL; 71574912Sjhb 71665557Sjasone 71774912Sjhb if ((Object) && 71874912Sjhb (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) 71974912Sjhb { 72074912Sjhb /* 72174912Sjhb * There is a valid object in this slot 72276272Sjhb * Decrement the reference count by one to balance the 72376272Sjhb * increment when the object was stored in the slot. 72476272Sjhb */ 72574912Sjhb AcpiUtRemoveReference (Object); 72674912Sjhb } 72774912Sjhb 72874912Sjhb 72974912Sjhb return_ACPI_STATUS (AE_OK); 730106781Sjhb} 73174912Sjhb 73274912Sjhb 73376272Sjhb/******************************************************************************* 73493811Sjhb * 73593811Sjhb * FUNCTION: AcpiDsStoreObjectToLocal 73693811Sjhb * 73776272Sjhb * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 73893811Sjhb * Index - Which localVar or argument to set 73993811Sjhb * SrcDesc - Value to be stored 74076272Sjhb * WalkState - Current walk state 74193811Sjhb * 74293811Sjhb * RETURN: Status 74393811Sjhb * 74476272Sjhb * DESCRIPTION: Store a value in an Arg or Local. The SrcDesc is installed 74593811Sjhb * as the new value for the Arg or Local and the reference count 74693811Sjhb * for SrcDesc is incremented. 74793811Sjhb * 74876272Sjhb ******************************************************************************/ 74993811Sjhb 75093811SjhbACPI_STATUS 75176272SjhbAcpiDsStoreObjectToLocal ( 75267676Sjhb UINT16 Opcode, 75367676Sjhb UINT32 Index, 75467676Sjhb ACPI_OPERAND_OBJECT *SrcDesc, 75565557Sjasone ACPI_WALK_STATE *WalkState) 75665557Sjasone{ 75765557Sjasone ACPI_STATUS Status; 75876272Sjhb ACPI_OPERAND_OBJECT **Entry; 75978871Sjhb 760111881Sjhb 761111881Sjhb FUNCTION_TRACE ("DsMethodDataSetValue"); 762111881Sjhb DEBUG_PRINTP (TRACE_EXEC, ("Opcode=%d Idx=%d Obj=%p\n", 76378871Sjhb Opcode, Index, SrcDesc)); 764111881Sjhb 765111881Sjhb 76674912Sjhb /* Parameter validation */ 76778871Sjhb 76887593Sobrien if (!SrcDesc) 76993811Sjhb { 77078871Sjhb return_ACPI_STATUS (AE_BAD_PARAMETER); 77178871Sjhb } 77278871Sjhb 77365557Sjasone 77465557Sjasone /* Get a pointer to the requested method stack entry */ 77567676Sjhb 776110779Speter Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); 777110779Speter if (ACPI_FAILURE (Status)) 778110779Speter { 779110779Speter goto Cleanup; 780110779Speter } 781110779Speter 78267676Sjhb if (*Entry == SrcDesc) 78365557Sjasone { 78465557Sjasone DEBUG_PRINTP (TRACE_EXEC, ("Obj=%p already installed!\n", SrcDesc)); 78574912Sjhb goto Cleanup; 78674912Sjhb } 78776272Sjhb 78878785Sjhb 78978785Sjhb /* 79065557Sjasone * If there is an object already in this slot, we either 79178785Sjhb * have to delete it, or if this is an argument and there 79287593Sobrien * is an object reference stored there, we have to do 79384680Sjhb * an indirect store! 79478785Sjhb */ 79565557Sjasone 79676272Sjhb if (*Entry) 79776272Sjhb { 79876272Sjhb /* 79976272Sjhb * Check for an indirect store if an argument 80076272Sjhb * contains an object reference (stored as an Node). 80176272Sjhb * We don't allow this automatic dereferencing for 80276272Sjhb * locals, since a store to a local should overwrite 80376272Sjhb * anything there, including an object reference. 80487593Sobrien * 80584680Sjhb * If both Arg0 and Local0 contain RefOf (Local4): 80665557Sjasone * 80765557Sjasone * Store (1, Arg0) - Causes indirect store to local4 80865557Sjasone * Store (1, Local0) - Stores 1 in local0, overwriting 80982244Sjhb * the reference to local4 81082244Sjhb * Store (1, DeRefof (Local0)) - Causes indirect store to local4 81182244Sjhb * 81282244Sjhb * Weird, but true. 81382244Sjhb */ 81482284Sjhb 81582244Sjhb if ((Opcode == AML_ARG_OP) && 81682244Sjhb (VALID_DESCRIPTOR_TYPE (*Entry, ACPI_DESC_TYPE_NAMED))) 81782244Sjhb { 81882244Sjhb DEBUG_PRINTP (TRACE_EXEC, 81982244Sjhb ("Arg (%p) is an ObjRef(Node), storing in %p\n", 82082244Sjhb SrcDesc, *Entry)); 82182244Sjhb 82282244Sjhb /* Detach an existing object from the Node */ 82382244Sjhb 82482244Sjhb AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) *Entry); 82582244Sjhb 82682244Sjhb /* 82783366Sjulian * Store this object into the Node 82882244Sjhb * (do the indirect store) 82982244Sjhb */ 83082244Sjhb Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) *Entry, SrcDesc, 83182244Sjhb SrcDesc->Common.Type); 83282244Sjhb return_ACPI_STATUS (Status); 83382244Sjhb } 83482244Sjhb 83582244Sjhb 83682244Sjhb#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION 83782244Sjhb /* 83882244Sjhb * Perform "Implicit conversion" of the new object to the type of the 83982244Sjhb * existing object 84082244Sjhb */ 84182244Sjhb Status = AcpiExConvertToTargetType ((*Entry)->Common.Type, &SrcDesc, WalkState); 84282244Sjhb if (ACPI_FAILURE (Status)) 84382244Sjhb { 84482244Sjhb goto Cleanup; 84582244Sjhb } 84682244Sjhb#endif 84782244Sjhb 84882284Sjhb /* 84982244Sjhb * Delete the existing object 85082244Sjhb * before storing the new one 85182244Sjhb */ 85282244Sjhb AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); 85382244Sjhb } 85482244Sjhb 85582244Sjhb 85682244Sjhb /* 85782244Sjhb * Install the ObjStack descriptor (*SrcDesc) into 85883366Sjulian * the descriptor for the Arg or Local. 85982244Sjhb * Install the new object in the stack entry 86082244Sjhb * (increments the object reference count by one) 86182244Sjhb */ 86282244Sjhb Status = AcpiDsMethodDataSetEntry (Opcode, Index, SrcDesc, WalkState); 86382244Sjhb if (ACPI_FAILURE (Status)) 86482244Sjhb { 86582244Sjhb goto Cleanup; 86682244Sjhb } 86782244Sjhb 86882244Sjhb /* Normal exit */ 86982244Sjhb 87082244Sjhb return_ACPI_STATUS (AE_OK); 87182244Sjhb 87282244Sjhb 87374912Sjhb /* Error exit */ 87465557Sjasone 87574912SjhbCleanup: 87676272Sjhb 87774912Sjhb return_ACPI_STATUS (Status); 87883366Sjulian} 87992858Simp 88074912Sjhb