^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: dsfield - Dispatcher field routines
^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 "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifdef ACPI_EXEC_APP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "aecommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define _COMPONENT ACPI_DISPATCHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ACPI_MODULE_NAME("dsfield")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include "acdisasm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) acpi_ds_create_external_region(acpi_status lookup_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) char *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct acpi_namespace_node **node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) acpi_ds_get_field_names(struct acpi_create_field_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) union acpi_parse_object *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * FUNCTION: acpi_ds_create_external_region (iASL Disassembler only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * PARAMETERS: lookup_status - Status from ns_lookup operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * op - Op containing the Field definition and args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * path - Pathname of the region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * ` walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * node - Where the new region node is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * region node/object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) acpi_ds_create_external_region(acpi_status lookup_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) char *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct acpi_namespace_node **node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (lookup_status != AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return (lookup_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Table disassembly:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * operation_region not found. Generate an External for it, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * insert the name into the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) walk_state, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* Must create and install a region object for the new node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) obj_desc->region.node = *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) status = acpi_ns_attach_object(*node, obj_desc, ACPI_TYPE_REGION);
^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) #endif
^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) * FUNCTION: acpi_ds_create_buffer_field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * PARAMETERS: op - Current parse op (create_XXField)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * DESCRIPTION: Execute the create_field operators:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * create_bit_field_op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * create_byte_field_op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * create_word_field_op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * create_dword_field_op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * create_qword_field_op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * create_field_op (all of which define a field in a buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *
^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) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) acpi_ds_create_buffer_field(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) union acpi_operand_object *second_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ACPI_FUNCTION_TRACE(ds_create_buffer_field);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * Get the name_string argument (name of the new buffer_field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* For create_field, name is the 4th argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) arg = acpi_ps_get_arg(op, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* For all other create_XXXField operators, name is the 3rd argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) arg = acpi_ps_get_arg(op, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (!arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return_ACPI_STATUS(AE_AML_NO_OPERAND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (walk_state->deferred_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) node = walk_state->deferred_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Execute flag should always be set when this function is entered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ACPI_ERROR((AE_INFO, "Parse execute mode is not set"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return_ACPI_STATUS(AE_AML_INTERNAL);
^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) /* Creating new namespace node, should not already exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) ACPI_NS_ERROR_IF_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Mark node temporary if we are executing a normal control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * method. (Don't mark if this is a module-level code method)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (walk_state->method_node &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) flags |= ACPI_NS_TEMPORARY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* Enter the name_string into the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) status = acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) arg->common.value.string, ACPI_TYPE_ANY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ACPI_IMODE_LOAD_PASS1, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) walk_state, &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) && status == AE_ALREADY_EXISTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) } else if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) arg->common.value.string, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) return_ACPI_STATUS(status);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * We could put the returned object (Node) on the object stack for later,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * but for now, we will put it in the "op" object that the parser uses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * so we can get it again at the end of this scope.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) op->common.node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * If there is no object attached to the node, this node was just created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * and we need to create the field object. Otherwise, this was a lookup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * of an existing node and we don't want to create the field object again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) obj_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * The Field definition is not fully parsed at this time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * (We must save the address of the AML for the buffer and index operands)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* Create the buffer field object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * Remember location in AML stream of the field unit opcode and operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * -- since the buffer and index operands must be evaluated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) second_desc = obj_desc->common.next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) second_desc->extra.aml_start = op->named.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) second_desc->extra.aml_length = op->named.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) obj_desc->buffer_field.node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /* Attach constructed field descriptors to parent node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* Remove local reference to the object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * FUNCTION: acpi_ds_get_field_names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * PARAMETERS: info - create_field info structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * arg - First parser arg for the field name list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * DESCRIPTION: Process all named fields in a field declaration. Names are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * entered into the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) acpi_ds_get_field_names(struct acpi_create_field_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) union acpi_parse_object *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) u64 position;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) union acpi_parse_object *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #ifdef ACPI_EXEC_APP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) union acpi_operand_object *result_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) char *name_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /* First field starts at bit zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) info->field_bit_position = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* Process all elements in the field list (of parse nodes) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) while (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * Four types of field elements are handled:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * 1) name - Enters a new named field into the namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * 2) offset - specifies a bit offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * 3) access_as - changes the access mode/attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * 4) connection - Associate a resource template with the field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) switch (arg->common.aml_opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) case AML_INT_RESERVEDFIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) position = (u64)info->field_bit_position +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) (u64)arg->common.value.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (position > ACPI_UINT32_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) "Bit offset within field too large (> 0xFFFFFFFF)"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) return_ACPI_STATUS(AE_SUPPORT);
^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) info->field_bit_position = (u32) position;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) case AML_INT_ACCESSFIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) case AML_INT_EXTACCESSFIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * Get new access_type, access_attribute, and access_length fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * -- to be used for all field units that follow, until the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * end-of-field or another access_as keyword is encountered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * NOTE. These three bytes are encoded in the integer value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * of the parseop for convenience.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * In field_flags, preserve the flag bits other than the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * ACCESS_TYPE bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /* access_type (byte_acc, word_acc, etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) info->field_flags = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) ((info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) ((u8)((u32)(arg->common.value.integer & 0x07))));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /* access_attribute (attrib_quick, attrib_byte, etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) info->attribute = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) ((arg->common.value.integer >> 8) & 0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /* access_length (for serial/buffer protocols) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) info->access_length = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) ((arg->common.value.integer >> 16) & 0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) case AML_INT_CONNECTION_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * Clear any previous connection. New connection is used for all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * fields that follow, similar to access_as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) info->resource_buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) info->connection_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) info->pin_number_index = 0;
^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) * A Connection() is either an actual resource descriptor (buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * or a named reference to a resource template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) child = arg->common.value.arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if (child->common.aml_opcode == AML_INT_BYTELIST_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) info->resource_buffer = child->named.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) info->resource_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) (u16)child->named.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /* Lookup the Connection() namepath, it should already exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) status = acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) child->common.value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) name, ACPI_TYPE_ANY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) ACPI_NS_DONT_OPEN_SCOPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) &info->connection_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) ACPI_ERROR_NAMESPACE(walk_state->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) child->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) value.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return_ACPI_STATUS(status);
^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) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) case AML_INT_NAMEDFIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /* Lookup the name, it should already exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) status = acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) (char *)&arg->named.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) info->field_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) ACPI_NS_DONT_OPEN_SCOPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) walk_state, &info->field_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) (char *)&arg->named.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) arg->common.node = info->field_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) info->field_bit_length = arg->common.value.size;
^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) * If there is no object attached to the node, this node was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * just created and we need to create the field object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * Otherwise, this was a lookup of an existing node and we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * don't want to create the field object again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (!acpi_ns_get_attached_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) (info->field_node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) status = acpi_ex_prep_field_value(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) #ifdef ACPI_EXEC_APP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) name_path =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) acpi_ns_get_external_pathname(info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) field_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if (ACPI_SUCCESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) (ae_lookup_init_file_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) (name_path, &obj_desc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) acpi_ex_write_data_to_field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) (obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) acpi_ns_get_attached_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) (info->field_node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) &result_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) acpi_ut_remove_reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) (obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) ACPI_FREE(name_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /* Keep track of bit position for the next field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) position = (u64)info->field_bit_position +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) (u64)arg->common.value.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (position > ACPI_UINT32_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) ACPI_CAST_PTR(char,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) &info->field_node->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) name)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) info->field_bit_position += info->field_bit_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) info->pin_number_index++; /* Index relative to previous Connection() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) "Invalid opcode in field list: 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) arg->common.aml_opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return_ACPI_STATUS(AE_AML_BAD_OPCODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) arg = arg->common.next;
^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(AE_OK);
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * FUNCTION: acpi_ds_create_field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * PARAMETERS: op - Op containing the Field definition and args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * region_node - Object for the containing Operation Region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * ` walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * DESCRIPTION: Create a new field in the specified operation region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) acpi_ds_create_field(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct acpi_namespace_node *region_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) struct acpi_create_field_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) ACPI_FUNCTION_TRACE_PTR(ds_create_field, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /* First arg is the name of the parent op_region (must already exist) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) arg = op->common.value.arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (!region_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) arg->common.value.name, ACPI_TYPE_REGION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) walk_state, ®ion_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) status = acpi_ds_create_external_region(status, arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) arg->common.value.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) ®ion_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) arg->common.value.name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) memset(&info, 0, sizeof(struct acpi_create_field_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /* Second arg is the field flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) info.field_flags = (u8) arg->common.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) info.attribute = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) /* Each remaining arg is a Named Field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) info.region_node = region_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (info.region_node->object->region.space_id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) ACPI_ADR_SPACE_PLATFORM_COMM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) region_node->object->field.internal_pcc_buffer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) ACPI_ALLOCATE_ZEROED(info.region_node->object->region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if (!region_node->object->field.internal_pcc_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) }
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * FUNCTION: acpi_ds_init_field_objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * PARAMETERS: op - Op containing the Field definition and args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * ` walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * DESCRIPTION: For each "Field Unit" name in the argument list that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * part of the field declaration, enter the name into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) *
^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) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) acpi_ds_init_field_objects(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) union acpi_parse_object *arg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) u8 type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) ACPI_FUNCTION_TRACE_PTR(ds_init_field_objects, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) /* Execute flag should always be set when this function is entered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) /* bank_field Op is deferred, just return OK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) ACPI_ERROR((AE_INFO, "Parse deferred mode is not set"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) return_ACPI_STATUS(AE_AML_INTERNAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) * Get the field_list argument for this opcode. This is the start of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) * list of field elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) case AML_FIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) arg = acpi_ps_get_arg(op, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) type = ACPI_TYPE_LOCAL_REGION_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) case AML_BANK_FIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) arg = acpi_ps_get_arg(op, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) type = ACPI_TYPE_LOCAL_BANK_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) case AML_INDEX_FIELD_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) arg = acpi_ps_get_arg(op, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) type = ACPI_TYPE_LOCAL_INDEX_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) /* Creating new namespace node(s), should not already exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) ACPI_NS_ERROR_IF_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * Mark node(s) temporary if we are executing a normal control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * method. (Don't mark if this is a module-level code method)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) if (walk_state->method_node &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) flags |= ACPI_NS_TEMPORARY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) #ifdef ACPI_EXEC_APP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) flags |= ACPI_NS_OVERRIDE_IF_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) * Walk the list of entries in the field_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) * Note: field_list can be of zero length. In this case, Arg will be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) while (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) * in the field names in order to enter them into the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) status = acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) (char *)&arg->named.name, type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) ACPI_IMODE_LOAD_PASS1, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) walk_state, &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) (char *)&arg->named.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) if (status != AE_ALREADY_EXISTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return_ACPI_STATUS(status);
^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) /* Name already exists, just ignore this error */
^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) arg->common.node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) /* Get the next field element in the list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) * FUNCTION: acpi_ds_create_bank_field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * PARAMETERS: op - Op containing the Field definition and args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * region_node - Object for the containing Operation Region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * DESCRIPTION: Create a new bank field in the specified operation region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) acpi_ds_create_bank_field(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) struct acpi_namespace_node *region_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) struct acpi_create_field_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) ACPI_FUNCTION_TRACE_PTR(ds_create_bank_field, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) /* First arg is the name of the parent op_region (must already exist) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) arg = op->common.value.arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (!region_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) acpi_ns_lookup(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) arg->common.value.name, ACPI_TYPE_REGION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) walk_state, ®ion_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #ifdef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) status = acpi_ds_create_external_region(status, arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) arg->common.value.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) ®ion_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) arg->common.value.name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) /* Second arg is the Bank Register (Field) (must already exist) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) ACPI_NS_SEARCH_PARENT, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) &info.register_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) arg->common.value.string, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * Third arg is the bank_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * This arg is a term_arg, not a constant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) * It will be evaluated later, by acpi_ds_eval_bank_field_operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) /* Fourth arg is the field flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) info.field_flags = (u8) arg->common.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) /* Each remaining arg is a Named Field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) info.region_node = region_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) * Use Info.data_register_node to store bank_field Op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) * It's safe because data_register_node will never be used when create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) * bank field \we store aml_start and aml_length in the bank_field Op for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * late evaluation. Used in acpi_ex_prep_field_value(Info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) * TBD: Or, should we add a field in struct acpi_create_field_info, like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) * "void *ParentOp"?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) info.data_register_node = (struct acpi_namespace_node *)op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) * FUNCTION: acpi_ds_create_index_field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) * PARAMETERS: op - Op containing the Field definition and args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) * region_node - Object for the containing Operation Region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) * ` walk_state - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) * DESCRIPTION: Create a new index field in the specified operation region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) acpi_ds_create_index_field(union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) struct acpi_namespace_node *region_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) struct acpi_create_field_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) ACPI_FUNCTION_TRACE_PTR(ds_create_index_field, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) /* First arg is the name of the Index register (must already exist) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) arg = op->common.value.arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) ACPI_NS_SEARCH_PARENT, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) &info.register_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) arg->common.value.string, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) /* Second arg is the data register (must already exist) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) ACPI_NS_SEARCH_PARENT, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) &info.data_register_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) ACPI_ERROR_NAMESPACE(walk_state->scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) arg->common.value.string, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) /* Next arg is the field flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) info.field_flags = (u8) arg->common.value.integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) /* Each remaining arg is a Named Field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) info.region_node = region_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }