^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: exconfig - Namespace reconfiguration (Load/Unload opcodes)
^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 "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define _COMPONENT ACPI_EXECUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ACPI_MODULE_NAME("exconfig")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) acpi_ex_add_table(u32 table_index, union acpi_operand_object **ddb_handle);
^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_region_read(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u32 length, u8 *buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^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) * FUNCTION: acpi_ex_add_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * PARAMETERS: table - Pointer to raw table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * parent_node - Where to load the table (scope)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * ddb_handle - Where to return the table handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * DESCRIPTION: Common function to Install and Load an ACPI table with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * returned table handle.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) acpi_ex_add_table(u32 table_index, union acpi_operand_object **ddb_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ACPI_FUNCTION_TRACE(ex_add_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Create an object to be the table handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return_ACPI_STATUS(AE_NO_MEMORY);
^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) /* Init the table handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) obj_desc->common.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) obj_desc->reference.class = ACPI_REFCLASS_TABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) obj_desc->reference.value = table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *ddb_handle = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return_ACPI_STATUS(AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * FUNCTION: acpi_ex_load_table_op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * PARAMETERS: walk_state - Current state with operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * return_desc - Where to store the return object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * DESCRIPTION: Load an ACPI table from the RSDT/XSDT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) union acpi_operand_object **return_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct acpi_namespace_node *parent_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct acpi_namespace_node *start_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct acpi_namespace_node *parameter_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) union acpi_operand_object *ddb_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) u32 table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ACPI_FUNCTION_TRACE(ex_load_table_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* Find the ACPI table in the RSDT/XSDT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) status = acpi_tb_find_table(operand[0]->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) operand[1]->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) operand[2]->string.pointer, &table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (status != AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Table not found, return an Integer=0 and AE_OK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ddb_handle = acpi_ut_create_integer_object((u64) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (!ddb_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return_ACPI_STATUS(AE_NO_MEMORY);
^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) *return_desc = ddb_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return_ACPI_STATUS(AE_OK);
^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) /* Default nodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) start_node = walk_state->scope_info->scope.node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) parent_node = acpi_gbl_root_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* root_path (optional parameter) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (operand[3]->string.length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * Find the node referenced by the root_path_string. This is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * location within the namespace where the table will be loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) status = acpi_ns_get_node_unlocked(start_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) operand[3]->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) &parent_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* parameter_path (optional parameter) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (operand[4]->string.length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if ((operand[4]->string.pointer[0] != AML_ROOT_PREFIX) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) (operand[4]->string.pointer[0] != AML_PARENT_PREFIX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * Path is not absolute, so it will be relative to the node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * referenced by the root_path_string (or the NS root if omitted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) start_node = parent_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Find the node referenced by the parameter_path_string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) status = acpi_ns_get_node_unlocked(start_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) operand[4]->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) ACPI_NS_SEARCH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ¶meter_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* Load the table into the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ACPI_INFO(("Dynamic OEM Table Load:"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) status = acpi_tb_load_table(table_index, parent_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) status = acpi_ex_add_table(table_index, &ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* Complete the initialization/resolution of new objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) acpi_ns_initialize_objects();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /* Parameter Data (optional) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (parameter_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* Store the parameter data into the optional parameter object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) status = acpi_ex_store(operand[5],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) ACPI_CAST_PTR(union acpi_operand_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) parameter_node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) (void)acpi_ex_unload_table(ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) acpi_ut_remove_reference(ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *return_desc = ddb_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * FUNCTION: acpi_ex_region_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * PARAMETERS: obj_desc - Region descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * length - Number of bytes to read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * buffer - Pointer to where to put the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * DESCRIPTION: Read data from an operation region. The read starts from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * beginning of the region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) u64 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) u32 region_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /* Bytewise reads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) for (i = 0; i < length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) region_offset, 8, &value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) *buffer = (u8)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) buffer++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) region_offset++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return (AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * FUNCTION: acpi_ex_load_op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * PARAMETERS: obj_desc - Region or Buffer/Field where the table will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * obtained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * target - Where a handle to the table will be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * walk_state - Current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * DESCRIPTION: Load an ACPI table from a field or operation region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * NOTE: Region Fields (Field, bank_field, index_fields) are resolved to buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * objects before this code is reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * If source is an operation region, it must refer to system_memory, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * per the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) acpi_ex_load_op(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) union acpi_operand_object *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) union acpi_operand_object *ddb_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct acpi_table_header *table_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct acpi_table_header *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) u32 table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ACPI_FUNCTION_TRACE(ex_load_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /* Source Object can be either an op_region or a Buffer/Field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) switch (obj_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) "Load table from Region %p\n", obj_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /* Region must be system_memory (from ACPI spec) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (obj_desc->region.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * If the Region Address and Length have not been previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * evaluated, evaluate them now and save the results.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) status = acpi_ds_get_region_arguments(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* Get the table header first so we can get the table length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) table_header = ACPI_ALLOCATE(sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if (!table_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) acpi_ex_region_read(obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) sizeof(struct acpi_table_header),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) ACPI_CAST_PTR(u8, table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) length = table_header->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ACPI_FREE(table_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* Must have at least an ACPI table header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (length < sizeof(struct acpi_table_header)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
^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) * The original implementation simply mapped the table, with no copy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * However, the memory region is not guaranteed to remain stable and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * we must copy the table to a local buffer. For example, the memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * region is corrupted after suspend on some machines. Dynamically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * loaded tables are usually small, so this overhead is minimal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * The latest implementation (5/2009) does not use a mapping at all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * We use the low-level operation region interface to read the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * instead of the obvious optimization of using a direct mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * This maintains a consistent use of operation regions across the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * entire subsystem. This is important if additional processing must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * be performed in the (possibly user-installed) operation region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * handler. For example, acpi_exec and ASLTS depend on this.
^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) /* Allocate a buffer for the table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) table = ACPI_ALLOCATE(length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (!table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) /* Read the entire table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) status = acpi_ex_region_read(obj_desc, length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) ACPI_CAST_PTR(u8, table));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ACPI_FREE(table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) "Load table from Buffer or Field %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) obj_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /* Must have at least an ACPI table header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (obj_desc->buffer.length < sizeof(struct acpi_table_header)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /* Get the actual table length from the table header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) table_header =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) ACPI_CAST_PTR(struct acpi_table_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) obj_desc->buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) length = table_header->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /* Table cannot extend beyond the buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (length > obj_desc->buffer.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) if (length < sizeof(struct acpi_table_header)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * Copy the table from the buffer because the buffer could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * modified or even deleted in the future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) table = ACPI_ALLOCATE(length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (!table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) memcpy(table, table_header, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* Install the new table into the local data structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) ACPI_INFO(("Dynamic OEM Table Load:"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) status = acpi_tb_install_and_load_table(ACPI_PTR_TO_PHYSADDR(table),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) TRUE, &table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /* Delete allocated table buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) ACPI_FREE(table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^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) * Add the table to the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * Note: Load the table objects relative to the root of the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * This appears to go against the ACPI specification, but we do it for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * compatibility with other ACPI implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) status = acpi_ex_add_table(table_index, &ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) /* On error, table_ptr was deallocated above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) /* Complete the initialization/resolution of new objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) acpi_ns_initialize_objects();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) /* Store the ddb_handle into the Target operand */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) status = acpi_ex_store(ddb_handle, target, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) (void)acpi_ex_unload_table(ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* table_ptr was deallocated above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) acpi_ut_remove_reference(ddb_handle);
^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) /* Remove the reference by added by acpi_ex_store above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) acpi_ut_remove_reference(ddb_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) * FUNCTION: acpi_ex_unload_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * PARAMETERS: ddb_handle - Handle to a previously loaded table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * DESCRIPTION: Unload an ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) union acpi_operand_object *table_desc = ddb_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) u32 table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) ACPI_FUNCTION_TRACE(ex_unload_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * Temporarily emit a warning so that the ASL for the machine can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * hopefully obtained. This is to say that the Unload() operator is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * extremely rare if not completely unused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) ACPI_WARNING((AE_INFO, "Received request to unload an ACPI table"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * May 2018: Unload is no longer supported for the following reasons:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * 1) A correct implementation on some hosts may not be possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * 2) Other ACPI implementations do not correctly/fully support it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * 3) It requires host device driver support which does not exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * (To properly support namespace unload out from underneath.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * 4) This AML operator has never been seen in the field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) ACPI_EXCEPTION((AE_INFO, AE_NOT_IMPLEMENTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) "AML Unload operator is not supported"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * Validate the handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) * Although the handle is partially validated in acpi_ex_reconfiguration()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * when it calls acpi_ex_resolve_operands(), the handle is more completely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * validated here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * Handle must be a valid operand object of type reference. Also, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * ddb_handle must still be marked valid (table has not been previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * unloaded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if ((!ddb_handle) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) (!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) /* Get the table index from the ddb_handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) table_index = table_desc->reference.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * Release the interpreter lock so that the table lock won't have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * strict order requirement against it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) status = acpi_tb_unload_table(table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * Invalidate the handle. We do this because the handle may be stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * in a named object and may not be actually deleted until much later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) ddb_handle->common.flags &= ~AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) }