^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: dsutils - Dispatcher utilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acdebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_DISPATCHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("dsutils")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * FUNCTION: acpi_ds_clear_implicit_return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * PARAMETERS: walk_state - Current State
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * RETURN: None.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * DESCRIPTION: Clear and remove a reference on an implicit return value. Used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * to delete "stale" return values (if enabled, the return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * from every operator is saved at least momentarily, in case the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * parent method exits.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ACPI_FUNCTION_NAME(ds_clear_implicit_return);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Slack must be enabled for this feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (!acpi_gbl_enable_interpreter_slack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (walk_state->implicit_return_obj) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Delete any "stale" implicit return. However, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * complex statements, the implicit return value can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * bubbled up several levels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "Removing reference on stale implicit return obj %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) walk_state->implicit_return_obj));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) acpi_ut_remove_reference(walk_state->implicit_return_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) walk_state->implicit_return_obj = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * FUNCTION: acpi_ds_do_implicit_return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * PARAMETERS: return_desc - The return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * walk_state - Current State
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * add_reference - True if a reference should be added to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * return object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * RETURN: TRUE if implicit return enabled, FALSE otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * DESCRIPTION: Implements the optional "implicit return". We save the result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * of every ASL operator and control method invocation in case the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * parent method exit. Before storing a new return value, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * delete the previous return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct acpi_walk_state *walk_state, u8 add_reference)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ACPI_FUNCTION_NAME(ds_do_implicit_return);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * Slack must be enabled for this feature, and we must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * have a valid return object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if ((!acpi_gbl_enable_interpreter_slack) || (!return_desc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return (FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) "Result %p will be implicitly returned; Prev=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return_desc, walk_state->implicit_return_obj));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * Delete any "stale" implicit return value first. However, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * complex statements, the implicit return value can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * bubbled up several levels, so we don't clear the value if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * is the same as the return_desc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (walk_state->implicit_return_obj) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (walk_state->implicit_return_obj == return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return (TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) acpi_ds_clear_implicit_return(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* Save the implicit return value, add a reference if requested */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) walk_state->implicit_return_obj = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (add_reference) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) acpi_ut_add_reference(return_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return (TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * FUNCTION: acpi_ds_is_result_used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * PARAMETERS: op - Current Op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * walk_state - Current State
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * RETURN: TRUE if result is used, FALSE otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * DESCRIPTION: Check if a result object will be used by the parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) acpi_ds_is_result_used(union acpi_parse_object * op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct acpi_walk_state * walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) const struct acpi_opcode_info *parent_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) ACPI_FUNCTION_TRACE_PTR(ds_is_result_used, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /* Must have both an Op and a Result Object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ACPI_ERROR((AE_INFO, "Null Op"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return_UINT8(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * We know that this operator is not a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * Return() operator (would not come here.) The following code is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * optional support for a so-called "implicit return". Some AML code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * assumes that the last value of the method is "implicitly" returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * to the caller. Just save the last result as the return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * NOTE: this is optional because the ASL language does not actually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * support this behavior.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) (void)acpi_ds_do_implicit_return(walk_state->result_obj, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * Now determine if the parent will use the result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * If there is no parent, or the parent is a scope_op, we are executing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * at the method level. An executing method typically has no parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * since each method is parsed separately. A method invoked externally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * via execute_control_method has a scope_op as the parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if ((!op->common.parent) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* No parent, the return value cannot possibly be used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) "At Method level, result of [%s] not used\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) acpi_ps_get_opcode_name(op->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) aml_opcode)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return_UINT8(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Get info on the parent. The root_op is AML_SCOPE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) parent_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (parent_info->class == AML_CLASS_UNKNOWN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return_UINT8(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * Decide what to do with the result based on the parent. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * the parent opcode will not use the result, delete the object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * Otherwise leave it as is, it will be deleted when it is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * as an operand later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) switch (parent_info->class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) case AML_CLASS_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) switch (op->common.parent->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) case AML_RETURN_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /* Never delete the return value associated with a return opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto result_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) case AML_IF_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) case AML_WHILE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * If we are executing the predicate AND this is the predicate op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * we will use the return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if ((walk_state->control_state->common.state ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ACPI_CONTROL_PREDICATE_EXECUTING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) (walk_state->control_state->control.predicate_op ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) op)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) goto result_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* Ignore other control opcodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* The general control opcode returns no result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) goto result_not_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) case AML_CLASS_CREATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * These opcodes allow term_arg(s) as operands and therefore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * the operands can be method calls. The result is used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) goto result_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) case AML_CLASS_NAMED_OBJECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) || (op->common.parent->common.aml_opcode == AML_PACKAGE_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) || (op->common.parent->common.aml_opcode == AML_BUFFER_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) || (op->common.parent->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) AML_VARIABLE_PACKAGE_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) || (op->common.parent->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) AML_INT_EVAL_SUBTREE_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) || (op->common.parent->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) AML_BANK_FIELD_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * These opcodes allow term_arg(s) as operands and therefore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * the operands can be method calls. The result is used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) goto result_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) goto result_not_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * In all other cases. the parent will actually use the return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * object, so keep it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) goto result_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) result_used:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) "Result of [%s] used by Parent [%s] Op=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) acpi_ps_get_opcode_name(op->common.aml_opcode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) acpi_ps_get_opcode_name(op->common.parent->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) aml_opcode), op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return_UINT8(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) result_not_used:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) "Result of [%s] not used by Parent [%s] Op=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) acpi_ps_get_opcode_name(op->common.aml_opcode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) acpi_ps_get_opcode_name(op->common.parent->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) aml_opcode), op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return_UINT8(FALSE);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * FUNCTION: acpi_ds_delete_result_if_not_used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * PARAMETERS: op - Current parse Op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * result_obj - Result of the operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * result descriptor, check if the parent opcode will actually use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * this result. If not, delete the result now so that it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * not become orphaned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) union acpi_operand_object *result_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ACPI_FUNCTION_TRACE_PTR(ds_delete_result_if_not_used, result_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) ACPI_ERROR((AE_INFO, "Null Op"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (!result_obj) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) if (!acpi_ds_is_result_used(op, walk_state)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /* Must pop the result stack (obj_desc should be equal to result_obj) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) status = acpi_ds_result_pop(&obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) acpi_ut_remove_reference(result_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^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) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * FUNCTION: acpi_ds_resolve_operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * PARAMETERS: walk_state - Current walk state with operands on stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * DESCRIPTION: Resolve all operands to their values. Used to prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * arguments to a control method invocation (a call from one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * method to another.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) ACPI_FUNCTION_TRACE_PTR(ds_resolve_operands, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * Attempt to resolve each of the valid operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * Method arguments are passed by reference, not by value. This means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * that the actual objects are passed, not copies of the objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) for (i = 0; i < walk_state->num_operands; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) acpi_ex_resolve_to_value(&walk_state->operands[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * FUNCTION: acpi_ds_clear_operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * PARAMETERS: walk_state - Current walk state with operands on stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * DESCRIPTION: Clear all operands on the current walk state operand stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) void acpi_ds_clear_operands(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) ACPI_FUNCTION_TRACE_PTR(ds_clear_operands, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /* Remove a reference on each operand on the stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) for (i = 0; i < walk_state->num_operands; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * Remove a reference to all operands, including both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * "Arguments" and "Targets".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) acpi_ut_remove_reference(walk_state->operands[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) walk_state->operands[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) walk_state->num_operands = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * FUNCTION: acpi_ds_create_operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * PARAMETERS: walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * arg - Parse object for the argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * arg_index - Which argument (zero based)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * DESCRIPTION: Translate a parse tree object that is an argument to an AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * opcode to the equivalent interpreter object. This may include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * looking up a name or entering a new name into the internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) acpi_ds_create_operand(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) union acpi_parse_object *arg, u32 arg_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) char *name_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) u32 name_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) union acpi_parse_object *parent_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) u16 opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) acpi_interpreter_mode interpreter_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) const struct acpi_opcode_info *op_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) ACPI_FUNCTION_TRACE_PTR(ds_create_operand, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /* A valid name must be looked up in the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) (arg->common.value.string) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) !(arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) arg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* Get the entire name string from the AML stream */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) status = acpi_ex_get_name_string(ACPI_TYPE_ANY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) arg->common.value.buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) &name_string, &name_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /* All prefixes have been handled, and the name is in name_string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * Special handling for buffer_field declarations. This is a deferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * opcode that unfortunately defines the field name as the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * parameter instead of the first. We get here when we are performing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * the deferred execution, so the actual name of the field is already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * in the namespace. We don't want to attempt to look it up again
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * because we may be executing in a different scope than where the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * actual opcode exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) if ((walk_state->deferred_node) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) && (arg_index == (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) ((walk_state->opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) obj_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) ACPI_CAST_PTR(union acpi_operand_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) walk_state->deferred_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) } else { /* All other opcodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * Differentiate between a namespace "create" operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * IMODE_EXECUTE) in order to support the creation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * namespace objects during the execution of control methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) parent_op = arg->common.parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) op_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) acpi_ps_get_opcode_info(parent_op->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) aml_opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if ((op_info->flags & AML_NSNODE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) (parent_op->common.aml_opcode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) AML_INT_METHODCALL_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) && (parent_op->common.aml_opcode != AML_REGION_OP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) && (parent_op->common.aml_opcode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) AML_INT_NAMEPATH_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) /* Enter name into namespace if not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) interpreter_mode = ACPI_IMODE_LOAD_PASS2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) /* Return a failure if name not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) interpreter_mode = ACPI_IMODE_EXECUTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) acpi_ns_lookup(walk_state->scope_info, name_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) ACPI_TYPE_ANY, interpreter_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) ACPI_NS_SEARCH_PARENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) ACPI_NS_DONT_OPEN_SCOPE, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) ACPI_CAST_INDIRECT_PTR(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) acpi_namespace_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) &obj_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * The only case where we pass through (ignore) a NOT_FOUND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * error is for the cond_ref_of opcode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (parent_op->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) AML_CONDITIONAL_REF_OF_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * For the Conditional Reference op, it's OK if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * the name is not found; We just need a way to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * indicate this to the interpreter, set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * object to the root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) obj_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) ACPI_CAST_PTR(union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) acpi_operand_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) acpi_gbl_root_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) } else if (parent_op->common.aml_opcode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) AML_EXTERNAL_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * This opcode should never appear here. It is used only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * by AML disassemblers and is surrounded by an If(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * by the ASL compiler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * Therefore, if we see it here, it is a serious error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) status = AE_AML_BAD_OPCODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * We just plain didn't find it -- which is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * very serious error at this point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) status = AE_AML_NAME_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) name_string, status);
^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) /* Free the namestring created above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) ACPI_FREE(name_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) /* Check status from the lookup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) /* Put the resulting object onto the current object stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) status = acpi_ds_obj_stack_push(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) acpi_db_display_argument_object(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) /* Check for null name case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) !(arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * If the name is null, this means that this is an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) * optional result parameter that was not specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) * in the original ASL. Create a Zero Constant for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) * placeholder. (Store to a constant is a Noop.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) opcode = AML_ZERO_OP; /* Has no arguments! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) "Null namepath: Arg=%p\n", arg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) opcode = arg->common.aml_opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) /* Get the object type of the argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) op_info = acpi_ps_get_opcode_info(opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (op_info->object_type == ACPI_TYPE_INVALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) if ((op_info->flags & AML_HAS_RETVAL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) (arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * Use value that was already previously returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * by the evaluation of this argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) status = acpi_ds_result_pop(&obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * Only error is underflow, and this indicates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * a missing or null operand!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) "Missing or null operand"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) /* Create an ACPI_INTERNAL_OBJECT for the argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) obj_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) acpi_ut_create_internal_object(op_info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) object_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) /* Initialize the new object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) acpi_ds_init_object_from_op(walk_state, arg, opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) &obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) acpi_ut_delete_object_desc(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) /* Put the operand object on the object stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) status = acpi_ds_obj_stack_push(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) acpi_db_display_argument_object(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) * FUNCTION: acpi_ds_create_operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) * PARAMETERS: walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) * first_arg - First argument of a parser argument tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * DESCRIPTION: Convert an operator's arguments from a parse tree format to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) * namespace objects and place those argument object on the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) * stack in preparation for evaluation by the interpreter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) acpi_ds_create_operands(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) union acpi_parse_object *first_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) union acpi_parse_object *arguments[ACPI_OBJ_NUM_OPERANDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) u32 arg_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) u32 index = walk_state->num_operands;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) ACPI_FUNCTION_TRACE_PTR(ds_create_operands, first_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) /* Get all arguments in the list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) arg = first_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) while (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if (index >= ACPI_OBJ_NUM_OPERANDS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) return_ACPI_STATUS(AE_BAD_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) arguments[index] = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) walk_state->operands[index] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) /* Move on to next argument, if any */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) arg_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) "NumOperands %d, ArgCount %d, Index %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) walk_state->num_operands, arg_count, index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) /* Create the interpreter arguments, in reverse order */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) index--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) for (i = 0; i < arg_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) arg = arguments[index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) walk_state->operand_index = (u8)index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) status = acpi_ds_create_operand(walk_state, arg, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) "Created Arg #%u (%p) %u args total\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) index, arg, arg_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) index--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * We must undo everything done above; meaning that we must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * pop everything off of the operand stack and delete those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %u", index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * FUNCTION: acpi_ds_evaluate_name_path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) * PARAMETERS: walk_state - Current state of the parse tree walk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) * the opcode of current operation should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) * AML_INT_NAMEPATH_OP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) * DESCRIPTION: Translate the -name_path- parse tree object to the equivalent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * interpreter object, convert it to value, if needed, duplicate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) * it, if needed, and push it onto the current result stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) union acpi_parse_object *op = walk_state->op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) union acpi_operand_object *new_obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) ACPI_FUNCTION_TRACE_PTR(ds_evaluate_name_path, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) if (!op->common.parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) /* This happens after certain exception processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) (op->common.parent->common.aml_opcode == AML_REF_OF_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) /* TBD: Should we specify this feature as a bit of op_info->Flags of these opcodes? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) status = acpi_ds_create_operand(walk_state, op, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) if (op->common.flags & ACPI_PARSEOP_TARGET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) new_obj_desc = *operand;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) goto push_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) type = (*operand)->common.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) status = acpi_ex_resolve_to_value(operand, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) if (type == ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) /* It was incremented by acpi_ex_resolve_to_value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) acpi_ut_remove_reference(*operand);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) acpi_ut_copy_iobject_to_iobject(*operand, &new_obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * The object either was anew created or is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * a Namespace node - don't decrement it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) new_obj_desc = *operand;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) /* Cleanup for name-path operand */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) status = acpi_ds_obj_stack_pop(1, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) walk_state->result_obj = new_obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) push_result:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) walk_state->result_obj = new_obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) status = acpi_ds_result_push(walk_state->result_obj, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) /* Force to take it from stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) op->common.flags |= ACPI_PARSEOP_IN_STACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) }