^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: nseval - Object evaluation, includes control method execution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define _COMPONENT ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ACPI_MODULE_NAME("nseval")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * FUNCTION: acpi_ns_evaluate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * PARAMETERS: info - Evaluation info block, contains these fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * and more:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * prefix_node - Prefix or Method/Object Node to execute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * relative_path - Name of method to execute, If NULL, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Node is the object to execute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * parameters - List of parameters to pass to the method,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * terminated by NULL. Params itself may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * NULL if no parameters are being passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * parameter_type - Type of Parameter list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * return_object - Where to put method's return value (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * any). If NULL, no value is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * flags - ACPI_IGNORE_RETURN_VALUE to delete return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * DESCRIPTION: Execute a control method or return the current value of an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * ACPI namespace object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * MUTEX: Locks interpreter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ACPI_FUNCTION_TRACE(ns_evaluate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (!info->node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Get the actual namespace node for the target object if we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * need to. Handles these cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * 1) Null node, valid pathname from root (absolute path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * 2) Node and valid pathname (path relative to Node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * 3) Node, Null pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) acpi_ns_get_node(info->prefix_node, info->relative_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ACPI_NS_NO_UPSEARCH, &info->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return_ACPI_STATUS(status);
^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) * For a method alias, we must grab the actual method node so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * proper scoping context will be established before execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) info->node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ACPI_CAST_PTR(struct acpi_namespace_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) info->node->object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* Complete the info block initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) info->return_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) info->node_flags = info->node->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) info->obj_desc = acpi_ns_get_attached_object(info->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) info->relative_pathname, info->node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) acpi_ns_get_attached_object(info->node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* Get info if we have a predefined name (_HID, etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) info->predefined =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) acpi_ut_match_predefined_method(info->node->name.ascii);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* Get the full pathname to the object, for use in warning messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) info->full_pathname = acpi_ns_get_normalized_pathname(info->node, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (!info->full_pathname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return_ACPI_STATUS(AE_NO_MEMORY);
^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) /* Optional object evaluation log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ACPI_DEBUG_PRINT_RAW((ACPI_DB_EVALUATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) "%-26s: %s (%s)\n", " Enter evaluation",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) &info->full_pathname[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) acpi_ut_get_type_name(info->node->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* Count the number of arguments being passed in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) info->param_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (info->parameters) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) while (info->parameters[info->param_count]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) info->param_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* Warn on impossible argument count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (info->param_count > ACPI_METHOD_NUM_ARGS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) "Excess arguments (%u) - using only %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) info->param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ACPI_METHOD_NUM_ARGS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) info->param_count = ACPI_METHOD_NUM_ARGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * For predefined names: Check that the declared argument count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * matches the ACPI spec -- otherwise this is a BIOS error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) acpi_ns_check_acpi_compliance(info->full_pathname, info->node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) info->predefined);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * For all names: Check that the incoming argument count for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * this method/object matches the actual ASL/AML definition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) acpi_ns_check_argument_count(info->full_pathname, info->node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) info->param_count, info->predefined);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* For predefined names: Typecheck all incoming arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) acpi_ns_check_argument_types(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * Three major evaluation cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * 1) Object types that cannot be evaluated by definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * 2) The object is a control method -- execute it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * 3) The object is not a method -- just return it's current value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) switch (acpi_ns_get_type(info->node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) case ACPI_TYPE_ANY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) case ACPI_TYPE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) case ACPI_TYPE_MUTEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) case ACPI_TYPE_LOCAL_SCOPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * 1) Disallow evaluation of these object types. For these,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * object evaluation is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) "%s: This object type [%s] "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) "never contains data and cannot be evaluated",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) acpi_ut_get_type_name(info->node->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * 2) Object is a control method - execute it
^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) /* Verify that there is a method object associated with this node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (!info->obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) "%s: Method has no attached sub-object",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) info->full_pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) status = AE_NULL_OBJECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) goto cleanup;
^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) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "**** Execute method [%s] at AML address %p length %X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) info->obj_desc->method.aml_start + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) info->obj_desc->method.aml_length - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * Any namespace deletion must acquire both the namespace and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * interpreter locks to ensure that no thread is using the portion of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * the namespace that is being deleted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Execute the method via the interpreter. The interpreter is locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * here before calling into the AML parser
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) status = acpi_ps_execute_method(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * 3) All other non-method objects -- get the current object value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * Some objects require additional resolution steps (e.g., the Node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * may be a field that must be read, etc.) -- we can't just grab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * the object out of the node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * Use resolve_node_to_value() to get the associated value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * NOTE: we can get away with passing in NULL for a walk state because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * the Node is guaranteed to not be a reference to either a method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * local or a method argument (because this interface is never called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * from a running method.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Even though we do not directly invoke the interpreter for object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * resolution, we must lock it because we could access an op_region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * The op_region access code assumes that the interpreter is locked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* TBD: resolve_node_to_value has a strange interface, fix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) info->return_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ACPI_CAST_PTR(union acpi_operand_object, info->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) (struct acpi_namespace_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) &info->return_object), NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) info->return_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) goto cleanup;
^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) ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Returned object %p [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) info->return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) acpi_ut_get_object_type_name(info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return_object)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^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) * For predefined names, check the return value against the ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * specification. Some incorrect return value types are repaired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) (void)acpi_ns_check_return_value(info->node, info, info->param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) status, &info->return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /* Check if there is a return value that must be dealt with */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (status == AE_CTRL_RETURN_VALUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /* If caller does not want the return value, delete it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (info->flags & ACPI_IGNORE_RETURN_VALUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) acpi_ut_remove_reference(info->return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) info->return_object = NULL;
^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) /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) } else if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* If return_object exists, delete it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (info->return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) acpi_ut_remove_reference(info->return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) info->return_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) "*** Completed evaluation of object %s ***\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) info->relative_pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /* Optional object evaluation log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ACPI_DEBUG_PRINT_RAW((ACPI_DB_EVALUATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) "%-26s: %s\n", " Exit evaluation",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) &info->full_pathname[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * Namespace was unlocked by the handling acpi_ns* function, so we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * just free the pathname and return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) ACPI_FREE(info->full_pathname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) info->full_pathname = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }