xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/dispatcher/dswload2.c (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /******************************************************************************
2  *
3  * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************/
115 
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acparser.h"
119 #include "amlcode.h"
120 #include "acdispat.h"
121 #include "acinterp.h"
122 #include "acnamesp.h"
123 #include "acevents.h"
124 
125 #define _COMPONENT          ACPI_DISPATCHER
126         ACPI_MODULE_NAME    ("dswload2")
127 
128 
129 /*******************************************************************************
130  *
131  * FUNCTION:    AcpiDsLoad2BeginOp
132  *
133  * PARAMETERS:  WalkState       - Current state of the parse tree walk
134  *              OutOp           - Wher to return op if a new one is created
135  *
136  * RETURN:      Status
137  *
138  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
139  *
140  ******************************************************************************/
141 
142 ACPI_STATUS
143 AcpiDsLoad2BeginOp (
144     ACPI_WALK_STATE         *WalkState,
145     ACPI_PARSE_OBJECT       **OutOp)
146 {
147     ACPI_PARSE_OBJECT       *Op;
148     ACPI_NAMESPACE_NODE     *Node;
149     ACPI_STATUS             Status;
150     ACPI_OBJECT_TYPE        ObjectType;
151     char                    *BufferPtr;
152     UINT32                  Flags;
153 
154 
155     ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
156 
157 
158     Op = WalkState->Op;
159     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
160 
161     if (Op)
162     {
163         if ((WalkState->ControlState) &&
164             (WalkState->ControlState->Common.State ==
165                 ACPI_CONTROL_CONDITIONAL_EXECUTING))
166         {
167             /* We are executing a while loop outside of a method */
168 
169             Status = AcpiDsExecBeginOp (WalkState, OutOp);
170             return_ACPI_STATUS (Status);
171         }
172 
173         /* We only care about Namespace opcodes here */
174 
175         if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE)   &&
176               (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
177             (!(WalkState->OpInfo->Flags & AML_NAMED)))
178         {
179             return_ACPI_STATUS (AE_OK);
180         }
181 
182         /* Get the name we are going to enter or lookup in the namespace */
183 
184         if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
185         {
186             /* For Namepath op, get the path string */
187 
188             BufferPtr = Op->Common.Value.String;
189             if (!BufferPtr)
190             {
191                 /* No name, just exit */
192 
193                 return_ACPI_STATUS (AE_OK);
194             }
195         }
196         else
197         {
198             /* Get name from the op */
199 
200             BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
201         }
202     }
203     else
204     {
205         /* Get the namestring from the raw AML */
206 
207         BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
208     }
209 
210     /* Map the opcode into an internal object type */
211 
212     ObjectType = WalkState->OpInfo->ObjectType;
213 
214     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
215         "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
216 
217     switch (WalkState->Opcode)
218     {
219     case AML_FIELD_OP:
220     case AML_BANK_FIELD_OP:
221     case AML_INDEX_FIELD_OP:
222 
223         Node = NULL;
224         Status = AE_OK;
225         break;
226 
227     case AML_INT_NAMEPATH_OP:
228         /*
229          * The NamePath is an object reference to an existing object.
230          * Don't enter the name into the namespace, but look it up
231          * for use later.
232          */
233         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
234             ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
235             WalkState, &(Node));
236         break;
237 
238     case AML_SCOPE_OP:
239 
240         /* Special case for Scope(\) -> refers to the Root node */
241 
242         if (Op && (Op->Named.Node == AcpiGbl_RootNode))
243         {
244             Node = Op->Named.Node;
245 
246             Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
247             if (ACPI_FAILURE (Status))
248             {
249                 return_ACPI_STATUS (Status);
250             }
251         }
252         else
253         {
254             /*
255              * The Path is an object reference to an existing object.
256              * Don't enter the name into the namespace, but look it up
257              * for use later.
258              */
259             Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
260                 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
261                 WalkState, &(Node));
262             if (ACPI_FAILURE (Status))
263             {
264 #ifdef ACPI_ASL_COMPILER
265                 if (Status == AE_NOT_FOUND)
266                 {
267                     Status = AE_OK;
268                 }
269                 else
270                 {
271                     ACPI_ERROR_NAMESPACE (BufferPtr, Status);
272                 }
273 #else
274                 ACPI_ERROR_NAMESPACE (BufferPtr, Status);
275 #endif
276                 return_ACPI_STATUS (Status);
277             }
278         }
279 
280         /*
281          * We must check to make sure that the target is
282          * one of the opcodes that actually opens a scope
283          */
284         switch (Node->Type)
285         {
286         case ACPI_TYPE_ANY:
287         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope */
288         case ACPI_TYPE_DEVICE:
289         case ACPI_TYPE_POWER:
290         case ACPI_TYPE_PROCESSOR:
291         case ACPI_TYPE_THERMAL:
292 
293             /* These are acceptable types */
294             break;
295 
296         case ACPI_TYPE_INTEGER:
297         case ACPI_TYPE_STRING:
298         case ACPI_TYPE_BUFFER:
299 
300             /*
301              * These types we will allow, but we will change the type.
302              * This enables some existing code of the form:
303              *
304              *  Name (DEB, 0)
305              *  Scope (DEB) { ... }
306              */
307             ACPI_WARNING ((AE_INFO,
308                 "Type override - [%4.4s] had invalid type (%s) "
309                 "for Scope operator, changed to type ANY",
310                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
311 
312             Node->Type = ACPI_TYPE_ANY;
313             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
314             break;
315 
316         case ACPI_TYPE_METHOD:
317 
318             /*
319              * Allow scope change to root during execution of module-level
320              * code. Root is typed METHOD during this time.
321              */
322             if ((Node == AcpiGbl_RootNode) &&
323                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
324             {
325                 break;
326             }
327 
328             /*lint -fallthrough */
329 
330         default:
331 
332             /* All other types are an error */
333 
334             ACPI_ERROR ((AE_INFO,
335                 "Invalid type (%s) for target of "
336                 "Scope operator [%4.4s] (Cannot override)",
337                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
338 
339             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
340         }
341         break;
342 
343     default:
344 
345         /* All other opcodes */
346 
347         if (Op && Op->Common.Node)
348         {
349             /* This op/node was previously entered into the namespace */
350 
351             Node = Op->Common.Node;
352 
353             if (AcpiNsOpensScope (ObjectType))
354             {
355                 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
356                 if (ACPI_FAILURE (Status))
357                 {
358                     return_ACPI_STATUS (Status);
359                 }
360             }
361 
362             return_ACPI_STATUS (AE_OK);
363         }
364 
365         /*
366          * Enter the named type into the internal namespace. We enter the name
367          * as we go downward in the parse tree. Any necessary subobjects that
368          * involve arguments to the opcode must be created as we go back up the
369          * parse tree later.
370          *
371          * Note: Name may already exist if we are executing a deferred opcode.
372          */
373         if (WalkState->DeferredNode)
374         {
375             /* This name is already in the namespace, get the node */
376 
377             Node = WalkState->DeferredNode;
378             Status = AE_OK;
379             break;
380         }
381 
382         Flags = ACPI_NS_NO_UPSEARCH;
383         if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
384         {
385             /* Execution mode, node cannot already exist, node is temporary */
386 
387             Flags |= ACPI_NS_ERROR_IF_FOUND;
388 
389             if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
390             {
391                 Flags |= ACPI_NS_TEMPORARY;
392             }
393         }
394 
395         /* Add new entry or lookup existing entry */
396 
397         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
398             ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
399 
400         if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
401         {
402             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
403                 "***New Node [%4.4s] %p is temporary\n",
404                 AcpiUtGetNodeName (Node), Node));
405         }
406         break;
407     }
408 
409     if (ACPI_FAILURE (Status))
410     {
411         ACPI_ERROR_NAMESPACE (BufferPtr, Status);
412         return_ACPI_STATUS (Status);
413     }
414 
415     if (!Op)
416     {
417         /* Create a new op */
418 
419         Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
420         if (!Op)
421         {
422             return_ACPI_STATUS (AE_NO_MEMORY);
423         }
424 
425         /* Initialize the new op */
426 
427         if (Node)
428         {
429             Op->Named.Name = Node->Name.Integer;
430         }
431         *OutOp = Op;
432     }
433 
434     /*
435      * Put the Node in the "op" object that the parser uses, so we
436      * can get it again quickly when this scope is closed
437      */
438     Op->Common.Node = Node;
439     return_ACPI_STATUS (Status);
440 }
441 
442 
443 /*******************************************************************************
444  *
445  * FUNCTION:    AcpiDsLoad2EndOp
446  *
447  * PARAMETERS:  WalkState       - Current state of the parse tree walk
448  *
449  * RETURN:      Status
450  *
451  * DESCRIPTION: Ascending callback used during the loading of the namespace,
452  *              both control methods and everything else.
453  *
454  ******************************************************************************/
455 
456 ACPI_STATUS
457 AcpiDsLoad2EndOp (
458     ACPI_WALK_STATE         *WalkState)
459 {
460     ACPI_PARSE_OBJECT       *Op;
461     ACPI_STATUS             Status = AE_OK;
462     ACPI_OBJECT_TYPE        ObjectType;
463     ACPI_NAMESPACE_NODE     *Node;
464     ACPI_PARSE_OBJECT       *Arg;
465     ACPI_NAMESPACE_NODE     *NewNode;
466 #ifndef ACPI_NO_METHOD_EXECUTION
467     UINT32                  i;
468     UINT8                   RegionSpace;
469 #endif
470 
471 
472     ACPI_FUNCTION_TRACE (DsLoad2EndOp);
473 
474     Op = WalkState->Op;
475     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
476         WalkState->OpInfo->Name, Op, WalkState));
477 
478     /* Check if opcode had an associated namespace object */
479 
480     if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
481     {
482         return_ACPI_STATUS (AE_OK);
483     }
484 
485     if (Op->Common.AmlOpcode == AML_SCOPE_OP)
486     {
487         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
488             "Ending scope Op=%p State=%p\n", Op, WalkState));
489     }
490 
491     ObjectType = WalkState->OpInfo->ObjectType;
492 
493     /*
494      * Get the Node/name from the earlier lookup
495      * (It was saved in the *op structure)
496      */
497     Node = Op->Common.Node;
498 
499     /*
500      * Put the Node on the object stack (Contains the ACPI Name of
501      * this object)
502      */
503     WalkState->Operands[0] = (void *) Node;
504     WalkState->NumOperands = 1;
505 
506     /* Pop the scope stack */
507 
508     if (AcpiNsOpensScope (ObjectType) &&
509        (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
510     {
511         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
512             AcpiUtGetTypeName (ObjectType), Op));
513 
514         Status = AcpiDsScopeStackPop (WalkState);
515         if (ACPI_FAILURE (Status))
516         {
517             goto Cleanup;
518         }
519     }
520 
521     /*
522      * Named operations are as follows:
523      *
524      * AML_ALIAS
525      * AML_BANKFIELD
526      * AML_CREATEBITFIELD
527      * AML_CREATEBYTEFIELD
528      * AML_CREATEDWORDFIELD
529      * AML_CREATEFIELD
530      * AML_CREATEQWORDFIELD
531      * AML_CREATEWORDFIELD
532      * AML_DATA_REGION
533      * AML_DEVICE
534      * AML_EVENT
535      * AML_FIELD
536      * AML_INDEXFIELD
537      * AML_METHOD
538      * AML_METHODCALL
539      * AML_MUTEX
540      * AML_NAME
541      * AML_NAMEDFIELD
542      * AML_OPREGION
543      * AML_POWERRES
544      * AML_PROCESSOR
545      * AML_SCOPE
546      * AML_THERMALZONE
547      */
548 
549     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
550         "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
551         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
552 
553     /* Decode the opcode */
554 
555     Arg = Op->Common.Value.Arg;
556 
557     switch (WalkState->OpInfo->Type)
558     {
559 #ifndef ACPI_NO_METHOD_EXECUTION
560 
561     case AML_TYPE_CREATE_FIELD:
562         /*
563          * Create the field object, but the field buffer and index must
564          * be evaluated later during the execution phase
565          */
566         Status = AcpiDsCreateBufferField (Op, WalkState);
567         break;
568 
569      case AML_TYPE_NAMED_FIELD:
570         /*
571          * If we are executing a method, initialize the field
572          */
573         if (WalkState->MethodNode)
574         {
575             Status = AcpiDsInitFieldObjects (Op, WalkState);
576         }
577 
578         switch (Op->Common.AmlOpcode)
579         {
580         case AML_INDEX_FIELD_OP:
581 
582             Status = AcpiDsCreateIndexField (
583                 Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);
584             break;
585 
586         case AML_BANK_FIELD_OP:
587 
588             Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
589             break;
590 
591         case AML_FIELD_OP:
592 
593             Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
594             break;
595 
596         default:
597 
598             /* All NAMED_FIELD opcodes must be handled above */
599             break;
600         }
601         break;
602 
603      case AML_TYPE_NAMED_SIMPLE:
604 
605         Status = AcpiDsCreateOperands (WalkState, Arg);
606         if (ACPI_FAILURE (Status))
607         {
608             goto Cleanup;
609         }
610 
611         switch (Op->Common.AmlOpcode)
612         {
613         case AML_PROCESSOR_OP:
614 
615             Status = AcpiExCreateProcessor (WalkState);
616             break;
617 
618         case AML_POWER_RES_OP:
619 
620             Status = AcpiExCreatePowerResource (WalkState);
621             break;
622 
623         case AML_MUTEX_OP:
624 
625             Status = AcpiExCreateMutex (WalkState);
626             break;
627 
628         case AML_EVENT_OP:
629 
630             Status = AcpiExCreateEvent (WalkState);
631             break;
632 
633         case AML_ALIAS_OP:
634 
635             Status = AcpiExCreateAlias (WalkState);
636             break;
637 
638         default:
639 
640             /* Unknown opcode */
641 
642             Status = AE_OK;
643             goto Cleanup;
644         }
645 
646         /* Delete operands */
647 
648         for (i = 1; i < WalkState->NumOperands; i++)
649         {
650             AcpiUtRemoveReference (WalkState->Operands[i]);
651             WalkState->Operands[i] = NULL;
652         }
653 
654         break;
655 #endif /* ACPI_NO_METHOD_EXECUTION */
656 
657     case AML_TYPE_NAMED_COMPLEX:
658 
659         switch (Op->Common.AmlOpcode)
660         {
661 #ifndef ACPI_NO_METHOD_EXECUTION
662         case AML_REGION_OP:
663         case AML_DATA_REGION_OP:
664 
665             if (Op->Common.AmlOpcode == AML_REGION_OP)
666             {
667                 RegionSpace = (ACPI_ADR_SPACE_TYPE)
668                     ((Op->Common.Value.Arg)->Common.Value.Integer);
669             }
670             else
671             {
672                 RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
673             }
674 
675             /*
676              * The OpRegion is not fully parsed at this time. The only valid
677              * argument is the SpaceId. (We must save the address of the
678              * AML of the address and length operands)
679              *
680              * If we have a valid region, initialize it. The namespace is
681              * unlocked at this point.
682              *
683              * Need to unlock interpreter if it is locked (if we are running
684              * a control method), in order to allow _REG methods to be run
685              * during AcpiEvInitializeRegion.
686              */
687             if (WalkState->MethodNode)
688             {
689                 /*
690                  * Executing a method: initialize the region and unlock
691                  * the interpreter
692                  */
693                 Status = AcpiExCreateRegion (Op->Named.Data,
694                     Op->Named.Length, RegionSpace, WalkState);
695                 if (ACPI_FAILURE (Status))
696                 {
697                     return_ACPI_STATUS (Status);
698                 }
699 
700                 AcpiExExitInterpreter ();
701             }
702 
703             Status = AcpiEvInitializeRegion (
704                 AcpiNsGetAttachedObject (Node), FALSE);
705             if (WalkState->MethodNode)
706             {
707                 AcpiExEnterInterpreter ();
708             }
709 
710             if (ACPI_FAILURE (Status))
711             {
712                 /*
713                  *  If AE_NOT_EXIST is returned, it is not fatal
714                  *  because many regions get created before a handler
715                  *  is installed for said region.
716                  */
717                 if (AE_NOT_EXIST == Status)
718                 {
719                     Status = AE_OK;
720                 }
721             }
722             break;
723 
724         case AML_NAME_OP:
725 
726             Status = AcpiDsCreateNode (WalkState, Node, Op);
727             break;
728 
729         case AML_METHOD_OP:
730             /*
731              * MethodOp PkgLength NameString MethodFlags TermList
732              *
733              * Note: We must create the method node/object pair as soon as we
734              * see the method declaration. This allows later pass1 parsing
735              * of invocations of the method (need to know the number of
736              * arguments.)
737              */
738             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
739                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
740                 WalkState, Op, Op->Named.Node));
741 
742             if (!AcpiNsGetAttachedObject (Op->Named.Node))
743             {
744                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
745                 WalkState->NumOperands = 1;
746 
747                 Status = AcpiDsCreateOperands (
748                     WalkState, Op->Common.Value.Arg);
749                 if (ACPI_SUCCESS (Status))
750                 {
751                     Status = AcpiExCreateMethod (
752                         Op->Named.Data, Op->Named.Length, WalkState);
753                 }
754 
755                 WalkState->Operands[0] = NULL;
756                 WalkState->NumOperands = 0;
757 
758                 if (ACPI_FAILURE (Status))
759                 {
760                     return_ACPI_STATUS (Status);
761                 }
762             }
763             break;
764 
765 #endif /* ACPI_NO_METHOD_EXECUTION */
766 
767         default:
768 
769             /* All NAMED_COMPLEX opcodes must be handled above */
770             break;
771         }
772         break;
773 
774     case AML_CLASS_INTERNAL:
775 
776         /* case AML_INT_NAMEPATH_OP: */
777         break;
778 
779     case AML_CLASS_METHOD_CALL:
780 
781         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
782             "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
783             WalkState, Op, Node));
784 
785         /*
786          * Lookup the method name and save the Node
787          */
788         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
789             ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
790             ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
791             WalkState, &(NewNode));
792         if (ACPI_SUCCESS (Status))
793         {
794             /*
795              * Make sure that what we found is indeed a method
796              * We didn't search for a method on purpose, to see if the name
797              * would resolve
798              */
799             if (NewNode->Type != ACPI_TYPE_METHOD)
800             {
801                 Status = AE_AML_OPERAND_TYPE;
802             }
803 
804             /* We could put the returned object (Node) on the object stack for
805              * later, but for now, we will put it in the "op" object that the
806              * parser uses, so we can get it again at the end of this scope
807              */
808             Op->Common.Node = NewNode;
809         }
810         else
811         {
812             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
813         }
814         break;
815 
816 
817     default:
818 
819         break;
820     }
821 
822 Cleanup:
823 
824     /* Remove the Node pushed at the very beginning */
825 
826     WalkState->Operands[0] = NULL;
827     WalkState->NumOperands = 0;
828     return_ACPI_STATUS (Status);
829 }
830