^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: dswload - Dispatcher first pass namespace load callbacks
^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) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "acdisasm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define _COMPONENT ACPI_DISPATCHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ACPI_MODULE_NAME("dswload")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * FUNCTION: acpi_ds_init_callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * PARAMETERS: walk_state - Current state of the parse tree walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * pass_number - 1, 2, or 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * DESCRIPTION: Init walk state callbacks
^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) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) switch (pass_number) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Parse only - caller will setup callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ACPI_PARSE_DELETE_TREE | ACPI_PARSE_DISASSEMBLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) walk_state->descending_callback = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) walk_state->ascending_callback = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Load pass 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ACPI_PARSE_DELETE_TREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) walk_state->descending_callback = acpi_ds_load1_begin_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) walk_state->ascending_callback = acpi_ds_load1_end_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Load pass 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ACPI_PARSE_DELETE_TREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) walk_state->descending_callback = acpi_ds_load2_begin_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) walk_state->ascending_callback = acpi_ds_load2_end_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Execution pass */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ACPI_PARSE_DELETE_TREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) walk_state->descending_callback = acpi_ds_exec_begin_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) walk_state->ascending_callback = acpi_ds_exec_end_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * FUNCTION: acpi_ds_load1_begin_op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * PARAMETERS: walk_state - Current state of the parse tree walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * out_op - Where to return op if a new one is created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * DESCRIPTION: Descending callback used during the loading of ACPI tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) union acpi_parse_object **out_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) union acpi_parse_object *op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) acpi_object_type object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ACPI_FUNCTION_TRACE_PTR(ds_load1_begin_op, walk_state->op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) op = walk_state->op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) walk_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /* We are only interested in opcodes that have an associated name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (!(walk_state->op_info->flags & AML_NAMED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) *out_op = op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* Check if this object has already been installed in the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (op->common.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) *out_op = op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) path = acpi_ps_get_next_namestring(&walk_state->parser_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Map the raw opcode into an internal object type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) object_type = walk_state->op_info->object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) "State=%p Op=%p [%s]\n", walk_state, op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) acpi_ut_get_type_name(object_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) case AML_SCOPE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * The target name of the Scope() operator must exist at this point so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * that we can actually open the scope to enter new names underneath it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * Allow search-to-root for single namesegs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) acpi_ns_lookup(walk_state->scope_info, path, object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) walk_state, &(node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * Table disassembly:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * Target of Scope() not found. Generate an External for it, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * insert the name into the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) acpi_dm_add_op_to_external_list(op, path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ACPI_TYPE_DEVICE, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) acpi_ns_lookup(walk_state->scope_info, path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) object_type, ACPI_IMODE_LOAD_PASS1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ACPI_NS_SEARCH_PARENT, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ACPI_ERROR_NAMESPACE(walk_state->scope_info, path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^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) * Check to make sure that the target is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * one of the opcodes that actually opens a scope
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) switch (node->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) case ACPI_TYPE_ANY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) case ACPI_TYPE_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* These are acceptable types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * These types we will allow, but we will change the type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * This enables some existing code of the form:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * Name (DEB, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Scope (DEB) { ... }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * Note: silently change the type here. On the second pass,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * we will report a warning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) "Type override - [%4.4s] had invalid type (%s) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "for Scope operator, changed to type ANY\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) acpi_ut_get_node_name(node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) acpi_ut_get_type_name(node->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) node->type = ACPI_TYPE_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) walk_state->scope_info->common.value = ACPI_TYPE_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * Allow scope change to root during execution of module-level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * code. Root is typed METHOD during this time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if ((node == acpi_gbl_root_node) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) (walk_state->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /*lint -fallthrough */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* All other types are an error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) "Invalid type (%s) for target of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) "Scope operator [%4.4s] (Cannot override)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) acpi_ut_get_type_name(node->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) acpi_ut_get_node_name(node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * For all other named opcodes, we will enter the name into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * Setup the search flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * Since we are entering a name into the namespace, we do not want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * enable the search-to-root upsearch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * There are only two conditions where it is acceptable that the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * already exists:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * 1) the Scope() operator can reopen a scoping object that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * previously defined (Scope, Method, Device, etc.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * 2) Whenever we are parsing a deferred opcode (op_region, Buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * buffer_field, or Package), the name of the object is already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * in the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (walk_state->deferred_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) /* This name is already in the namespace, get the node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) node = walk_state->deferred_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * If we are executing a method, do not create any namespace objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * during the load phase, only during execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (walk_state->method_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) break;
^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) flags = ACPI_NS_NO_UPSEARCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if ((walk_state->opcode != AML_SCOPE_OP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (walk_state->namespace_override) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) flags |= ACPI_NS_OVERRIDE_IF_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) "[%s] Override allowed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) acpi_ut_get_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) (object_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) flags |= ACPI_NS_ERROR_IF_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) "[%s] Cannot already exist\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) acpi_ut_get_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) (object_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) "[%s] Both Find or Create allowed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) acpi_ut_get_type_name(object_type)));
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * Enter the named type into the internal namespace. We enter the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * as we go downward in the parse tree. Any necessary subobjects that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * involve arguments to the opcode must be created as we go back up the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * parse tree later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) acpi_ns_lookup(walk_state->scope_info, path, object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ACPI_IMODE_LOAD_PASS1, flags, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) if (status == AE_ALREADY_EXISTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* The name already exists in this scope */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (node->flags & ANOBJ_IS_EXTERNAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * Allow one create on an object or segment that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * previously declared External
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) node->flags &= ~ANOBJ_IS_EXTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) node->type = (u8) object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* Just retyped a node, probably will need to open a scope */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (acpi_ns_opens_scope(object_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) acpi_ds_scope_stack_push
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) (node, object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) return_ACPI_STATUS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) path, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) return_ACPI_STATUS(status);
^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) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /* Common exit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /* Create a new op */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) op = acpi_ps_alloc_op(walk_state->opcode, walk_state->aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* Initialize the op */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #ifdef ACPI_CONSTANT_EVAL_ONLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) op->named.path = path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * Put the Node in the "op" object that the parser uses, so we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * can get it again quickly when this scope is closed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) op->common.node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) op->named.name = node->name.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) *out_op = op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) return_ACPI_STATUS(status);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * FUNCTION: acpi_ds_load1_end_op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * PARAMETERS: walk_state - Current state of the parse tree walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * DESCRIPTION: Ascending callback used during the loading of the namespace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * both control methods and everything else.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) union acpi_parse_object *op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) acpi_object_type object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) u8 param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) ACPI_FUNCTION_TRACE(ds_load1_end_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) op = walk_state->op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) walk_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * Disassembler: handle create field operators here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * create_buffer_field is a deferred op that is typically processed in load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * pass 2. However, disassembly of control method contents walk the parse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * in a later walk. This is a problem when there is a control method that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * has the same name as the AML_CREATE object. In this case, any use of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * name segment will be detected as a method call rather than a reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * to a buffer field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * This earlier creation during disassembly solves this issue by inserting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * the named object in the ACPI namespace so that references to this name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * would be a name string rather than a method call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) (walk_state->op_info->flags & AML_CREATE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) status = acpi_ds_create_buffer_field(op, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) /* We are only interested in opcodes that have an associated name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) /* Get the object type to determine if we should pop the scope */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) object_type = walk_state->op_info->object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) if (walk_state->op_info->flags & AML_FIELD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) * If we are executing a method, do not create any namespace objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * during the load phase, only during execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if (!walk_state->method_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (walk_state->opcode == AML_FIELD_OP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) walk_state->opcode == AML_BANK_FIELD_OP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) walk_state->opcode == AML_INDEX_FIELD_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) acpi_ds_init_field_objects(op, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * If we are executing a method, do not create any namespace objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * during the load phase, only during execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (!walk_state->method_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (op->common.aml_opcode == AML_REGION_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) acpi_ex_create_region(op->named.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) op->named.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) (acpi_adr_space_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) ((op->common.value.arg)->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) common.value.integer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) } else if (op->common.aml_opcode == AML_DATA_REGION_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) acpi_ex_create_region(op->named.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) op->named.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) ACPI_ADR_SPACE_DATA_TABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (op->common.aml_opcode == AML_NAME_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) /* For Name opcode, get the object type from the argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (op->common.value.arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) object_type = (acpi_ps_get_opcode_info((op->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) value.arg)->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) aml_opcode))->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) /* Set node type if we have a namespace node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (op->common.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) op->common.node->type = (u8) object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * For external opcode, get the object type from the argument and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * get the parameter count from the argument's next.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (acpi_gbl_disasm_flag &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) op->common.node && op->common.aml_opcode == AML_EXTERNAL_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * Note, if this external is not a method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * Therefore, param_count will be 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) param_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) (u8)op->common.value.arg->common.next->common.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) object_type = (u8)op->common.value.arg->common.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) op->common.node->flags |= ANOBJ_IS_EXTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) op->common.node->type = (u8)object_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) acpi_dm_create_subobject_for_external((u8)object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) &op->common.node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) param_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * Add the external to the external list because we may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * emitting code based off of the items within the external list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) acpi_dm_add_op_to_external_list(op, op->named.path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) (u8)object_type, param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) ACPI_EXT_ORIGIN_FROM_OPCODE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) ACPI_EXT_RESOLVED_REFERENCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * If we are executing a method, do not create any namespace objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * during the load phase, only during execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (!walk_state->method_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (op->common.aml_opcode == AML_METHOD_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * method_op pkg_length name_string method_flags term_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * Note: We must create the method node/object pair as soon as we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * see the method declaration. This allows later pass1 parsing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * of invocations of the method (need to know the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * arguments.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) walk_state, op, op->named.node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (!acpi_ns_get_attached_object(op->named.node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) walk_state->operands[0] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) ACPI_CAST_PTR(void, op->named.node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) walk_state->num_operands = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) acpi_ds_create_operands(walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) op->common.value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) acpi_ex_create_method(op->named.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) op->named.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) walk_state->operands[0] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) walk_state->num_operands = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) /* Pop the scope stack (only if loading a table) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if (!walk_state->method_node &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) op->common.aml_opcode != AML_EXTERNAL_OP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) acpi_ns_opens_scope(object_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) "(%s): Popping scope for Op %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) acpi_ut_get_type_name(object_type), op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) status = acpi_ds_scope_stack_pop(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }