1 /******************************************************************************
3 * Module Name: psloop - Main AML parse loop
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2007, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 * Parse the AML and build an operation tree as most interpreters, (such as
46 * Perl) do. Parsing is done by hand rather than with a YACC generated parser
47 * to tightly constrain stack and dynamic memory usage. Parsing is kept
48 * flexible and the code fairly compact by parsing based on a list of AML
49 * opcode templates in aml_op_info[].
52 #include <acpi/acpi.h>
53 #include <acpi/acparser.h>
54 #include <acpi/acdispat.h>
55 #include <acpi/amlcode.h>
57 #define _COMPONENT ACPI_PARSER
58 ACPI_MODULE_NAME("psloop")
60 static u32 acpi_gbl_depth = 0;
62 /* Local prototypes */
64 static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
67 acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
69 union acpi_parse_object *unnamed_op,
70 union acpi_parse_object **op);
73 acpi_ps_create_op(struct acpi_walk_state *walk_state,
74 u8 * aml_op_start, union acpi_parse_object **new_op);
77 acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
78 u8 * aml_op_start, union acpi_parse_object *op);
81 acpi_ps_complete_op(struct acpi_walk_state *walk_state,
82 union acpi_parse_object **op, acpi_status status);
85 acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
86 union acpi_parse_object *op, acpi_status status);
88 /*******************************************************************************
90 * FUNCTION: acpi_ps_get_aml_opcode
92 * PARAMETERS: walk_state - Current state
96 * DESCRIPTION: Extract the next AML opcode from the input stream.
98 ******************************************************************************/
100 static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
103 ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
105 walk_state->aml_offset =
106 (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml,
107 walk_state->parser_state.aml_start);
108 walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
111 * First cut to determine what we have found:
112 * 1) A valid AML opcode
114 * 3) An unknown/invalid opcode
116 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
118 switch (walk_state->op_info->class) {
119 case AML_CLASS_ASCII:
120 case AML_CLASS_PREFIX:
122 * Starts with a valid prefix or ASCII char, this is a name
123 * string. Convert the bare name string to a namepath.
125 walk_state->opcode = AML_INT_NAMEPATH_OP;
126 walk_state->arg_types = ARGP_NAMESTRING;
129 case AML_CLASS_UNKNOWN:
131 /* The opcode is unrecognized. Just skip unknown opcodes */
134 "Found unknown opcode %X at AML address %p offset %X, ignoring",
135 walk_state->opcode, walk_state->parser_state.aml,
136 walk_state->aml_offset));
138 ACPI_DUMP_BUFFER(walk_state->parser_state.aml, 128);
140 /* Assume one-byte bad opcode */
142 walk_state->parser_state.aml++;
143 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
147 /* Found opcode info, this is a normal opcode */
149 walk_state->parser_state.aml +=
150 acpi_ps_get_opcode_size(walk_state->opcode);
151 walk_state->arg_types = walk_state->op_info->parse_args;
155 return_ACPI_STATUS(AE_OK);
158 /*******************************************************************************
160 * FUNCTION: acpi_ps_build_named_op
162 * PARAMETERS: walk_state - Current state
163 * aml_op_start - Begin of named Op in AML
164 * unnamed_op - Early Op (not a named Op)
169 * DESCRIPTION: Parse a named Op
171 ******************************************************************************/
174 acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
176 union acpi_parse_object *unnamed_op,
177 union acpi_parse_object **op)
179 acpi_status status = AE_OK;
180 union acpi_parse_object *arg = NULL;
182 ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
184 unnamed_op->common.value.arg = NULL;
185 unnamed_op->common.arg_list_length = 0;
186 unnamed_op->common.aml_opcode = walk_state->opcode;
189 * Get and append arguments until we find the node that contains
190 * the name (the type ARGP_NAME).
192 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
193 (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
195 acpi_ps_get_next_arg(walk_state,
196 &(walk_state->parser_state),
197 GET_CURRENT_ARG_TYPE(walk_state->
199 if (ACPI_FAILURE(status)) {
200 return_ACPI_STATUS(status);
203 acpi_ps_append_arg(unnamed_op, arg);
204 INCREMENT_ARG_LIST(walk_state->arg_types);
208 * Make sure that we found a NAME and didn't run out of arguments
210 if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
211 return_ACPI_STATUS(AE_AML_NO_OPERAND);
214 /* We know that this arg is a name, move to next arg */
216 INCREMENT_ARG_LIST(walk_state->arg_types);
219 * Find the object. This will either insert the object into
220 * the namespace or simply look it up
222 walk_state->op = NULL;
224 status = walk_state->descending_callback(walk_state, op);
225 if (ACPI_FAILURE(status)) {
226 ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
227 return_ACPI_STATUS(status);
231 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
234 status = acpi_ps_next_parse_state(walk_state, *op, status);
235 if (ACPI_FAILURE(status)) {
236 if (status == AE_CTRL_PENDING) {
237 return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
239 return_ACPI_STATUS(status);
242 acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
245 if ((*op)->common.aml_opcode == AML_REGION_OP) {
247 * Defer final parsing of an operation_region body, because we don't
248 * have enough info in the first pass to parse it correctly (i.e.,
249 * there may be method calls within the term_arg elements of the body.)
251 * However, we must continue parsing because the opregion is not a
252 * standalone package -- we don't know where the end is at this point.
254 * (Length is unknown until parse of the body complete)
256 (*op)->named.data = aml_op_start;
257 (*op)->named.length = 0;
260 return_ACPI_STATUS(AE_OK);
263 /*******************************************************************************
265 * FUNCTION: acpi_ps_create_op
267 * PARAMETERS: walk_state - Current state
268 * aml_op_start - Op start in AML
269 * new_op - Returned Op
273 * DESCRIPTION: Get Op from AML
275 ******************************************************************************/
278 acpi_ps_create_op(struct acpi_walk_state *walk_state,
279 u8 * aml_op_start, union acpi_parse_object **new_op)
281 acpi_status status = AE_OK;
282 union acpi_parse_object *op;
283 union acpi_parse_object *named_op = NULL;
284 union acpi_parse_object *parent_scope;
286 const struct acpi_opcode_info *op_info;
288 ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
290 status = acpi_ps_get_aml_opcode(walk_state);
291 if (status == AE_CTRL_PARSE_CONTINUE) {
292 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
295 /* Create Op structure and append to parent's argument list */
297 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
298 op = acpi_ps_alloc_op(walk_state->opcode);
300 return_ACPI_STATUS(AE_NO_MEMORY);
303 if (walk_state->op_info->flags & AML_NAMED) {
305 acpi_ps_build_named_op(walk_state, aml_op_start, op,
308 if (ACPI_FAILURE(status)) {
309 return_ACPI_STATUS(status);
313 return_ACPI_STATUS(AE_OK);
316 /* Not a named opcode, just allocate Op and append to parent */
318 if (walk_state->op_info->flags & AML_CREATE) {
320 * Backup to beginning of create_xXXfield declaration
321 * body_length is unknown until we parse the body
323 op->named.data = aml_op_start;
324 op->named.length = 0;
327 parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
328 acpi_ps_append_arg(parent_scope, op);
332 acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
333 if (op_info->flags & AML_HAS_TARGET) {
335 acpi_ps_get_argument_count(op_info->type);
336 if (parent_scope->common.arg_list_length >
338 op->common.flags |= ACPI_PARSEOP_TARGET;
340 } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) {
341 op->common.flags |= ACPI_PARSEOP_TARGET;
345 if (walk_state->descending_callback != NULL) {
347 * Find the object. This will either insert the object into
348 * the namespace or simply look it up
350 walk_state->op = *new_op = op;
352 status = walk_state->descending_callback(walk_state, &op);
353 status = acpi_ps_next_parse_state(walk_state, op, status);
354 if (status == AE_CTRL_PENDING) {
355 status = AE_CTRL_PARSE_PENDING;
359 return_ACPI_STATUS(status);
362 /*******************************************************************************
364 * FUNCTION: acpi_ps_get_arguments
366 * PARAMETERS: walk_state - Current state
367 * aml_op_start - Op start in AML
372 * DESCRIPTION: Get arguments for passed Op.
374 ******************************************************************************/
377 acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
378 u8 * aml_op_start, union acpi_parse_object *op)
380 acpi_status status = AE_OK;
381 union acpi_parse_object *arg = NULL;
383 ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
385 switch (op->common.aml_opcode) {
386 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
387 case AML_WORD_OP: /* AML_WORDDATA_ARG */
388 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
389 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
390 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
392 /* Fill in constant or string argument directly */
394 acpi_ps_get_next_simple_arg(&(walk_state->parser_state),
395 GET_CURRENT_ARG_TYPE(walk_state->
400 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
403 acpi_ps_get_next_namepath(walk_state,
404 &(walk_state->parser_state), op,
406 if (ACPI_FAILURE(status)) {
407 return_ACPI_STATUS(status);
410 walk_state->arg_types = 0;
415 * Op is not a constant or string, append each argument to the Op
417 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types)
418 && !walk_state->arg_count) {
419 walk_state->aml_offset =
420 (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml,
421 walk_state->parser_state.
425 acpi_ps_get_next_arg(walk_state,
426 &(walk_state->parser_state),
428 (walk_state->arg_types), &arg);
429 if (ACPI_FAILURE(status)) {
430 return_ACPI_STATUS(status);
434 arg->common.aml_offset = walk_state->aml_offset;
435 acpi_ps_append_arg(op, arg);
438 INCREMENT_ARG_LIST(walk_state->arg_types);
441 /* Special processing for certain opcodes */
443 /* TBD (remove): Temporary mechanism to disable this code if needed */
445 #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
447 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
448 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
450 * We want to skip If/Else/While constructs during Pass1 because we
451 * want to actually conditionally execute the code during Pass2.
453 * Except for disassembly, where we always want to walk the
454 * If/Else/While packages
456 switch (op->common.aml_opcode) {
461 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
462 "Pass1: Skipping an If/Else/While body\n"));
464 /* Skip body of if/else/while in pass 1 */
466 walk_state->parser_state.aml =
467 walk_state->parser_state.pkg_end;
468 walk_state->arg_count = 0;
477 switch (op->common.aml_opcode) {
480 * Skip parsing of control method because we don't have enough
481 * info in the first pass to parse it correctly.
483 * Save the length and address of the body
485 op->named.data = walk_state->parser_state.aml;
486 op->named.length = (u32)
487 (walk_state->parser_state.pkg_end -
488 walk_state->parser_state.aml);
490 /* Skip body of method */
492 walk_state->parser_state.aml =
493 walk_state->parser_state.pkg_end;
494 walk_state->arg_count = 0;
499 case AML_VAR_PACKAGE_OP:
501 if ((op->common.parent) &&
502 (op->common.parent->common.aml_opcode ==
504 && (walk_state->pass_number <=
505 ACPI_IMODE_LOAD_PASS2)) {
507 * Skip parsing of Buffers and Packages because we don't have
508 * enough info in the first pass to parse them correctly.
510 op->named.data = aml_op_start;
511 op->named.length = (u32)
512 (walk_state->parser_state.pkg_end -
517 walk_state->parser_state.aml =
518 walk_state->parser_state.pkg_end;
519 walk_state->arg_count = 0;
525 if (walk_state->control_state) {
526 walk_state->control_state->control.package_end =
527 walk_state->parser_state.pkg_end;
533 /* No action for all other opcodes */
540 return_ACPI_STATUS(AE_OK);
543 /*******************************************************************************
545 * FUNCTION: acpi_ps_complete_op
547 * PARAMETERS: walk_state - Current state
549 * Status - Parse status before complete Op
553 * DESCRIPTION: Complete Op
555 ******************************************************************************/
558 acpi_ps_complete_op(struct acpi_walk_state *walk_state,
559 union acpi_parse_object **op, acpi_status status)
563 ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
566 * Finished one argument of the containing scope
568 walk_state->parser_state.scope->parse_scope.arg_count--;
570 /* Close this Op (will result in parse subtree deletion) */
572 status2 = acpi_ps_complete_this_op(walk_state, *op);
573 if (ACPI_FAILURE(status2)) {
574 return_ACPI_STATUS(status2);
583 case AE_CTRL_TRANSFER:
585 /* We are about to transfer to a called method */
587 walk_state->prev_op = NULL;
588 walk_state->prev_arg_types = walk_state->arg_types;
589 return_ACPI_STATUS(status);
593 acpi_ps_pop_scope(&(walk_state->parser_state), op,
594 &walk_state->arg_types,
595 &walk_state->arg_count);
598 walk_state->op = *op;
599 walk_state->op_info =
600 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
601 walk_state->opcode = (*op)->common.aml_opcode;
603 status = walk_state->ascending_callback(walk_state);
605 acpi_ps_next_parse_state(walk_state, *op, status);
607 status2 = acpi_ps_complete_this_op(walk_state, *op);
608 if (ACPI_FAILURE(status2)) {
609 return_ACPI_STATUS(status2);
617 case AE_CTRL_CONTINUE:
619 /* Pop off scopes until we find the While */
621 while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
622 acpi_ps_pop_scope(&(walk_state->parser_state), op,
623 &walk_state->arg_types,
624 &walk_state->arg_count);
627 /* Close this iteration of the While loop */
629 walk_state->op = *op;
630 walk_state->op_info =
631 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
632 walk_state->opcode = (*op)->common.aml_opcode;
634 status = walk_state->ascending_callback(walk_state);
635 status = acpi_ps_next_parse_state(walk_state, *op, status);
637 status2 = acpi_ps_complete_this_op(walk_state, *op);
638 if (ACPI_FAILURE(status2)) {
639 return_ACPI_STATUS(status2);
645 case AE_CTRL_TERMINATE:
651 acpi_ps_complete_this_op(walk_state, *op);
652 if (ACPI_FAILURE(status2)) {
653 return_ACPI_STATUS(status2);
656 acpi_ut_delete_generic_state
657 (acpi_ut_pop_generic_state
658 (&walk_state->control_state));
661 acpi_ps_pop_scope(&(walk_state->parser_state), op,
662 &walk_state->arg_types,
663 &walk_state->arg_count);
667 return_ACPI_STATUS(AE_OK);
669 default: /* All other non-AE_OK status */
674 acpi_ps_complete_this_op(walk_state, *op);
675 if (ACPI_FAILURE(status2)) {
676 return_ACPI_STATUS(status2);
680 acpi_ps_pop_scope(&(walk_state->parser_state), op,
681 &walk_state->arg_types,
682 &walk_state->arg_count);
688 * TBD: Cleanup parse ops on error
691 acpi_ps_pop_scope(parser_state, op,
692 &walk_state->arg_types,
693 &walk_state->arg_count);
696 walk_state->prev_op = NULL;
697 walk_state->prev_arg_types = walk_state->arg_types;
698 return_ACPI_STATUS(status);
701 /* This scope complete? */
703 if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
704 acpi_ps_pop_scope(&(walk_state->parser_state), op,
705 &walk_state->arg_types,
706 &walk_state->arg_count);
707 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
712 return_ACPI_STATUS(AE_OK);
715 /*******************************************************************************
717 * FUNCTION: acpi_ps_complete_final_op
719 * PARAMETERS: walk_state - Current state
721 * Status - Current parse status before complete last
726 * DESCRIPTION: Complete last Op.
728 ******************************************************************************/
731 acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
732 union acpi_parse_object *op, acpi_status status)
736 ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
739 * Complete the last Op (if not completed), and clear the scope stack.
740 * It is easily possible to end an AML "package" with an unbounded number
741 * of open scopes (such as when several ASL blocks are closed with
742 * sequential closing braces). We want to terminate each one cleanly.
744 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
748 if (walk_state->ascending_callback != NULL) {
750 walk_state->op_info =
751 acpi_ps_get_opcode_info(op->common.
753 walk_state->opcode = op->common.aml_opcode;
756 walk_state->ascending_callback(walk_state);
758 acpi_ps_next_parse_state(walk_state, op,
760 if (status == AE_CTRL_PENDING) {
762 acpi_ps_complete_op(walk_state, &op,
764 if (ACPI_FAILURE(status)) {
765 return_ACPI_STATUS(status);
769 if (status == AE_CTRL_TERMINATE) {
776 acpi_ps_complete_this_op
796 return_ACPI_STATUS(status);
799 else if (ACPI_FAILURE(status)) {
801 /* First error is most important */
804 acpi_ps_complete_this_op(walk_state,
806 return_ACPI_STATUS(status);
810 status2 = acpi_ps_complete_this_op(walk_state, op);
811 if (ACPI_FAILURE(status2)) {
812 return_ACPI_STATUS(status2);
816 acpi_ps_pop_scope(&(walk_state->parser_state), &op,
817 &walk_state->arg_types,
818 &walk_state->arg_count);
822 return_ACPI_STATUS(status);
825 /*******************************************************************************
827 * FUNCTION: acpi_ps_parse_loop
829 * PARAMETERS: walk_state - Current state
833 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
836 ******************************************************************************/
838 acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
840 acpi_status status = AE_OK;
841 union acpi_parse_object *op = NULL; /* current op */
842 struct acpi_parse_state *parser_state;
843 u8 *aml_op_start = NULL;
845 ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state);
847 if (walk_state->descending_callback == NULL) {
848 return_ACPI_STATUS(AE_BAD_PARAMETER);
851 parser_state = &walk_state->parser_state;
852 walk_state->arg_types = 0;
854 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
856 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
858 /* We are restarting a preempted control method */
860 if (acpi_ps_has_completed_scope(parser_state)) {
862 * We must check if a predicate to an IF or WHILE statement
865 if ((parser_state->scope->parse_scope.op) &&
866 ((parser_state->scope->parse_scope.op->common.
867 aml_opcode == AML_IF_OP)
868 || (parser_state->scope->parse_scope.op->common.
869 aml_opcode == AML_WHILE_OP))
870 && (walk_state->control_state)
871 && (walk_state->control_state->common.state ==
872 ACPI_CONTROL_PREDICATE_EXECUTING)) {
874 * A predicate was just completed, get the value of the
875 * predicate and branch based on that value
877 walk_state->op = NULL;
879 acpi_ds_get_predicate_value(walk_state,
882 if (ACPI_FAILURE(status)
883 && ((status & AE_CODE_MASK) !=
885 if (status == AE_AML_NO_RETURN_VALUE) {
886 ACPI_EXCEPTION((AE_INFO, status,
887 "Invoked method did not return a value"));
891 ACPI_EXCEPTION((AE_INFO, status,
892 "GetPredicate Failed"));
893 return_ACPI_STATUS(status);
897 acpi_ps_next_parse_state(walk_state, op,
901 acpi_ps_pop_scope(parser_state, &op,
902 &walk_state->arg_types,
903 &walk_state->arg_count);
904 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
905 "Popped scope, Op=%p\n", op));
906 } else if (walk_state->prev_op) {
908 /* We were in the middle of an op */
910 op = walk_state->prev_op;
911 walk_state->arg_types = walk_state->prev_arg_types;
916 /* Iterative parsing loop, while there is more AML to process: */
918 while ((parser_state->aml < parser_state->aml_end) || (op)) {
919 aml_op_start = parser_state->aml;
922 acpi_ps_create_op(walk_state, aml_op_start, &op);
923 if (ACPI_FAILURE(status)) {
924 if (status == AE_CTRL_PARSE_CONTINUE) {
928 if (status == AE_CTRL_PARSE_PENDING) {
933 acpi_ps_complete_op(walk_state, &op,
935 if (ACPI_FAILURE(status)) {
936 return_ACPI_STATUS(status);
942 op->common.aml_offset = walk_state->aml_offset;
944 if (walk_state->op_info) {
945 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
946 "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
947 (u32) op->common.aml_opcode,
948 walk_state->op_info->name, op,
950 op->common.aml_offset));
955 * Start arg_count at zero because we don't know if there are
958 walk_state->arg_count = 0;
960 /* Are there any arguments that must be processed? */
962 if (walk_state->arg_types) {
967 acpi_ps_get_arguments(walk_state, aml_op_start, op);
968 if (ACPI_FAILURE(status)) {
970 acpi_ps_complete_op(walk_state, &op,
972 if (ACPI_FAILURE(status)) {
973 return_ACPI_STATUS(status);
980 /* Check for arguments that need to be processed */
982 if (walk_state->arg_count) {
984 * There are arguments (complex ones), push Op and
985 * prepare for argument
987 status = acpi_ps_push_scope(parser_state, op,
988 walk_state->arg_types,
989 walk_state->arg_count);
990 if (ACPI_FAILURE(status)) {
992 acpi_ps_complete_op(walk_state, &op,
994 if (ACPI_FAILURE(status)) {
995 return_ACPI_STATUS(status);
1006 * All arguments have been processed -- Op is complete,
1009 walk_state->op_info =
1010 acpi_ps_get_opcode_info(op->common.aml_opcode);
1011 if (walk_state->op_info->flags & AML_NAMED) {
1012 if (acpi_gbl_depth) {
1016 if (op->common.aml_opcode == AML_REGION_OP) {
1018 * Skip parsing of control method or opregion body,
1019 * because we don't have enough info in the first pass
1020 * to parse them correctly.
1022 * Completed parsing an op_region declaration, we now
1026 (u32) (parser_state->aml - op->named.data);
1030 if (walk_state->op_info->flags & AML_CREATE) {
1032 * Backup to beginning of create_xXXfield declaration (1 for
1035 * body_length is unknown until we parse the body
1038 (u32) (parser_state->aml - op->named.data);
1041 /* This op complete, notify the dispatcher */
1043 if (walk_state->ascending_callback != NULL) {
1044 walk_state->op = op;
1045 walk_state->opcode = op->common.aml_opcode;
1047 status = walk_state->ascending_callback(walk_state);
1049 acpi_ps_next_parse_state(walk_state, op, status);
1050 if (status == AE_CTRL_PENDING) {
1055 status = acpi_ps_complete_op(walk_state, &op, status);
1056 if (ACPI_FAILURE(status)) {
1057 return_ACPI_STATUS(status);
1060 } /* while parser_state->Aml */
1062 status = acpi_ps_complete_final_op(walk_state, op, status);
1063 return_ACPI_STATUS(status);