^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: exstore - AML Interpreter object store support
^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 "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_EXECUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("exstore")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) union acpi_operand_object *dest_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct acpi_walk_state *walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct acpi_walk_state *walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * FUNCTION: acpi_ex_store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * PARAMETERS: *source_desc - Value to be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * *dest_desc - Where to store it. Must be an NS node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * or union acpi_operand_object of type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Reference;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * DESCRIPTION: Store the value described by source_desc into the location
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * described by dest_desc. Called by various interpreter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * functions to store the result of an operation into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * the destination operand -- not just simply the actual "Store"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * ASL operator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) acpi_ex_store(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) union acpi_operand_object *dest_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) union acpi_operand_object *ref_desc = dest_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ACPI_FUNCTION_TRACE_PTR(ex_store, dest_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Validate parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (!source_desc || !dest_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ACPI_ERROR((AE_INFO, "Null parameter"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return_ACPI_STATUS(AE_AML_NO_OPERAND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* dest_desc can be either a namespace node or an ACPI object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * Dest is a namespace node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * Storing an object into a Named node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) status = acpi_ex_store_object_to_node(source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) (struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) acpi_namespace_node *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) dest_desc, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ACPI_IMPLICIT_CONVERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* Destination object must be a Reference or a Constant object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) switch (dest_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* Allow stores to Constants -- a Noop as per ACPI spec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /*lint -fallthrough */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* Destination is not a Reference object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) "Target is not a Reference or Constant object - [%s] %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) acpi_ut_get_object_type_name(dest_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dest_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * Examine the Reference class. These cases are handled:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * 1) Store to Name (Change the object associated with a name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * 2) Store to an indexed area of a Buffer or Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * 3) Store to a Method Local or Arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * 4) Store to the debug object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) switch (ref_desc->reference.class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) case ACPI_REFCLASS_REFOF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* Storing an object into a Name "container" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) status = acpi_ex_store_object_to_node(source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ref_desc->reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) object, walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ACPI_IMPLICIT_CONVERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) case ACPI_REFCLASS_INDEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Storing to an Index (pointer into a packager or buffer) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) acpi_ex_store_object_to_index(source_desc, ref_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) case ACPI_REFCLASS_LOCAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) case ACPI_REFCLASS_ARG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Store to a method local/arg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) acpi_ds_store_object_to_local(ref_desc->reference.class,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ref_desc->reference.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) source_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) case ACPI_REFCLASS_DEBUG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * Storing to the Debug object causes the value stored to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * displayed and otherwise has no effect -- see ACPI Specification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) "**** Write to Debug Object: Object %p [%s] ****:\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) acpi_ut_get_object_type_name(source_desc)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) ACPI_DEBUG_OBJECT(source_desc, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ACPI_ERROR((AE_INFO, "Unknown Reference Class 0x%2.2X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ref_desc->reference.class));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) status = AE_AML_INTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * FUNCTION: acpi_ex_store_object_to_index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * PARAMETERS: *source_desc - Value to be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * *dest_desc - Named object to receive the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * DESCRIPTION: Store the object to indexed Buffer or Package element
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) union acpi_operand_object *index_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) union acpi_operand_object *new_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u8 value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) ACPI_FUNCTION_TRACE(ex_store_object_to_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * Destination must be a reference pointer, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * must point to either a buffer or a package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) switch (index_desc->reference.target_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * Storing to a package element. Copy the object and replace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * any existing object with the new object. No implicit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * conversion is performed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * The object at *(index_desc->Reference.Where) is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * element within the package that is to be modified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * The parent package object is at index_desc->Reference.Object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) obj_desc = *(index_desc->reference.where);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) source_desc->reference.class == ACPI_REFCLASS_TABLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* This is a DDBHandle, just add a reference to it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) acpi_ut_add_reference(source_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) new_desc = source_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* Normal object, copy it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) acpi_ut_copy_iobject_to_iobject(source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) &new_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* Decrement reference count by the ref count of the parent package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) for (i = 0; i < ((union acpi_operand_object *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) index_desc->reference.object)->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) reference_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *(index_desc->reference.where) = new_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* Increment ref count by the ref count of the parent package-1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) for (i = 1; i < ((union acpi_operand_object *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) index_desc->reference.object)->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) reference_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) acpi_ut_add_reference(new_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * Store into a Buffer or String (not actually a real buffer_field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * at a location defined by an Index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * The first 8-bit element of the source object is written to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * 8-bit Buffer location defined by the Index destination object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * according to the ACPI 2.0 specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * Make sure the target is a Buffer or String. An error should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * not happen here, since the reference_object was constructed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * by the INDEX_OP code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) obj_desc = index_desc->reference.object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if ((obj_desc->common.type != ACPI_TYPE_BUFFER) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) (obj_desc->common.type != ACPI_TYPE_STRING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * The assignment of the individual elements will be slightly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * different for each source type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) switch (source_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* Use the least-significant byte of the integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) value = (u8) (source_desc->integer.value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) /* Note: Takes advantage of common string/buffer fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) value = source_desc->buffer.pointer[0];
^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) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /* All other types are invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) "Source must be type [Integer/Buffer/String], found [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) acpi_ut_get_object_type_name(source_desc)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /* Store the source value into the target buffer byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) obj_desc->buffer.pointer[index_desc->reference.value] = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) "Target is not of type [Package/BufferField]"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) status = AE_AML_TARGET_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * FUNCTION: acpi_ex_store_object_to_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * PARAMETERS: source_desc - Value to be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * node - Named object to receive the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * implicit_conversion - Perform implicit conversion (yes/no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * DESCRIPTION: Store the object to the named object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * The assignment of an object to a named object is handled here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * The value passed in will replace the current value (if any)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * with the input value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * When storing into an object the data is converted to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * target object type then stored in the object. This means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * that the target object type (for an initialized target) will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) * not be changed by a store operation. A copy_object can change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * the target type, however.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * The implicit_conversion flag is set to NO/FALSE only when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * storing to an arg_x -- as per the rules of the ACPI spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * Assumes parameters are already validated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) u8 implicit_conversion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) union acpi_operand_object *target_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) union acpi_operand_object *new_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) acpi_object_type target_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) ACPI_FUNCTION_TRACE_PTR(ex_store_object_to_node, source_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /* Get current type of the node, and object attached to Node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) target_type = acpi_ns_get_type(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) target_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) acpi_ut_get_object_type_name(source_desc), node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) acpi_ut_get_type_name(target_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /* Only limited target types possible for everything except copy_object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (walk_state->opcode != AML_COPY_OBJECT_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * Only copy_object allows all object types to be overwritten. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * target_ref(s), there are restrictions on the object types that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * are allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * Allowable operations/typing for Store:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * 1) Simple Store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * Integer --> Integer (Named/Local/Arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * String --> String (Named/Local/Arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * Buffer --> Buffer (Named/Local/Arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * Package --> Package (Named/Local/Arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * 2) Store with implicit conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * Integer --> String or Buffer (Named)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * String --> Integer or Buffer (Named)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * Buffer --> Integer or String (Named)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) switch (target_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * Here, can only store a package to an existing package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * Storing a package to a Local/Arg is OK, and handled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * elsewhere.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (walk_state->opcode == AML_STORE_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) if (source_desc->common.type !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) "Cannot assign type [%s] to [Package] "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) "(source must be type Pkg)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) acpi_ut_get_object_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) (source_desc)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) return_ACPI_STATUS(AE_AML_TARGET_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) break;
^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) /* Fallthrough */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) case ACPI_TYPE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) case ACPI_TYPE_MUTEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) case ACPI_TYPE_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) "Target must be [Buffer/Integer/String/Reference]"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) ", found [%s] (%4.4s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) acpi_ut_get_type_name(node->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) node->name.ascii));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return_ACPI_STATUS(AE_AML_TARGET_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) * Resolve the source object to an actual value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * (If it is a reference object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) status = acpi_ex_resolve_object(&source_desc, target_type, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* Do the actual store operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) switch (target_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * The simple data types all support implicit source operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * conversion before the store.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if ((walk_state->opcode == AML_COPY_OBJECT_OP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) !implicit_conversion) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * However, copy_object and Stores to arg_x do not perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * an implicit conversion, as per the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * A direct store is performed instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) acpi_ex_store_direct_to_node(source_desc, node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) /* Store with implicit source operand conversion support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) acpi_ex_store_object_to_object(source_desc, target_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) &new_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (new_desc != target_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * Store the new new_desc as the new value of the Name, and set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * the Name's type to that of the value being stored in it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * source_desc reference count is incremented by attach_object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * Note: This may change the type of the node if an explicit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * store has been performed such that the node/object type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * has been changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) acpi_ns_attach_object(node, new_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) new_desc->common.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) "Store type [%s] into [%s] via Convert/Attach\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) acpi_ut_get_object_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) (source_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) acpi_ut_get_object_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) (new_desc)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) case ACPI_TYPE_LOCAL_REGION_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) case ACPI_TYPE_LOCAL_INDEX_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * For all fields, always write the source data to the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * field. Any required implicit source operand conversion is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * performed in the function below as necessary. Note, field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * objects must retain their original type permanently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) status = acpi_ex_write_data_to_field(source_desc, target_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) &walk_state->result_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * copy_object operator: No conversions for all other types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * Instead, directly store a copy of the source object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * This is the ACPI spec-defined behavior for the copy_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * operator. (Note, for this default case, all normal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * Store/Target operations exited above with an error).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) acpi_ex_store_direct_to_node(source_desc, node, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * FUNCTION: acpi_ex_store_direct_to_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * PARAMETERS: source_desc - Value to be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * node - Named object to receive the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * DESCRIPTION: "Store" an object directly to a node. This involves a copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * and an attach.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) union acpi_operand_object *new_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) ACPI_FUNCTION_TRACE(ex_store_direct_to_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) "Storing [%s] (%p) directly into node [%s] (%p)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) " with no implicit conversion\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) acpi_ut_get_object_type_name(source_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) source_desc, acpi_ut_get_type_name(node->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) /* Copy the source object to a new object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) /* Attach the new object to the node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) status = acpi_ns_attach_object(node, new_desc, new_desc->common.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) acpi_ut_remove_reference(new_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }