1 /******************************************************************************
3 * Module Name: psobject - Support for parse objects
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
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
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
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;
37 * The above copyright and patent license is granted only if the following
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.
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
80 * 4. Disclaimer and Export Compliance
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
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
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
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.
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.
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.
150 *****************************************************************************/
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/acconvert.h>
158 #define _COMPONENT ACPI_PARSER
159 ACPI_MODULE_NAME ("psobject")
162 /* Local prototypes */
166 ACPI_WALK_STATE *WalkState);
169 /*******************************************************************************
171 * FUNCTION: AcpiPsGetAmlOpcode
173 * PARAMETERS: WalkState - Current state
177 * DESCRIPTION: Extract the next AML opcode from the input stream.
179 ******************************************************************************/
183 ACPI_WALK_STATE *WalkState)
188 ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
191 WalkState->Aml = WalkState->ParserState.Aml;
192 WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
195 * First cut to determine what we have found:
196 * 1) A valid AML opcode
198 * 3) An unknown/invalid opcode
200 WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
202 switch (WalkState->OpInfo->Class)
204 case AML_CLASS_ASCII:
205 case AML_CLASS_PREFIX:
207 * Starts with a valid prefix or ASCII char, this is a name
208 * string. Convert the bare name string to a namepath.
210 WalkState->Opcode = AML_INT_NAMEPATH_OP;
211 WalkState->ArgTypes = ARGP_NAMESTRING;
214 case AML_CLASS_UNKNOWN:
216 /* The opcode is unrecognized. Complain and skip unknown opcodes */
218 if (WalkState->PassNumber == 2)
220 AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
221 WalkState->ParserState.AmlStart);
223 ACPI_ERROR ((AE_INFO,
224 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
226 (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER))));
228 ACPI_DUMP_BUFFER ((WalkState->ParserState.Aml - 16), 48);
230 #ifdef ACPI_ASL_COMPILER
232 * This is executed for the disassembler only. Output goes
233 * to the disassembled ASL output file.
236 "/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
238 (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER)));
240 ACPI_ERROR ((AE_INFO,
241 "Aborting disassembly, AML byte code is corrupt"));
243 /* Dump the context surrounding the invalid opcode */
245 AcpiUtDumpBuffer (((UINT8 *) WalkState->ParserState.Aml - 16),
247 (AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16));
248 AcpiOsPrintf (" */\n");
251 * Just abort the disassembly, cannot continue because the
252 * parser is essentially lost. The disassembler can then
253 * randomly fail because an ill-constructed parse tree
256 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
260 /* Increment past one-byte or two-byte opcode */
262 WalkState->ParserState.Aml++;
263 if (WalkState->Opcode > 0xFF) /* Can only happen if first byte is 0x5B */
265 WalkState->ParserState.Aml++;
268 return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
272 /* Found opcode info, this is a normal opcode */
274 WalkState->ParserState.Aml +=
275 AcpiPsGetOpcodeSize (WalkState->Opcode);
276 WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
280 return_ACPI_STATUS (AE_OK);
284 /*******************************************************************************
286 * FUNCTION: AcpiPsBuildNamedOp
288 * PARAMETERS: WalkState - Current state
289 * AmlOpStart - Begin of named Op in AML
290 * UnnamedOp - Early Op (not a named Op)
295 * DESCRIPTION: Parse a named Op
297 ******************************************************************************/
301 ACPI_WALK_STATE *WalkState,
303 ACPI_PARSE_OBJECT *UnnamedOp,
304 ACPI_PARSE_OBJECT **Op)
306 ACPI_STATUS Status = AE_OK;
307 ACPI_PARSE_OBJECT *Arg = NULL;
310 ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
313 UnnamedOp->Common.Value.Arg = NULL;
314 UnnamedOp->Common.ArgListLength = 0;
315 UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
318 * Get and append arguments until we find the node that contains
319 * the name (the type ARGP_NAME).
321 while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
322 (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
324 ASL_CV_CAPTURE_COMMENTS (WalkState);
325 Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
326 GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
327 if (ACPI_FAILURE (Status))
329 return_ACPI_STATUS (Status);
332 AcpiPsAppendArg (UnnamedOp, Arg);
333 INCREMENT_ARG_LIST (WalkState->ArgTypes);
336 /* are there any inline comments associated with the NameSeg?? If so, save this. */
338 ASL_CV_CAPTURE_COMMENTS (WalkState);
340 #ifdef ACPI_ASL_COMPILER
341 if (AcpiGbl_CurrentInlineComment != NULL)
343 UnnamedOp->Common.NameComment = AcpiGbl_CurrentInlineComment;
344 AcpiGbl_CurrentInlineComment = NULL;
349 * Make sure that we found a NAME and didn't run out of arguments
351 if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
353 return_ACPI_STATUS (AE_AML_NO_OPERAND);
356 /* We know that this arg is a name, move to next arg */
358 INCREMENT_ARG_LIST (WalkState->ArgTypes);
361 * Find the object. This will either insert the object into
362 * the namespace or simply look it up
364 WalkState->Op = NULL;
366 Status = WalkState->DescendingCallback (WalkState, Op);
367 if (ACPI_FAILURE (Status))
369 if (Status != AE_CTRL_TERMINATE)
371 ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
373 return_ACPI_STATUS (Status);
378 return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
381 Status = AcpiPsNextParseState (WalkState, *Op, Status);
382 if (ACPI_FAILURE (Status))
384 if (Status == AE_CTRL_PENDING)
386 Status = AE_CTRL_PARSE_PENDING;
388 return_ACPI_STATUS (Status);
391 AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
393 #ifdef ACPI_ASL_COMPILER
395 /* save any comments that might be associated with UnnamedOp. */
397 (*Op)->Common.InlineComment = UnnamedOp->Common.InlineComment;
398 (*Op)->Common.EndNodeComment = UnnamedOp->Common.EndNodeComment;
399 (*Op)->Common.CloseBraceComment = UnnamedOp->Common.CloseBraceComment;
400 (*Op)->Common.NameComment = UnnamedOp->Common.NameComment;
401 (*Op)->Common.CommentList = UnnamedOp->Common.CommentList;
402 (*Op)->Common.EndBlkComment = UnnamedOp->Common.EndBlkComment;
403 (*Op)->Common.CvFilename = UnnamedOp->Common.CvFilename;
404 (*Op)->Common.CvParentFilename = UnnamedOp->Common.CvParentFilename;
405 (*Op)->Named.Aml = UnnamedOp->Common.Aml;
407 UnnamedOp->Common.InlineComment = NULL;
408 UnnamedOp->Common.EndNodeComment = NULL;
409 UnnamedOp->Common.CloseBraceComment = NULL;
410 UnnamedOp->Common.NameComment = NULL;
411 UnnamedOp->Common.CommentList = NULL;
412 UnnamedOp->Common.EndBlkComment = NULL;
415 if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
416 (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
419 * Defer final parsing of an OperationRegion body, because we don't
420 * have enough info in the first pass to parse it correctly (i.e.,
421 * there may be method calls within the TermArg elements of the body.)
423 * However, we must continue parsing because the opregion is not a
424 * standalone package -- we don't know where the end is at this point.
426 * (Length is unknown until parse of the body complete)
428 (*Op)->Named.Data = AmlOpStart;
429 (*Op)->Named.Length = 0;
432 return_ACPI_STATUS (AE_OK);
436 /*******************************************************************************
438 * FUNCTION: AcpiPsCreateOp
440 * PARAMETERS: WalkState - Current state
441 * AmlOpStart - Op start in AML
442 * NewOp - Returned Op
446 * DESCRIPTION: Get Op from AML
448 ******************************************************************************/
452 ACPI_WALK_STATE *WalkState,
454 ACPI_PARSE_OBJECT **NewOp)
456 ACPI_STATUS Status = AE_OK;
457 ACPI_PARSE_OBJECT *Op;
458 ACPI_PARSE_OBJECT *NamedOp = NULL;
459 ACPI_PARSE_OBJECT *ParentScope;
461 const ACPI_OPCODE_INFO *OpInfo;
464 ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
467 Status = AcpiPsGetAmlOpcode (WalkState);
468 if (Status == AE_CTRL_PARSE_CONTINUE)
470 return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
472 if (ACPI_FAILURE (Status))
474 return_ACPI_STATUS (Status);
477 /* Create Op structure and append to parent's argument list */
479 WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
480 Op = AcpiPsAllocOp (WalkState->Opcode, AmlOpStart);
483 return_ACPI_STATUS (AE_NO_MEMORY);
486 if (WalkState->OpInfo->Flags & AML_NAMED)
488 Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
491 #ifdef ACPI_ASL_COMPILER
492 if (AcpiGbl_DisasmFlag && WalkState->Opcode == AML_EXTERNAL_OP &&
493 Status == AE_NOT_FOUND)
496 * If parsing of AML_EXTERNAL_OP's name path fails, then skip
497 * past this opcode and keep parsing. This is a much better
498 * alternative than to abort the entire disassembler. At this
499 * point, the ParserState is at the end of the namepath of the
500 * external declaration opcode. Setting WalkState->Aml to
501 * WalkState->ParserState.Aml + 2 moves increments the
502 * WalkState->Aml past the object type and the paramcount of the
505 WalkState->Aml = WalkState->ParserState.Aml + 2;
506 WalkState->ParserState.Aml = WalkState->Aml;
507 return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
510 if (ACPI_FAILURE (Status))
512 return_ACPI_STATUS (Status);
516 return_ACPI_STATUS (AE_OK);
519 /* Not a named opcode, just allocate Op and append to parent */
521 if (WalkState->OpInfo->Flags & AML_CREATE)
524 * Backup to beginning of CreateXXXfield declaration
525 * BodyLength is unknown until we parse the body
527 Op->Named.Data = AmlOpStart;
528 Op->Named.Length = 0;
531 if (WalkState->Opcode == AML_BANK_FIELD_OP)
534 * Backup to beginning of BankField declaration
535 * BodyLength is unknown until we parse the body
537 Op->Named.Data = AmlOpStart;
538 Op->Named.Length = 0;
541 ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
542 AcpiPsAppendArg (ParentScope, Op);
546 OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
547 if (OpInfo->Flags & AML_HAS_TARGET)
549 ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
550 if (ParentScope->Common.ArgListLength > ArgumentCount)
552 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
557 * Special case for both Increment() and Decrement(), where
558 * the lone argument is both a source and a target.
560 else if ((ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) ||
561 (ParentScope->Common.AmlOpcode == AML_DECREMENT_OP))
563 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
567 if (WalkState->DescendingCallback != NULL)
570 * Find the object. This will either insert the object into
571 * the namespace or simply look it up
573 WalkState->Op = *NewOp = Op;
575 Status = WalkState->DescendingCallback (WalkState, &Op);
576 Status = AcpiPsNextParseState (WalkState, Op, Status);
577 if (Status == AE_CTRL_PENDING)
579 Status = AE_CTRL_PARSE_PENDING;
583 return_ACPI_STATUS (Status);
587 /*******************************************************************************
589 * FUNCTION: AcpiPsCompleteOp
591 * PARAMETERS: WalkState - Current state
593 * Status - Parse status before complete Op
597 * DESCRIPTION: Complete Op
599 ******************************************************************************/
603 ACPI_WALK_STATE *WalkState,
604 ACPI_PARSE_OBJECT **Op,
610 ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
614 * Finished one argument of the containing scope
616 WalkState->ParserState.Scope->ParseScope.ArgCount--;
618 /* Close this Op (will result in parse subtree deletion) */
620 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
621 if (ACPI_FAILURE (Status2))
623 return_ACPI_STATUS (Status2);
634 case AE_CTRL_TRANSFER:
636 /* We are about to transfer to a called method */
638 WalkState->PrevOp = NULL;
639 WalkState->PrevArgTypes = WalkState->ArgTypes;
640 return_ACPI_STATUS (Status);
644 AcpiPsPopScope (&(WalkState->ParserState), Op,
645 &WalkState->ArgTypes, &WalkState->ArgCount);
650 WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
651 WalkState->Opcode = (*Op)->Common.AmlOpcode;
653 Status = WalkState->AscendingCallback (WalkState);
654 Status = AcpiPsNextParseState (WalkState, *Op, Status);
656 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
657 if (ACPI_FAILURE (Status2))
659 return_ACPI_STATUS (Status2);
667 case AE_CTRL_CONTINUE:
669 /* Pop off scopes until we find the While */
671 while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
673 AcpiPsPopScope (&(WalkState->ParserState), Op,
674 &WalkState->ArgTypes, &WalkState->ArgCount);
677 /* Close this iteration of the While loop */
680 WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
681 WalkState->Opcode = (*Op)->Common.AmlOpcode;
683 Status = WalkState->AscendingCallback (WalkState);
684 Status = AcpiPsNextParseState (WalkState, *Op, Status);
686 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
687 if (ACPI_FAILURE (Status2))
689 return_ACPI_STATUS (Status2);
695 case AE_CTRL_TERMINATE:
702 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
703 if (ACPI_FAILURE (Status2))
705 return_ACPI_STATUS (Status2);
708 AcpiUtDeleteGenericState (
709 AcpiUtPopGenericState (&WalkState->ControlState));
712 AcpiPsPopScope (&(WalkState->ParserState), Op,
713 &WalkState->ArgTypes, &WalkState->ArgCount);
717 return_ACPI_STATUS (AE_OK);
719 default: /* All other non-AE_OK status */
725 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
726 if (ACPI_FAILURE (Status2))
728 return_ACPI_STATUS (Status2);
732 AcpiPsPopScope (&(WalkState->ParserState), Op,
733 &WalkState->ArgTypes, &WalkState->ArgCount);
740 * TBD: Cleanup parse ops on error
744 AcpiPsPopScope (ParserState, Op,
745 &WalkState->ArgTypes, &WalkState->ArgCount);
748 WalkState->PrevOp = NULL;
749 WalkState->PrevArgTypes = WalkState->ArgTypes;
750 return_ACPI_STATUS (Status);
753 /* This scope complete? */
755 if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
757 AcpiPsPopScope (&(WalkState->ParserState), Op,
758 &WalkState->ArgTypes, &WalkState->ArgCount);
759 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
766 return_ACPI_STATUS (AE_OK);
770 /*******************************************************************************
772 * FUNCTION: AcpiPsCompleteFinalOp
774 * PARAMETERS: WalkState - Current state
776 * Status - Current parse status before complete last
781 * DESCRIPTION: Complete last Op.
783 ******************************************************************************/
786 AcpiPsCompleteFinalOp (
787 ACPI_WALK_STATE *WalkState,
788 ACPI_PARSE_OBJECT *Op,
794 ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
798 * Complete the last Op (if not completed), and clear the scope stack.
799 * It is easily possible to end an AML "package" with an unbounded number
800 * of open scopes (such as when several ASL blocks are closed with
801 * sequential closing braces). We want to terminate each one cleanly.
803 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
808 if (WalkState->AscendingCallback != NULL)
811 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
812 WalkState->Opcode = Op->Common.AmlOpcode;
814 Status = WalkState->AscendingCallback (WalkState);
815 Status = AcpiPsNextParseState (WalkState, Op, Status);
816 if (Status == AE_CTRL_PENDING)
818 Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
819 if (ACPI_FAILURE (Status))
821 return_ACPI_STATUS (Status);
825 if (Status == AE_CTRL_TERMINATE)
834 Status2 = AcpiPsCompleteThisOp (WalkState, Op);
835 if (ACPI_FAILURE (Status2))
837 return_ACPI_STATUS (Status2);
841 AcpiPsPopScope (&(WalkState->ParserState), &Op,
842 &WalkState->ArgTypes, &WalkState->ArgCount);
846 return_ACPI_STATUS (Status);
849 else if (ACPI_FAILURE (Status))
851 /* First error is most important */
853 (void) AcpiPsCompleteThisOp (WalkState, Op);
854 return_ACPI_STATUS (Status);
858 Status2 = AcpiPsCompleteThisOp (WalkState, Op);
859 if (ACPI_FAILURE (Status2))
861 return_ACPI_STATUS (Status2);
865 AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
866 &WalkState->ArgCount);
870 return_ACPI_STATUS (Status);