Merge from vendor branch LESS:
[dragonfly.git] / sys / contrib / dev / acpica / dsutils.c
1 /*******************************************************************************
2  *
3  * Module Name: dsutils - Dispatcher utilities
4  *              $Revision: 99 $
5  *
6  ******************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dsutils.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
117
118 #define __DSUTILS_C__
119
120 #include "acpi.h"
121 #include "acparser.h"
122 #include "amlcode.h"
123 #include "acdispat.h"
124 #include "acinterp.h"
125 #include "acnamesp.h"
126 #include "acdebug.h"
127
128 #define _COMPONENT          ACPI_DISPATCHER
129         ACPI_MODULE_NAME    ("dsutils")
130
131 #ifndef ACPI_NO_METHOD_EXECUTION
132
133 /*******************************************************************************
134  *
135  * FUNCTION:    AcpiDsIsResultUsed
136  *
137  * PARAMETERS:  Op
138  *              ResultObj
139  *              WalkState
140  *
141  * RETURN:      Status
142  *
143  * DESCRIPTION: Check if a result object will be used by the parent
144  *
145  ******************************************************************************/
146
147 BOOLEAN
148 AcpiDsIsResultUsed (
149     ACPI_PARSE_OBJECT       *Op,
150     ACPI_WALK_STATE         *WalkState)
151 {
152     const ACPI_OPCODE_INFO  *ParentInfo;
153
154
155     ACPI_FUNCTION_TRACE_PTR ("DsIsResultUsed", Op);
156
157
158     /* Must have both an Op and a Result Object */
159
160     if (!Op)
161     {
162         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
163         return_VALUE (TRUE);
164     }
165
166     /*
167      * If there is no parent, the result can't possibly be used!
168      * (An executing method typically has no parent, since each
169      * method is parsed separately)  However, a method that is
170      * invoked from another method has a parent.
171      */
172     if (!Op->Common.Parent)
173     {
174         return_VALUE (FALSE);
175     }
176
177     /*
178      * Get info on the parent.  The root Op is AML_SCOPE
179      */
180     ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
181     if (ParentInfo->Class == AML_CLASS_UNKNOWN)
182     {
183         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", Op));
184         return_VALUE (FALSE);
185     }
186
187     /*
188      * Decide what to do with the result based on the parent.  If
189      * the parent opcode will not use the result, delete the object.
190      * Otherwise leave it as is, it will be deleted when it is used
191      * as an operand later.
192      */
193     switch (ParentInfo->Class)
194     {
195     case AML_CLASS_CONTROL:
196
197         switch (Op->Common.Parent->Common.AmlOpcode)
198         {
199         case AML_RETURN_OP:
200
201             /* Never delete the return value associated with a return opcode */
202
203             goto ResultUsed;
204
205         case AML_IF_OP:
206         case AML_WHILE_OP:
207
208             /*
209              * If we are executing the predicate AND this is the predicate op,
210              * we will use the return value
211              */
212             if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
213                 (WalkState->ControlState->Control.PredicateOp == Op))
214             {
215                 goto ResultUsed;
216             }
217             break;
218
219         default:
220             /* Ignore other control opcodes */
221             break;
222         }
223
224         /* The general control opcode returns no result */
225
226         goto ResultNotUsed;
227
228
229     case AML_CLASS_CREATE:
230
231         /*
232          * These opcodes allow TermArg(s) as operands and therefore
233          * the operands can be method calls.  The result is used.
234          */
235         goto ResultUsed;
236
237
238     case AML_CLASS_NAMED_OBJECT:
239
240         if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
241             (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
242             (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
243             (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)  ||
244             (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
245             (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP))
246         {
247             /*
248              * These opcodes allow TermArg(s) as operands and therefore
249              * the operands can be method calls.  The result is used.
250              */
251             goto ResultUsed;
252         }
253
254         goto ResultNotUsed;
255
256
257     default:
258
259         /*
260          * In all other cases. the parent will actually use the return
261          * object, so keep it.
262          */
263         goto ResultUsed;
264     }
265
266
267 ResultUsed:
268     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
269             AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
270             AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
271
272     return_VALUE (TRUE);
273
274
275 ResultNotUsed:
276     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
277             AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
278             AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
279
280     return_VALUE (FALSE);
281
282 }
283
284
285 /*******************************************************************************
286  *
287  * FUNCTION:    AcpiDsDeleteResultIfNotUsed
288  *
289  * PARAMETERS:  Op
290  *              ResultObj
291  *              WalkState
292  *
293  * RETURN:      Status
294  *
295  * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
296  *              result descriptor, check if the parent opcode will actually use
297  *              this result.  If not, delete the result now so that it will
298  *              not become orphaned.
299  *
300  ******************************************************************************/
301
302 void
303 AcpiDsDeleteResultIfNotUsed (
304     ACPI_PARSE_OBJECT       *Op,
305     ACPI_OPERAND_OBJECT     *ResultObj,
306     ACPI_WALK_STATE         *WalkState)
307 {
308     ACPI_OPERAND_OBJECT     *ObjDesc;
309     ACPI_STATUS             Status;
310
311
312     ACPI_FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj);
313
314
315     if (!Op)
316     {
317         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
318         return_VOID;
319     }
320
321     if (!ResultObj)
322     {
323         return_VOID;
324     }
325
326
327     if (!AcpiDsIsResultUsed (Op, WalkState))
328     {
329         /*
330          * Must pop the result stack (ObjDesc should be equal to ResultObj)
331          */
332         Status = AcpiDsResultPop (&ObjDesc, WalkState);
333         if (ACPI_SUCCESS (Status))
334         {
335             AcpiUtRemoveReference (ResultObj);
336         }
337     }
338
339     return_VOID;
340 }
341
342
343 /*******************************************************************************
344  *
345  * FUNCTION:    AcpiDsResolveOperands
346  *
347  * PARAMETERS:  WalkState           - Current walk state with operands on stack
348  *
349  * RETURN:      Status
350  *
351  * DESCRIPTION: Resolve all operands to their values.  Used to prepare
352  *              arguments to a control method invocation (a call from one
353  *              method to another.)
354  *
355  ******************************************************************************/
356
357 ACPI_STATUS
358 AcpiDsResolveOperands (
359     ACPI_WALK_STATE         *WalkState)
360 {
361     UINT32                  i;
362     ACPI_STATUS             Status = AE_OK;
363
364
365     ACPI_FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState);
366
367
368     /*
369      * Attempt to resolve each of the valid operands
370      * Method arguments are passed by value, not by reference
371      */
372     for (i = 0; i < WalkState->NumOperands; i++)
373     {
374         Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
375         if (ACPI_FAILURE (Status))
376         {
377             break;
378         }
379     }
380
381     return_ACPI_STATUS (Status);
382 }
383
384
385 /*******************************************************************************
386  *
387  * FUNCTION:    AcpiDsClearOperands
388  *
389  * PARAMETERS:  WalkState           - Current walk state with operands on stack
390  *
391  * RETURN:      None
392  *
393  * DESCRIPTION: Clear all operands on the current walk state operand stack.
394  *
395  ******************************************************************************/
396
397 void
398 AcpiDsClearOperands (
399     ACPI_WALK_STATE         *WalkState)
400 {
401     UINT32                  i;
402
403
404     ACPI_FUNCTION_TRACE_PTR ("AcpiDsClearOperands", WalkState);
405
406
407     /*
408      * Remove a reference on each operand on the stack
409      */
410     for (i = 0; i < WalkState->NumOperands; i++)
411     {
412         /*
413          * Remove a reference to all operands, including both
414          * "Arguments" and "Targets".
415          */
416         AcpiUtRemoveReference (WalkState->Operands[i]);
417         WalkState->Operands[i] = NULL;
418     }
419
420     WalkState->NumOperands = 0;
421     return_VOID;
422 }
423 #endif
424
425
426 /*******************************************************************************
427  *
428  * FUNCTION:    AcpiDsCreateOperand
429  *
430  * PARAMETERS:  WalkState
431  *              Arg
432  *
433  * RETURN:      Status
434  *
435  * DESCRIPTION: Translate a parse tree object that is an argument to an AML
436  *              opcode to the equivalent interpreter object.  This may include
437  *              looking up a name or entering a new name into the internal
438  *              namespace.
439  *
440  ******************************************************************************/
441
442 ACPI_STATUS
443 AcpiDsCreateOperand (
444     ACPI_WALK_STATE         *WalkState,
445     ACPI_PARSE_OBJECT       *Arg,
446     UINT32                  ArgIndex)
447 {
448     ACPI_STATUS             Status = AE_OK;
449     char                    *NameString;
450     UINT32                  NameLength;
451     ACPI_OPERAND_OBJECT     *ObjDesc;
452     ACPI_PARSE_OBJECT       *ParentOp;
453     UINT16                  Opcode;
454     ACPI_INTERPRETER_MODE   InterpreterMode;
455     const ACPI_OPCODE_INFO  *OpInfo;
456
457
458     ACPI_FUNCTION_TRACE_PTR ("DsCreateOperand", Arg);
459
460
461     /* A valid name must be looked up in the namespace */
462
463     if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
464         (Arg->Common.Value.String))
465     {
466         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg));
467
468         /* Get the entire name string from the AML stream */
469
470         Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer,
471                         &NameString, &NameLength);
472
473         if (ACPI_FAILURE (Status))
474         {
475             return_ACPI_STATUS (Status);
476         }
477
478         /*
479          * All prefixes have been handled, and the name is
480          * in NameString
481          */
482
483         /*
484          * Differentiate between a namespace "create" operation
485          * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
486          * IMODE_EXECUTE) in order to support the creation of
487          * namespace objects during the execution of control methods.
488          */
489         ParentOp = Arg->Common.Parent;
490         OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
491         if ((OpInfo->Flags & AML_NSNODE) &&
492             (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
493             (ParentOp->Common.AmlOpcode != AML_REGION_OP) &&
494             (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
495         {
496             /* Enter name into namespace if not found */
497
498             InterpreterMode = ACPI_IMODE_LOAD_PASS2;
499         }
500
501         else
502         {
503             /* Return a failure if name not found */
504
505             InterpreterMode = ACPI_IMODE_EXECUTE;
506         }
507
508         Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
509                                 ACPI_TYPE_ANY, InterpreterMode,
510                                 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
511                                 WalkState,
512                                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc));
513         /*
514          * The only case where we pass through (ignore) a NOT_FOUND
515          * error is for the CondRefOf opcode.
516          */
517         if (Status == AE_NOT_FOUND)
518         {
519             if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP)
520             {
521                 /*
522                  * For the Conditional Reference op, it's OK if
523                  * the name is not found;  We just need a way to
524                  * indicate this to the interpreter, set the
525                  * object to the root
526                  */
527                 ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, AcpiGbl_RootNode);
528                 Status = AE_OK;
529             }
530
531             else
532             {
533                 /*
534                  * We just plain didn't find it -- which is a
535                  * very serious error at this point
536                  */
537                 Status = AE_AML_NAME_NOT_FOUND;
538             }
539         }
540
541         if (ACPI_FAILURE (Status))
542         {
543             ACPI_REPORT_NSERROR (NameString, Status);
544         }
545
546         /* Free the namestring created above */
547
548         ACPI_MEM_FREE (NameString);
549
550         /* Check status from the lookup */
551
552         if (ACPI_FAILURE (Status))
553         {
554             return_ACPI_STATUS (Status);
555         }
556
557         /* Put the resulting object onto the current object stack */
558
559         Status = AcpiDsObjStackPush (ObjDesc, WalkState);
560         if (ACPI_FAILURE (Status))
561         {
562             return_ACPI_STATUS (Status);
563         }
564         ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
565     }
566
567
568     else
569     {
570         /* Check for null name case */
571
572         if (Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
573         {
574             /*
575              * If the name is null, this means that this is an
576              * optional result parameter that was not specified
577              * in the original ASL.  Create a Zero Constant for a
578              * placeholder.  (Store to a constant is a Noop.)
579              */
580             Opcode = AML_ZERO_OP;       /* Has no arguments! */
581
582             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg));
583         }
584
585         else
586         {
587             Opcode = Arg->Common.AmlOpcode;
588         }
589
590         /* Get the object type of the argument */
591
592         OpInfo = AcpiPsGetOpcodeInfo (Opcode);
593         if (OpInfo->ObjectType == ACPI_TYPE_INVALID)
594         {
595             return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
596         }
597
598         if (OpInfo->Flags & AML_HAS_RETVAL)
599         {
600             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
601                 "Argument previously created, already stacked \n"));
602
603             ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (
604                 WalkState->Operands [WalkState->NumOperands - 1], WalkState));
605
606             /*
607              * Use value that was already previously returned
608              * by the evaluation of this argument
609              */
610             Status = AcpiDsResultPopFromBottom (&ObjDesc, WalkState);
611             if (ACPI_FAILURE (Status))
612             {
613                 /*
614                  * Only error is underflow, and this indicates
615                  * a missing or null operand!
616                  */
617                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
618                     AcpiFormatException (Status)));
619                 return_ACPI_STATUS (Status);
620             }
621         }
622         else
623         {
624             /* Create an ACPI_INTERNAL_OBJECT for the argument */
625
626             ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType);
627             if (!ObjDesc)
628             {
629                 return_ACPI_STATUS (AE_NO_MEMORY);
630             }
631
632             /* Initialize the new object */
633
634             Status = AcpiDsInitObjectFromOp (WalkState, Arg,
635                                                 Opcode, &ObjDesc);
636             if (ACPI_FAILURE (Status))
637             {
638                 AcpiUtDeleteObjectDesc (ObjDesc);
639                 return_ACPI_STATUS (Status);
640             }
641         }
642
643         /* Put the operand object on the object stack */
644
645         Status = AcpiDsObjStackPush (ObjDesc, WalkState);
646         if (ACPI_FAILURE (Status))
647         {
648             return_ACPI_STATUS (Status);
649         }
650
651         ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
652     }
653
654     return_ACPI_STATUS (AE_OK);
655 }
656
657
658 /*******************************************************************************
659  *
660  * FUNCTION:    AcpiDsCreateOperands
661  *
662  * PARAMETERS:  FirstArg            - First argument of a parser argument tree
663  *
664  * RETURN:      Status
665  *
666  * DESCRIPTION: Convert an operator's arguments from a parse tree format to
667  *              namespace objects and place those argument object on the object
668  *              stack in preparation for evaluation by the interpreter.
669  *
670  ******************************************************************************/
671
672 ACPI_STATUS
673 AcpiDsCreateOperands (
674     ACPI_WALK_STATE         *WalkState,
675     ACPI_PARSE_OBJECT       *FirstArg)
676 {
677     ACPI_STATUS             Status = AE_OK;
678     ACPI_PARSE_OBJECT       *Arg;
679     UINT32                  ArgCount = 0;
680
681
682     ACPI_FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg);
683
684
685     /* For all arguments in the list... */
686
687     Arg = FirstArg;
688     while (Arg)
689     {
690         Status = AcpiDsCreateOperand (WalkState, Arg, ArgCount);
691         if (ACPI_FAILURE (Status))
692         {
693             goto Cleanup;
694         }
695
696         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n",
697             ArgCount, Arg, FirstArg));
698
699         /* Move on to next argument, if any */
700
701         Arg = Arg->Common.Next;
702         ArgCount++;
703     }
704
705     return_ACPI_STATUS (Status);
706
707
708 Cleanup:
709     /*
710      * We must undo everything done above; meaning that we must
711      * pop everything off of the operand stack and delete those
712      * objects
713      */
714     (void) AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
715
716     ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
717         (ArgCount + 1), AcpiFormatException (Status)));
718     return_ACPI_STATUS (Status);
719 }
720
721