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: rsutils - Utilities for the resource manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "acresrc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define _COMPONENT          ACPI_RESOURCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) ACPI_MODULE_NAME("rsutils")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * FUNCTION:    acpi_rs_decode_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * PARAMETERS:  mask            - Bitmask to decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *              list            - Where the converted list is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * RETURN:      Count of bits set (length of list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * DESCRIPTION: Convert a bit mask into a list of values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u8 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u8 bit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	/* Decode the mask bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	for (i = 0, bit_count = 0; mask; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		if (mask & 0x0001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			list[bit_count] = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			bit_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		mask >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return (bit_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * FUNCTION:    acpi_rs_encode_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * PARAMETERS:  list            - List of values to encode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *              count           - Length of list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * RETURN:      Encoded bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * DESCRIPTION: Convert a list of values to an encoded bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *
^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) u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u16 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* Encode the list into a single bitmask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	for (i = 0, mask = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		mask |= (0x1 << list[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return (mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * FUNCTION:    acpi_rs_move_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * PARAMETERS:  destination         - Pointer to the destination descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *              source              - Pointer to the source descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *              item_count          - How many items to move
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *              move_type           - Byte width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *              alignment issues and endian issues if necessary, as configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	/* One move per item */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	for (i = 0; i < item_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		switch (move_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			 * For the 8-bit case, we can perform the move all at once
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			 * since there are no alignment or endian issues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		case ACPI_RSC_MOVE8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		case ACPI_RSC_MOVE_GPIO_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		case ACPI_RSC_MOVE_SERIAL_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		case ACPI_RSC_MOVE_SERIAL_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			memcpy(destination, source, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 * 16-, 32-, and 64-bit cases must use the move macros that perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			 * endian conversion and/or accommodate hardware that cannot perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			 * misaligned memory transfers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		case ACPI_RSC_MOVE16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		case ACPI_RSC_MOVE_GPIO_PIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 					   &ACPI_CAST_PTR(u16, source)[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		case ACPI_RSC_MOVE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 					   &ACPI_CAST_PTR(u32, source)[i]);
^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_RSC_MOVE64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 					   &ACPI_CAST_PTR(u64, source)[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^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)  * FUNCTION:    acpi_rs_set_resource_length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * PARAMETERS:  total_length        - Length of the AML descriptor, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *                                    the header and length fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  *              aml                 - Pointer to the raw AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * DESCRIPTION: Set the resource_length field of an AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *              resource descriptor, both Large and Small descriptors are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *              supported automatically. Note: Descriptor Type field must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  *              be valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			    union aml_resource *aml)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	acpi_rs_length resource_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	/* Length is the total descriptor length minus the header length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	resource_length = (acpi_rs_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	    (total_length - acpi_ut_get_resource_header_length(aml));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	/* Length is stored differently for large and small descriptors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		/* Large descriptor -- bytes 1-2 contain the 16-bit length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				   &resource_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		 * Small descriptor -- bits 2:0 of byte 0 contain the length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		 * Clear any existing length, preserving descriptor type bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		aml->small_header.descriptor_type = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		    ((aml->small_header.descriptor_type &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		      ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		     | resource_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	}
^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_rs_set_resource_header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * PARAMETERS:  descriptor_type     - Byte to be inserted as the type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *              total_length        - Length of the AML descriptor, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  *                                    the header and length fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  *              aml                 - Pointer to the raw AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  *              resource descriptor, both Large and Small descriptors are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  *              supported automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) acpi_rs_set_resource_header(u8 descriptor_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			    acpi_rsdesc_size total_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			    union aml_resource *aml)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	/* Set the Resource Type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	aml->small_header.descriptor_type = descriptor_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	/* Set the Resource Length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	acpi_rs_set_resource_length(total_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * FUNCTION:    acpi_rs_strcpy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * PARAMETERS:  destination         - Pointer to the destination string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  *              source              - Pointer to the source string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * RETURN:      String length, including NULL terminator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * DESCRIPTION: Local string copy that returns the string length, saving a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  *              strcpy followed by a strlen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static u16 acpi_rs_strcpy(char *destination, char *source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	for (i = 0; source[i]; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		destination[i] = source[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	destination[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	/* Return string length including the NULL terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return ((u16) (i + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * FUNCTION:    acpi_rs_get_resource_source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * PARAMETERS:  resource_length     - Length field of the descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  *              minimum_length      - Minimum length of the descriptor (minus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  *                                    any optional fields)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  *              resource_source     - Where the resource_source is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  *              aml                 - Pointer to the raw AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  *              string_ptr          - (optional) where to store the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  *                                    resource_source string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * RETURN:      Length of the string plus NULL terminator, rounded up to native
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  *              word boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  *              to an internal resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) acpi_rs_length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) acpi_rs_get_resource_source(acpi_rs_length resource_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			    acpi_rs_length minimum_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			    struct acpi_resource_source * resource_source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			    union aml_resource * aml, char *string_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	acpi_rsdesc_size total_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	u8 *aml_resource_source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	total_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	    resource_length + sizeof(struct aml_resource_large_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	 * resource_source is present if the length of the descriptor is longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	 * than the minimum length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	 * Note: Some resource descriptors will have an additional null, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	 * we add 1 to the minimum length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (total_length > (acpi_rsdesc_size)(minimum_length + 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		/* Get the resource_source_index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		resource_source->index = aml_resource_source[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		resource_source->string_ptr = string_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		if (!string_ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			 * String destination pointer is not specified; Set the String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			 * pointer to the end of the current resource_source structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			resource_source->string_ptr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			    ACPI_ADD_PTR(char, resource_source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 					 sizeof(struct acpi_resource_source));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		 * In order for the Resource length to be a multiple of the native
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		 * word, calculate the length of the string (+1 for NULL terminator)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		 * and expand to the next word multiple.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		 * Zero the entire area of the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		total_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		    (u32)strlen(ACPI_CAST_PTR(char, &aml_resource_source[1])) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		    1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		total_length = (u32)ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		memset(resource_source->string_ptr, 0, total_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		/* Copy the resource_source string to the destination */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		resource_source->string_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		    acpi_rs_strcpy(resource_source->string_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 				   ACPI_CAST_PTR(char,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 						 &aml_resource_source[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		return ((acpi_rs_length)total_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	/* resource_source is not present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	resource_source->index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	resource_source->string_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	resource_source->string_ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	return (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^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)  * FUNCTION:    acpi_rs_set_resource_source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  * PARAMETERS:  aml                 - Pointer to the raw AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  *              minimum_length      - Minimum length of the descriptor (minus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *                                    any optional fields)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  *              resource_source     - Internal resource_source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  * RETURN:      Total length of the AML descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)  * DESCRIPTION: Convert an optional resource_source from internal format to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  *              raw AML resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) acpi_rsdesc_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) acpi_rs_set_resource_source(union aml_resource *aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			    acpi_rs_length minimum_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 			    struct acpi_resource_source *resource_source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	u8 *aml_resource_source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	acpi_rsdesc_size descriptor_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	descriptor_length = minimum_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	/* Non-zero string length indicates presence of a resource_source */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (resource_source->string_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		/* Point to the end of the AML descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		/* Copy the resource_source_index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		aml_resource_source[0] = (u8) resource_source->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		/* Copy the resource_source string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		strcpy(ACPI_CAST_PTR(char, &aml_resource_source[1]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		       resource_source->string_ptr);
^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) 		 * Add the length of the string (+ 1 for null terminator) to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		 * final descriptor length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		descriptor_length += ((acpi_rsdesc_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 				      resource_source->string_length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	/* Return the new total length of the AML descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	return (descriptor_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^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)  * FUNCTION:    acpi_rs_get_prt_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)  * PARAMETERS:  node            - Device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)  *              ret_buffer      - Pointer to a buffer structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)  *                                results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  * DESCRIPTION: This function is called to get the _PRT value of an object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  *              contained in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  *              and the contents of the callers buffer is undefined.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			    struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	ACPI_FUNCTION_TRACE(rs_get_prt_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	/* Parameters guaranteed valid by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	/* Execute the method, no parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	    acpi_ut_evaluate_object(node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 				    &obj_desc);
^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) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	 * Create a resource linked list from the byte stream buffer that comes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	 * back from the _CRS method execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	/* On exit, we must delete the object returned by evaluate_object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)  * FUNCTION:    acpi_rs_get_crs_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)  * PARAMETERS:  node            - Device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)  *              ret_buffer      - Pointer to a buffer structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)  *                                results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)  * DESCRIPTION: This function is called to get the _CRS value of an object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)  *              contained in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  *              and the contents of the callers buffer is undefined.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			    struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	ACPI_FUNCTION_TRACE(rs_get_crs_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	/* Parameters guaranteed valid by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	/* Execute the method, no parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	    acpi_ut_evaluate_object(node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 				    &obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	 * Make the call to create a resource linked list from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	 * byte stream buffer that comes back from the _CRS method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	 * execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	/* On exit, we must delete the object returned by evaluateObject */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)  * FUNCTION:    acpi_rs_get_prs_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)  * PARAMETERS:  node            - Device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)  *              ret_buffer      - Pointer to a buffer structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)  *                                results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)  * DESCRIPTION: This function is called to get the _PRS value of an object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)  *              contained in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)  *              and the contents of the callers buffer is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 			    struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	ACPI_FUNCTION_TRACE(rs_get_prs_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	/* Parameters guaranteed valid by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	/* Execute the method, no parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	    acpi_ut_evaluate_object(node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 				    &obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	 * Make the call to create a resource linked list from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	 * byte stream buffer that comes back from the _CRS method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	 * execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	/* On exit, we must delete the object returned by evaluateObject */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)  * FUNCTION:    acpi_rs_get_aei_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)  * PARAMETERS:  node            - Device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)  *              ret_buffer      - Pointer to a buffer structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)  *                                results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)  * DESCRIPTION: This function is called to get the _AEI value of an object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)  *              contained in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)  *              and the contents of the callers buffer is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 			    struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	ACPI_FUNCTION_TRACE(rs_get_aei_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	/* Parameters guaranteed valid by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	/* Execute the method, no parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	    acpi_ut_evaluate_object(node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 				    &obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	 * Make the call to create a resource linked list from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	 * byte stream buffer that comes back from the _CRS method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	 * execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	/* On exit, we must delete the object returned by evaluateObject */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)  * FUNCTION:    acpi_rs_get_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)  * PARAMETERS:  handle          - Handle to the containing object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)  *              path            - Path to method, relative to Handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)  *              ret_buffer      - Pointer to a buffer structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)  *                                results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)  *              object contained in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  *              and the contents of the callers buffer is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) acpi_rs_get_method_data(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 			const char *path, struct acpi_buffer *ret_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	ACPI_FUNCTION_TRACE(rs_get_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	/* Parameters guaranteed valid by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	/* Execute the method, no parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	    acpi_ut_evaluate_object(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 				    (struct acpi_namespace_node, handle), path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 				    ACPI_BTYPE_BUFFER, &obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	 * Make the call to create a resource linked list from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	 * byte stream buffer that comes back from the method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	 * execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	/* On exit, we must delete the object returned by evaluate_object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)  * FUNCTION:    acpi_rs_set_srs_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)  * PARAMETERS:  node            - Device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)  *              in_buffer       - Pointer to a buffer structure of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)  *                                parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)  * DESCRIPTION: This function is called to set the _SRS of an object contained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)  *              in an object specified by the handle passed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)  *              and the contents of the callers buffer is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)  * Note: Parameters guaranteed valid by caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 			    struct acpi_buffer *in_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	struct acpi_evaluate_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	union acpi_operand_object *args[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	struct acpi_buffer buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	ACPI_FUNCTION_TRACE(rs_set_srs_method_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 	/* Allocate and initialize the evaluation information block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 	info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 	info->prefix_node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 	info->relative_pathname = METHOD_NAME__SRS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 	info->parameters = args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	info->flags = ACPI_IGNORE_RETURN_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	 * The in_buffer parameter will point to a linked list of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	 * resource parameters. It needs to be formatted into a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	 * byte stream to be sent in as an input parameter to _SRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	 * Convert the linked list into a byte stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	status = acpi_rs_create_aml_resources(in_buffer, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	/* Create and initialize the method parameter object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	if (!args[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 		 * Must free the buffer allocated above (otherwise it is freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 		 * later)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		ACPI_FREE(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 		status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	args[0]->buffer.length = (u32) buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	args[0]->buffer.pointer = buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	args[0]->common.flags = AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	args[1] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 	/* Execute the method, no return value is expected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 	status = acpi_ns_evaluate(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 	/* Clean up and return the status from acpi_ns_evaluate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	acpi_ut_remove_reference(args[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 	ACPI_FREE(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) }