Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / sys / contrib / dev / acpica-unix / dispatcher / dswload2.c
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 - 2011, 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 #define __DSWLOAD2_C__
117
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "acparser.h"
121 #include "amlcode.h"
122 #include "acdispat.h"
123 #include "acinterp.h"
124 #include "acnamesp.h"
125 #include "acevents.h"
126
127 #define _COMPONENT          ACPI_DISPATCHER
128         ACPI_MODULE_NAME    ("dswload2")
129
130
131 /*******************************************************************************
132  *
133  * FUNCTION:    AcpiDsLoad2BeginOp
134  *
135  * PARAMETERS:  WalkState       - Current state of the parse tree walk
136  *              OutOp           - Wher to return op if a new one is created
137  *
138  * RETURN:      Status
139  *
140  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
141  *
142  ******************************************************************************/
143
144 ACPI_STATUS
145 AcpiDsLoad2BeginOp (
146     ACPI_WALK_STATE         *WalkState,
147     ACPI_PARSE_OBJECT       **OutOp)
148 {
149     ACPI_PARSE_OBJECT       *Op;
150     ACPI_NAMESPACE_NODE     *Node;
151     ACPI_STATUS             Status;
152     ACPI_OBJECT_TYPE        ObjectType;
153     char                    *BufferPtr;
154     UINT32                  Flags;
155
156
157     ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
158
159
160     Op = WalkState->Op;
161     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
162
163     if (Op)
164     {
165         if ((WalkState->ControlState) &&
166             (WalkState->ControlState->Common.State ==
167                 ACPI_CONTROL_CONDITIONAL_EXECUTING))
168         {
169             /* We are executing a while loop outside of a method */
170
171             Status = AcpiDsExecBeginOp (WalkState, OutOp);
172             return_ACPI_STATUS (Status);
173         }
174
175         /* We only care about Namespace opcodes here */
176
177         if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE)   &&
178               (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
179             (!(WalkState->OpInfo->Flags & AML_NAMED)))
180         {
181             return_ACPI_STATUS (AE_OK);
182         }
183
184         /* Get the name we are going to enter or lookup in the namespace */
185
186         if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
187         {
188             /* For Namepath op, get the path string */
189
190             BufferPtr = Op->Common.Value.String;
191             if (!BufferPtr)
192             {
193                 /* No name, just exit */
194
195                 return_ACPI_STATUS (AE_OK);
196             }
197         }
198         else
199         {
200             /* Get name from the op */
201
202             BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
203         }
204     }
205     else
206     {
207         /* Get the namestring from the raw AML */
208
209         BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
210     }
211
212     /* Map the opcode into an internal object type */
213
214     ObjectType = WalkState->OpInfo->ObjectType;
215
216     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
217         "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
218
219     switch (WalkState->Opcode)
220     {
221     case AML_FIELD_OP:
222     case AML_BANK_FIELD_OP:
223     case AML_INDEX_FIELD_OP:
224
225         Node = NULL;
226         Status = AE_OK;
227         break;
228
229     case AML_INT_NAMEPATH_OP:
230         /*
231          * The NamePath is an object reference to an existing object.
232          * Don't enter the name into the namespace, but look it up
233          * for use later.
234          */
235         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
236                         ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
237                         WalkState, &(Node));
238         break;
239
240     case AML_SCOPE_OP:
241
242         /* Special case for Scope(\) -> refers to the Root node */
243
244         if (Op && (Op->Named.Node == AcpiGbl_RootNode))
245         {
246             Node = Op->Named.Node;
247
248             Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
249             if (ACPI_FAILURE (Status))
250             {
251                 return_ACPI_STATUS (Status);
252             }
253         }
254         else
255         {
256             /*
257              * The Path is an object reference to an existing object.
258              * Don't enter the name into the namespace, but look it up
259              * for use later.
260              */
261             Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
262                         ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
263                         WalkState, &(Node));
264             if (ACPI_FAILURE (Status))
265             {
266 #ifdef ACPI_ASL_COMPILER
267                 if (Status == AE_NOT_FOUND)
268                 {
269                     Status = AE_OK;
270                 }
271                 else
272                 {
273                     ACPI_ERROR_NAMESPACE (BufferPtr, Status);
274                 }
275 #else
276                 ACPI_ERROR_NAMESPACE (BufferPtr, Status);
277 #endif
278                 return_ACPI_STATUS (Status);
279             }
280         }
281
282         /*
283          * We must check to make sure that the target is
284          * one of the opcodes that actually opens a scope
285          */
286         switch (Node->Type)
287         {
288         case ACPI_TYPE_ANY:
289         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope */
290         case ACPI_TYPE_DEVICE:
291         case ACPI_TYPE_POWER:
292         case ACPI_TYPE_PROCESSOR:
293         case ACPI_TYPE_THERMAL:
294
295             /* These are acceptable types */
296             break;
297
298         case ACPI_TYPE_INTEGER:
299         case ACPI_TYPE_STRING:
300         case ACPI_TYPE_BUFFER:
301
302             /*
303              * These types we will allow, but we will change the type.
304              * This enables some existing code of the form:
305              *
306              *  Name (DEB, 0)
307              *  Scope (DEB) { ... }
308              */
309             ACPI_WARNING ((AE_INFO,
310                 "Type override - [%4.4s] had invalid type (%s) "
311                 "for Scope operator, changed to type ANY\n",
312                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
313
314             Node->Type = ACPI_TYPE_ANY;
315             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
316             break;
317
318         default:
319
320             /* All other types are an error */
321
322             ACPI_ERROR ((AE_INFO,
323                 "Invalid type (%s) for target of "
324                 "Scope operator [%4.4s] (Cannot override)",
325                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
326
327             return (AE_AML_OPERAND_TYPE);
328         }
329         break;
330
331     default:
332
333         /* All other opcodes */
334
335         if (Op && Op->Common.Node)
336         {
337             /* This op/node was previously entered into the namespace */
338
339             Node = Op->Common.Node;
340
341             if (AcpiNsOpensScope (ObjectType))
342             {
343                 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
344                 if (ACPI_FAILURE (Status))
345                 {
346                     return_ACPI_STATUS (Status);
347                 }
348             }
349
350             return_ACPI_STATUS (AE_OK);
351         }
352
353         /*
354          * Enter the named type into the internal namespace. We enter the name
355          * as we go downward in the parse tree. Any necessary subobjects that
356          * involve arguments to the opcode must be created as we go back up the
357          * parse tree later.
358          *
359          * Note: Name may already exist if we are executing a deferred opcode.
360          */
361         if (WalkState->DeferredNode)
362         {
363             /* This name is already in the namespace, get the node */
364
365             Node = WalkState->DeferredNode;
366             Status = AE_OK;
367             break;
368         }
369
370         Flags = ACPI_NS_NO_UPSEARCH;
371         if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
372         {
373             /* Execution mode, node cannot already exist, node is temporary */
374
375             Flags |= ACPI_NS_ERROR_IF_FOUND;
376
377             if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
378             {
379                 Flags |= ACPI_NS_TEMPORARY;
380             }
381         }
382
383         /* Add new entry or lookup existing entry */
384
385         Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
386                     ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
387
388         if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
389         {
390             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
391                 "***New Node [%4.4s] %p is temporary\n",
392                 AcpiUtGetNodeName (Node), Node));
393         }
394         break;
395     }
396
397     if (ACPI_FAILURE (Status))
398     {
399         ACPI_ERROR_NAMESPACE (BufferPtr, Status);
400         return_ACPI_STATUS (Status);
401     }
402
403     if (!Op)
404     {
405         /* Create a new op */
406
407         Op = AcpiPsAllocOp (WalkState->Opcode);
408         if (!Op)
409         {
410             return_ACPI_STATUS (AE_NO_MEMORY);
411         }
412
413         /* Initialize the new op */
414
415         if (Node)
416         {
417             Op->Named.Name = Node->Name.Integer;
418         }
419         *OutOp = Op;
420     }
421
422     /*
423      * Put the Node in the "op" object that the parser uses, so we
424      * can get it again quickly when this scope is closed
425      */
426     Op->Common.Node = Node;
427     return_ACPI_STATUS (Status);
428 }
429
430
431 /*******************************************************************************
432  *
433  * FUNCTION:    AcpiDsLoad2EndOp
434  *
435  * PARAMETERS:  WalkState       - Current state of the parse tree walk
436  *
437  * RETURN:      Status
438  *
439  * DESCRIPTION: Ascending callback used during the loading of the namespace,
440  *              both control methods and everything else.
441  *
442  ******************************************************************************/
443
444 ACPI_STATUS
445 AcpiDsLoad2EndOp (
446     ACPI_WALK_STATE         *WalkState)
447 {
448     ACPI_PARSE_OBJECT       *Op;
449     ACPI_STATUS             Status = AE_OK;
450     ACPI_OBJECT_TYPE        ObjectType;
451     ACPI_NAMESPACE_NODE     *Node;
452     ACPI_PARSE_OBJECT       *Arg;
453     ACPI_NAMESPACE_NODE     *NewNode;
454 #ifndef ACPI_NO_METHOD_EXECUTION
455     UINT32                  i;
456     UINT8                   RegionSpace;
457 #endif
458
459
460     ACPI_FUNCTION_TRACE (DsLoad2EndOp);
461
462     Op = WalkState->Op;
463     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
464             WalkState->OpInfo->Name, Op, WalkState));
465
466     /* Check if opcode had an associated namespace object */
467
468     if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
469     {
470         return_ACPI_STATUS (AE_OK);
471     }
472
473     if (Op->Common.AmlOpcode == AML_SCOPE_OP)
474     {
475         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
476             "Ending scope Op=%p State=%p\n", Op, WalkState));
477     }
478
479     ObjectType = WalkState->OpInfo->ObjectType;
480
481     /*
482      * Get the Node/name from the earlier lookup
483      * (It was saved in the *op structure)
484      */
485     Node = Op->Common.Node;
486
487     /*
488      * Put the Node on the object stack (Contains the ACPI Name of
489      * this object)
490      */
491     WalkState->Operands[0] = (void *) Node;
492     WalkState->NumOperands = 1;
493
494     /* Pop the scope stack */
495
496     if (AcpiNsOpensScope (ObjectType) &&
497        (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
498     {
499         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
500             AcpiUtGetTypeName (ObjectType), Op));
501
502         Status = AcpiDsScopeStackPop (WalkState);
503         if (ACPI_FAILURE (Status))
504         {
505             goto Cleanup;
506         }
507     }
508
509     /*
510      * Named operations are as follows:
511      *
512      * AML_ALIAS
513      * AML_BANKFIELD
514      * AML_CREATEBITFIELD
515      * AML_CREATEBYTEFIELD
516      * AML_CREATEDWORDFIELD
517      * AML_CREATEFIELD
518      * AML_CREATEQWORDFIELD
519      * AML_CREATEWORDFIELD
520      * AML_DATA_REGION
521      * AML_DEVICE
522      * AML_EVENT
523      * AML_FIELD
524      * AML_INDEXFIELD
525      * AML_METHOD
526      * AML_METHODCALL
527      * AML_MUTEX
528      * AML_NAME
529      * AML_NAMEDFIELD
530      * AML_OPREGION
531      * AML_POWERRES
532      * AML_PROCESSOR
533      * AML_SCOPE
534      * AML_THERMALZONE
535      */
536
537     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
538         "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
539         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
540
541     /* Decode the opcode */
542
543     Arg = Op->Common.Value.Arg;
544
545     switch (WalkState->OpInfo->Type)
546     {
547 #ifndef ACPI_NO_METHOD_EXECUTION
548
549     case AML_TYPE_CREATE_FIELD:
550         /*
551          * Create the field object, but the field buffer and index must
552          * be evaluated later during the execution phase
553          */
554         Status = AcpiDsCreateBufferField (Op, WalkState);
555         break;
556
557
558      case AML_TYPE_NAMED_FIELD:
559         /*
560          * If we are executing a method, initialize the field
561          */
562         if (WalkState->MethodNode)
563         {
564             Status = AcpiDsInitFieldObjects (Op, WalkState);
565         }
566
567         switch (Op->Common.AmlOpcode)
568         {
569         case AML_INDEX_FIELD_OP:
570
571             Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
572                         WalkState);
573             break;
574
575         case AML_BANK_FIELD_OP:
576
577             Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
578             break;
579
580         case AML_FIELD_OP:
581
582             Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
583             break;
584
585         default:
586             /* All NAMED_FIELD opcodes must be handled above */
587             break;
588         }
589         break;
590
591
592      case AML_TYPE_NAMED_SIMPLE:
593
594         Status = AcpiDsCreateOperands (WalkState, Arg);
595         if (ACPI_FAILURE (Status))
596         {
597             goto Cleanup;
598         }
599
600         switch (Op->Common.AmlOpcode)
601         {
602         case AML_PROCESSOR_OP:
603
604             Status = AcpiExCreateProcessor (WalkState);
605             break;
606
607         case AML_POWER_RES_OP:
608
609             Status = AcpiExCreatePowerResource (WalkState);
610             break;
611
612         case AML_MUTEX_OP:
613
614             Status = AcpiExCreateMutex (WalkState);
615             break;
616
617         case AML_EVENT_OP:
618
619             Status = AcpiExCreateEvent (WalkState);
620             break;
621
622
623         case AML_ALIAS_OP:
624
625             Status = AcpiExCreateAlias (WalkState);
626             break;
627
628         default:
629             /* Unknown opcode */
630
631             Status = AE_OK;
632             goto Cleanup;
633         }
634
635         /* Delete operands */
636
637         for (i = 1; i < WalkState->NumOperands; i++)
638         {
639             AcpiUtRemoveReference (WalkState->Operands[i]);
640             WalkState->Operands[i] = NULL;
641         }
642
643         break;
644 #endif /* ACPI_NO_METHOD_EXECUTION */
645
646     case AML_TYPE_NAMED_COMPLEX:
647
648         switch (Op->Common.AmlOpcode)
649         {
650 #ifndef ACPI_NO_METHOD_EXECUTION
651         case AML_REGION_OP:
652         case AML_DATA_REGION_OP:
653
654             if (Op->Common.AmlOpcode == AML_REGION_OP)
655             {
656                 RegionSpace = (ACPI_ADR_SPACE_TYPE)
657                       ((Op->Common.Value.Arg)->Common.Value.Integer);
658             }
659             else
660             {
661                 RegionSpace = REGION_DATA_TABLE;
662             }
663
664             /*
665              * The OpRegion is not fully parsed at this time. The only valid
666              * argument is the SpaceId. (We must save the address of the
667              * AML of the address and length operands)
668              *
669              * If we have a valid region, initialize it. The namespace is
670              * unlocked at this point.
671              *
672              * Need to unlock interpreter if it is locked (if we are running
673              * a control method), in order to allow _REG methods to be run
674              * during AcpiEvInitializeRegion.
675              */
676             if (WalkState->MethodNode)
677             {
678                 /*
679                  * Executing a method: initialize the region and unlock
680                  * the interpreter
681                  */
682                 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
683                             RegionSpace, WalkState);
684                 if (ACPI_FAILURE (Status))
685                 {
686                     return (Status);
687                 }
688
689                 AcpiExExitInterpreter ();
690             }
691
692             Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
693                         FALSE);
694             if (WalkState->MethodNode)
695             {
696                 AcpiExEnterInterpreter ();
697             }
698
699             if (ACPI_FAILURE (Status))
700             {
701                 /*
702                  *  If AE_NOT_EXIST is returned, it is not fatal
703                  *  because many regions get created before a handler
704                  *  is installed for said region.
705                  */
706                 if (AE_NOT_EXIST == Status)
707                 {
708                     Status = AE_OK;
709                 }
710             }
711             break;
712
713
714         case AML_NAME_OP:
715
716             Status = AcpiDsCreateNode (WalkState, Node, Op);
717             break;
718
719
720         case AML_METHOD_OP:
721             /*
722              * MethodOp PkgLength NameString MethodFlags TermList
723              *
724              * Note: We must create the method node/object pair as soon as we
725              * see the method declaration. This allows later pass1 parsing
726              * of invocations of the method (need to know the number of
727              * arguments.)
728              */
729             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
730                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
731                 WalkState, Op, Op->Named.Node));
732
733             if (!AcpiNsGetAttachedObject (Op->Named.Node))
734             {
735                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
736                 WalkState->NumOperands = 1;
737
738                 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
739                 if (ACPI_SUCCESS (Status))
740                 {
741                     Status = AcpiExCreateMethod (Op->Named.Data,
742                                         Op->Named.Length, WalkState);
743                 }
744                 WalkState->Operands[0] = NULL;
745                 WalkState->NumOperands = 0;
746
747                 if (ACPI_FAILURE (Status))
748                 {
749                     return_ACPI_STATUS (Status);
750                 }
751             }
752             break;
753
754 #endif /* ACPI_NO_METHOD_EXECUTION */
755
756         default:
757             /* All NAMED_COMPLEX opcodes must be handled above */
758             break;
759         }
760         break;
761
762
763     case AML_CLASS_INTERNAL:
764
765         /* case AML_INT_NAMEPATH_OP: */
766         break;
767
768
769     case AML_CLASS_METHOD_CALL:
770
771         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
772             "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
773             WalkState, Op, Node));
774
775         /*
776          * Lookup the method name and save the Node
777          */
778         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
779                         ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
780                         ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
781                         WalkState, &(NewNode));
782         if (ACPI_SUCCESS (Status))
783         {
784             /*
785              * Make sure that what we found is indeed a method
786              * We didn't search for a method on purpose, to see if the name
787              * would resolve
788              */
789             if (NewNode->Type != ACPI_TYPE_METHOD)
790             {
791                 Status = AE_AML_OPERAND_TYPE;
792             }
793
794             /* We could put the returned object (Node) on the object stack for
795              * later, but for now, we will put it in the "op" object that the
796              * parser uses, so we can get it again at the end of this scope
797              */
798             Op->Common.Node = NewNode;
799         }
800         else
801         {
802             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
803         }
804         break;
805
806
807     default:
808         break;
809     }
810
811 Cleanup:
812
813     /* Remove the Node pushed at the very beginning */
814
815     WalkState->Operands[0] = NULL;
816     WalkState->NumOperands = 0;
817     return_ACPI_STATUS (Status);
818 }