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.aml_opcode = walk_state->opcode;
188 * Get and append arguments until we find the node that contains
189 * the name (the type ARGP_NAME).
191 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
192 (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
194 acpi_ps_get_next_arg(walk_state,
195 &(walk_state->parser_state),
196 GET_CURRENT_ARG_TYPE(walk_state->
198 if (ACPI_FAILURE(status)) {
199 return_ACPI_STATUS(status);
202 acpi_ps_append_arg(unnamed_op, arg);
203 INCREMENT_ARG_LIST(walk_state->arg_types);
207 * Make sure that we found a NAME and didn't run out of arguments
209 if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
210 return_ACPI_STATUS(AE_AML_NO_OPERAND);
213 /* We know that this arg is a name, move to next arg */
215 INCREMENT_ARG_LIST(walk_state->arg_types);
218 * Find the object. This will either insert the object into
219 * the namespace or simply look it up
221 walk_state->op = NULL;
223 status = walk_state->descending_callback(walk_state, op);
224 if (ACPI_FAILURE(status)) {
225 ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
226 return_ACPI_STATUS(status);
230 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
233 status = acpi_ps_next_parse_state(walk_state, *op, status);
234 if (ACPI_FAILURE(status)) {
235 if (status == AE_CTRL_PENDING) {
236 return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
238 return_ACPI_STATUS(status);
241 acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
244 if ((*op)->common.aml_opcode == AML_REGION_OP) {
246 * Defer final parsing of an operation_region body, because we don't
247 * have enough info in the first pass to parse it correctly (i.e.,
248 * there may be method calls within the term_arg elements of the body.)
250 * However, we must continue parsing because the opregion is not a
251 * standalone package -- we don't know where the end is at this point.
253 * (Length is unknown until parse of the body complete)
255 (*op)->named.data = aml_op_start;
256 (*op)->named.length = 0;
259 return_ACPI_STATUS(AE_OK);
262 /*******************************************************************************
264 * FUNCTION: acpi_ps_create_op
266 * PARAMETERS: walk_state - Current state
267 * aml_op_start - Op start in AML
268 * new_op - Returned Op
272 * DESCRIPTION: Get Op from AML
274 ******************************************************************************/
277 acpi_ps_create_op(struct acpi_walk_state *walk_state,
278 u8 * aml_op_start, union acpi_parse_object **new_op)
280 acpi_status status = AE_OK;
281 union acpi_parse_object *op;
282 union acpi_parse_object *named_op = NULL;
284 ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
286 status = acpi_ps_get_aml_opcode(walk_state);
287 if (status == AE_CTRL_PARSE_CONTINUE) {
288 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
291 /* Create Op structure and append to parent's argument list */
293 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
294 op = acpi_ps_alloc_op(walk_state->opcode);
296 return_ACPI_STATUS(AE_NO_MEMORY);
299 if (walk_state->op_info->flags & AML_NAMED) {
301 acpi_ps_build_named_op(walk_state, aml_op_start, op,
304 if (ACPI_FAILURE(status)) {
305 return_ACPI_STATUS(status);
309 return_ACPI_STATUS(AE_OK);
312 /* Not a named opcode, just allocate Op and append to parent */
314 if (walk_state->op_info->flags & AML_CREATE) {
316 * Backup to beginning of create_xXXfield declaration
317 * body_length is unknown until we parse the body
319 op->named.data = aml_op_start;
320 op->named.length = 0;
323 acpi_ps_append_arg(acpi_ps_get_parent_scope
324 (&(walk_state->parser_state)), op);
326 if (walk_state->descending_callback != NULL) {
328 * Find the object. This will either insert the object into
329 * the namespace or simply look it up
331 walk_state->op = *new_op = op;
333 status = walk_state->descending_callback(walk_state, &op);
334 status = acpi_ps_next_parse_state(walk_state, op, status);
335 if (status == AE_CTRL_PENDING) {
336 status = AE_CTRL_PARSE_PENDING;
340 return_ACPI_STATUS(status);
343 /*******************************************************************************
345 * FUNCTION: acpi_ps_get_arguments
347 * PARAMETERS: walk_state - Current state
348 * aml_op_start - Op start in AML
353 * DESCRIPTION: Get arguments for passed Op.
355 ******************************************************************************/
358 acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
359 u8 * aml_op_start, union acpi_parse_object *op)
361 acpi_status status = AE_OK;
362 union acpi_parse_object *arg = NULL;
364 ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
366 switch (op->common.aml_opcode) {
367 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
368 case AML_WORD_OP: /* AML_WORDDATA_ARG */
369 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
370 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
371 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
373 /* Fill in constant or string argument directly */
375 acpi_ps_get_next_simple_arg(&(walk_state->parser_state),
376 GET_CURRENT_ARG_TYPE(walk_state->
381 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
384 acpi_ps_get_next_namepath(walk_state,
385 &(walk_state->parser_state), op,
387 if (ACPI_FAILURE(status)) {
388 return_ACPI_STATUS(status);
391 walk_state->arg_types = 0;
396 * Op is not a constant or string, append each argument to the Op
398 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types)
399 && !walk_state->arg_count) {
400 walk_state->aml_offset =
401 (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml,
402 walk_state->parser_state.
406 acpi_ps_get_next_arg(walk_state,
407 &(walk_state->parser_state),
409 (walk_state->arg_types), &arg);
410 if (ACPI_FAILURE(status)) {
411 return_ACPI_STATUS(status);
415 arg->common.aml_offset = walk_state->aml_offset;
416 acpi_ps_append_arg(op, arg);
419 INCREMENT_ARG_LIST(walk_state->arg_types);
422 /* Special processing for certain opcodes */
424 /* TBD (remove): Temporary mechanism to disable this code if needed */
426 #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
428 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
429 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
431 * We want to skip If/Else/While constructs during Pass1 because we
432 * want to actually conditionally execute the code during Pass2.
434 * Except for disassembly, where we always want to walk the
435 * If/Else/While packages
437 switch (op->common.aml_opcode) {
442 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
443 "Pass1: Skipping an If/Else/While body\n"));
445 /* Skip body of if/else/while in pass 1 */
447 walk_state->parser_state.aml =
448 walk_state->parser_state.pkg_end;
449 walk_state->arg_count = 0;
458 switch (op->common.aml_opcode) {
461 * Skip parsing of control method because we don't have enough
462 * info in the first pass to parse it correctly.
464 * Save the length and address of the body
466 op->named.data = walk_state->parser_state.aml;
467 op->named.length = (u32)
468 (walk_state->parser_state.pkg_end -
469 walk_state->parser_state.aml);
471 /* Skip body of method */
473 walk_state->parser_state.aml =
474 walk_state->parser_state.pkg_end;
475 walk_state->arg_count = 0;
480 case AML_VAR_PACKAGE_OP:
482 if ((op->common.parent) &&
483 (op->common.parent->common.aml_opcode ==
485 && (walk_state->pass_number <=
486 ACPI_IMODE_LOAD_PASS2)) {
488 * Skip parsing of Buffers and Packages because we don't have
489 * enough info in the first pass to parse them correctly.
491 op->named.data = aml_op_start;
492 op->named.length = (u32)
493 (walk_state->parser_state.pkg_end -
498 walk_state->parser_state.aml =
499 walk_state->parser_state.pkg_end;
500 walk_state->arg_count = 0;
506 if (walk_state->control_state) {
507 walk_state->control_state->control.package_end =
508 walk_state->parser_state.pkg_end;
514 /* No action for all other opcodes */
521 return_ACPI_STATUS(AE_OK);
524 /*******************************************************************************
526 * FUNCTION: acpi_ps_complete_op
528 * PARAMETERS: walk_state - Current state
530 * Status - Parse status before complete Op
534 * DESCRIPTION: Complete Op
536 ******************************************************************************/
539 acpi_ps_complete_op(struct acpi_walk_state *walk_state,
540 union acpi_parse_object **op, acpi_status status)
544 ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
547 * Finished one argument of the containing scope
549 walk_state->parser_state.scope->parse_scope.arg_count--;
551 /* Close this Op (will result in parse subtree deletion) */
553 status2 = acpi_ps_complete_this_op(walk_state, *op);
554 if (ACPI_FAILURE(status2)) {
555 return_ACPI_STATUS(status2);
564 case AE_CTRL_TRANSFER:
566 /* We are about to transfer to a called method */
568 walk_state->prev_op = NULL;
569 walk_state->prev_arg_types = walk_state->arg_types;
570 return_ACPI_STATUS(status);
574 acpi_ps_pop_scope(&(walk_state->parser_state), op,
575 &walk_state->arg_types,
576 &walk_state->arg_count);
579 walk_state->op = *op;
580 walk_state->op_info =
581 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
582 walk_state->opcode = (*op)->common.aml_opcode;
584 status = walk_state->ascending_callback(walk_state);
586 acpi_ps_next_parse_state(walk_state, *op, status);
588 status2 = acpi_ps_complete_this_op(walk_state, *op);
589 if (ACPI_FAILURE(status2)) {
590 return_ACPI_STATUS(status2);
598 case AE_CTRL_CONTINUE:
600 /* Pop off scopes until we find the While */
602 while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
603 acpi_ps_pop_scope(&(walk_state->parser_state), op,
604 &walk_state->arg_types,
605 &walk_state->arg_count);
607 if ((*op)->common.aml_opcode != AML_WHILE_OP) {
608 status2 = acpi_ds_result_stack_pop(walk_state);
609 if (ACPI_FAILURE(status2)) {
610 return_ACPI_STATUS(status2);
615 /* Close this iteration of the While loop */
617 walk_state->op = *op;
618 walk_state->op_info =
619 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
620 walk_state->opcode = (*op)->common.aml_opcode;
622 status = walk_state->ascending_callback(walk_state);
623 status = acpi_ps_next_parse_state(walk_state, *op, status);
625 status2 = acpi_ps_complete_this_op(walk_state, *op);
626 if (ACPI_FAILURE(status2)) {
627 return_ACPI_STATUS(status2);
633 case AE_CTRL_TERMINATE:
639 acpi_ps_complete_this_op(walk_state, *op);
640 if (ACPI_FAILURE(status2)) {
641 return_ACPI_STATUS(status2);
643 status2 = acpi_ds_result_stack_pop(walk_state);
644 if (ACPI_FAILURE(status2)) {
645 return_ACPI_STATUS(status2);
648 acpi_ut_delete_generic_state
649 (acpi_ut_pop_generic_state
650 (&walk_state->control_state));
653 acpi_ps_pop_scope(&(walk_state->parser_state), op,
654 &walk_state->arg_types,
655 &walk_state->arg_count);
659 return_ACPI_STATUS(AE_OK);
661 default: /* All other non-AE_OK status */
666 acpi_ps_complete_this_op(walk_state, *op);
667 if (ACPI_FAILURE(status2)) {
668 return_ACPI_STATUS(status2);
672 acpi_ps_pop_scope(&(walk_state->parser_state), op,
673 &walk_state->arg_types,
674 &walk_state->arg_count);
680 * TBD: Cleanup parse ops on error
683 acpi_ps_pop_scope(parser_state, op,
684 &walk_state->arg_types,
685 &walk_state->arg_count);
688 walk_state->prev_op = NULL;
689 walk_state->prev_arg_types = walk_state->arg_types;
690 return_ACPI_STATUS(status);
693 /* This scope complete? */
695 if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
696 acpi_ps_pop_scope(&(walk_state->parser_state), op,
697 &walk_state->arg_types,
698 &walk_state->arg_count);
699 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
704 return_ACPI_STATUS(AE_OK);
707 /*******************************************************************************
709 * FUNCTION: acpi_ps_complete_final_op
711 * PARAMETERS: walk_state - Current state
713 * Status - Current parse status before complete last
718 * DESCRIPTION: Complete last Op.
720 ******************************************************************************/
723 acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
724 union acpi_parse_object *op, acpi_status status)
728 ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
731 * Complete the last Op (if not completed), and clear the scope stack.
732 * It is easily possible to end an AML "package" with an unbounded number
733 * of open scopes (such as when several ASL blocks are closed with
734 * sequential closing braces). We want to terminate each one cleanly.
736 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
740 if (walk_state->ascending_callback != NULL) {
742 walk_state->op_info =
743 acpi_ps_get_opcode_info(op->common.
745 walk_state->opcode = op->common.aml_opcode;
748 walk_state->ascending_callback(walk_state);
750 acpi_ps_next_parse_state(walk_state, op,
752 if (status == AE_CTRL_PENDING) {
754 acpi_ps_complete_op(walk_state, &op,
756 if (ACPI_FAILURE(status)) {
757 return_ACPI_STATUS(status);
761 if (status == AE_CTRL_TERMINATE) {
768 acpi_ps_complete_this_op
788 return_ACPI_STATUS(status);
791 else if (ACPI_FAILURE(status)) {
793 /* First error is most important */
796 acpi_ps_complete_this_op(walk_state,
798 return_ACPI_STATUS(status);
802 status2 = acpi_ps_complete_this_op(walk_state, op);
803 if (ACPI_FAILURE(status2)) {
804 return_ACPI_STATUS(status2);
808 acpi_ps_pop_scope(&(walk_state->parser_state), &op,
809 &walk_state->arg_types,
810 &walk_state->arg_count);
814 return_ACPI_STATUS(status);
817 /*******************************************************************************
819 * FUNCTION: acpi_ps_parse_loop
821 * PARAMETERS: walk_state - Current state
825 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
828 ******************************************************************************/
830 acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
832 acpi_status status = AE_OK;
833 union acpi_parse_object *op = NULL; /* current op */
834 struct acpi_parse_state *parser_state;
835 u8 *aml_op_start = NULL;
837 ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state);
839 if (walk_state->descending_callback == NULL) {
840 return_ACPI_STATUS(AE_BAD_PARAMETER);
843 parser_state = &walk_state->parser_state;
844 walk_state->arg_types = 0;
846 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
848 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
850 /* We are restarting a preempted control method */
852 if (acpi_ps_has_completed_scope(parser_state)) {
854 * We must check if a predicate to an IF or WHILE statement
857 if ((parser_state->scope->parse_scope.op) &&
858 ((parser_state->scope->parse_scope.op->common.
859 aml_opcode == AML_IF_OP)
860 || (parser_state->scope->parse_scope.op->common.
861 aml_opcode == AML_WHILE_OP))
862 && (walk_state->control_state)
863 && (walk_state->control_state->common.state ==
864 ACPI_CONTROL_PREDICATE_EXECUTING)) {
866 * A predicate was just completed, get the value of the
867 * predicate and branch based on that value
869 walk_state->op = NULL;
871 acpi_ds_get_predicate_value(walk_state,
874 if (ACPI_FAILURE(status)
875 && ((status & AE_CODE_MASK) !=
877 if (status == AE_AML_NO_RETURN_VALUE) {
878 ACPI_EXCEPTION((AE_INFO, status,
879 "Invoked method did not return a value"));
883 ACPI_EXCEPTION((AE_INFO, status,
884 "GetPredicate Failed"));
885 return_ACPI_STATUS(status);
889 acpi_ps_next_parse_state(walk_state, op,
893 acpi_ps_pop_scope(parser_state, &op,
894 &walk_state->arg_types,
895 &walk_state->arg_count);
896 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
897 "Popped scope, Op=%p\n", op));
898 } else if (walk_state->prev_op) {
900 /* We were in the middle of an op */
902 op = walk_state->prev_op;
903 walk_state->arg_types = walk_state->prev_arg_types;
908 /* Iterative parsing loop, while there is more AML to process: */
910 while ((parser_state->aml < parser_state->aml_end) || (op)) {
911 aml_op_start = parser_state->aml;
914 acpi_ps_create_op(walk_state, aml_op_start, &op);
915 if (ACPI_FAILURE(status)) {
916 if (status == AE_CTRL_PARSE_CONTINUE) {
920 if (status == AE_CTRL_PARSE_PENDING) {
925 acpi_ps_complete_op(walk_state, &op,
927 if (ACPI_FAILURE(status)) {
928 return_ACPI_STATUS(status);
934 op->common.aml_offset = walk_state->aml_offset;
936 if (walk_state->op_info) {
937 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
938 "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
939 (u32) op->common.aml_opcode,
940 walk_state->op_info->name, op,
942 op->common.aml_offset));
947 * Start arg_count at zero because we don't know if there are
950 walk_state->arg_count = 0;
952 /* Are there any arguments that must be processed? */
954 if (walk_state->arg_types) {
959 acpi_ps_get_arguments(walk_state, aml_op_start, op);
960 if (ACPI_FAILURE(status)) {
962 acpi_ps_complete_op(walk_state, &op,
964 if (ACPI_FAILURE(status)) {
965 return_ACPI_STATUS(status);
972 /* Check for arguments that need to be processed */
974 if (walk_state->arg_count) {
976 * There are arguments (complex ones), push Op and
977 * prepare for argument
979 status = acpi_ps_push_scope(parser_state, op,
980 walk_state->arg_types,
981 walk_state->arg_count);
982 if (ACPI_FAILURE(status)) {
984 acpi_ps_complete_op(walk_state, &op,
986 if (ACPI_FAILURE(status)) {
987 return_ACPI_STATUS(status);
998 * All arguments have been processed -- Op is complete,
1001 walk_state->op_info =
1002 acpi_ps_get_opcode_info(op->common.aml_opcode);
1003 if (walk_state->op_info->flags & AML_NAMED) {
1004 if (acpi_gbl_depth) {
1008 if (op->common.aml_opcode == AML_REGION_OP) {
1010 * Skip parsing of control method or opregion body,
1011 * because we don't have enough info in the first pass
1012 * to parse them correctly.
1014 * Completed parsing an op_region declaration, we now
1018 (u32) (parser_state->aml - op->named.data);
1022 if (walk_state->op_info->flags & AML_CREATE) {
1024 * Backup to beginning of create_xXXfield declaration (1 for
1027 * body_length is unknown until we parse the body
1030 (u32) (parser_state->aml - op->named.data);
1033 /* This op complete, notify the dispatcher */
1035 if (walk_state->ascending_callback != NULL) {
1036 walk_state->op = op;
1037 walk_state->opcode = op->common.aml_opcode;
1039 status = walk_state->ascending_callback(walk_state);
1041 acpi_ps_next_parse_state(walk_state, op, status);
1042 if (status == AE_CTRL_PENDING) {
1047 status = acpi_ps_complete_op(walk_state, &op, status);
1048 if (ACPI_FAILURE(status)) {
1049 return_ACPI_STATUS(status);
1052 } /* while parser_state->Aml */
1054 status = acpi_ps_complete_final_op(walk_state, op, status);
1055 return_ACPI_STATUS(status);