^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: nsconvert - Object conversions for objects returned by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * predefined methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2000 - 2020, Intel Corp.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "accommon.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 "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acpredef.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "amlresrc.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("nsconvert")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * FUNCTION: acpi_ns_convert_to_integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * PARAMETERS: original_object - Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * RETURN: Status. AE_OK if conversion was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) u64 value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) switch (original_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* String-to-Integer conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) acpi_ut_strtoul64(original_object->string.pointer, &value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (original_object->buffer.length > 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* Extract each buffer byte to create the integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) for (i = 0; i < original_object->buffer.length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) value |= ((u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) original_object->buffer.pointer[i] << (i *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) new_object = acpi_ut_create_integer_object(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return (AE_NO_MEMORY);
^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) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return (AE_OK);
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * FUNCTION: acpi_ns_convert_to_string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * PARAMETERS: original_object - Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * RETURN: Status. AE_OK if conversion was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^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) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) acpi_ns_convert_to_string(union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) acpi_size length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) switch (original_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * Integer-to-String conversion. Commonly, convert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * an integer of value 0 to a NULL string. The last element of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * _BIF and _BIX packages occasionally need this fix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (original_object->integer.value == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* Allocate a new NULL string object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) new_object = acpi_ut_create_string_object(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) status = acpi_ex_convert_to_string(original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) &new_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ACPI_IMPLICIT_CONVERT_HEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return (status);
^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) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * Buffer-to-String conversion. Use a to_string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * conversion, no transform performed on the buffer data. The best
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * example of this is the _BIF method, where the string data from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * the battery is often (incorrectly) returned as buffer object(s).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) while ((length < original_object->buffer.length) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) (original_object->buffer.pointer[length])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) length++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Allocate a new string object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) new_object = acpi_ut_create_string_object(length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return (AE_NO_MEMORY);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * Copy the raw buffer data with no transform. String is already NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * terminated at Length+1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) memcpy(new_object->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) original_object->buffer.pointer, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return (AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * FUNCTION: acpi_ns_convert_to_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * PARAMETERS: original_object - Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * RETURN: Status. AE_OK if conversion was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) union acpi_operand_object **elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u32 *dword_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) switch (original_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * Integer-to-Buffer conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * Convert the Integer to a packed-byte buffer. _MAT and other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * objects need this sometimes, if a read has been performed on a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * Field object that is less than or equal to the global integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * size (32 or 64 bits).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) acpi_ex_convert_to_buffer(original_object, &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /* String-to-Buffer conversion. Simple data copy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) new_object = acpi_ut_create_buffer_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) (original_object->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) memcpy(new_object->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) original_object->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) original_object->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * This case is often seen for predefined names that must return a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Buffer object with multiple DWORD integers within. For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * _FDE and _GTM. The Package can be converted to a Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* All elements of the Package must be integers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) elements = original_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) count = original_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if ((!*elements) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) elements++;
^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) /* Create the new buffer object to replace the Package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* Copy the package elements (integers) to the buffer as DWORDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) elements = original_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *dword_buffer = (u32)(*elements)->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) dword_buffer++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return (AE_AML_OPERAND_TYPE);
^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) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * FUNCTION: acpi_ns_convert_to_unicode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * PARAMETERS: scope - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * original_object - ASCII String Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * RETURN: Status. AE_OK if conversion was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) acpi_ns_convert_to_unicode(struct acpi_namespace_node *scope,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) char *ascii_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) u16 *unicode_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) u32 unicode_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (!original_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return (AE_OK);
^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) /* If a Buffer was returned, it must be at least two bytes long */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (original_object->common.type == ACPI_TYPE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (original_object->buffer.length < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) return (AE_AML_OPERAND_VALUE);
^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) *return_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return (AE_OK);
^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) * The original object is an ASCII string. Convert this string to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * a unicode buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) ascii_string = original_object->string.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) unicode_length = (original_object->string.length * 2) + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /* Create a new buffer object for the Unicode data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) new_object = acpi_ut_create_buffer_object(unicode_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /* Convert ASCII to Unicode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) for (i = 0; i < original_object->string.length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) unicode_buffer[i] = (u16)ascii_string[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return (AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * FUNCTION: acpi_ns_convert_to_resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * PARAMETERS: scope - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * original_object - Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * RETURN: Status. AE_OK if conversion was successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * DESCRIPTION: Attempt to convert a Integer object to a resource_template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) acpi_ns_convert_to_resource(struct acpi_namespace_node *scope,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) u8 *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * We can fix the following cases for an expected resource template:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * 1. No return value (interpreter slack mode is disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * 2. A "Return (Zero)" statement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * 3. A "Return empty buffer" statement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) * We will return a buffer containing a single end_tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * resource descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (original_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) switch (original_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /* We can only repair an Integer==0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if (original_object->integer.value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if (original_object->buffer.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /* Additional checks can be added in the future */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) *return_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /* Create the new buffer object for the resource descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) new_object = acpi_ut_create_buffer_object(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) buffer = ACPI_CAST_PTR(u8, new_object->buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /* Initialize the Buffer with a single end_tag descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) buffer[1] = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * FUNCTION: acpi_ns_convert_to_reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * PARAMETERS: scope - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * original_object - Object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * return_object - Where the new converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * RETURN: Status. AE_OK if conversion was successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * DESCRIPTION: Attempt to convert a Integer object to a object_reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) acpi_ns_convert_to_reference(struct acpi_namespace_node *scope,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) union acpi_operand_object **return_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) union acpi_operand_object *new_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) union acpi_generic_state scope_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) ACPI_FUNCTION_NAME(ns_convert_to_reference);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* Convert path into internal presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) acpi_ns_internalize_name(original_object->string.pointer, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) /* Find the namespace node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) scope_info.scope.node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) ACPI_CAST_PTR(struct acpi_namespace_node, scope);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) acpi_ns_lookup(&scope_info, name, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) NULL, &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* Check if we are resolving a named reference within a package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) ACPI_ERROR_NAMESPACE(&scope_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) original_object->string.pointer, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /* Create and init a new internal ACPI object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) new_object = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) new_object->reference.node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) new_object->reference.object = node->object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) new_object->reference.class = ACPI_REFCLASS_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * Increase reference of the object if needed (the object is likely a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * null for device nodes).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) acpi_ut_add_reference(node->object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) ACPI_FREE(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) *return_object = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }