Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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: dspkginit - Completion of deferred package initialization
^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 "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define _COMPONENT          ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) ACPI_MODULE_NAME("dspkginit")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) acpi_ds_resolve_package_element(union acpi_operand_object **element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * FUNCTION:    acpi_ds_build_internal_package_obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * PARAMETERS:  walk_state      - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *              op              - Parser object to be translated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *              element_count   - Number of elements in the package - this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *                                the num_elements argument to Package()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *              obj_desc_ptr    - Where the ACPI internal object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * DESCRIPTION: Translate a parser Op package object to the equivalent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *              namespace object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * NOTE: The number of elements in the package will be always be the num_elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * count, regardless of the number of elements in the package list. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * num_elements is smaller, only that many package list elements are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * if num_elements is larger, the Package object is padded out with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * objects of type Uninitialized (as per ACPI spec.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * Even though the ASL compilers do not allow num_elements to be smaller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * than the Package list length (for the fixed length package opcode), some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * BIOS code modifies the AML on the fly to adjust the num_elements, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * this code compensates for that. This also provides compatibility with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * other AML interpreters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				   union acpi_parse_object *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				   u32 element_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				   union acpi_operand_object **obj_desc_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	union acpi_parse_object *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	union acpi_parse_object *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	union acpi_operand_object *obj_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u8 module_level_code = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u16 reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ACPI_FUNCTION_TRACE(ds_build_internal_package_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	/* Check if we are executing module level code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		module_level_code = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/* Find the parent of a possibly nested package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	parent = op->common.parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	       (parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		parent = parent->common.parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * If we are evaluating a Named package object of the form:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 *      Name (xxxx, Package)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * the package object already exists, otherwise it must be created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	obj_desc = *obj_desc_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		*obj_desc_ptr = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		obj_desc->package.node = parent->common.node;
^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) 	if (obj_desc->package.flags & AOPOBJ_DATA_VALID) {	/* Just in case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	 * Allocate the element array (array of pointers to the individual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 * objects) if necessary. the count is based on the num_elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 * parameter. Add an extra pointer slot so that the list is always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	 * null terminated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!obj_desc->package.elements) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 								   element_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 								   +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 								   1) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 								  sizeof(void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 									 *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (!obj_desc->package.elements) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			acpi_ut_delete_object_desc(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		obj_desc->package.count = element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	/* First arg is element count. Second arg begins the initializer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	arg = op->common.value.arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	 * If we are executing module-level code, we will defer the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 * full resolution of the package elements in order to support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 * forward references from the elements. This provides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	 * compatibility with other ACPI implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (module_level_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		obj_desc->package.aml_start = walk_state->aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		obj_desc->package.aml_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		ACPI_DEBUG_PRINT_RAW((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 				      "%s: Deferring resolution of Package elements\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 				      ACPI_GET_FUNCTION_NAME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	}
^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) 	 * Initialize the elements of the package, up to the num_elements count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 * Package is automatically padded with uninitialized (NULL) elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 * if num_elements is greater than the package list length. Likewise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	 * Package is truncated if num_elements is less than the list length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	for (i = 0; arg && (i < element_count); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			if (!arg->common.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				 * This is the case where an expression has returned a value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				 * The use of expressions (term_args) within individual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 				 * package elements is not supported by the AML interpreter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 				 * even though the ASL grammar supports it. Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				 *      Name (INT1, 0x1234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				 *      Name (PKG3, Package () {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				 *          Add (INT1, 0xAAAA0000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				 *      })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 				 *  1) No known AML interpreter supports this type of construct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 				 *  2) This fixes a fault if the construct is encountered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 				ACPI_EXCEPTION((AE_INFO, AE_SUPPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 						"Expressions within package elements are not supported"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				/* Cleanup the return object, it is not needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 				acpi_ut_remove_reference(walk_state->results->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 							 results.obj_desc[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 				return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			if (arg->common.node->type == ACPI_TYPE_METHOD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				 * A method reference "looks" to the parser to be a method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				 * invocation, so we special case it here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				    acpi_ds_build_internal_object(walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 								  arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 								  &obj_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 								  package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 								  elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				/* This package element is already built, just get it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 				obj_desc->package.elements[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				    ACPI_CAST_PTR(union acpi_operand_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 						  arg->common.node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			    acpi_ds_build_internal_object(walk_state, arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 							  &obj_desc->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 							  elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				ACPI_ERROR((AE_INFO, "%-48s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 					    "****DS namepath not found"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			if (!module_level_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 				 * Initialize this package element. This function handles the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				 * resolution of named references within the package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 				 * Forward references from module-level code are deferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				 * until all ACPI tables are loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				acpi_ds_init_package_element(0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 							     obj_desc->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 							     elements[i], NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 							     &obj_desc->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 							     elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		if (*obj_desc_ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			/* Existing package, get existing reference count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			reference_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			    (*obj_desc_ptr)->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			if (reference_count > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				/* Make new element ref count match original ref count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				/* TBD: Probably need an acpi_ut_add_references function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				for (index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 				     index < ((u32)reference_count - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 				     index++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 					acpi_ut_add_reference((obj_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 							       package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 							       elements[i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	/* Check for match between num_elements and actual length of package_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		 * num_elements was exhausted, but there are remaining elements in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		 * the package_list. Truncate the package to num_elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		 * Note: technically, this is an error, from ACPI spec: "It is an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		 * error for NumElements to be less than the number of elements in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		 * the PackageList". However, we just print a message and no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		 * exception is returned. This provides compatibility with other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		 * ACPI implementations. Some firmware implementations will alter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		 * the num_elements on the fly, possibly creating this type of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		 * ill-formed package object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		while (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			 * We must delete any package elements that were created earlier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			 * and are not going to be used because of the package truncation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 			if (arg->common.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 				acpi_ut_remove_reference(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 							 (union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 							  acpi_operand_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 							  arg->common.node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 				arg->common.node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			/* Find out how many elements there really are */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			arg = arg->common.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		ACPI_INFO(("Actual Package length (%u) is larger than "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			   "NumElements field (%u), truncated",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			   i, element_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	} else if (i < element_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		 * Arg list (elements) was exhausted, but we did not reach
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		 * num_elements count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		 * Note: this is not an error, the package is padded out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		 * with NULLs as per the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				      "%s: Package List length (%u) smaller than NumElements "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				      "count (%u), padded with null elements\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 				      ACPI_GET_FUNCTION_NAME, i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 				      element_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	/* Module-level packages will be resolved later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (!module_level_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		obj_desc->package.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^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)  * FUNCTION:    acpi_ds_init_package_element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * PARAMETERS:  acpi_pkg_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * DESCRIPTION: Resolve a named reference element within a package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) acpi_ds_init_package_element(u8 object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 			     union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			     union acpi_generic_state *state, void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	union acpi_operand_object **element_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	ACPI_FUNCTION_TRACE(ds_init_package_element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	if (!source_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	 * The following code is a bit of a hack to workaround a (current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	 * limitation of the acpi_pkg_callback interface. We need a pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	 * to the location within the element array because a new object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	 * may be created and stored there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	if (context) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		/* A direct call was made to this function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		element_ptr = (union acpi_operand_object **)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		/* Call came from acpi_ut_walk_package_tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		element_ptr = state->pkg.this_target_obj;
^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) 	/* We are only interested in reference objects/elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	if (source_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		/* Attempt to resolve the (named) reference to a namespace node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		acpi_ds_resolve_package_element(element_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	} else if (source_object->common.type == ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		source_object->package.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  * FUNCTION:    acpi_ds_resolve_package_element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * PARAMETERS:  element_ptr         - Pointer to a reference object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  * RETURN:      Possible new element is stored to the indirect element_ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  * DESCRIPTION: Resolve a package element that is a reference to a named
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  *              object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) acpi_ds_resolve_package_element(union acpi_operand_object **element_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	acpi_status status2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	union acpi_generic_state scope_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	union acpi_operand_object *element = *element_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	struct acpi_namespace_node *resolved_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	struct acpi_namespace_node *original_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	char *external_path = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	acpi_object_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	ACPI_FUNCTION_TRACE(ds_resolve_package_element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	/* Check if reference element is already resolved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	if (element->reference.resolved) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		ACPI_DEBUG_PRINT_RAW((ACPI_DB_PARSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 				      "%s: Package element is already resolved\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 				      ACPI_GET_FUNCTION_NAME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	/* Element must be a reference object of correct type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	scope_info.scope.node = element->reference.node;	/* Prefix node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	status = acpi_ns_lookup(&scope_info, (char *)element->reference.aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 				ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 				ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 				NULL, &resolved_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		if ((status == AE_NOT_FOUND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		    && acpi_gbl_ignore_package_resolution_errors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			 * Optionally be silent about the NOT_FOUND case for the referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			 * name. Although this is potentially a serious problem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			 * it can generate a lot of noise/errors on platforms whose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			 * firmware carries around a bunch of unused Package objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 			 * To disable these errors, set this global to TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			 *     acpi_gbl_ignore_package_resolution_errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			 * If the AML actually tries to use such a package, the unresolved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			 * element(s) will be replaced with NULL elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			/* Referenced name not found, set the element to NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 			acpi_ut_remove_reference(*element_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			*element_ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 			return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		status2 = acpi_ns_externalize_name(ACPI_UINT32_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 						   (char *)element->reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 						   aml, NULL, &external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 				"While resolving a named reference package element - %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 				external_path));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		if (ACPI_SUCCESS(status2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 			ACPI_FREE(external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		/* Could not resolve name, set the element to NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		acpi_ut_remove_reference(*element_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		*element_ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	} else if (resolved_node->type == ACPI_TYPE_ANY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		/* Named reference not resolved, return a NULL package element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			    "Could not resolve named package element [%4.4s] in [%4.4s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			    resolved_node->name.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			    scope_info.scope.node->name.ascii));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		*element_ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	}
^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) 	 * Special handling for Alias objects. We need resolved_node to point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	 * to the Alias target. This effectively "resolves" the alias.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (resolved_node->type == ACPI_TYPE_LOCAL_ALIAS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		resolved_node = ACPI_CAST_PTR(struct acpi_namespace_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 					      resolved_node->object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	/* Update the reference object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	element->reference.resolved = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	element->reference.node = resolved_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	type = element->reference.node->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	 * Attempt to resolve the node to a value before we insert it into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	 * the package. If this is a reference to a common data type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	 * resolve it immediately. According to the ACPI spec, package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	 * elements can only be "data objects" or method references.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	 * Attempt to resolve to an Integer, Buffer, String or Package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	 * If cannot, return the named reference (for things like Devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	 * Methods, etc.) Buffer Fields and Fields will resolve to simple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	 * objects (int/buf/str/pkg).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	 * NOTE: References to things like Devices, Methods, Mutexes, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	 * will remain as named references. This behavior is not described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	 * in the ACPI spec, but it appears to be an oversight.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	original_node = resolved_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	status = acpi_ex_resolve_node_to_value(&resolved_node, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		 * These object types are a result of named references, so we will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		 * leave them as reference objects. In other words, these types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		 * have no intrinsic "value".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	case ACPI_TYPE_MUTEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	case ACPI_TYPE_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	case ACPI_TYPE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		/* acpi_ex_resolve_node_to_value gave these an extra reference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		acpi_ut_remove_reference(original_node->object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		 * For all other types - the node was resolved to an actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		 * operand object with a value, return the object. Remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 		 * a reference on the existing object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		acpi_ut_remove_reference(element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		*element_ptr = (union acpi_operand_object *)resolved_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }