OSDN Git Service

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