xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/parser/psloop.c (revision 91c0454716f24a7454b20f7a54cfe32e288e3710)
1 /******************************************************************************
2  *
3  * Module Name: psloop - Main AML parse loop
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2014, 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 
117 /*
118  * Parse the AML and build an operation tree as most interpreters, (such as
119  * Perl) do. Parsing is done by hand rather than with a YACC generated parser
120  * to tightly constrain stack and dynamic memory usage. Parsing is kept
121  * flexible and the code fairly compact by parsing based on a list of AML
122  * opcode templates in AmlOpInfo[].
123  */
124 
125 #include "acpi.h"
126 #include "accommon.h"
127 #include "acparser.h"
128 #include "acdispat.h"
129 #include "amlcode.h"
130 
131 #define _COMPONENT          ACPI_PARSER
132         ACPI_MODULE_NAME    ("psloop")
133 
134 
135 /* Local prototypes */
136 
137 static ACPI_STATUS
138 AcpiPsGetArguments (
139     ACPI_WALK_STATE         *WalkState,
140     UINT8                   *AmlOpStart,
141     ACPI_PARSE_OBJECT       *Op);
142 
143 static void
144 AcpiPsLinkModuleCode (
145     ACPI_PARSE_OBJECT       *ParentOp,
146     UINT8                   *AmlStart,
147     UINT32                  AmlLength,
148     ACPI_OWNER_ID           OwnerId);
149 
150 
151 /*******************************************************************************
152  *
153  * FUNCTION:    AcpiPsGetArguments
154  *
155  * PARAMETERS:  WalkState           - Current state
156  *              AmlOpStart          - Op start in AML
157  *              Op                  - Current Op
158  *
159  * RETURN:      Status
160  *
161  * DESCRIPTION: Get arguments for passed Op.
162  *
163  ******************************************************************************/
164 
165 static ACPI_STATUS
166 AcpiPsGetArguments (
167     ACPI_WALK_STATE         *WalkState,
168     UINT8                   *AmlOpStart,
169     ACPI_PARSE_OBJECT       *Op)
170 {
171     ACPI_STATUS             Status = AE_OK;
172     ACPI_PARSE_OBJECT       *Arg = NULL;
173     const ACPI_OPCODE_INFO  *OpInfo;
174 
175 
176     ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
177 
178 
179     switch (Op->Common.AmlOpcode)
180     {
181     case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
182     case AML_WORD_OP:       /* AML_WORDDATA_ARG */
183     case AML_DWORD_OP:      /* AML_DWORDATA_ARG */
184     case AML_QWORD_OP:      /* AML_QWORDATA_ARG */
185     case AML_STRING_OP:     /* AML_ASCIICHARLIST_ARG */
186 
187         /* Fill in constant or string argument directly */
188 
189         AcpiPsGetNextSimpleArg (&(WalkState->ParserState),
190             GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
191         break;
192 
193     case AML_INT_NAMEPATH_OP:   /* AML_NAMESTRING_ARG */
194 
195         Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1);
196         if (ACPI_FAILURE (Status))
197         {
198             return_ACPI_STATUS (Status);
199         }
200 
201         WalkState->ArgTypes = 0;
202         break;
203 
204     default:
205         /*
206          * Op is not a constant or string, append each argument to the Op
207          */
208         while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
209         {
210             WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
211                 WalkState->ParserState.AmlStart);
212 
213             Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
214                         GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
215             if (ACPI_FAILURE (Status))
216             {
217                 return_ACPI_STATUS (Status);
218             }
219 
220             if (Arg)
221             {
222                 Arg->Common.AmlOffset = WalkState->AmlOffset;
223                 AcpiPsAppendArg (Op, Arg);
224             }
225 
226             INCREMENT_ARG_LIST (WalkState->ArgTypes);
227         }
228 
229 
230         /*
231          * Handle executable code at "module-level". This refers to
232          * executable opcodes that appear outside of any control method.
233          */
234         if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) &&
235             ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0))
236         {
237             /*
238              * We want to skip If/Else/While constructs during Pass1 because we
239              * want to actually conditionally execute the code during Pass2.
240              *
241              * Except for disassembly, where we always want to walk the
242              * If/Else/While packages
243              */
244             switch (Op->Common.AmlOpcode)
245             {
246             case AML_IF_OP:
247             case AML_ELSE_OP:
248             case AML_WHILE_OP:
249                 /*
250                  * Currently supported module-level opcodes are:
251                  * IF/ELSE/WHILE. These appear to be the most common,
252                  * and easiest to support since they open an AML
253                  * package.
254                  */
255                 if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1)
256                 {
257                     AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart,
258                         (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart),
259                         WalkState->OwnerId);
260                 }
261 
262                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
263                     "Pass1: Skipping an If/Else/While body\n"));
264 
265                 /* Skip body of if/else/while in pass 1 */
266 
267                 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
268                 WalkState->ArgCount = 0;
269                 break;
270 
271             default:
272                 /*
273                  * Check for an unsupported executable opcode at module
274                  * level. We must be in PASS1, the parent must be a SCOPE,
275                  * The opcode class must be EXECUTE, and the opcode must
276                  * not be an argument to another opcode.
277                  */
278                 if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) &&
279                     (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
280                 {
281                     OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
282                     if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
283                         (!Arg))
284                     {
285                         ACPI_WARNING ((AE_INFO,
286                             "Unsupported module-level executable opcode "
287                             "0x%.2X at table offset 0x%.4X",
288                             Op->Common.AmlOpcode,
289                             (UINT32) (ACPI_PTR_DIFF (AmlOpStart,
290                                 WalkState->ParserState.AmlStart) +
291                                 sizeof (ACPI_TABLE_HEADER))));
292                     }
293                 }
294                 break;
295             }
296         }
297 
298         /* Special processing for certain opcodes */
299 
300         switch (Op->Common.AmlOpcode)
301         {
302         case AML_METHOD_OP:
303             /*
304              * Skip parsing of control method because we don't have enough
305              * info in the first pass to parse it correctly.
306              *
307              * Save the length and address of the body
308              */
309             Op->Named.Data = WalkState->ParserState.Aml;
310             Op->Named.Length = (UINT32)
311                 (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml);
312 
313             /* Skip body of method */
314 
315             WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
316             WalkState->ArgCount = 0;
317             break;
318 
319         case AML_BUFFER_OP:
320         case AML_PACKAGE_OP:
321         case AML_VAR_PACKAGE_OP:
322 
323             if ((Op->Common.Parent) &&
324                 (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
325                 (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
326             {
327                 /*
328                  * Skip parsing of Buffers and Packages because we don't have
329                  * enough info in the first pass to parse them correctly.
330                  */
331                 Op->Named.Data = AmlOpStart;
332                 Op->Named.Length = (UINT32)
333                     (WalkState->ParserState.PkgEnd - AmlOpStart);
334 
335                 /* Skip body */
336 
337                 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
338                 WalkState->ArgCount = 0;
339             }
340             break;
341 
342         case AML_WHILE_OP:
343 
344             if (WalkState->ControlState)
345             {
346                 WalkState->ControlState->Control.PackageEnd =
347                     WalkState->ParserState.PkgEnd;
348             }
349             break;
350 
351         default:
352 
353             /* No action for all other opcodes */
354 
355             break;
356         }
357 
358         break;
359     }
360 
361     return_ACPI_STATUS (AE_OK);
362 }
363 
364 
365 /*******************************************************************************
366  *
367  * FUNCTION:    AcpiPsLinkModuleCode
368  *
369  * PARAMETERS:  ParentOp            - Parent parser op
370  *              AmlStart            - Pointer to the AML
371  *              AmlLength           - Length of executable AML
372  *              OwnerId             - OwnerId of module level code
373  *
374  * RETURN:      None.
375  *
376  * DESCRIPTION: Wrap the module-level code with a method object and link the
377  *              object to the global list. Note, the mutex field of the method
378  *              object is used to link multiple module-level code objects.
379  *
380  ******************************************************************************/
381 
382 static void
383 AcpiPsLinkModuleCode (
384     ACPI_PARSE_OBJECT       *ParentOp,
385     UINT8                   *AmlStart,
386     UINT32                  AmlLength,
387     ACPI_OWNER_ID           OwnerId)
388 {
389     ACPI_OPERAND_OBJECT     *Prev;
390     ACPI_OPERAND_OBJECT     *Next;
391     ACPI_OPERAND_OBJECT     *MethodObj;
392     ACPI_NAMESPACE_NODE     *ParentNode;
393 
394 
395     /* Get the tail of the list */
396 
397     Prev = Next = AcpiGbl_ModuleCodeList;
398     while (Next)
399     {
400         Prev = Next;
401         Next = Next->Method.Mutex;
402     }
403 
404     /*
405      * Insert the module level code into the list. Merge it if it is
406      * adjacent to the previous element.
407      */
408     if (!Prev ||
409        ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart))
410     {
411         /* Create, initialize, and link a new temporary method object */
412 
413         MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
414         if (!MethodObj)
415         {
416             return;
417         }
418 
419         if (ParentOp->Common.Node)
420         {
421             ParentNode = ParentOp->Common.Node;
422         }
423         else
424         {
425             ParentNode = AcpiGbl_RootNode;
426         }
427 
428         MethodObj->Method.AmlStart = AmlStart;
429         MethodObj->Method.AmlLength = AmlLength;
430         MethodObj->Method.OwnerId = OwnerId;
431         MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL;
432 
433         /*
434          * Save the parent node in NextObject. This is cheating, but we
435          * don't want to expand the method object.
436          */
437         MethodObj->Method.NextObject =
438             ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode);
439 
440         if (!Prev)
441         {
442             AcpiGbl_ModuleCodeList = MethodObj;
443         }
444         else
445         {
446             Prev->Method.Mutex = MethodObj;
447         }
448     }
449     else
450     {
451         Prev->Method.AmlLength += AmlLength;
452     }
453 }
454 
455 /*******************************************************************************
456  *
457  * FUNCTION:    AcpiPsParseLoop
458  *
459  * PARAMETERS:  WalkState           - Current state
460  *
461  * RETURN:      Status
462  *
463  * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
464  *              a tree of ops.
465  *
466  ******************************************************************************/
467 
468 ACPI_STATUS
469 AcpiPsParseLoop (
470     ACPI_WALK_STATE         *WalkState)
471 {
472     ACPI_STATUS             Status = AE_OK;
473     ACPI_PARSE_OBJECT       *Op = NULL;     /* current op */
474     ACPI_PARSE_STATE        *ParserState;
475     UINT8                   *AmlOpStart = NULL;
476 
477 
478     ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
479 
480 
481     if (WalkState->DescendingCallback == NULL)
482     {
483         return_ACPI_STATUS (AE_BAD_PARAMETER);
484     }
485 
486     ParserState = &WalkState->ParserState;
487     WalkState->ArgTypes = 0;
488 
489 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
490 
491     if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
492     {
493         /* We are restarting a preempted control method */
494 
495         if (AcpiPsHasCompletedScope (ParserState))
496         {
497             /*
498              * We must check if a predicate to an IF or WHILE statement
499              * was just completed
500              */
501             if ((ParserState->Scope->ParseScope.Op) &&
502                ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
503                 (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
504                 (WalkState->ControlState) &&
505                 (WalkState->ControlState->Common.State ==
506                     ACPI_CONTROL_PREDICATE_EXECUTING))
507             {
508                 /*
509                  * A predicate was just completed, get the value of the
510                  * predicate and branch based on that value
511                  */
512                 WalkState->Op = NULL;
513                 Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
514                 if (ACPI_FAILURE (Status) &&
515                     ((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
516                 {
517                     if (Status == AE_AML_NO_RETURN_VALUE)
518                     {
519                         ACPI_EXCEPTION ((AE_INFO, Status,
520                             "Invoked method did not return a value"));
521                     }
522 
523                     ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
524                     return_ACPI_STATUS (Status);
525                 }
526 
527                 Status = AcpiPsNextParseState (WalkState, Op, Status);
528             }
529 
530             AcpiPsPopScope (ParserState, &Op,
531                 &WalkState->ArgTypes, &WalkState->ArgCount);
532             ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
533         }
534         else if (WalkState->PrevOp)
535         {
536             /* We were in the middle of an op */
537 
538             Op = WalkState->PrevOp;
539             WalkState->ArgTypes = WalkState->PrevArgTypes;
540         }
541     }
542 #endif
543 
544     /* Iterative parsing loop, while there is more AML to process: */
545 
546     while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
547     {
548         AmlOpStart = ParserState->Aml;
549         if (!Op)
550         {
551             Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
552             if (ACPI_FAILURE (Status))
553             {
554                 if (Status == AE_CTRL_PARSE_CONTINUE)
555                 {
556                     continue;
557                 }
558 
559                 if (Status == AE_CTRL_PARSE_PENDING)
560                 {
561                     Status = AE_OK;
562                 }
563 
564                 if (Status == AE_CTRL_TERMINATE)
565                 {
566                     return_ACPI_STATUS (Status);
567                 }
568 
569                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
570                 if (ACPI_FAILURE (Status))
571                 {
572                     return_ACPI_STATUS (Status);
573                 }
574 
575                 continue;
576             }
577 
578             Op->Common.AmlOffset = WalkState->AmlOffset;
579 
580             if (WalkState->OpInfo)
581             {
582                 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
583                     "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
584                      (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
585                      Op, ParserState->Aml, Op->Common.AmlOffset));
586             }
587         }
588 
589 
590         /*
591          * Start ArgCount at zero because we don't know if there are
592          * any args yet
593          */
594         WalkState->ArgCount  = 0;
595 
596         /* Are there any arguments that must be processed? */
597 
598         if (WalkState->ArgTypes)
599         {
600             /* Get arguments */
601 
602             Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
603             if (ACPI_FAILURE (Status))
604             {
605                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
606                 if (ACPI_FAILURE (Status))
607                 {
608                     return_ACPI_STATUS (Status);
609                 }
610 
611                 continue;
612             }
613         }
614 
615         /* Check for arguments that need to be processed */
616 
617         if (WalkState->ArgCount)
618         {
619             /*
620              * There are arguments (complex ones), push Op and
621              * prepare for argument
622              */
623             Status = AcpiPsPushScope (ParserState, Op,
624                         WalkState->ArgTypes, WalkState->ArgCount);
625             if (ACPI_FAILURE (Status))
626             {
627                 Status = AcpiPsCompleteOp (WalkState, &Op, Status);
628                 if (ACPI_FAILURE (Status))
629                 {
630                     return_ACPI_STATUS (Status);
631                 }
632 
633                 continue;
634             }
635 
636             Op = NULL;
637             continue;
638         }
639 
640         /*
641          * All arguments have been processed -- Op is complete,
642          * prepare for next
643          */
644         WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
645         if (WalkState->OpInfo->Flags & AML_NAMED)
646         {
647             if (Op->Common.AmlOpcode == AML_REGION_OP ||
648                 Op->Common.AmlOpcode == AML_DATA_REGION_OP)
649             {
650                 /*
651                  * Skip parsing of control method or opregion body,
652                  * because we don't have enough info in the first pass
653                  * to parse them correctly.
654                  *
655                  * Completed parsing an OpRegion declaration, we now
656                  * know the length.
657                  */
658                 Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
659             }
660         }
661 
662         if (WalkState->OpInfo->Flags & AML_CREATE)
663         {
664             /*
665              * Backup to beginning of CreateXXXfield declaration (1 for
666              * Opcode)
667              *
668              * BodyLength is unknown until we parse the body
669              */
670             Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
671         }
672 
673         if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
674         {
675             /*
676              * Backup to beginning of BankField declaration
677              *
678              * BodyLength is unknown until we parse the body
679              */
680             Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
681         }
682 
683         /* This op complete, notify the dispatcher */
684 
685         if (WalkState->AscendingCallback != NULL)
686         {
687             WalkState->Op = Op;
688             WalkState->Opcode = Op->Common.AmlOpcode;
689 
690             Status = WalkState->AscendingCallback (WalkState);
691             Status = AcpiPsNextParseState (WalkState, Op, Status);
692             if (Status == AE_CTRL_PENDING)
693             {
694                 Status = AE_OK;
695             }
696         }
697 
698         Status = AcpiPsCompleteOp (WalkState, &Op, Status);
699         if (ACPI_FAILURE (Status))
700         {
701             return_ACPI_STATUS (Status);
702         }
703 
704     } /* while ParserState->Aml */
705 
706     Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
707     return_ACPI_STATUS (Status);
708 }
709