Path: blob/main/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c
48521 views
/*******************************************************************************1*2* Module Name: dsmthdat - control method arguments and local variables3*4******************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acdispat.h>154#include <contrib/dev/acpica/include/acnamesp.h>155#include <contrib/dev/acpica/include/acinterp.h>156157158#define _COMPONENT ACPI_DISPATCHER159ACPI_MODULE_NAME ("dsmthdat")160161/* Local prototypes */162163static void164AcpiDsMethodDataDeleteValue (165UINT8 Type,166UINT32 Index,167ACPI_WALK_STATE *WalkState);168169static ACPI_STATUS170AcpiDsMethodDataSetValue (171UINT8 Type,172UINT32 Index,173ACPI_OPERAND_OBJECT *Object,174ACPI_WALK_STATE *WalkState);175176#ifdef ACPI_OBSOLETE_FUNCTIONS177ACPI_OBJECT_TYPE178AcpiDsMethodDataGetType (179UINT16 Opcode,180UINT32 Index,181ACPI_WALK_STATE *WalkState);182#endif183184185/*******************************************************************************186*187* FUNCTION: AcpiDsMethodDataInit188*189* PARAMETERS: WalkState - Current walk state object190*191* RETURN: Status192*193* DESCRIPTION: Initialize the data structures that hold the method's arguments194* and locals. The data struct is an array of namespace nodes for195* each - this allows RefOf and DeRefOf to work properly for these196* special data types.197*198* NOTES: WalkState fields are initialized to zero by the199* ACPI_ALLOCATE_ZEROED().200*201* A pseudo-Namespace Node is assigned to each argument and local202* so that RefOf() can return a pointer to the Node.203*204******************************************************************************/205206void207AcpiDsMethodDataInit (208ACPI_WALK_STATE *WalkState)209{210UINT32 i;211212213ACPI_FUNCTION_TRACE (DsMethodDataInit);214215216/* Init the method arguments */217218for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)219{220ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name,221NAMEOF_ARG_NTE);222223WalkState->Arguments[i].Name.Integer |= (i << 24);224WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;225WalkState->Arguments[i].Type = ACPI_TYPE_ANY;226WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;227}228229/* Init the method locals */230231for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)232{233ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name,234NAMEOF_LOCAL_NTE);235236WalkState->LocalVariables[i].Name.Integer |= (i << 24);237WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;238WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;239WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;240}241242return_VOID;243}244245246/*******************************************************************************247*248* FUNCTION: AcpiDsMethodDataDeleteAll249*250* PARAMETERS: WalkState - Current walk state object251*252* RETURN: None253*254* DESCRIPTION: Delete method locals and arguments. Arguments are only255* deleted if this method was called from another method.256*257******************************************************************************/258259void260AcpiDsMethodDataDeleteAll (261ACPI_WALK_STATE *WalkState)262{263UINT32 Index;264265266ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);267268269/* Detach the locals */270271for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)272{273if (WalkState->LocalVariables[Index].Object)274{275ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",276Index, WalkState->LocalVariables[Index].Object));277278/* Detach object (if present) and remove a reference */279280AcpiNsDetachObject (&WalkState->LocalVariables[Index]);281}282}283284/* Detach the arguments */285286for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)287{288if (WalkState->Arguments[Index].Object)289{290ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",291Index, WalkState->Arguments[Index].Object));292293/* Detach object (if present) and remove a reference */294295AcpiNsDetachObject (&WalkState->Arguments[Index]);296}297}298299return_VOID;300}301302303/*******************************************************************************304*305* FUNCTION: AcpiDsMethodDataInitArgs306*307* PARAMETERS: *Params - Pointer to a parameter list for the method308* MaxParamCount - The arg count for this method309* WalkState - Current walk state object310*311* RETURN: Status312*313* DESCRIPTION: Initialize arguments for a method. The parameter list is a list314* of ACPI operand objects, either null terminated or whose length315* is defined by MaxParamCount.316*317******************************************************************************/318319ACPI_STATUS320AcpiDsMethodDataInitArgs (321ACPI_OPERAND_OBJECT **Params,322UINT32 MaxParamCount,323ACPI_WALK_STATE *WalkState)324{325ACPI_STATUS Status;326UINT32 Index = 0;327328329ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);330331332if (!Params)333{334ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,335"No parameter list passed to method\n"));336return_ACPI_STATUS (AE_OK);337}338339/* Copy passed parameters into the new method stack frame */340341while ((Index < ACPI_METHOD_NUM_ARGS) &&342(Index < MaxParamCount) &&343Params[Index])344{345/*346* A valid parameter.347* Store the argument in the method/walk descriptor.348* Do not copy the arg in order to implement call by reference349*/350Status = AcpiDsMethodDataSetValue (351ACPI_REFCLASS_ARG, Index, Params[Index], WalkState);352if (ACPI_FAILURE (Status))353{354return_ACPI_STATUS (Status);355}356357Index++;358}359AcpiExTraceArgs(Params, Index);360361ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));362return_ACPI_STATUS (AE_OK);363}364365366/*******************************************************************************367*368* FUNCTION: AcpiDsMethodDataGetNode369*370* PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or371* ACPI_REFCLASS_ARG372* Index - Which Local or Arg whose type to get373* WalkState - Current walk state object374* Node - Where the node is returned.375*376* RETURN: Status and node377*378* DESCRIPTION: Get the Node associated with a local or arg.379*380******************************************************************************/381382ACPI_STATUS383AcpiDsMethodDataGetNode (384UINT8 Type,385UINT32 Index,386ACPI_WALK_STATE *WalkState,387ACPI_NAMESPACE_NODE **Node)388{389ACPI_FUNCTION_TRACE (DsMethodDataGetNode);390391392/*393* Method Locals and Arguments are supported394*/395switch (Type)396{397case ACPI_REFCLASS_LOCAL:398399if (Index > ACPI_METHOD_MAX_LOCAL)400{401ACPI_ERROR ((AE_INFO,402"Local index %u is invalid (max %u)",403Index, ACPI_METHOD_MAX_LOCAL));404return_ACPI_STATUS (AE_AML_INVALID_INDEX);405}406407/* Return a pointer to the pseudo-node */408409*Node = &WalkState->LocalVariables[Index];410break;411412case ACPI_REFCLASS_ARG:413414if (Index > ACPI_METHOD_MAX_ARG)415{416ACPI_ERROR ((AE_INFO,417"Arg index %u is invalid (max %u)",418Index, ACPI_METHOD_MAX_ARG));419return_ACPI_STATUS (AE_AML_INVALID_INDEX);420}421422/* Return a pointer to the pseudo-node */423424*Node = &WalkState->Arguments[Index];425break;426427default:428429ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));430return_ACPI_STATUS (AE_TYPE);431}432433return_ACPI_STATUS (AE_OK);434}435436437/*******************************************************************************438*439* FUNCTION: AcpiDsMethodDataSetValue440*441* PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or442* ACPI_REFCLASS_ARG443* Index - Which Local or Arg to get444* Object - Object to be inserted into the stack entry445* WalkState - Current walk state object446*447* RETURN: Status448*449* DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.450* Note: There is no "implicit conversion" for locals.451*452******************************************************************************/453454static ACPI_STATUS455AcpiDsMethodDataSetValue (456UINT8 Type,457UINT32 Index,458ACPI_OPERAND_OBJECT *Object,459ACPI_WALK_STATE *WalkState)460{461ACPI_STATUS Status;462ACPI_NAMESPACE_NODE *Node;463464465ACPI_FUNCTION_TRACE (DsMethodDataSetValue);466467468ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,469"NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,470Type, Object->Common.ReferenceCount,471AcpiUtGetTypeName (Object->Common.Type)));472473/* Get the namespace node for the arg/local */474475Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);476if (ACPI_FAILURE (Status))477{478return_ACPI_STATUS (Status);479}480481/*482* Increment ref count so object can't be deleted while installed.483* NOTE: We do not copy the object in order to preserve the call by484* reference semantics of ACPI Control Method invocation.485* (See ACPI Specification 2.0C)486*/487AcpiUtAddReference (Object);488489/* Install the object */490491Node->Object = Object;492return_ACPI_STATUS (Status);493}494495496/*******************************************************************************497*498* FUNCTION: AcpiDsMethodDataGetValue499*500* PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or501* ACPI_REFCLASS_ARG502* Index - Which localVar or argument to get503* WalkState - Current walk state object504* DestDesc - Where Arg or Local value is returned505*506* RETURN: Status507*508* DESCRIPTION: Retrieve value of selected Arg or Local for this method509* Used only in AcpiExResolveToValue().510*511******************************************************************************/512513ACPI_STATUS514AcpiDsMethodDataGetValue (515UINT8 Type,516UINT32 Index,517ACPI_WALK_STATE *WalkState,518ACPI_OPERAND_OBJECT **DestDesc)519{520ACPI_STATUS Status;521ACPI_NAMESPACE_NODE *Node;522ACPI_OPERAND_OBJECT *Object;523524525ACPI_FUNCTION_TRACE (DsMethodDataGetValue);526527528/* Validate the object descriptor */529530if (!DestDesc)531{532ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));533return_ACPI_STATUS (AE_BAD_PARAMETER);534}535536/* Get the namespace node for the arg/local */537538Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);539if (ACPI_FAILURE (Status))540{541return_ACPI_STATUS (Status);542}543544/* Get the object from the node */545546Object = Node->Object;547548/* Examine the returned object, it must be valid. */549550if (!Object)551{552/*553* Index points to uninitialized object.554* This means that either 1) The expected argument was555* not passed to the method, or 2) A local variable556* was referenced by the method (via the ASL)557* before it was initialized. Either case is an error.558*/559560/* If slack enabled, init the LocalX/ArgX to an Integer of value zero */561562if (AcpiGbl_EnableInterpreterSlack)563{564Object = AcpiUtCreateIntegerObject ((UINT64) 0);565if (!Object)566{567return_ACPI_STATUS (AE_NO_MEMORY);568}569570Node->Object = Object;571}572573/* Otherwise, return the error */574575else switch (Type)576{577case ACPI_REFCLASS_ARG:578579ACPI_ERROR ((AE_INFO,580"Uninitialized Arg[%u] at node %p",581Index, Node));582583return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);584585case ACPI_REFCLASS_LOCAL:586/*587* No error message for this case, will be trapped again later to588* detect and ignore cases of Store(LocalX,LocalX)589*/590return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);591592default:593594ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));595return_ACPI_STATUS (AE_AML_INTERNAL);596}597}598599/*600* The Index points to an initialized and valid object.601* Return an additional reference to the object602*/603*DestDesc = Object;604AcpiUtAddReference (Object);605606return_ACPI_STATUS (AE_OK);607}608609610/*******************************************************************************611*612* FUNCTION: AcpiDsMethodDataDeleteValue613*614* PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or615* ACPI_REFCLASS_ARG616* Index - Which localVar or argument to delete617* WalkState - Current walk state object618*619* RETURN: None620*621* DESCRIPTION: Delete the entry at Opcode:Index. Inserts622* a null into the stack slot after the object is deleted.623*624******************************************************************************/625626static void627AcpiDsMethodDataDeleteValue (628UINT8 Type,629UINT32 Index,630ACPI_WALK_STATE *WalkState)631{632ACPI_STATUS Status;633ACPI_NAMESPACE_NODE *Node;634ACPI_OPERAND_OBJECT *Object;635636637ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);638639640/* Get the namespace node for the arg/local */641642Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);643if (ACPI_FAILURE (Status))644{645return_VOID;646}647648/* Get the associated object */649650Object = AcpiNsGetAttachedObject (Node);651652/*653* Undefine the Arg or Local by setting its descriptor654* pointer to NULL. Locals/Args can contain both655* ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs656*/657Node->Object = NULL;658659if ((Object) &&660(ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))661{662/*663* There is a valid object.664* Decrement the reference count by one to balance the665* increment when the object was stored.666*/667AcpiUtRemoveReference (Object);668}669670return_VOID;671}672673674/*******************************************************************************675*676* FUNCTION: AcpiDsStoreObjectToLocal677*678* PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or679* ACPI_REFCLASS_ARG680* Index - Which Local or Arg to set681* ObjDesc - Value to be stored682* WalkState - Current walk state683*684* RETURN: Status685*686* DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed687* as the new value for the Arg or Local and the reference count688* for ObjDesc is incremented.689*690******************************************************************************/691692ACPI_STATUS693AcpiDsStoreObjectToLocal (694UINT8 Type,695UINT32 Index,696ACPI_OPERAND_OBJECT *ObjDesc,697ACPI_WALK_STATE *WalkState)698{699ACPI_STATUS Status;700ACPI_NAMESPACE_NODE *Node;701ACPI_OPERAND_OBJECT *CurrentObjDesc;702ACPI_OPERAND_OBJECT *NewObjDesc;703704705ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);706ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",707Type, Index, ObjDesc));708709/* Parameter validation */710711if (!ObjDesc)712{713return_ACPI_STATUS (AE_BAD_PARAMETER);714}715716/* Get the namespace node for the arg/local */717718Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);719if (ACPI_FAILURE (Status))720{721return_ACPI_STATUS (Status);722}723724CurrentObjDesc = AcpiNsGetAttachedObject (Node);725if (CurrentObjDesc == ObjDesc)726{727ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",728ObjDesc));729return_ACPI_STATUS (Status);730}731732/*733* If the reference count on the object is more than one, we must734* take a copy of the object before we store. A reference count735* of exactly 1 means that the object was just created during the736* evaluation of an expression, and we can safely use it since it737* is not used anywhere else.738*/739NewObjDesc = ObjDesc;740if (ObjDesc->Common.ReferenceCount > 1)741{742Status = AcpiUtCopyIobjectToIobject (743ObjDesc, &NewObjDesc, WalkState);744if (ACPI_FAILURE (Status))745{746return_ACPI_STATUS (Status);747}748}749750/*751* If there is an object already in this slot, we either752* have to delete it, or if this is an argument and there753* is an object reference stored there, we have to do754* an indirect store!755*/756if (CurrentObjDesc)757{758/*759* Check for an indirect store if an argument760* contains an object reference (stored as an Node).761* We don't allow this automatic dereferencing for762* locals, since a store to a local should overwrite763* anything there, including an object reference.764*765* If both Arg0 and Local0 contain RefOf (Local4):766*767* Store (1, Arg0) - Causes indirect store to local4768* Store (1, Local0) - Stores 1 in local0, overwriting769* the reference to local4770* Store (1, DeRefof (Local0)) - Causes indirect store to local4771*772* Weird, but true.773*/774if (Type == ACPI_REFCLASS_ARG)775{776/*777* If we have a valid reference object that came from RefOf(),778* do the indirect store779*/780if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) ==781ACPI_DESC_TYPE_OPERAND) &&782(CurrentObjDesc->Common.Type ==783ACPI_TYPE_LOCAL_REFERENCE) &&784(CurrentObjDesc->Reference.Class ==785ACPI_REFCLASS_REFOF))786{787ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,788"Arg (%p) is an ObjRef(Node), storing in node %p\n",789NewObjDesc, CurrentObjDesc));790791/*792* Store this object to the Node (perform the indirect store)793* NOTE: No implicit conversion is performed, as per the ACPI794* specification rules on storing to Locals/Args.795*/796Status = AcpiExStoreObjectToNode (NewObjDesc,797CurrentObjDesc->Reference.Object, WalkState,798ACPI_NO_IMPLICIT_CONVERSION);799800/* Remove local reference if we copied the object above */801802if (NewObjDesc != ObjDesc)803{804AcpiUtRemoveReference (NewObjDesc);805}806807return_ACPI_STATUS (Status);808}809}810811/* Delete the existing object before storing the new one */812813AcpiDsMethodDataDeleteValue (Type, Index, WalkState);814}815816/*817* Install the Obj descriptor (*NewObjDesc) into818* the descriptor for the Arg or Local.819* (increments the object reference count by one)820*/821Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);822823/* Remove local reference if we copied the object above */824825if (NewObjDesc != ObjDesc)826{827AcpiUtRemoveReference (NewObjDesc);828}829830return_ACPI_STATUS (Status);831}832833834#ifdef ACPI_OBSOLETE_FUNCTIONS835/*******************************************************************************836*837* FUNCTION: AcpiDsMethodDataGetType838*839* PARAMETERS: Opcode - Either AML_FIRST LOCAL_OP or840* AML_FIRST_ARG_OP841* Index - Which Local or Arg whose type to get842* WalkState - Current walk state object843*844* RETURN: Data type of current value of the selected Arg or Local845*846* DESCRIPTION: Get the type of the object stored in the Local or Arg847*848******************************************************************************/849850ACPI_OBJECT_TYPE851AcpiDsMethodDataGetType (852UINT16 Opcode,853UINT32 Index,854ACPI_WALK_STATE *WalkState)855{856ACPI_STATUS Status;857ACPI_NAMESPACE_NODE *Node;858ACPI_OPERAND_OBJECT *Object;859860861ACPI_FUNCTION_TRACE (DsMethodDataGetType);862863864/* Get the namespace node for the arg/local */865866Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);867if (ACPI_FAILURE (Status))868{869return_VALUE ((ACPI_TYPE_NOT_FOUND));870}871872/* Get the object */873874Object = AcpiNsGetAttachedObject (Node);875if (!Object)876{877/* Uninitialized local/arg, return TYPE_ANY */878879return_VALUE (ACPI_TYPE_ANY);880}881882/* Get the object type */883884return_VALUE (Object->Type);885}886#endif887888889