Sync ACPICA with Intel's version 20180508 (from previously 20170831).
[dragonfly.git] / sys / contrib / dev / acpica / source / components / dispatcher / dsmthdat.c
blob044646d424d82f6578a0660dd639f9952c531858
1 /*******************************************************************************
3 * Module Name: dsmthdat - control method arguments and local variables
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acdispat.h"
155 #include "acnamesp.h"
156 #include "acinterp.h"
159 #define _COMPONENT ACPI_DISPATCHER
160 ACPI_MODULE_NAME ("dsmthdat")
162 /* Local prototypes */
164 static void
165 AcpiDsMethodDataDeleteValue (
166 UINT8 Type,
167 UINT32 Index,
168 ACPI_WALK_STATE *WalkState);
170 static ACPI_STATUS
171 AcpiDsMethodDataSetValue (
172 UINT8 Type,
173 UINT32 Index,
174 ACPI_OPERAND_OBJECT *Object,
175 ACPI_WALK_STATE *WalkState);
177 #ifdef ACPI_OBSOLETE_FUNCTIONS
178 ACPI_OBJECT_TYPE
179 AcpiDsMethodDataGetType (
180 UINT16 Opcode,
181 UINT32 Index,
182 ACPI_WALK_STATE *WalkState);
183 #endif
186 /*******************************************************************************
188 * FUNCTION: AcpiDsMethodDataInit
190 * PARAMETERS: WalkState - Current walk state object
192 * RETURN: Status
194 * DESCRIPTION: Initialize the data structures that hold the method's arguments
195 * and locals. The data struct is an array of namespace nodes for
196 * each - this allows RefOf and DeRefOf to work properly for these
197 * special data types.
199 * NOTES: WalkState fields are initialized to zero by the
200 * ACPI_ALLOCATE_ZEROED().
202 * A pseudo-Namespace Node is assigned to each argument and local
203 * so that RefOf() can return a pointer to the Node.
205 ******************************************************************************/
207 void
208 AcpiDsMethodDataInit (
209 ACPI_WALK_STATE *WalkState)
211 UINT32 i;
214 ACPI_FUNCTION_TRACE (DsMethodDataInit);
217 /* Init the method arguments */
219 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
221 ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name,
222 NAMEOF_ARG_NTE);
224 WalkState->Arguments[i].Name.Integer |= (i << 24);
225 WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
226 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
227 WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
230 /* Init the method locals */
232 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
234 ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name,
235 NAMEOF_LOCAL_NTE);
237 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
238 WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
239 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
240 WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
243 return_VOID;
247 /*******************************************************************************
249 * FUNCTION: AcpiDsMethodDataDeleteAll
251 * PARAMETERS: WalkState - Current walk state object
253 * RETURN: None
255 * DESCRIPTION: Delete method locals and arguments. Arguments are only
256 * deleted if this method was called from another method.
258 ******************************************************************************/
260 void
261 AcpiDsMethodDataDeleteAll (
262 ACPI_WALK_STATE *WalkState)
264 UINT32 Index;
267 ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
270 /* Detach the locals */
272 for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
274 if (WalkState->LocalVariables[Index].Object)
276 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
277 Index, WalkState->LocalVariables[Index].Object));
279 /* Detach object (if present) and remove a reference */
281 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
285 /* Detach the arguments */
287 for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
289 if (WalkState->Arguments[Index].Object)
291 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
292 Index, WalkState->Arguments[Index].Object));
294 /* Detach object (if present) and remove a reference */
296 AcpiNsDetachObject (&WalkState->Arguments[Index]);
300 return_VOID;
304 /*******************************************************************************
306 * FUNCTION: AcpiDsMethodDataInitArgs
308 * PARAMETERS: *Params - Pointer to a parameter list for the method
309 * MaxParamCount - The arg count for this method
310 * WalkState - Current walk state object
312 * RETURN: Status
314 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
315 * of ACPI operand objects, either null terminated or whose length
316 * is defined by MaxParamCount.
318 ******************************************************************************/
320 ACPI_STATUS
321 AcpiDsMethodDataInitArgs (
322 ACPI_OPERAND_OBJECT **Params,
323 UINT32 MaxParamCount,
324 ACPI_WALK_STATE *WalkState)
326 ACPI_STATUS Status;
327 UINT32 Index = 0;
330 ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
333 if (!Params)
335 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
336 "No parameter list passed to method\n"));
337 return_ACPI_STATUS (AE_OK);
340 /* Copy passed parameters into the new method stack frame */
342 while ((Index < ACPI_METHOD_NUM_ARGS) &&
343 (Index < MaxParamCount) &&
344 Params[Index])
347 * A valid parameter.
348 * Store the argument in the method/walk descriptor.
349 * Do not copy the arg in order to implement call by reference
351 Status = AcpiDsMethodDataSetValue (
352 ACPI_REFCLASS_ARG, Index, Params[Index], WalkState);
353 if (ACPI_FAILURE (Status))
355 return_ACPI_STATUS (Status);
358 Index++;
361 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
362 return_ACPI_STATUS (AE_OK);
366 /*******************************************************************************
368 * FUNCTION: AcpiDsMethodDataGetNode
370 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
371 * ACPI_REFCLASS_ARG
372 * Index - Which Local or Arg whose type to get
373 * WalkState - Current walk state object
374 * Node - Where the node is returned.
376 * RETURN: Status and node
378 * DESCRIPTION: Get the Node associated with a local or arg.
380 ******************************************************************************/
382 ACPI_STATUS
383 AcpiDsMethodDataGetNode (
384 UINT8 Type,
385 UINT32 Index,
386 ACPI_WALK_STATE *WalkState,
387 ACPI_NAMESPACE_NODE **Node)
389 ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
393 * Method Locals and Arguments are supported
395 switch (Type)
397 case ACPI_REFCLASS_LOCAL:
399 if (Index > ACPI_METHOD_MAX_LOCAL)
401 ACPI_ERROR ((AE_INFO,
402 "Local index %u is invalid (max %u)",
403 Index, ACPI_METHOD_MAX_LOCAL));
404 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
407 /* Return a pointer to the pseudo-node */
409 *Node = &WalkState->LocalVariables[Index];
410 break;
412 case ACPI_REFCLASS_ARG:
414 if (Index > ACPI_METHOD_MAX_ARG)
416 ACPI_ERROR ((AE_INFO,
417 "Arg index %u is invalid (max %u)",
418 Index, ACPI_METHOD_MAX_ARG));
419 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
422 /* Return a pointer to the pseudo-node */
424 *Node = &WalkState->Arguments[Index];
425 break;
427 default:
429 ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
430 return_ACPI_STATUS (AE_TYPE);
433 return_ACPI_STATUS (AE_OK);
437 /*******************************************************************************
439 * FUNCTION: AcpiDsMethodDataSetValue
441 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
442 * ACPI_REFCLASS_ARG
443 * Index - Which Local or Arg to get
444 * Object - Object to be inserted into the stack entry
445 * WalkState - Current walk state object
447 * RETURN: Status
449 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
450 * Note: There is no "implicit conversion" for locals.
452 ******************************************************************************/
454 static ACPI_STATUS
455 AcpiDsMethodDataSetValue (
456 UINT8 Type,
457 UINT32 Index,
458 ACPI_OPERAND_OBJECT *Object,
459 ACPI_WALK_STATE *WalkState)
461 ACPI_STATUS Status;
462 ACPI_NAMESPACE_NODE *Node;
465 ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
468 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
469 "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
470 Type, Object->Common.ReferenceCount,
471 AcpiUtGetTypeName (Object->Common.Type)));
473 /* Get the namespace node for the arg/local */
475 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
476 if (ACPI_FAILURE (Status))
478 return_ACPI_STATUS (Status);
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 by
484 * reference semantics of ACPI Control Method invocation.
485 * (See ACPI Specification 2.0C)
487 AcpiUtAddReference (Object);
489 /* Install the object */
491 Node->Object = Object;
492 return_ACPI_STATUS (Status);
496 /*******************************************************************************
498 * FUNCTION: AcpiDsMethodDataGetValue
500 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
501 * ACPI_REFCLASS_ARG
502 * Index - Which localVar or argument to get
503 * WalkState - Current walk state object
504 * DestDesc - Where Arg or Local value is returned
506 * RETURN: Status
508 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
509 * Used only in AcpiExResolveToValue().
511 ******************************************************************************/
513 ACPI_STATUS
514 AcpiDsMethodDataGetValue (
515 UINT8 Type,
516 UINT32 Index,
517 ACPI_WALK_STATE *WalkState,
518 ACPI_OPERAND_OBJECT **DestDesc)
520 ACPI_STATUS Status;
521 ACPI_NAMESPACE_NODE *Node;
522 ACPI_OPERAND_OBJECT *Object;
525 ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
528 /* Validate the object descriptor */
530 if (!DestDesc)
532 ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
533 return_ACPI_STATUS (AE_BAD_PARAMETER);
536 /* Get the namespace node for the arg/local */
538 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
539 if (ACPI_FAILURE (Status))
541 return_ACPI_STATUS (Status);
544 /* Get the object from the node */
546 Object = Node->Object;
548 /* Examine the returned object, it must be valid. */
550 if (!Object)
553 * Index points to uninitialized object.
554 * This means that either 1) The expected argument was
555 * not passed to the method, or 2) A local variable
556 * was referenced by the method (via the ASL)
557 * before it was initialized. Either case is an error.
560 /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
562 if (AcpiGbl_EnableInterpreterSlack)
564 Object = AcpiUtCreateIntegerObject ((UINT64) 0);
565 if (!Object)
567 return_ACPI_STATUS (AE_NO_MEMORY);
570 Node->Object = Object;
573 /* Otherwise, return the error */
575 else switch (Type)
577 case ACPI_REFCLASS_ARG:
579 ACPI_ERROR ((AE_INFO,
580 "Uninitialized Arg[%u] at node %p",
581 Index, Node));
583 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
585 case ACPI_REFCLASS_LOCAL:
587 * No error message for this case, will be trapped again later to
588 * detect and ignore cases of Store(LocalX,LocalX)
590 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
592 default:
594 ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
595 return_ACPI_STATUS (AE_AML_INTERNAL);
600 * The Index points to an initialized and valid object.
601 * Return an additional reference to the object
603 *DestDesc = Object;
604 AcpiUtAddReference (Object);
606 return_ACPI_STATUS (AE_OK);
610 /*******************************************************************************
612 * FUNCTION: AcpiDsMethodDataDeleteValue
614 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
615 * ACPI_REFCLASS_ARG
616 * Index - Which localVar or argument to delete
617 * WalkState - Current walk state object
619 * RETURN: None
621 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
622 * a null into the stack slot after the object is deleted.
624 ******************************************************************************/
626 static void
627 AcpiDsMethodDataDeleteValue (
628 UINT8 Type,
629 UINT32 Index,
630 ACPI_WALK_STATE *WalkState)
632 ACPI_STATUS Status;
633 ACPI_NAMESPACE_NODE *Node;
634 ACPI_OPERAND_OBJECT *Object;
637 ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
640 /* Get the namespace node for the arg/local */
642 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
643 if (ACPI_FAILURE (Status))
645 return_VOID;
648 /* Get the associated object */
650 Object = AcpiNsGetAttachedObject (Node);
653 * Undefine the Arg or Local by setting its descriptor
654 * pointer to NULL. Locals/Args can contain both
655 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
657 Node->Object = NULL;
659 if ((Object) &&
660 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
663 * There is a valid object.
664 * Decrement the reference count by one to balance the
665 * increment when the object was stored.
667 AcpiUtRemoveReference (Object);
670 return_VOID;
674 /*******************************************************************************
676 * FUNCTION: AcpiDsStoreObjectToLocal
678 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
679 * ACPI_REFCLASS_ARG
680 * Index - Which Local or Arg to set
681 * ObjDesc - Value to be stored
682 * WalkState - Current walk state
684 * RETURN: Status
686 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
687 * as the new value for the Arg or Local and the reference count
688 * for ObjDesc is incremented.
690 ******************************************************************************/
692 ACPI_STATUS
693 AcpiDsStoreObjectToLocal (
694 UINT8 Type,
695 UINT32 Index,
696 ACPI_OPERAND_OBJECT *ObjDesc,
697 ACPI_WALK_STATE *WalkState)
699 ACPI_STATUS Status;
700 ACPI_NAMESPACE_NODE *Node;
701 ACPI_OPERAND_OBJECT *CurrentObjDesc;
702 ACPI_OPERAND_OBJECT *NewObjDesc;
705 ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
706 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
707 Type, Index, ObjDesc));
709 /* Parameter validation */
711 if (!ObjDesc)
713 return_ACPI_STATUS (AE_BAD_PARAMETER);
716 /* Get the namespace node for the arg/local */
718 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
719 if (ACPI_FAILURE (Status))
721 return_ACPI_STATUS (Status);
724 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
725 if (CurrentObjDesc == ObjDesc)
727 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
728 ObjDesc));
729 return_ACPI_STATUS (Status);
733 * If the reference count on the object is more than one, we must
734 * take a copy of the object before we store. A reference count
735 * of exactly 1 means that the object was just created during the
736 * evaluation of an expression, and we can safely use it since it
737 * is not used anywhere else.
739 NewObjDesc = ObjDesc;
740 if (ObjDesc->Common.ReferenceCount > 1)
742 Status = AcpiUtCopyIobjectToIobject (
743 ObjDesc, &NewObjDesc, WalkState);
744 if (ACPI_FAILURE (Status))
746 return_ACPI_STATUS (Status);
751 * If there is an object already in this slot, we either
752 * have to delete it, or if this is an argument and there
753 * is an object reference stored there, we have to do
754 * an indirect store!
756 if (CurrentObjDesc)
759 * Check for an indirect store if an argument
760 * contains an object reference (stored as an Node).
761 * We don't allow this automatic dereferencing for
762 * locals, since a store to a local should overwrite
763 * anything there, including an object reference.
765 * If both Arg0 and Local0 contain RefOf (Local4):
767 * Store (1, Arg0) - Causes indirect store to local4
768 * Store (1, Local0) - Stores 1 in local0, overwriting
769 * the reference to local4
770 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
772 * Weird, but true.
774 if (Type == ACPI_REFCLASS_ARG)
777 * If we have a valid reference object that came from RefOf(),
778 * do the indirect store
780 if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) ==
781 ACPI_DESC_TYPE_OPERAND) &&
782 (CurrentObjDesc->Common.Type ==
783 ACPI_TYPE_LOCAL_REFERENCE) &&
784 (CurrentObjDesc->Reference.Class ==
785 ACPI_REFCLASS_REFOF))
787 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
788 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
789 NewObjDesc, CurrentObjDesc));
792 * Store this object to the Node (perform the indirect store)
793 * NOTE: No implicit conversion is performed, as per the ACPI
794 * specification rules on storing to Locals/Args.
796 Status = AcpiExStoreObjectToNode (NewObjDesc,
797 CurrentObjDesc->Reference.Object, WalkState,
798 ACPI_NO_IMPLICIT_CONVERSION);
800 /* Remove local reference if we copied the object above */
802 if (NewObjDesc != ObjDesc)
804 AcpiUtRemoveReference (NewObjDesc);
807 return_ACPI_STATUS (Status);
811 /* Delete the existing object before storing the new one */
813 AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
817 * Install the Obj descriptor (*NewObjDesc) into
818 * the descriptor for the Arg or Local.
819 * (increments the object reference count by one)
821 Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
823 /* Remove local reference if we copied the object above */
825 if (NewObjDesc != ObjDesc)
827 AcpiUtRemoveReference (NewObjDesc);
830 return_ACPI_STATUS (Status);
834 #ifdef ACPI_OBSOLETE_FUNCTIONS
835 /*******************************************************************************
837 * FUNCTION: AcpiDsMethodDataGetType
839 * PARAMETERS: Opcode - Either AML_FIRST LOCAL_OP or
840 * AML_FIRST_ARG_OP
841 * Index - Which Local or Arg whose type to get
842 * WalkState - Current walk state object
844 * RETURN: Data type of current value of the selected Arg or Local
846 * DESCRIPTION: Get the type of the object stored in the Local or Arg
848 ******************************************************************************/
850 ACPI_OBJECT_TYPE
851 AcpiDsMethodDataGetType (
852 UINT16 Opcode,
853 UINT32 Index,
854 ACPI_WALK_STATE *WalkState)
856 ACPI_STATUS Status;
857 ACPI_NAMESPACE_NODE *Node;
858 ACPI_OPERAND_OBJECT *Object;
861 ACPI_FUNCTION_TRACE (DsMethodDataGetType);
864 /* Get the namespace node for the arg/local */
866 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
867 if (ACPI_FAILURE (Status))
869 return_VALUE ((ACPI_TYPE_NOT_FOUND));
872 /* Get the object */
874 Object = AcpiNsGetAttachedObject (Node);
875 if (!Object)
877 /* Uninitialized local/arg, return TYPE_ANY */
879 return_VALUE (ACPI_TYPE_ANY);
882 /* Get the object type */
884 return_VALUE (Object->Type);
886 #endif