dsmthdat.c revision 87031
1/*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
4 *              $Revision: 53 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code.  No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision.  In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change.  Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee.  Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution.  In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government.  In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSMTHDAT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "acdispat.h"
122#include "acinterp.h"
123#include "amlcode.h"
124#include "acnamesp.h"
125
126
127#define _COMPONENT          ACPI_DISPATCHER
128        MODULE_NAME         ("dsmthdat")
129
130
131/*******************************************************************************
132 *
133 * FUNCTION:    AcpiDsMethodDataInit
134 *
135 * PARAMETERS:  WalkState           - Current walk state object
136 *
137 * RETURN:      Status
138 *
139 * DESCRIPTION: Initialize the data structures that hold the method's arguments
140 *              and locals.  The data struct is an array of NTEs for each.
141 *              This allows RefOf and DeRefOf to work properly for these
142 *              special data types.
143 *
144 * NOTES:       WalkState fields are initialized to zero by the
145 *              ACPI_MEM_CALLOCATE().
146 *
147 *              A pseudo-Namespace Node is assigned to each argument and local
148 *              so that RefOf() can return a pointer to the Node.
149 *
150 ******************************************************************************/
151
152ACPI_STATUS
153AcpiDsMethodDataInit (
154    ACPI_WALK_STATE         *WalkState)
155{
156    UINT32                  i;
157
158
159    FUNCTION_TRACE ("DsMethodDataInit");
160
161
162    /* Init the method arguments */
163
164    for (i = 0; i < MTH_NUM_ARGS; i++)
165    {
166        MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name,
167                                NAMEOF_ARG_NTE);
168        WalkState->Arguments[i].Name       |= (i << 24);
169        WalkState->Arguments[i].DataType    = ACPI_DESC_TYPE_NAMED;
170        WalkState->Arguments[i].Type        = ACPI_TYPE_ANY;
171        WalkState->Arguments[i].Flags       = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
172    }
173
174    /* Init the method locals */
175
176    for (i = 0; i < MTH_NUM_LOCALS; i++)
177    {
178        MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name,
179                                NAMEOF_LOCAL_NTE);
180
181        WalkState->LocalVariables[i].Name    |= (i << 24);
182        WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED;
183        WalkState->LocalVariables[i].Type     = ACPI_TYPE_ANY;
184        WalkState->LocalVariables[i].Flags    = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
185    }
186
187    return_ACPI_STATUS (AE_OK);
188}
189
190
191/*******************************************************************************
192 *
193 * FUNCTION:    AcpiDsMethodDataDeleteAll
194 *
195 * PARAMETERS:  WalkState           - Current walk state object
196 *
197 * RETURN:      Status
198 *
199 * DESCRIPTION: Delete method locals and arguments.  Arguments are only
200 *              deleted if this method was called from another method.
201 *
202 ******************************************************************************/
203
204ACPI_STATUS
205AcpiDsMethodDataDeleteAll (
206    ACPI_WALK_STATE         *WalkState)
207{
208    UINT32                  Index;
209
210
211    FUNCTION_TRACE ("DsMethodDataDeleteAll");
212
213
214    /* Detach the locals */
215
216    for (Index = 0; Index < MTH_NUM_LOCALS; Index++)
217    {
218        if (WalkState->LocalVariables[Index].Object)
219        {
220            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
221                    Index, WalkState->LocalVariables[Index].Object));
222
223            /* Detach object (if present) and remove a reference */
224
225            AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
226       }
227    }
228
229    /* Detach the arguments */
230
231    for (Index = 0; Index < MTH_NUM_ARGS; Index++)
232    {
233        if (WalkState->Arguments[Index].Object)
234        {
235            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
236                    Index, WalkState->Arguments[Index].Object));
237
238            /* Detach object (if present) and remove a reference */
239
240            AcpiNsDetachObject (&WalkState->Arguments[Index]);
241        }
242    }
243
244    return_ACPI_STATUS (AE_OK);
245}
246
247
248/*******************************************************************************
249 *
250 * FUNCTION:    AcpiDsMethodDataInitArgs
251 *
252 * PARAMETERS:  *Params         - Pointer to a parameter list for the method
253 *              MaxParamCount   - The arg count for this method
254 *              WalkState       - Current walk state object
255 *
256 * RETURN:      Status
257 *
258 * DESCRIPTION: Initialize arguments for a method.  The parameter list is a list
259 *              of ACPI operand objects, either null terminated or whose length
260 *              is defined by MaxParamCount.
261 *
262 ******************************************************************************/
263
264ACPI_STATUS
265AcpiDsMethodDataInitArgs (
266    ACPI_OPERAND_OBJECT     **Params,
267    UINT32                  MaxParamCount,
268    ACPI_WALK_STATE         *WalkState)
269{
270    ACPI_STATUS             Status;
271    UINT32                  Index = 0;
272
273
274    FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params);
275
276
277    if (!Params)
278    {
279        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
280        return_ACPI_STATUS (AE_OK);
281    }
282
283    /* Copy passed parameters into the new method stack frame  */
284
285    while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index])
286    {
287        /*
288         * A valid parameter.
289         * Store the argument in the method/walk descriptor
290         */
291        Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index],
292                                            WalkState);
293        if (ACPI_FAILURE (Status))
294        {
295            return_ACPI_STATUS (Status);
296        }
297
298        Index++;
299    }
300
301    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index));
302    return_ACPI_STATUS (AE_OK);
303}
304
305
306/*******************************************************************************
307 *
308 * FUNCTION:    AcpiDsMethodDataGetNode
309 *
310 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
311 *              Index               - Which localVar or argument whose type
312 *                                      to get
313 *              WalkState           - Current walk state object
314 *
315 * RETURN:      Get the Node associated with a local or arg.
316 *
317 ******************************************************************************/
318
319ACPI_STATUS
320AcpiDsMethodDataGetNode (
321    UINT16                  Opcode,
322    UINT32                  Index,
323    ACPI_WALK_STATE         *WalkState,
324    ACPI_NAMESPACE_NODE     **Node)
325{
326    FUNCTION_TRACE ("DsMethodDataGetNode");
327
328
329    /*
330     * Method Locals and Arguments are supported
331     */
332    switch (Opcode)
333    {
334    case AML_LOCAL_OP:
335
336        if (Index > MTH_MAX_LOCAL)
337        {
338            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
339                Index, MTH_MAX_LOCAL));
340            return_ACPI_STATUS (AE_AML_INVALID_INDEX);
341        }
342
343        /* Return a pointer to the pseudo-node */
344
345        *Node = &WalkState->LocalVariables[Index];
346        break;
347
348    case AML_ARG_OP:
349
350        if (Index > MTH_MAX_ARG)
351        {
352            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
353                Index, MTH_MAX_ARG));
354            return_ACPI_STATUS (AE_AML_INVALID_INDEX);
355        }
356
357        /* Return a pointer to the pseudo-node */
358
359        *Node = &WalkState->Arguments[Index];
360        break;
361
362    default:
363        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode));
364        return_ACPI_STATUS (AE_AML_BAD_OPCODE);
365        break;
366    }
367
368    return_ACPI_STATUS (AE_OK);
369}
370
371
372/*******************************************************************************
373 *
374 * FUNCTION:    AcpiDsMethodDataSetValue
375 *
376 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
377 *              Index               - Which localVar or argument to get
378 *              Object              - Object to be inserted into the stack entry
379 *              WalkState           - Current walk state object
380 *
381 * RETURN:      Status
382 *
383 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
384 *
385 ******************************************************************************/
386
387ACPI_STATUS
388AcpiDsMethodDataSetValue (
389    UINT16                  Opcode,
390    UINT32                  Index,
391    ACPI_OPERAND_OBJECT     *Object,
392    ACPI_WALK_STATE         *WalkState)
393{
394    ACPI_STATUS             Status;
395    ACPI_NAMESPACE_NODE     *Node;
396
397
398    FUNCTION_TRACE ("DsMethodDataSetValue");
399
400
401    /* Get the namespace node for the arg/local */
402
403    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
404    if (ACPI_FAILURE (Status))
405    {
406        return_ACPI_STATUS (Status);
407    }
408
409    /* Increment ref count so object can't be deleted while installed */
410
411    AcpiUtAddReference (Object);
412
413    /* Install the object into the stack entry */
414
415    Node->Object = Object;
416    return_ACPI_STATUS (AE_OK);
417}
418
419
420/*******************************************************************************
421 *
422 * FUNCTION:    AcpiDsMethodDataGetType
423 *
424 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
425 *              Index               - Which localVar or argument whose type
426 *                                      to get
427 *              WalkState           - Current walk state object
428 *
429 * RETURN:      Data type of current value of the selected Arg or Local
430 *
431 ******************************************************************************/
432
433ACPI_OBJECT_TYPE8
434AcpiDsMethodDataGetType (
435    UINT16                  Opcode,
436    UINT32                  Index,
437    ACPI_WALK_STATE         *WalkState)
438{
439    ACPI_STATUS             Status;
440    ACPI_NAMESPACE_NODE     *Node;
441    ACPI_OPERAND_OBJECT     *Object;
442
443
444    FUNCTION_TRACE ("DsMethodDataGetType");
445
446
447    /* Get the namespace node for the arg/local */
448
449    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
450    if (ACPI_FAILURE (Status))
451    {
452        return_VALUE ((ACPI_TYPE_NOT_FOUND));
453    }
454
455    /* Get the object */
456
457    Object = AcpiNsGetAttachedObject (Node);
458    if (!Object)
459    {
460        /* Uninitialized local/arg, return TYPE_ANY */
461
462        return_VALUE (ACPI_TYPE_ANY);
463    }
464
465    /* Get the object type */
466
467    return_VALUE (Object->Common.Type);
468}
469
470
471/*******************************************************************************
472 *
473 * FUNCTION:    AcpiDsMethodDataGetValue
474 *
475 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
476 *              Index               - Which localVar or argument to get
477 *              WalkState           - Current walk state object
478 *              *DestDesc           - Ptr to Descriptor into which selected Arg
479 *                                    or Local value should be copied
480 *
481 * RETURN:      Status
482 *
483 * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame
484 *              at the current top of the method stack.
485 *              Used only in AcpiExResolveToValue().
486 *
487 ******************************************************************************/
488
489ACPI_STATUS
490AcpiDsMethodDataGetValue (
491    UINT16                  Opcode,
492    UINT32                  Index,
493    ACPI_WALK_STATE         *WalkState,
494    ACPI_OPERAND_OBJECT     **DestDesc)
495{
496    ACPI_STATUS             Status;
497    ACPI_NAMESPACE_NODE     *Node;
498    ACPI_OPERAND_OBJECT     *Object;
499
500
501    FUNCTION_TRACE ("DsMethodDataGetValue");
502
503
504    /* Validate the object descriptor */
505
506    if (!DestDesc)
507    {
508        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
509        return_ACPI_STATUS (AE_BAD_PARAMETER);
510    }
511
512    /* Get the namespace node for the arg/local */
513
514    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
515    if (ACPI_FAILURE (Status))
516    {
517        return_ACPI_STATUS (Status);
518    }
519
520    /* Get the object from the node */
521
522    Object = Node->Object;
523
524    /* Examine the returned object, it must be valid. */
525
526    if (!Object)
527    {
528        /*
529         * Index points to uninitialized object.
530         * This means that either 1) The expected argument was
531         * not passed to the method, or 2) A local variable
532         * was referenced by the method (via the ASL)
533         * before it was initialized.  Either case is an error.
534         */
535        switch (Opcode)
536        {
537        case AML_ARG_OP:
538
539            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
540                Index, Node));
541
542            return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
543            break;
544
545        case AML_LOCAL_OP:
546
547            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
548                Index, Node));
549
550            return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
551            break;
552        }
553    }
554
555    /*
556     * The Index points to an initialized and valid object.
557     * Return an additional reference to the object
558     */
559    *DestDesc = Object;
560    AcpiUtAddReference (Object);
561
562    return_ACPI_STATUS (AE_OK);
563}
564
565
566/*******************************************************************************
567 *
568 * FUNCTION:    AcpiDsMethodDataDeleteValue
569 *
570 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
571 *              Index               - Which localVar or argument to delete
572 *              WalkState           - Current walk state object
573 *
574 * RETURN:      Status
575 *
576 * DESCRIPTION: Delete the entry at Opcode:Index on the method stack.  Inserts
577 *              a null into the stack slot after the object is deleted.
578 *
579 ******************************************************************************/
580
581ACPI_STATUS
582AcpiDsMethodDataDeleteValue (
583    UINT16                  Opcode,
584    UINT32                  Index,
585    ACPI_WALK_STATE         *WalkState)
586{
587    ACPI_STATUS             Status;
588    ACPI_NAMESPACE_NODE     *Node;
589    ACPI_OPERAND_OBJECT     *Object;
590
591
592    FUNCTION_TRACE ("DsMethodDataDeleteValue");
593
594
595    /* Get the namespace node for the arg/local */
596
597    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
598    if (ACPI_FAILURE (Status))
599    {
600        return_ACPI_STATUS (Status);
601    }
602
603    /* Get the associated object */
604
605    Object = AcpiNsGetAttachedObject (Node);
606
607    /*
608     * Undefine the Arg or Local by setting its descriptor
609     * pointer to NULL. Locals/Args can contain both
610     * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
611     */
612    Node->Object = NULL;
613
614    if ((Object) &&
615        (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL)))
616    {
617        /*
618         * There is a valid object.
619         * Decrement the reference count by one to balance the
620         * increment when the object was stored.
621         */
622        AcpiUtRemoveReference (Object);
623    }
624
625    return_ACPI_STATUS (AE_OK);
626}
627
628
629/*******************************************************************************
630 *
631 * FUNCTION:    AcpiDsStoreObjectToLocal
632 *
633 * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
634 *              Index               - Which localVar or argument to set
635 *              ObjDesc             - Value to be stored
636 *              WalkState           - Current walk state
637 *
638 * RETURN:      Status
639 *
640 * DESCRIPTION: Store a value in an Arg or Local.  The ObjDesc is installed
641 *              as the new value for the Arg or Local and the reference count
642 *              for ObjDesc is incremented.
643 *
644 ******************************************************************************/
645
646ACPI_STATUS
647AcpiDsStoreObjectToLocal (
648    UINT16                  Opcode,
649    UINT32                  Index,
650    ACPI_OPERAND_OBJECT     *ObjDesc,
651    ACPI_WALK_STATE         *WalkState)
652{
653    ACPI_STATUS             Status;
654    ACPI_NAMESPACE_NODE     *Node;
655    ACPI_OPERAND_OBJECT     *CurrentObjDesc;
656
657
658    FUNCTION_TRACE ("DsStoreObjectToLocal");
659    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
660        Opcode, Index, ObjDesc));
661
662
663    /* Parameter validation */
664
665    if (!ObjDesc)
666    {
667        return_ACPI_STATUS (AE_BAD_PARAMETER);
668    }
669
670    /* Get the namespace node for the arg/local */
671
672    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
673    if (ACPI_FAILURE (Status))
674    {
675        return_ACPI_STATUS (Status);
676    }
677
678    CurrentObjDesc = AcpiNsGetAttachedObject (Node);
679    if (CurrentObjDesc == ObjDesc)
680    {
681        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc));
682        return_ACPI_STATUS (Status);
683    }
684
685    /*
686     * If there is an object already in this slot, we either
687     * have to delete it, or if this is an argument and there
688     * is an object reference stored there, we have to do
689     * an indirect store!
690     */
691    if (CurrentObjDesc)
692    {
693        /*
694         * Check for an indirect store if an argument
695         * contains an object reference (stored as an Node).
696         * We don't allow this automatic dereferencing for
697         * locals, since a store to a local should overwrite
698         * anything there, including an object reference.
699         *
700         * If both Arg0 and Local0 contain RefOf (Local4):
701         *
702         * Store (1, Arg0)             - Causes indirect store to local4
703         * Store (1, Local0)           - Stores 1 in local0, overwriting
704         *                                  the reference to local4
705         * Store (1, DeRefof (Local0)) - Causes indirect store to local4
706         *
707         * Weird, but true.
708         */
709        if ((Opcode == AML_ARG_OP) &&
710            (VALID_DESCRIPTOR_TYPE (CurrentObjDesc, ACPI_DESC_TYPE_NAMED)))
711        {
712            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
713                "Arg (%p) is an ObjRef(Node), storing in node %p\n",
714                ObjDesc, CurrentObjDesc));
715
716            /* Detach an existing object from the Node */
717
718            AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc);
719
720            /*
721             * Store this object into the Node
722             * (perform the indirect store)
723             */
724            Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc,
725                            ObjDesc, ObjDesc->Common.Type);
726            return_ACPI_STATUS (Status);
727        }
728
729        /*
730         * Delete the existing object
731         * before storing the new one
732         */
733        AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState);
734    }
735
736    /*
737     * Install the ObjStack descriptor (*ObjDesc) into
738     * the descriptor for the Arg or Local.
739     * Install the new object in the stack entry
740     * (increments the object reference count by one)
741     */
742    Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState);
743    return_ACPI_STATUS (Status);
744}
745
746
747