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