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: utcopy - Internal to external object translation utilities
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define _COMPONENT          ACPI_UTILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) ACPI_MODULE_NAME("utcopy")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 				union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 				u8 *data_space, acpi_size *buffer_space_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) acpi_ut_copy_ielement_to_ielement(u8 object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 				  union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 				  union acpi_generic_state *state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 				  void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 				  u8 *buffer, acpi_size *space_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 				union acpi_operand_object **return_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 				  union acpi_operand_object **internal_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			   union acpi_operand_object *dest_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) acpi_ut_copy_ielement_to_eelement(u8 object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				  union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 				  union acpi_generic_state *state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				  void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				  union acpi_operand_object *dest_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 				  struct acpi_walk_state *walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * FUNCTION:    acpi_ut_copy_isimple_to_esimple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * PARAMETERS:  internal_object     - Source object to be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *              external_object     - Where to return the copied object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *              data_space          - Where object data is returned (such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *                                    buffer and string data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *              buffer_space_used   - Length of data_space that was used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * DESCRIPTION: This function is called to copy a simple internal object to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *              an external object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *              The data_space buffer is assumed to have sufficient space for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *              the object.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 				u8 *data_space, acpi_size *buffer_space_used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	*buffer_space_used = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 * Check for NULL object case (could be an uninitialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 * package element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (!internal_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* Always clear the external object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	memset(external_object, 0, sizeof(union acpi_object));
^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) 	 * In general, the external object will be the same type as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 * the internal object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	external_object->type = internal_object->common.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/* However, only a limited number of external types are supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	switch (internal_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		external_object->string.pointer = (char *)data_space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		external_object->string.length = internal_object->string.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		*buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 								  internal_object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 								  string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 								  length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		memcpy((void *)data_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		       (void *)internal_object->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		       (acpi_size)internal_object->string.length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		external_object->buffer.pointer = data_space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		external_object->buffer.length = internal_object->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		*buffer_space_used =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		    ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 						 length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		memcpy((void *)data_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		       (void *)internal_object->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		       internal_object->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		external_object->integer.value = internal_object->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		/* This is an object reference. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		switch (internal_object->reference.class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		case ACPI_REFCLASS_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			 * For namepath, return the object handle ("reference")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			 * We are referring to the namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			external_object->reference.handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			    internal_object->reference.node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			external_object->reference.actual_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			    acpi_ns_get_type(internal_object->reference.node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			/* All other reference types are unsupported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			return_ACPI_STATUS(AE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		external_object->processor.proc_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		    internal_object->processor.proc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		external_object->processor.pblk_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		    internal_object->processor.address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		external_object->processor.pblk_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		    internal_object->processor.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	case ACPI_TYPE_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		external_object->power_resource.system_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		    internal_object->power_resource.system_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		external_object->power_resource.resource_order =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		    internal_object->power_resource.resource_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		 * There is no corresponding external object type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			    "Unsupported object type, cannot convert to external object: %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			    acpi_ut_get_type_name(internal_object->common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 						  type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * FUNCTION:    acpi_ut_copy_ielement_to_eelement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * PARAMETERS:  acpi_pkg_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * DESCRIPTION: Copy one package element to another package element
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) acpi_ut_copy_ielement_to_eelement(u8 object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				  union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 				  union acpi_generic_state *state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				  void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	acpi_size object_space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	u32 this_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	union acpi_object *target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	this_index = state->pkg.index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	target_object = (union acpi_object *)&((union acpi_object *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					       (state->pkg.dest_object))->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	    package.elements[this_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	switch (object_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	case ACPI_COPY_TYPE_SIMPLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		 * This is a simple or null object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		status = acpi_ut_copy_isimple_to_esimple(source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 							 target_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 							 info->free_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 							 &object_space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	case ACPI_COPY_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		 * Build the package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		target_object->type = ACPI_TYPE_PACKAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		target_object->package.count = source_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		target_object->package.elements =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		    ACPI_CAST_PTR(union acpi_object, info->free_space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		 * Pass the new package object back to the package walk routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		state->pkg.this_target_obj = target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		 * Save space for the array of objects (Package elements)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		 * update the buffer length counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 							    target_object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 							    package.count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 							    sizeof(union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 								   acpi_object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	info->free_space += object_space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	info->length += object_space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * FUNCTION:    acpi_ut_copy_ipackage_to_epackage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * PARAMETERS:  internal_object     - Pointer to the object we are returning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  *              buffer              - Where the object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  *              space_used          - Where the object length is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  * DESCRIPTION: This function is called to place a package object in a user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  *              buffer. A package object by definition contains other objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  *              The buffer is assumed to have sufficient space for the object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  *              The caller must have verified the buffer length needed using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  *              the acpi_ut_get_object_size function before calling this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				  u8 *buffer, acpi_size *space_used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	union acpi_object *external_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	struct acpi_pkg_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	 * First package at head of the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	external_object = ACPI_CAST_PTR(union acpi_object, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	 * Free space begins right after the first package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	info.free_space = buffer +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	    ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	info.object_space = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	info.num_packages = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	external_object->type = internal_object->common.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	external_object->package.count = internal_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	external_object->package.elements =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	    ACPI_CAST_PTR(union acpi_object, info.free_space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	 * Leave room for an array of ACPI_OBJECTS in the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	 * and move the free space past it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	info.length += (acpi_size)external_object->package.count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	    ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	info.free_space += external_object->package.count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	    ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	status = acpi_ut_walk_package_tree(internal_object, external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 					   acpi_ut_copy_ielement_to_eelement,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 					   &info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	*space_used = info.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  * FUNCTION:    acpi_ut_copy_iobject_to_eobject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  * PARAMETERS:  internal_object     - The internal object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  *              ret_buffer          - Where the object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * DESCRIPTION: This function is called to build an API object to be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  *              to the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 				struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	if (internal_object->common.type == ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		 * Package object:  Copy all subobjects (including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		 * nested packages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		status = acpi_ut_copy_ipackage_to_epackage(internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 							   ret_buffer->pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 							   &ret_buffer->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		 * Build a simple object (no nested objects)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		status = acpi_ut_copy_isimple_to_esimple(internal_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 							 ACPI_CAST_PTR(union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 								       acpi_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 								       ret_buffer->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 								       pointer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 							 ACPI_ADD_PTR(u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 								      ret_buffer->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 								      pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 								      ACPI_ROUND_UP_TO_NATIVE_WORD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 								      (sizeof
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 								       (union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 									acpi_object))),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 							 &ret_buffer->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		 * build simple does not include the object size in the length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		 * so we add it in here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		ret_buffer->length += sizeof(union acpi_object);
^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) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * FUNCTION:    acpi_ut_copy_esimple_to_isimple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * PARAMETERS:  external_object     - The external object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *              ret_internal_object - Where the internal object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  * DESCRIPTION: This function copies an external object to an internal one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  *              NOTE: Pointers can be copied, we don't need to copy data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)  *              (The pointers have to be valid in our address space no matter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)  *              what we do with them!)
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 				union acpi_operand_object **ret_internal_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	union acpi_operand_object *internal_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	 * Simple types supported are: String, Buffer, Integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	switch (external_object->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		internal_object = acpi_ut_create_internal_object((u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 								 external_object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 								 type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		if (!internal_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	case ACPI_TYPE_ANY:	/* This is the case for a NULL object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		*ret_internal_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		/* All other types are not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 			    "Unsupported object type, cannot convert to internal object: %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 			    acpi_ut_get_type_name(external_object->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	/* Must COPY string and buffer contents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	switch (external_object->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		internal_object->string.pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		    ACPI_ALLOCATE_ZEROED((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 					 external_object->string.length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		if (!internal_object->string.pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			goto error_exit;
^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) 		memcpy(internal_object->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		       external_object->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		       external_object->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		internal_object->string.length = external_object->string.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		internal_object->buffer.pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		    ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		if (!internal_object->buffer.pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		memcpy(internal_object->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 		       external_object->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		       external_object->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		internal_object->buffer.length = external_object->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		/* Mark buffer data valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		internal_object->buffer.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		internal_object->integer.value = external_object->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		/* An incoming reference is defined to be a namespace node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		internal_object->reference.class = ACPI_REFCLASS_REFOF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		internal_object->reference.object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		    external_object->reference.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		/* Other types can't get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	*ret_internal_object = internal_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	acpi_ut_remove_reference(internal_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)  * FUNCTION:    acpi_ut_copy_epackage_to_ipackage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)  * PARAMETERS:  external_object     - The external object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)  *              internal_object     - Where the internal object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)  * DESCRIPTION: Copy an external package object to an internal package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)  *              Handles nested packages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 				  union acpi_operand_object **internal_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	union acpi_operand_object *package_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	union acpi_operand_object **package_elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	/* Create the package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	package_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	    acpi_ut_create_package_object(external_object->package.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	if (!package_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	package_elements = package_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	 * Recursive implementation. Probably ok, since nested external
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	 * packages as parameters should be very rare.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	for (i = 0; i < external_object->package.count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		    acpi_ut_copy_eobject_to_iobject(&external_object->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 						    elements[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 						    &package_elements[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 			/* Truncate package and delete it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 			package_object->package.count = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 			package_elements[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 			acpi_ut_remove_reference(package_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 			return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	/* Mark package data valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	package_object->package.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	*internal_object = package_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)  * FUNCTION:    acpi_ut_copy_eobject_to_iobject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)  * PARAMETERS:  external_object     - The external object to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)  *              internal_object     - Where the internal object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)  * DESCRIPTION: Converts an external object to an internal object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 				union acpi_operand_object **internal_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	if (external_object->type == ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 		    acpi_ut_copy_epackage_to_ipackage(external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 						      internal_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		 * Build a simple object (no nested objects)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 		status = acpi_ut_copy_esimple_to_isimple(external_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 							 internal_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)  * FUNCTION:    acpi_ut_copy_simple_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)  * PARAMETERS:  source_desc         - The internal object to be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)  *              dest_desc           - New target object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)  * DESCRIPTION: Simple copy of one internal object to another. Reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)  *              of the destination object is preserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 			   union acpi_operand_object *dest_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	u16 reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	union acpi_operand_object *next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	acpi_size copy_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	/* Save fields from destination that we don't want to overwrite */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	reference_count = dest_desc->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	next_object = dest_desc->common.next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	 * Copy the entire source object over the destination object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	 * Note: Source can be either an operand object or namespace node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	copy_size = sizeof(union acpi_operand_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 		copy_size = sizeof(struct acpi_namespace_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	memcpy(ACPI_CAST_PTR(char, dest_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	       ACPI_CAST_PTR(char, source_desc), copy_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	/* Restore the saved fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	dest_desc->common.reference_count = reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	dest_desc->common.next_object = next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	/* New object is not static, regardless of source */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	/* Handle the objects with extra data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	switch (dest_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		 * Allocate and copy the actual buffer if and only if:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		 * 1) There is a valid buffer pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		 * 2) The buffer has a length > 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		if ((source_desc->buffer.pointer) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		    (source_desc->buffer.length)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 			dest_desc->buffer.pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 			    ACPI_ALLOCATE(source_desc->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 			if (!dest_desc->buffer.pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 				return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 			/* Copy the actual buffer data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 			memcpy(dest_desc->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 			       source_desc->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 			       source_desc->buffer.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 		 * Allocate and copy the actual string if and only if:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 		 * 1) There is a valid string pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		 * (Pointer to a NULL string is allowed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 		if (source_desc->string.pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 			dest_desc->string.pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 			    ACPI_ALLOCATE((acpi_size)source_desc->string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 					  length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 			if (!dest_desc->string.pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 				return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 			/* Copy the actual string data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 			memcpy(dest_desc->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 			       source_desc->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 			       (acpi_size)source_desc->string.length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 		 * We copied the reference object, so we now must add a reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 		 * to the object pointed to by the reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 		 * DDBHandle reference (from Load/load_table) is a special reference,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 		 * it does not have a Reference.Object, so does not need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 		 * increase the reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		acpi_ut_add_reference(source_desc->reference.object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 		 * We copied the Region Handler, so we now must add a reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 		if (dest_desc->region.handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 			acpi_ut_add_reference(dest_desc->region.handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 		 * For Mutex and Event objects, we cannot simply copy the underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 		 * OS object. We must create a new one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	case ACPI_TYPE_MUTEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 		status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	case ACPI_TYPE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 		status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 						  &dest_desc->event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 						  os_semaphore);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 		/* Nothing to do for other simple objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)  * FUNCTION:    acpi_ut_copy_ielement_to_ielement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)  * PARAMETERS:  acpi_pkg_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)  * DESCRIPTION: Copy one package element to another package element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) acpi_ut_copy_ielement_to_ielement(u8 object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 				  union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 				  union acpi_generic_state *state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 				  void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	u32 this_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	union acpi_operand_object **this_target_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	union acpi_operand_object *target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	this_index = state->pkg.index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 	this_target_ptr = (union acpi_operand_object **)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	    &state->pkg.dest_object->package.elements[this_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	switch (object_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 	case ACPI_COPY_TYPE_SIMPLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 		/* A null source object indicates a (legal) null package element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 		if (source_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 			 * This is a simple object, just copy it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 			target_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 			    acpi_ut_create_internal_object(source_object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 							   common.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 			if (!target_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 				return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) 			    acpi_ut_copy_simple_object(source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 						       target_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 				goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 			*this_target_ptr = target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 			/* Pass through a null element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 			*this_target_ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 	case ACPI_COPY_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 		 * This object is a package - go down another nesting level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 		 * Create and build the package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 		target_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 		    acpi_ut_create_package_object(source_object->package.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 		if (!target_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 			return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 		target_object->common.flags = source_object->common.flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) 		/* Pass the new package object back to the package walk routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) 		state->pkg.this_target_obj = target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) 		/* Store the object pointer in the parent package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) 		*this_target_ptr = target_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) 	acpi_ut_remove_reference(target_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)  * FUNCTION:    acpi_ut_copy_ipackage_to_ipackage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)  * PARAMETERS:  source_obj      - Pointer to the source package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)  *              dest_obj        - Where the internal object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878)  *              walk_state      - Current Walk state descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)  * DESCRIPTION: This function is called to copy an internal package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)  *              into another internal package object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) 				  union acpi_operand_object *dest_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) 				  struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) 	ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) 	dest_obj->common.type = source_obj->common.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) 	dest_obj->common.flags = source_obj->common.flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) 	dest_obj->package.count = source_obj->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) 	 * Create the object array and walk the source package tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) 	dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) 							   source_obj->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) 							   count +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) 							   1) * sizeof(void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) 	if (!dest_obj->package.elements) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) 		ACPI_ERROR((AE_INFO, "Package allocation failure"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) 	 * Copy the package element-by-element by walking the package "tree".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) 	 * This handles nested packages of arbitrary depth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) 	status = acpi_ut_walk_package_tree(source_obj, dest_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) 					   acpi_ut_copy_ielement_to_ielement,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) 					   walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) 		/* On failure, delete the destination package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) 		acpi_ut_remove_reference(dest_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)  * FUNCTION:    acpi_ut_copy_iobject_to_iobject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)  * PARAMETERS:  source_desc         - The internal object to be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)  *              dest_desc           - Where the copied object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)  *              walk_state          - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)  * DESCRIPTION: Copy an internal object to a new internal object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) 				union acpi_operand_object **dest_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) 				struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) 	ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) 	/* Create the top level object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) 	*dest_desc = acpi_ut_create_internal_object(source_desc->common.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) 	if (!*dest_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) 	/* Copy the object and possible subobjects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) 	if (source_desc->common.type == ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) 		    acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) 						      walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) 		status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) 	/* Delete the allocated object if copy failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) 		acpi_ut_remove_reference(*dest_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) }