* Intel ACPI 20030228 distribution with local DragonFly changes.
[dragonfly.git] / sys / contrib / dev / acpica / dswexec.c
1 /******************************************************************************
2  *
3  * Module Name: dswexec - Dispatcher method execution callbacks;
4  *                        dispatch to interpreter.
5  *              $Revision: 98 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dswexec.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
118
119 #define __DSWEXEC_C__
120
121 #include "acpi.h"
122 #include "acparser.h"
123 #include "amlcode.h"
124 #include "acdispat.h"
125 #include "acinterp.h"
126 #include "acnamesp.h"
127 #include "acdebug.h"
128
129
130 #define _COMPONENT          ACPI_DISPATCHER
131         ACPI_MODULE_NAME    ("dswexec")
132
133 /*
134  * Dispatch table for opcode classes
135  */
136 static ACPI_EXECUTE_OP      AcpiGbl_OpTypeDispatch [] = {
137                             AcpiExOpcode_1A_0T_0R,
138                             AcpiExOpcode_1A_0T_1R,
139                             AcpiExOpcode_1A_1T_0R,
140                             AcpiExOpcode_1A_1T_1R,
141                             AcpiExOpcode_2A_0T_0R,
142                             AcpiExOpcode_2A_0T_1R,
143                             AcpiExOpcode_2A_1T_1R,
144                             AcpiExOpcode_2A_2T_1R,
145                             AcpiExOpcode_3A_0T_0R,
146                             AcpiExOpcode_3A_1T_1R,
147                             AcpiExOpcode_6A_0T_1R};
148
149 /*****************************************************************************
150  *
151  * FUNCTION:    AcpiDsGetPredicateValue
152  *
153  * PARAMETERS:  WalkState       - Current state of the parse tree walk
154  *
155  * RETURN:      Status
156  *
157  * DESCRIPTION: Get the result of a predicate evaluation
158  *
159  ****************************************************************************/
160
161 ACPI_STATUS
162 AcpiDsGetPredicateValue (
163     ACPI_WALK_STATE         *WalkState,
164     ACPI_OPERAND_OBJECT     *ResultObj)
165 {
166     ACPI_STATUS             Status = AE_OK;
167     ACPI_OPERAND_OBJECT     *ObjDesc;
168
169
170     ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState);
171
172
173     WalkState->ControlState->Common.State = 0;
174
175     if (ResultObj)
176     {
177         Status = AcpiDsResultPop (&ObjDesc, WalkState);
178         if (ACPI_FAILURE (Status))
179         {
180             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
181                 "Could not get result from predicate evaluation, %s\n",
182                 AcpiFormatException (Status)));
183
184             return_ACPI_STATUS (Status);
185         }
186     }
187     else
188     {
189         Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
190         if (ACPI_FAILURE (Status))
191         {
192             return_ACPI_STATUS (Status);
193         }
194
195         Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
196         if (ACPI_FAILURE (Status))
197         {
198             return_ACPI_STATUS (Status);
199         }
200
201         ObjDesc = WalkState->Operands [0];
202     }
203
204     if (!ObjDesc)
205     {
206         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate ObjDesc=%p State=%p\n",
207             ObjDesc, WalkState));
208
209         return_ACPI_STATUS (AE_AML_NO_OPERAND);
210     }
211
212     /*
213      * Result of predicate evaluation currently must
214      * be a number
215      */
216     if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)
217     {
218         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
219             "Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n",
220             ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc)));
221
222         Status = AE_AML_OPERAND_TYPE;
223         goto Cleanup;
224     }
225
226     /* Truncate the predicate to 32-bits if necessary */
227
228     AcpiExTruncateFor32bitTable (ObjDesc);
229
230     /*
231      * Save the result of the predicate evaluation on
232      * the control stack
233      */
234     if (ObjDesc->Integer.Value)
235     {
236         WalkState->ControlState->Common.Value = TRUE;
237     }
238     else
239     {
240         /*
241          * Predicate is FALSE, we will just toss the
242          * rest of the package
243          */
244         WalkState->ControlState->Common.Value = FALSE;
245         Status = AE_CTRL_FALSE;
246     }
247
248
249 Cleanup:
250
251     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
252         WalkState->ControlState->Common.Value, WalkState->Op));
253
254      /* Break to debugger to display result */
255
256     ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState));
257
258     /*
259      * Delete the predicate result object (we know that
260      * we don't need it anymore)
261      */
262     AcpiUtRemoveReference (ObjDesc);
263
264     WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
265     return_ACPI_STATUS (Status);
266 }
267
268
269 /*****************************************************************************
270  *
271  * FUNCTION:    AcpiDsExecBeginOp
272  *
273  * PARAMETERS:  WalkState       - Current state of the parse tree walk
274  *              OutOp           - Return op if a new one is created
275  *
276  * RETURN:      Status
277  *
278  * DESCRIPTION: Descending callback used during the execution of control
279  *              methods.  This is where most operators and operands are
280  *              dispatched to the interpreter.
281  *
282  ****************************************************************************/
283
284 ACPI_STATUS
285 AcpiDsExecBeginOp (
286     ACPI_WALK_STATE         *WalkState,
287     ACPI_PARSE_OBJECT       **OutOp)
288 {
289     ACPI_PARSE_OBJECT       *Op;
290     ACPI_STATUS             Status = AE_OK;
291     UINT32                  OpcodeClass;
292
293
294     ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState);
295
296
297     Op = WalkState->Op;
298     if (!Op)
299     {
300         Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
301         if (ACPI_FAILURE (Status))
302         {
303             return_ACPI_STATUS (Status);
304         }
305
306         Op = *OutOp;
307         WalkState->Op = Op;
308         WalkState->Opcode = Op->Common.AmlOpcode;
309         WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
310
311         if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
312         {
313             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
314                 AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
315
316             Status = AcpiDsScopeStackPop (WalkState);
317             if (ACPI_FAILURE (Status))
318             {
319                 return_ACPI_STATUS (Status);
320             }
321         }
322     }
323
324     if (Op == WalkState->Origin)
325     {
326         if (OutOp)
327         {
328             *OutOp = Op;
329         }
330
331         return_ACPI_STATUS (AE_OK);
332     }
333
334     /*
335      * If the previous opcode was a conditional, this opcode
336      * must be the beginning of the associated predicate.
337      * Save this knowledge in the current scope descriptor
338      */
339     if ((WalkState->ControlState) &&
340         (WalkState->ControlState->Common.State ==
341             ACPI_CONTROL_CONDITIONAL_EXECUTING))
342     {
343         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
344                         Op, WalkState));
345
346         WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING;
347
348         /* Save start of predicate */
349
350         WalkState->ControlState->Control.PredicateOp = Op;
351     }
352
353
354     OpcodeClass = WalkState->OpInfo->Class;
355
356     /* We want to send namepaths to the load code */
357
358     if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
359     {
360         OpcodeClass = AML_CLASS_NAMED_OBJECT;
361     }
362
363     /*
364      * Handle the opcode based upon the opcode type
365      */
366     switch (OpcodeClass)
367     {
368     case AML_CLASS_CONTROL:
369
370         Status = AcpiDsResultStackPush (WalkState);
371         if (ACPI_FAILURE (Status))
372         {
373             return_ACPI_STATUS (Status);
374         }
375
376         Status = AcpiDsExecBeginControlOp (WalkState, Op);
377         break;
378
379
380     case AML_CLASS_NAMED_OBJECT:
381
382         if (WalkState->WalkType == ACPI_WALK_METHOD)
383         {
384             /*
385              * Found a named object declaration during method
386              * execution;  we must enter this object into the
387              * namespace.  The created object is temporary and
388              * will be deleted upon completion of the execution
389              * of this method.
390              */
391             Status = AcpiDsLoad2BeginOp (WalkState, NULL);
392         }
393
394         if (Op->Common.AmlOpcode == AML_REGION_OP)
395         {
396             Status = AcpiDsResultStackPush (WalkState);
397         }
398         break;
399
400
401     case AML_CLASS_EXECUTE:
402     case AML_CLASS_CREATE:
403
404         /* most operators with arguments */
405         /* Start a new result/operand state */
406
407         Status = AcpiDsResultStackPush (WalkState);
408         break;
409
410
411     default:
412         break;
413     }
414
415     /* Nothing to do here during method execution */
416
417     return_ACPI_STATUS (Status);
418 }
419
420
421 /*****************************************************************************
422  *
423  * FUNCTION:    AcpiDsExecEndOp
424  *
425  * PARAMETERS:  WalkState       - Current state of the parse tree walk
426  *              Op              - Op that has been just been completed in the
427  *                                walk;  Arguments have now been evaluated.
428  *
429  * RETURN:      Status
430  *
431  * DESCRIPTION: Ascending callback used during the execution of control
432  *              methods.  The only thing we really need to do here is to
433  *              notice the beginning of IF, ELSE, and WHILE blocks.
434  *
435  ****************************************************************************/
436
437 ACPI_STATUS
438 AcpiDsExecEndOp (
439     ACPI_WALK_STATE         *WalkState)
440 {
441     ACPI_PARSE_OBJECT       *Op;
442     ACPI_STATUS             Status = AE_OK;
443     UINT32                  OpType;
444     UINT32                  OpClass;
445     ACPI_PARSE_OBJECT       *NextOp;
446     ACPI_PARSE_OBJECT       *FirstArg;
447
448
449     ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState);
450
451
452     Op      = WalkState->Op;
453     OpType  = WalkState->OpInfo->Type;
454     OpClass = WalkState->OpInfo->Class;
455
456     if (OpClass == AML_CLASS_UNKNOWN)
457     {
458         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode));
459         return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
460     }
461
462     FirstArg = Op->Common.Value.Arg;
463
464     /* Init the walk state */
465
466     WalkState->NumOperands = 0;
467     WalkState->ReturnDesc = NULL;
468     WalkState->ResultObj = NULL;
469
470     /* Call debugger for single step support (DEBUG build only) */
471
472     ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
473     ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
474
475     /* Decode the Opcode Class */
476
477     switch (OpClass)
478     {
479     case AML_CLASS_ARGUMENT:    /* constants, literals, etc. -- do nothing */
480         break;
481
482
483     case AML_CLASS_EXECUTE:     /* most operators with arguments */
484
485         /* Build resolved operand stack */
486
487         Status = AcpiDsCreateOperands (WalkState, FirstArg);
488         if (ACPI_FAILURE (Status))
489         {
490             goto Cleanup;
491         }
492
493         /* Done with this result state (Now that operand stack is built) */
494
495         Status = AcpiDsResultStackPop (WalkState);
496         if (ACPI_FAILURE (Status))
497         {
498             goto Cleanup;
499         }
500
501         /* Resolve all operands */
502
503         Status = AcpiExResolveOperands (WalkState->Opcode,
504                         &(WalkState->Operands [WalkState->NumOperands -1]),
505                         WalkState);
506         if (ACPI_SUCCESS (Status))
507         {
508             ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
509                             AcpiPsGetOpcodeName (WalkState->Opcode),
510                             WalkState->NumOperands, "after ExResolveOperands");
511
512             /*
513              * Dispatch the request to the appropriate interpreter handler
514              * routine.  There is one routine per opcode "type" based upon the
515              * number of opcode arguments and return type.
516              */
517             Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState);
518         }
519         else
520         {
521             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
522                 "[%s]: Could not resolve operands, %s\n",
523                 AcpiPsGetOpcodeName (WalkState->Opcode),
524                 AcpiFormatException (Status)));
525         }
526
527         /* Always delete the argument objects and clear the operand stack */
528
529         AcpiDsClearOperands (WalkState);
530
531         /*
532          * If a result object was returned from above, push it on the
533          * current result stack
534          */
535         if (ACPI_SUCCESS (Status) &&
536             WalkState->ResultObj)
537         {
538             Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
539         }
540
541         break;
542
543
544     default:
545
546         switch (OpType)
547         {
548         case AML_TYPE_CONTROL:    /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
549
550             /* 1 Operand, 0 ExternalResult, 0 InternalResult */
551
552             Status = AcpiDsExecEndControlOp (WalkState, Op);
553             if (ACPI_FAILURE (Status))
554             {
555                 break;
556             }
557
558             Status = AcpiDsResultStackPop (WalkState);
559             break;
560
561
562         case AML_TYPE_METHOD_CALL:
563
564             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op));
565
566             /*
567              * (AML_METHODCALL) Op->Value->Arg->Node contains
568              * the method Node pointer
569              */
570             /* NextOp points to the op that holds the method name */
571
572             NextOp = FirstArg;
573
574             /* NextOp points to first argument op */
575
576             NextOp = NextOp->Common.Next;
577
578             /*
579              * Get the method's arguments and put them on the operand stack
580              */
581             Status = AcpiDsCreateOperands (WalkState, NextOp);
582             if (ACPI_FAILURE (Status))
583             {
584                 break;
585             }
586
587             /*
588              * Since the operands will be passed to another control method,
589              * we must resolve all local references here (Local variables,
590              * arguments to *this* method, etc.)
591              */
592             Status = AcpiDsResolveOperands (WalkState);
593             if (ACPI_FAILURE (Status))
594             {
595                 /* On error, clear all resolved operands */
596
597                 AcpiDsClearOperands (WalkState);
598                 break;
599             }
600
601             /*
602              * Tell the walk loop to preempt this running method and
603              * execute the new method
604              */
605             Status = AE_CTRL_TRANSFER;
606
607             /*
608              * Return now; we don't want to disturb anything,
609              * especially the operand count!
610              */
611             return_ACPI_STATUS (Status);
612
613
614         case AML_TYPE_CREATE_FIELD:
615
616             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
617                 "Executing CreateField Buffer/Index Op=%p\n", Op));
618
619             Status = AcpiDsLoad2EndOp (WalkState);
620             if (ACPI_FAILURE (Status))
621             {
622                 break;
623             }
624
625             Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
626             break;
627
628
629         case AML_TYPE_CREATE_OBJECT:
630
631             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
632                 "Executing CreateObject (Buffer/Package) Op=%p\n", Op));
633
634             switch (Op->Common.Parent->Common.AmlOpcode)
635             {
636             case AML_NAME_OP:
637
638                 /*
639                  * Put the Node on the object stack (Contains the ACPI Name of
640                  * this object)
641                  */
642                 WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node;
643                 WalkState->NumOperands = 1;
644
645                 Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent);
646                 if (ACPI_FAILURE (Status))
647                 {
648                     break;
649                 }
650
651                 /* Fall through */
652                 /*lint -fallthrough */
653
654             case AML_INT_EVAL_SUBTREE_OP:
655
656                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
657                                 AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
658                 break;
659
660             default:
661
662                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
663                 break;
664             }
665
666             /*
667              * If a result object was returned from above, push it on the
668              * current result stack
669              */
670             if (ACPI_SUCCESS (Status) &&
671                 WalkState->ResultObj)
672             {
673                 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
674             }
675             break;
676
677
678         case AML_TYPE_NAMED_FIELD:
679         case AML_TYPE_NAMED_COMPLEX:
680         case AML_TYPE_NAMED_SIMPLE:
681         case AML_TYPE_NAMED_NO_OBJ:
682
683             Status = AcpiDsLoad2EndOp (WalkState);
684             if (ACPI_FAILURE (Status))
685             {
686                 break;
687             }
688
689             if (Op->Common.AmlOpcode == AML_REGION_OP)
690             {
691                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
692                     "Executing OpRegion Address/Length Op=%p\n", Op));
693
694                 Status = AcpiDsEvalRegionOperands (WalkState, Op);
695                 if (ACPI_FAILURE (Status))
696                 {
697                     break;
698                 }
699
700                 Status = AcpiDsResultStackPop (WalkState);
701             }
702
703             break;
704
705
706         case AML_TYPE_UNDEFINED:
707
708             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", Op));
709             return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
710
711
712         case AML_TYPE_BOGUS:
713
714             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
715                 "Internal opcode=%X type Op=%p\n",
716                 WalkState->Opcode, Op));
717             break;
718
719
720         default:
721
722             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
723                 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
724                 OpClass, OpType, Op->Common.AmlOpcode, Op));
725
726             Status = AE_NOT_IMPLEMENTED;
727             break;
728         }
729     }
730
731     /*
732      * ACPI 2.0 support for 64-bit integers: Truncate numeric
733      * result value if we are executing from a 32-bit ACPI table
734      */
735     AcpiExTruncateFor32bitTable (WalkState->ResultObj);
736
737     /*
738      * Check if we just completed the evaluation of a
739      * conditional predicate
740      */
741
742     if ((WalkState->ControlState) &&
743         (WalkState->ControlState->Common.State ==
744             ACPI_CONTROL_PREDICATE_EXECUTING) &&
745         (WalkState->ControlState->Control.PredicateOp == Op))
746     {
747         Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
748         WalkState->ResultObj = NULL;
749     }
750
751
752 Cleanup:
753     if (WalkState->ResultObj)
754     {
755         /* Break to debugger to display result */
756
757         ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState));
758
759         /*
760          * Delete the result op if and only if:
761          * Parent will not use the result -- such as any
762          * non-nested type2 op in a method (parent will be method)
763          */
764         AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
765     }
766
767 #if _UNDER_DEVELOPMENT
768
769     if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
770     {
771         AcpiDbMethodEnd (WalkState);
772     }
773 #endif
774
775     /* Always clear the object stack */
776
777     WalkState->NumOperands = 0;
778     return_ACPI_STATUS (Status);
779 }
780
781