xref: /freebsd/sys/contrib/dev/acpica/components/dispatcher/dswexec.c (revision f976241773df2260e6170317080761d1c5814fe5)
1 /******************************************************************************
2  *
3  * Module Name: dswexec - Dispatcher method execution callbacks;
4  *                        dispatch to interpreter.
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2020, 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  * Alternatively, you may choose to be licensed under the terms of the
118  * following license:
119  *
120  * Redistribution and use in source and binary forms, with or without
121  * modification, are permitted provided that the following conditions
122  * are met:
123  * 1. Redistributions of source code must retain the above copyright
124  *    notice, this list of conditions, and the following disclaimer,
125  *    without modification.
126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127  *    substantially similar to the "NO WARRANTY" disclaimer below
128  *    ("Disclaimer") and any redistribution must be conditioned upon
129  *    including a substantially similar Disclaimer requirement for further
130  *    binary redistribution.
131  * 3. Neither the names of the above-listed copyright holders nor the names
132  *    of any contributors may be used to endorse or promote products derived
133  *    from this software without specific prior written permission.
134  *
135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146  *
147  * Alternatively, you may choose to be licensed under the terms of the
148  * GNU General Public License ("GPL") version 2 as published by the Free
149  * Software Foundation.
150  *
151  *****************************************************************************/
152 
153 #include <contrib/dev/acpica/include/acpi.h>
154 #include <contrib/dev/acpica/include/accommon.h>
155 #include <contrib/dev/acpica/include/acparser.h>
156 #include <contrib/dev/acpica/include/amlcode.h>
157 #include <contrib/dev/acpica/include/acdispat.h>
158 #include <contrib/dev/acpica/include/acinterp.h>
159 #include <contrib/dev/acpica/include/acnamesp.h>
160 #include <contrib/dev/acpica/include/acdebug.h>
161 
162 
163 #define _COMPONENT          ACPI_DISPATCHER
164         ACPI_MODULE_NAME    ("dswexec")
165 
166 /*
167  * Dispatch table for opcode classes
168  */
169 static ACPI_EXECUTE_OP      AcpiGbl_OpTypeDispatch [] =
170 {
171     AcpiExOpcode_0A_0T_1R,
172     AcpiExOpcode_1A_0T_0R,
173     AcpiExOpcode_1A_0T_1R,
174     AcpiExOpcode_1A_1T_0R,
175     AcpiExOpcode_1A_1T_1R,
176     AcpiExOpcode_2A_0T_0R,
177     AcpiExOpcode_2A_0T_1R,
178     AcpiExOpcode_2A_1T_1R,
179     AcpiExOpcode_2A_2T_1R,
180     AcpiExOpcode_3A_0T_0R,
181     AcpiExOpcode_3A_1T_1R,
182     AcpiExOpcode_6A_0T_1R
183 };
184 
185 
186 /*****************************************************************************
187  *
188  * FUNCTION:    AcpiDsGetPredicateValue
189  *
190  * PARAMETERS:  WalkState       - Current state of the parse tree walk
191  *              ResultObj       - if non-zero, pop result from result stack
192  *
193  * RETURN:      Status
194  *
195  * DESCRIPTION: Get the result of a predicate evaluation
196  *
197  ****************************************************************************/
198 
199 ACPI_STATUS
200 AcpiDsGetPredicateValue (
201     ACPI_WALK_STATE         *WalkState,
202     ACPI_OPERAND_OBJECT     *ResultObj)
203 {
204     ACPI_STATUS             Status = AE_OK;
205     ACPI_OPERAND_OBJECT     *ObjDesc;
206     ACPI_OPERAND_OBJECT     *LocalObjDesc = NULL;
207 
208 
209     ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState);
210 
211 
212     WalkState->ControlState->Common.State = 0;
213 
214     if (ResultObj)
215     {
216         Status = AcpiDsResultPop (&ObjDesc, WalkState);
217         if (ACPI_FAILURE (Status))
218         {
219             ACPI_EXCEPTION ((AE_INFO, Status,
220                 "Could not get result from predicate evaluation"));
221 
222             return_ACPI_STATUS (Status);
223         }
224     }
225     else
226     {
227         Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
228         if (ACPI_FAILURE (Status))
229         {
230             return_ACPI_STATUS (Status);
231         }
232 
233         Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
234         if (ACPI_FAILURE (Status))
235         {
236             return_ACPI_STATUS (Status);
237         }
238 
239         ObjDesc = WalkState->Operands [0];
240     }
241 
242     if (!ObjDesc)
243     {
244         ACPI_ERROR ((AE_INFO,
245             "No predicate ObjDesc=%p State=%p",
246             ObjDesc, WalkState));
247 
248         return_ACPI_STATUS (AE_AML_NO_OPERAND);
249     }
250 
251     /*
252      * Result of predicate evaluation must be an Integer
253      * object. Implicitly convert the argument if necessary.
254      */
255     Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc,
256         ACPI_IMPLICIT_CONVERSION);
257     if (ACPI_FAILURE (Status))
258     {
259         goto Cleanup;
260     }
261 
262     if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER)
263     {
264         ACPI_ERROR ((AE_INFO,
265             "Bad predicate (not an integer) ObjDesc=%p State=%p Type=0x%X",
266             ObjDesc, WalkState, ObjDesc->Common.Type));
267 
268         Status = AE_AML_OPERAND_TYPE;
269         goto Cleanup;
270     }
271 
272     /* Truncate the predicate to 32-bits if necessary */
273 
274     (void) AcpiExTruncateFor32bitTable (LocalObjDesc);
275 
276     /*
277      * Save the result of the predicate evaluation on
278      * the control stack
279      */
280     if (LocalObjDesc->Integer.Value)
281     {
282         WalkState->ControlState->Common.Value = TRUE;
283     }
284     else
285     {
286         /*
287          * Predicate is FALSE, we will just toss the
288          * rest of the package
289          */
290         WalkState->ControlState->Common.Value = FALSE;
291         Status = AE_CTRL_FALSE;
292     }
293 
294     /* Predicate can be used for an implicit return value */
295 
296     (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE);
297 
298 
299 Cleanup:
300 
301     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
302         "Completed a predicate eval=%X Op=%p\n",
303         WalkState->ControlState->Common.Value, WalkState->Op));
304 
305     /* Break to debugger to display result */
306 
307     AcpiDbDisplayResultObject (LocalObjDesc, WalkState);
308 
309     /*
310      * Delete the predicate result object (we know that
311      * we don't need it anymore)
312      */
313     if (LocalObjDesc != ObjDesc)
314     {
315         AcpiUtRemoveReference (LocalObjDesc);
316     }
317     AcpiUtRemoveReference (ObjDesc);
318 
319     WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
320     return_ACPI_STATUS (Status);
321 }
322 
323 
324 /*****************************************************************************
325  *
326  * FUNCTION:    AcpiDsExecBeginOp
327  *
328  * PARAMETERS:  WalkState       - Current state of the parse tree walk
329  *              OutOp           - Where to return op if a new one is created
330  *
331  * RETURN:      Status
332  *
333  * DESCRIPTION: Descending callback used during the execution of control
334  *              methods. This is where most operators and operands are
335  *              dispatched to the interpreter.
336  *
337  ****************************************************************************/
338 
339 ACPI_STATUS
340 AcpiDsExecBeginOp (
341     ACPI_WALK_STATE         *WalkState,
342     ACPI_PARSE_OBJECT       **OutOp)
343 {
344     ACPI_PARSE_OBJECT       *Op;
345     ACPI_STATUS             Status = AE_OK;
346     UINT32                  OpcodeClass;
347 
348 
349     ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState);
350 
351 
352     Op = WalkState->Op;
353     if (!Op)
354     {
355         Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
356         if (ACPI_FAILURE (Status))
357         {
358             goto ErrorExit;
359         }
360 
361         Op = *OutOp;
362         WalkState->Op = Op;
363         WalkState->Opcode = Op->Common.AmlOpcode;
364         WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
365 
366         if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
367         {
368             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
369                 "(%s) Popping scope for Op %p\n",
370                 AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
371 
372             Status = AcpiDsScopeStackPop (WalkState);
373             if (ACPI_FAILURE (Status))
374             {
375                 goto ErrorExit;
376             }
377         }
378     }
379 
380     if (Op == WalkState->Origin)
381     {
382         if (OutOp)
383         {
384             *OutOp = Op;
385         }
386 
387         return_ACPI_STATUS (AE_OK);
388     }
389 
390     /*
391      * If the previous opcode was a conditional, this opcode
392      * must be the beginning of the associated predicate.
393      * Save this knowledge in the current scope descriptor
394      */
395     if ((WalkState->ControlState) &&
396         (WalkState->ControlState->Common.State ==
397             ACPI_CONTROL_CONDITIONAL_EXECUTING))
398     {
399         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
400             "Exec predicate Op=%p State=%p\n",
401             Op, WalkState));
402 
403         WalkState->ControlState->Common.State =
404             ACPI_CONTROL_PREDICATE_EXECUTING;
405 
406         /* Save start of predicate */
407 
408         WalkState->ControlState->Control.PredicateOp = Op;
409     }
410 
411 
412     OpcodeClass = WalkState->OpInfo->Class;
413 
414     /* We want to send namepaths to the load code */
415 
416     if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
417     {
418         OpcodeClass = AML_CLASS_NAMED_OBJECT;
419     }
420 
421     /*
422      * Handle the opcode based upon the opcode type
423      */
424     switch (OpcodeClass)
425     {
426     case AML_CLASS_CONTROL:
427 
428         Status = AcpiDsExecBeginControlOp (WalkState, Op);
429         break;
430 
431     case AML_CLASS_NAMED_OBJECT:
432 
433         if (WalkState->WalkType & ACPI_WALK_METHOD)
434         {
435             /*
436              * Found a named object declaration during method execution;
437              * we must enter this object into the namespace. The created
438              * object is temporary and will be deleted upon completion of
439              * the execution of this method.
440              *
441              * Note 10/2010: Except for the Scope() op. This opcode does
442              * not actually create a new object, it refers to an existing
443              * object. However, for Scope(), we want to indeed open a
444              * new scope.
445              */
446             if (Op->Common.AmlOpcode != AML_SCOPE_OP)
447             {
448                 Status = AcpiDsLoad2BeginOp (WalkState, NULL);
449             }
450             else
451             {
452                 Status = AcpiDsScopeStackPush (
453                     Op->Named.Node, Op->Named.Node->Type, WalkState);
454                 if (ACPI_FAILURE (Status))
455                 {
456                     return_ACPI_STATUS (Status);
457                 }
458             }
459         }
460         break;
461 
462     case AML_CLASS_EXECUTE:
463     case AML_CLASS_CREATE:
464 
465         break;
466 
467     default:
468 
469         break;
470     }
471 
472     /* Nothing to do here during method execution */
473 
474     return_ACPI_STATUS (Status);
475 
476 
477 ErrorExit:
478     Status = AcpiDsMethodError (Status, WalkState);
479     return_ACPI_STATUS (Status);
480 }
481 
482 
483 /*****************************************************************************
484  *
485  * FUNCTION:    AcpiDsExecEndOp
486  *
487  * PARAMETERS:  WalkState       - Current state of the parse tree walk
488  *
489  * RETURN:      Status
490  *
491  * DESCRIPTION: Ascending callback used during the execution of control
492  *              methods. The only thing we really need to do here is to
493  *              notice the beginning of IF, ELSE, and WHILE blocks.
494  *
495  ****************************************************************************/
496 
497 ACPI_STATUS
498 AcpiDsExecEndOp (
499     ACPI_WALK_STATE         *WalkState)
500 {
501     ACPI_PARSE_OBJECT       *Op;
502     ACPI_STATUS             Status = AE_OK;
503     UINT32                  OpType;
504     UINT32                  OpClass;
505     ACPI_PARSE_OBJECT       *NextOp;
506     ACPI_PARSE_OBJECT       *FirstArg;
507 
508 
509     ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState);
510 
511 
512     Op = WalkState->Op;
513     OpType = WalkState->OpInfo->Type;
514     OpClass = WalkState->OpInfo->Class;
515 
516     if (OpClass == AML_CLASS_UNKNOWN)
517     {
518         ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode));
519         return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
520     }
521 
522     FirstArg = Op->Common.Value.Arg;
523 
524     /* Init the walk state */
525 
526     WalkState->NumOperands = 0;
527     WalkState->OperandIndex = 0;
528     WalkState->ReturnDesc = NULL;
529     WalkState->ResultObj = NULL;
530 
531     /* Call debugger for single step support (DEBUG build only) */
532 
533     Status = AcpiDbSingleStep (WalkState, Op, OpClass);
534     if (ACPI_FAILURE (Status))
535     {
536         return_ACPI_STATUS (Status);
537     }
538 
539     /* Decode the Opcode Class */
540 
541     switch (OpClass)
542     {
543     case AML_CLASS_ARGUMENT:    /* Constants, literals, etc. */
544 
545         if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
546         {
547             Status = AcpiDsEvaluateNamePath (WalkState);
548             if (ACPI_FAILURE (Status))
549             {
550                 goto Cleanup;
551             }
552         }
553         break;
554 
555     case AML_CLASS_EXECUTE:     /* Most operators with arguments */
556 
557         /* Build resolved operand stack */
558 
559         Status = AcpiDsCreateOperands (WalkState, FirstArg);
560         if (ACPI_FAILURE (Status))
561         {
562             goto Cleanup;
563         }
564 
565         /*
566          * All opcodes require operand resolution, with the only exceptions
567          * being the ObjectType and SizeOf operators.
568          */
569         if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE))
570         {
571             /* Resolve all operands */
572 
573             Status = AcpiExResolveOperands (WalkState->Opcode,
574                 &(WalkState->Operands [WalkState->NumOperands -1]),
575                 WalkState);
576         }
577 
578         if (ACPI_SUCCESS (Status))
579         {
580             /*
581              * Dispatch the request to the appropriate interpreter handler
582              * routine. There is one routine per opcode "type" based upon the
583              * number of opcode arguments and return type.
584              */
585             Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState);
586         }
587         else
588         {
589             /*
590              * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
591              * Local is uninitialized.
592              */
593             if  ((Status == AE_AML_UNINITIALIZED_LOCAL) &&
594                 (WalkState->Opcode == AML_STORE_OP) &&
595                 (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
596                 (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
597                 (WalkState->Operands[0]->Reference.Class ==
598                  WalkState->Operands[1]->Reference.Class) &&
599                 (WalkState->Operands[0]->Reference.Value ==
600                  WalkState->Operands[1]->Reference.Value))
601             {
602                 Status = AE_OK;
603             }
604             else
605             {
606                 ACPI_EXCEPTION ((AE_INFO, Status,
607                     "While resolving operands for [%s]",
608                     AcpiPsGetOpcodeName (WalkState->Opcode)));
609             }
610         }
611 
612         /* Always delete the argument objects and clear the operand stack */
613 
614         AcpiDsClearOperands (WalkState);
615 
616         /*
617          * If a result object was returned from above, push it on the
618          * current result stack
619          */
620         if (ACPI_SUCCESS (Status) &&
621             WalkState->ResultObj)
622         {
623             Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
624         }
625         break;
626 
627     default:
628 
629         switch (OpType)
630         {
631         case AML_TYPE_CONTROL:    /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
632 
633             /* 1 Operand, 0 ExternalResult, 0 InternalResult */
634 
635             Status = AcpiDsExecEndControlOp (WalkState, Op);
636 
637             break;
638 
639         case AML_TYPE_METHOD_CALL:
640             /*
641              * If the method is referenced from within a package
642              * declaration, it is not a invocation of the method, just
643              * a reference to it.
644              */
645             if ((Op->Asl.Parent) &&
646                ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
647                 (Op->Asl.Parent->Asl.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
648             {
649                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
650                     "Method Reference in a Package, Op=%p\n", Op));
651 
652                 Op->Common.Node = (ACPI_NAMESPACE_NODE *)
653                     Op->Asl.Value.Arg->Asl.Node;
654                 AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object);
655                 return_ACPI_STATUS (AE_OK);
656             }
657 
658             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
659                 "Method invocation, Op=%p\n", Op));
660 
661             /*
662              * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
663              * the method Node pointer
664              */
665             /* NextOp points to the op that holds the method name */
666 
667             NextOp = FirstArg;
668 
669             /* NextOp points to first argument op */
670 
671             NextOp = NextOp->Common.Next;
672 
673             /*
674              * Get the method's arguments and put them on the operand stack
675              */
676             Status = AcpiDsCreateOperands (WalkState, NextOp);
677             if (ACPI_FAILURE (Status))
678             {
679                 break;
680             }
681 
682             /*
683              * Since the operands will be passed to another control method,
684              * we must resolve all local references here (Local variables,
685              * arguments to *this* method, etc.)
686              */
687             Status = AcpiDsResolveOperands (WalkState);
688             if (ACPI_FAILURE (Status))
689             {
690                 /* On error, clear all resolved operands */
691 
692                 AcpiDsClearOperands (WalkState);
693                 break;
694             }
695 
696             /*
697              * Tell the walk loop to preempt this running method and
698              * execute the new method
699              */
700             Status = AE_CTRL_TRANSFER;
701 
702             /*
703              * Return now; we don't want to disturb anything,
704              * especially the operand count!
705              */
706             return_ACPI_STATUS (Status);
707 
708         case AML_TYPE_CREATE_FIELD:
709 
710             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
711                 "Executing CreateField Buffer/Index Op=%p\n", Op));
712 
713             Status = AcpiDsLoad2EndOp (WalkState);
714             if (ACPI_FAILURE (Status))
715             {
716                 break;
717             }
718 
719             Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
720             break;
721 
722 
723         case AML_TYPE_CREATE_OBJECT:
724 
725             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
726                 "Executing CreateObject (Buffer/Package) Op=%p Child=%p ParentOpcode=%4.4X\n",
727                 Op, Op->Named.Value.Arg, Op->Common.Parent->Common.AmlOpcode));
728 
729             switch (Op->Common.Parent->Common.AmlOpcode)
730             {
731             case AML_NAME_OP:
732                 /*
733                  * Put the Node on the object stack (Contains the ACPI Name
734                  * of this object)
735                  */
736                 WalkState->Operands[0] = (void *)
737                     Op->Common.Parent->Common.Node;
738                 WalkState->NumOperands = 1;
739 
740                 Status = AcpiDsCreateNode (WalkState,
741                     Op->Common.Parent->Common.Node, Op->Common.Parent);
742                 if (ACPI_FAILURE (Status))
743                 {
744                     break;
745                 }
746 
747                 /* Fall through */
748                 /*lint -fallthrough */
749 
750             case AML_INT_EVAL_SUBTREE_OP:
751 
752                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
753                     AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
754                 break;
755 
756             default:
757 
758                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
759                 break;
760             }
761 
762             /*
763              * If a result object was returned from above, push it on the
764              * current result stack
765              */
766             if (WalkState->ResultObj)
767             {
768                 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
769             }
770             break;
771 
772         case AML_TYPE_NAMED_FIELD:
773         case AML_TYPE_NAMED_COMPLEX:
774         case AML_TYPE_NAMED_SIMPLE:
775         case AML_TYPE_NAMED_NO_OBJ:
776 
777             Status = AcpiDsLoad2EndOp (WalkState);
778             if (ACPI_FAILURE (Status))
779             {
780                 break;
781             }
782 
783             if (Op->Common.AmlOpcode == AML_REGION_OP)
784             {
785                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
786                     "Executing OpRegion Address/Length Op=%p\n", Op));
787 
788                 Status = AcpiDsEvalRegionOperands (WalkState, Op);
789                 if (ACPI_FAILURE (Status))
790                 {
791                     break;
792                 }
793             }
794             else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
795             {
796                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
797                     "Executing DataTableRegion Strings Op=%p\n", Op));
798 
799                 Status = AcpiDsEvalTableRegionOperands (WalkState, Op);
800                 if (ACPI_FAILURE (Status))
801                 {
802                     break;
803                 }
804             }
805             else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
806             {
807                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
808                     "Executing BankField Op=%p\n", Op));
809 
810                 Status = AcpiDsEvalBankFieldOperands (WalkState, Op);
811                 if (ACPI_FAILURE (Status))
812                 {
813                     break;
814                 }
815             }
816             break;
817 
818         case AML_TYPE_UNDEFINED:
819 
820             ACPI_ERROR ((AE_INFO,
821                 "Undefined opcode type Op=%p", Op));
822             return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
823 
824         case AML_TYPE_BOGUS:
825 
826             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
827                 "Internal opcode=%X type Op=%p\n",
828                 WalkState->Opcode, Op));
829             break;
830 
831         default:
832 
833             ACPI_ERROR ((AE_INFO,
834                 "Unimplemented opcode, class=0x%X "
835                 "type=0x%X Opcode=0x%X Op=%p",
836                 OpClass, OpType, Op->Common.AmlOpcode, Op));
837 
838             Status = AE_NOT_IMPLEMENTED;
839             break;
840         }
841     }
842 
843     /*
844      * ACPI 2.0 support for 64-bit integers: Truncate numeric
845      * result value if we are executing from a 32-bit ACPI table
846      */
847     (void) AcpiExTruncateFor32bitTable (WalkState->ResultObj);
848 
849     /*
850      * Check if we just completed the evaluation of a
851      * conditional predicate
852      */
853     if ((ACPI_SUCCESS (Status)) &&
854         (WalkState->ControlState) &&
855         (WalkState->ControlState->Common.State ==
856             ACPI_CONTROL_PREDICATE_EXECUTING) &&
857         (WalkState->ControlState->Control.PredicateOp == Op))
858     {
859         Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
860         WalkState->ResultObj = NULL;
861     }
862 
863 
864 Cleanup:
865 
866     if (WalkState->ResultObj)
867     {
868         /* Break to debugger to display result */
869 
870         AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState);
871 
872         /*
873          * Delete the result op if and only if:
874          * Parent will not use the result -- such as any
875          * non-nested type2 op in a method (parent will be method)
876          */
877         AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
878     }
879 
880 #ifdef _UNDER_DEVELOPMENT
881 
882     if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
883     {
884         AcpiDbMethodEnd (WalkState);
885     }
886 #endif
887 
888     /* Invoke exception handler on error */
889 
890     if (ACPI_FAILURE (Status))
891     {
892         Status = AcpiDsMethodError (Status, WalkState);
893     }
894 
895     /* Always clear the object stack */
896 
897     WalkState->NumOperands = 0;
898     return_ACPI_STATUS (Status);
899 }
900