^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Module Name: psloop - Main AML parse loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Parse the AML and build an operation tree as most interpreters, (such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Perl) do. Parsing is done by hand rather than with a YACC generated parser
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * to tightly constrain stack and dynamic memory usage. Parsing is kept
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * flexible and the code fairly compact by parsing based on a list of AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * opcode templates in aml_op_info[].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "acconvert.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define _COMPONENT ACPI_PARSER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ACPI_MODULE_NAME("psloop")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u8 * aml_op_start, union acpi_parse_object *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * FUNCTION: acpi_ps_get_arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * PARAMETERS: walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * aml_op_start - Op start in AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * op - Current Op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * DESCRIPTION: Get arguments for passed Op.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u8 * aml_op_start, union acpi_parse_object *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) union acpi_parse_object *arg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "Get arguments for opcode [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) op->common.aml_op_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) switch (op->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) case AML_WORD_OP: /* AML_WORDDATA_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) case AML_DWORD_OP: /* AML_DWORDATA_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) case AML_QWORD_OP: /* AML_QWORDATA_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* Fill in constant or string argument directly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) acpi_ps_get_next_simple_arg(&(walk_state->parser_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) GET_CURRENT_ARG_TYPE(walk_state->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) arg_types),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) status = acpi_ps_get_next_namepath(walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) &(walk_state->parser_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ACPI_POSSIBLE_METHOD_CALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) walk_state->arg_types = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * Op is not a constant or string, append each argument to the Op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) !walk_state->arg_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) walk_state->aml = walk_state->parser_state.aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) switch (op->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) case AML_METHOD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) case AML_BUFFER_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) case AML_PACKAGE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) case AML_VARIABLE_PACKAGE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) case AML_WHILE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ASL_CV_CAPTURE_COMMENTS(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) acpi_ps_get_next_arg(walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) &(walk_state->parser_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) GET_CURRENT_ARG_TYPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) (walk_state->arg_types), &arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) acpi_ps_append_arg(op, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) INCREMENT_ARG_LIST(walk_state->arg_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) "Final argument count: %8.8X pass %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) walk_state->arg_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) walk_state->pass_number));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Special processing for certain opcodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) switch (op->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) case AML_METHOD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * Skip parsing of control method because we don't have enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * info in the first pass to parse it correctly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * Save the length and address of the body
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) op->named.data = walk_state->parser_state.aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) op->named.length = (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) (walk_state->parser_state.pkg_end -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) walk_state->parser_state.aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* Skip body of method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) walk_state->parser_state.pkg_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) walk_state->arg_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) case AML_BUFFER_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) case AML_PACKAGE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) case AML_VARIABLE_PACKAGE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if ((op->common.parent) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) (op->common.parent->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) AML_NAME_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) && (walk_state->pass_number <=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ACPI_IMODE_LOAD_PASS2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) "Setup Package/Buffer: Pass %u, AML Ptr: %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) walk_state->pass_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) aml_op_start));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * Skip parsing of Buffers and Packages because we don't have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * enough info in the first pass to parse them correctly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) op->named.data = aml_op_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) op->named.length = (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) (walk_state->parser_state.pkg_end -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) aml_op_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Skip body */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) walk_state->parser_state.pkg_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) walk_state->arg_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) case AML_WHILE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (walk_state->control_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) walk_state->control_state->control.package_end =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) walk_state->parser_state.pkg_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /* No action for all other opcodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * FUNCTION: acpi_ps_parse_loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * PARAMETERS: walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * a tree of ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) union acpi_parse_object *op = NULL; /* current op */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct acpi_parse_state *parser_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u8 *aml_op_start = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) u8 opcode_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (walk_state->descending_callback == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) parser_state = &walk_state->parser_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) walk_state->arg_types = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #ifndef ACPI_CONSTANT_EVAL_ONLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* We are restarting a preempted control method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (acpi_ps_has_completed_scope(parser_state)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * We must check if a predicate to an IF or WHILE statement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * was just completed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if ((parser_state->scope->parse_scope.op) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) ((parser_state->scope->parse_scope.op->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) aml_opcode == AML_IF_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) || (parser_state->scope->parse_scope.op->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) aml_opcode == AML_WHILE_OP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) && (walk_state->control_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) && (walk_state->control_state->common.state ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) ACPI_CONTROL_PREDICATE_EXECUTING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * A predicate was just completed, get the value of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * predicate and branch based on that value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) walk_state->op = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) acpi_ds_get_predicate_value(walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) ACPI_TO_POINTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) (TRUE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (ACPI_FAILURE(status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) && ((status & AE_CODE_MASK) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) AE_CODE_CONTROL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (status == AE_AML_NO_RETURN_VALUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) "Invoked method did not return a value"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) "GetPredicate Failed"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) acpi_ps_next_parse_state(walk_state, op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) acpi_ps_pop_scope(parser_state, &op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) &walk_state->arg_types,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) &walk_state->arg_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) "Popped scope, Op=%p\n", op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) } else if (walk_state->prev_op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) /* We were in the middle of an op */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) op = walk_state->prev_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) walk_state->arg_types = walk_state->prev_arg_types;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Iterative parsing loop, while there is more AML to process: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) while ((parser_state->aml < parser_state->aml_end) || (op)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) ASL_CV_CAPTURE_COMMENTS(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) aml_op_start = parser_state->aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) acpi_ps_create_op(walk_state, aml_op_start, &op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * executing it as a control method. However, if we encounter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * an error while loading the table, we need to keep trying to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * load the table rather than aborting the table load. Set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * status to AE_OK to proceed with the table load.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if ((walk_state->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) parse_flags & ACPI_PARSE_MODULE_LEVEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) && ((status == AE_ALREADY_EXISTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) || (status == AE_NOT_FOUND))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) if (status == AE_CTRL_PARSE_CONTINUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (status == AE_CTRL_PARSE_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (status == AE_CTRL_TERMINATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) acpi_ps_complete_op(walk_state, &op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if (acpi_ns_opens_scope
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) (acpi_ps_get_opcode_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) (walk_state->opcode)->object_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * If the scope/device op fails to parse, skip the body of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * the scope op because the parse failure indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * the device may not exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) ACPI_INFO(("Skipping parse of AML opcode: %s (0x%4.4X)", acpi_ps_get_opcode_name(walk_state->opcode), walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * Determine the opcode length before skipping the opcode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * An opcode can be 1 byte or 2 bytes in length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) opcode_length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if ((walk_state->opcode & 0xFF00) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) AML_EXTENDED_OPCODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) opcode_length = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) walk_state->aml + opcode_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) acpi_ps_get_next_package_end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) (&walk_state->parser_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) walk_state->aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) walk_state->parser_state.aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) acpi_ex_start_trace_opcode(op, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * Start arg_count at zero because we don't know if there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * any args yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) walk_state->arg_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) switch (op->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) case AML_BYTE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) case AML_WORD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) case AML_DWORD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) case AML_QWORD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ASL_CV_CAPTURE_COMMENTS(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /* Are there any arguments that must be processed? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) if (walk_state->arg_types) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /* Get arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) acpi_ps_get_arguments(walk_state, aml_op_start, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) acpi_ps_complete_op(walk_state, &op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if ((walk_state->control_state) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) ((walk_state->control_state->control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) opcode == AML_IF_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) || (walk_state->control_state->control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) opcode == AML_WHILE_OP))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * If the if/while op fails to parse, we will skip parsing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * the body of the op.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) parser_state->aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) walk_state->control_state->control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) aml_predicate_start + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) parser_state->aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) acpi_ps_get_next_package_end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) (parser_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) walk_state->aml = parser_state->aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) "Skipping While/If block"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (*walk_state->aml == AML_ELSE_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) "Skipping Else block"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) walk_state->aml + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) walk_state->parser_state.aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) acpi_ps_get_next_package_end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) (parser_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) walk_state->aml =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) parser_state->aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) ACPI_FREE(acpi_ut_pop_generic_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) (&walk_state->control_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) op = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) /* Check for arguments that need to be processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) "Parseloop: argument count: %8.8X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) walk_state->arg_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) if (walk_state->arg_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * There are arguments (complex ones), push Op and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * prepare for argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) status = acpi_ps_push_scope(parser_state, op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) walk_state->arg_types,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) walk_state->arg_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) acpi_ps_complete_op(walk_state, &op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) op = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * All arguments have been processed -- Op is complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * prepare for next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) walk_state->op_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) acpi_ps_get_opcode_info(op->common.aml_opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (walk_state->op_info->flags & AML_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if (op->common.aml_opcode == AML_REGION_OP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) op->common.aml_opcode == AML_DATA_REGION_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * Skip parsing of control method or opregion body,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * because we don't have enough info in the first pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * to parse them correctly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * Completed parsing an op_region declaration, we now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * know the length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) op->named.length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) (u32) (parser_state->aml - op->named.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (walk_state->op_info->flags & AML_CREATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * Backup to beginning of create_XXXfield declaration (1 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * Opcode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * body_length is unknown until we parse the body
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) op->named.length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) (u32) (parser_state->aml - op->named.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (op->common.aml_opcode == AML_BANK_FIELD_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * Backup to beginning of bank_field declaration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * body_length is unknown until we parse the body
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) op->named.length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) (u32) (parser_state->aml - op->named.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) /* This op complete, notify the dispatcher */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) if (walk_state->ascending_callback != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) walk_state->op = op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) walk_state->opcode = op->common.aml_opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) status = walk_state->ascending_callback(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) acpi_ps_next_parse_state(walk_state, op, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if (status == AE_CTRL_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if ((walk_state->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) parse_flags & ACPI_PARSE_MODULE_LEVEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) && (ACPI_AML_EXCEPTION(status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) || status == AE_ALREADY_EXISTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) || status == AE_NOT_FOUND)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * ACPI_PARSE_MODULE_LEVEL flag means that we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * are currently loading a table by executing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * it as a control method. However, if we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * encounter an error while loading the table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * we need to keep trying to load the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * rather than aborting the table load (setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * the status to AE_OK continues the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * load). If we get a failure at this point, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * means that the dispatcher got an error while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * trying to execute the Op.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) status = acpi_ps_complete_op(walk_state, &op, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) } /* while parser_state->Aml */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) status = acpi_ps_complete_final_op(walk_state, op, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }