^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: rsmisc - Miscellaneous resource descriptors
^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 "acresrc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define _COMPONENT ACPI_RESOURCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ACPI_MODULE_NAME("rsmisc")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define INIT_RESOURCE_TYPE(i) i->resource_offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define INIT_RESOURCE_LENGTH(i) i->aml_offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define INIT_TABLE_LENGTH(i) i->value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define COMPARE_OPCODE(i) i->resource_offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define COMPARE_TARGET(i) i->aml_offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define COMPARE_VALUE(i) i->value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * FUNCTION: acpi_rs_convert_aml_to_resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * PARAMETERS: resource - Pointer to the resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * aml - Where the AML descriptor is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * info - Pointer to appropriate conversion table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * internal resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) union aml_resource *aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct acpi_rsconvert_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) acpi_rs_length aml_resource_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) void *source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void *destination;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) char *target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) u8 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u8 flags_mode = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) u16 item_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u16 temp16 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (((acpi_size)resource) & 0x3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Each internal resource struct is expected to be 32-bit aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) resource, resource->type, resource->length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Extract the resource Length field (does not include header length) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) aml_resource_length = acpi_ut_get_resource_length(aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * First table entry must be ACPI_RSC_INITxxx and must contain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * table length (# of table entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) count = INIT_TABLE_LENGTH(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Source is the external AML byte stream buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * destination is the internal resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) source = ACPI_ADD_PTR(void, aml, info->aml_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) destination =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ACPI_ADD_PTR(void, resource, info->resource_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) switch (info->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) case ACPI_RSC_INITGET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Get the resource type and the initial (minimum) length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) memset(resource, 0, INIT_RESOURCE_LENGTH(info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) resource->type = INIT_RESOURCE_TYPE(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) resource->length = INIT_RESOURCE_LENGTH(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) case ACPI_RSC_INITSET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) case ACPI_RSC_FLAGINIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) flags_mode = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) case ACPI_RSC_1BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * Mask and shift the flag bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ACPI_SET8(destination,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ((ACPI_GET8(source) >> info->value) & 0x01));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) case ACPI_RSC_2BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * Mask and shift the flag bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ACPI_SET8(destination,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ((ACPI_GET8(source) >> info->value) & 0x03));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) case ACPI_RSC_3BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * Mask and shift the flag bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ACPI_SET8(destination,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ((ACPI_GET8(source) >> info->value) & 0x07));
^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_RSC_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) item_count = ACPI_GET8(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ACPI_SET8(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) resource->length = resource->length +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) (info->value * (item_count - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) case ACPI_RSC_COUNT16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) item_count = aml_resource_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) resource->length = resource->length +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) (info->value * (item_count - 1));
^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_RSC_COUNT_GPIO_PIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) target = ACPI_ADD_PTR(void, aml, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) item_count = ACPI_GET16(target) - ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) resource->length = resource->length + item_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) item_count = item_count / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) case ACPI_RSC_COUNT_GPIO_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) item_count = ACPI_GET8(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ACPI_SET8(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) resource->length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) resource->length + (info->value * item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) case ACPI_RSC_COUNT_GPIO_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Vendor data is optional (length/offset may both be zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * Examine vendor data length field first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) target = ACPI_ADD_PTR(void, aml, (info->value + 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (ACPI_GET16(target)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /* Use vendor offset to get resource source length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) target = ACPI_ADD_PTR(void, aml, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) item_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ACPI_GET16(target) - ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* No vendor data to worry about */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) item_count = aml->large_header.resource_length +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) sizeof(struct aml_resource_large_header) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) resource->length = resource->length + item_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) case ACPI_RSC_COUNT_SERIAL_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) item_count = ACPI_GET16(source) - info->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) resource->length = resource->length + item_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) case ACPI_RSC_COUNT_SERIAL_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) item_count = (aml_resource_length +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) sizeof(struct aml_resource_large_header))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) - ACPI_GET16(source) - info->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) resource->length = resource->length + item_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) case ACPI_RSC_LENGTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) resource->length = resource->length + info->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) case ACPI_RSC_MOVE8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) case ACPI_RSC_MOVE16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) case ACPI_RSC_MOVE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) case ACPI_RSC_MOVE64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * Raw data move. Use the Info value field unless item_count has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * been previously initialized via a COUNT opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (info->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) item_count = info->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) case ACPI_RSC_MOVE_GPIO_PIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* Generate and set the PIN data pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) target = (char *)ACPI_ADD_PTR(void, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) (resource->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) item_count * 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) *(u16 **)destination = ACPI_CAST_PTR(u16, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* Copy the PIN data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) acpi_rs_move_data(target, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) case ACPI_RSC_MOVE_GPIO_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) /* Generate and set the resource_source string pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) target = (char *)ACPI_ADD_PTR(void, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) (resource->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *(u8 **)destination = ACPI_CAST_PTR(u8, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /* Copy the resource_source string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) acpi_rs_move_data(target, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) case ACPI_RSC_MOVE_SERIAL_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /* Generate and set the Vendor Data pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) target = (char *)ACPI_ADD_PTR(void, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) (resource->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *(u8 **)destination = ACPI_CAST_PTR(u8, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /* Copy the Vendor Data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) source = ACPI_ADD_PTR(void, aml, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) acpi_rs_move_data(target, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) case ACPI_RSC_MOVE_SERIAL_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* Generate and set the resource_source string pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) target = (char *)ACPI_ADD_PTR(void, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) (resource->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) *(u8 **)destination = ACPI_CAST_PTR(u8, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* Copy the resource_source string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) source =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) ACPI_ADD_PTR(void, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) (ACPI_GET16(source) + info->value));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) acpi_rs_move_data(target, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) case ACPI_RSC_SET8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) memset(destination, info->aml_offset, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) case ACPI_RSC_DATA8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) target = ACPI_ADD_PTR(char, resource, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) memcpy(destination, source, ACPI_GET16(target));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case ACPI_RSC_ADDRESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * Common handler for address descriptor flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) if (!acpi_rs_get_address_common(resource, aml)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return_ACPI_STATUS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) (AE_AML_INVALID_RESOURCE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) case ACPI_RSC_SOURCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * Optional resource_source (Index and String)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) resource->length +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) acpi_rs_get_resource_source(aml_resource_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) info->value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) destination, aml, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) case ACPI_RSC_SOURCEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * Optional resource_source (Index and String). This is the more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * complicated case used by the Interrupt() macro
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) target = ACPI_ADD_PTR(char, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) info->aml_offset +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) (item_count * 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) resource->length +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) acpi_rs_get_resource_source(aml_resource_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) (acpi_rs_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) (((item_count -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 1) * sizeof(u32)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) info->value),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) destination, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) case ACPI_RSC_BITMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * 8-bit encoded bitmask (DMA macro)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) item_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) acpi_rs_decode_bitmask(ACPI_GET8(source),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) destination);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) if (item_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) resource->length += (item_count - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) target = ACPI_ADD_PTR(char, resource, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) ACPI_SET8(target, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) case ACPI_RSC_BITMASK16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * 16-bit encoded bitmask (IRQ macro)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ACPI_MOVE_16_TO_16(&temp16, source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) item_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) acpi_rs_decode_bitmask(temp16, destination);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) if (item_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) resource->length += (item_count - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) target = ACPI_ADD_PTR(char, resource, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) ACPI_SET8(target, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) case ACPI_RSC_EXIT_NE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * control - Exit conversion if not equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) switch (info->resource_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) case ACPI_RSC_COMPARE_AML_LENGTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (aml_resource_length != info->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) case ACPI_RSC_COMPARE_VALUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (ACPI_GET8(source) != info->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) "Invalid conversion sub-opcode"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) return_ACPI_STATUS(AE_BAD_PARAMETER);
^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) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) info++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (!flags_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) /* Round the resource struct length up to the next boundary (32 or 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) resource->length = (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * FUNCTION: acpi_rs_convert_resource_to_aml
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * PARAMETERS: resource - Pointer to the resource descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * aml - Where the AML descriptor is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * info - Pointer to appropriate conversion table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * DESCRIPTION: Convert an internal resource descriptor to the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * external AML resource descriptor.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) union aml_resource *aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) struct acpi_rsconvert_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) void *source = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) void *destination;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) char *target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) acpi_rsdesc_size aml_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) u8 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) u16 temp16 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) u16 item_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return_ACPI_STATUS(AE_BAD_PARAMETER);
^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) * First table entry must be ACPI_RSC_INITxxx and must contain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * table length (# of table entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) count = INIT_TABLE_LENGTH(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * Source is the internal resource descriptor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * destination is the external AML byte stream buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) source = ACPI_ADD_PTR(void, resource, info->resource_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) switch (info->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) case ACPI_RSC_INITSET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) memset(aml, 0, INIT_RESOURCE_LENGTH(info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) aml_length = INIT_RESOURCE_LENGTH(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) case ACPI_RSC_INITGET:
^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_RSC_FLAGINIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * Clear the flag byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) ACPI_SET8(destination, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) case ACPI_RSC_1BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * Mask and shift the flag bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) ((ACPI_GET8(source) & 0x01) << info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) value));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) case ACPI_RSC_2BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * Mask and shift the flag bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) ((ACPI_GET8(source) & 0x03) << info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) value));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) case ACPI_RSC_3BITFLAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * Mask and shift the flag bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) ((ACPI_GET8(source) & 0x07) << info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) value));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) case ACPI_RSC_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) item_count = ACPI_GET8(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) ACPI_SET8(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) aml_length = (u16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) (aml_length + (info->value * (item_count - 1)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) case ACPI_RSC_COUNT16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) aml_length = (u16) (aml_length + item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) case ACPI_RSC_COUNT_GPIO_PIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) ACPI_SET16(destination, aml_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) aml_length = (u16)(aml_length + item_count * 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) target = ACPI_ADD_PTR(void, aml, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) ACPI_SET16(target, aml_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) case ACPI_RSC_COUNT_GPIO_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) ACPI_SET16(destination, item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) aml_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) (u16)(aml_length + (info->value * item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) case ACPI_RSC_COUNT_GPIO_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) /* Set resource source string length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) ACPI_SET16(destination, aml_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) /* Compute offset for the Vendor Data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) aml_length = (u16)(aml_length + item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) target = ACPI_ADD_PTR(void, aml, info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /* Set vendor offset only if there is vendor data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) ACPI_SET16(target, aml_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) case ACPI_RSC_COUNT_SERIAL_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) ACPI_SET16(destination, item_count + info->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) aml_length = (u16)(aml_length + item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) case ACPI_RSC_COUNT_SERIAL_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) item_count = ACPI_GET16(source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) aml_length = (u16)(aml_length + item_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) case ACPI_RSC_LENGTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) acpi_rs_set_resource_length(info->value, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) case ACPI_RSC_MOVE8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) case ACPI_RSC_MOVE16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) case ACPI_RSC_MOVE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) case ACPI_RSC_MOVE64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (info->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) item_count = info->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) case ACPI_RSC_MOVE_GPIO_PIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) destination = (char *)ACPI_ADD_PTR(void, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) ACPI_GET16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) (destination));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) source = *(u16 **)source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) case ACPI_RSC_MOVE_GPIO_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /* Used for both resource_source string and vendor_data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) destination = (char *)ACPI_ADD_PTR(void, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) ACPI_GET16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) (destination));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) source = *(u8 **)source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) case ACPI_RSC_MOVE_SERIAL_VEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) destination = (char *)ACPI_ADD_PTR(void, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) (aml_length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) source = *(u8 **)source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) case ACPI_RSC_MOVE_SERIAL_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) destination = (char *)ACPI_ADD_PTR(void, aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) (aml_length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) item_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) source = *(u8 **)source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) acpi_rs_move_data(destination, source, item_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) info->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) case ACPI_RSC_ADDRESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) /* Set the Resource Type, General Flags, and Type-Specific Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) acpi_rs_set_address_common(aml, resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) case ACPI_RSC_SOURCEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) * Optional resource_source (Index and String)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) aml_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) acpi_rs_set_resource_source(aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) (acpi_rs_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) aml_length, source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) case ACPI_RSC_SOURCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * Optional resource_source (Index and String). This is the more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * complicated case used by the Interrupt() macro
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) aml_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) acpi_rs_set_resource_source(aml, info->value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) acpi_rs_set_resource_length(aml_length, aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) case ACPI_RSC_BITMASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * 8-bit encoded bitmask (DMA macro)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) ACPI_SET8(destination,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) acpi_rs_encode_bitmask(source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) *ACPI_ADD_PTR(u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) value)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) case ACPI_RSC_BITMASK16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) * 16-bit encoded bitmask (IRQ macro)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) temp16 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) acpi_rs_encode_bitmask(source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) *ACPI_ADD_PTR(u8, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) info->value));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) ACPI_MOVE_16_TO_16(destination, &temp16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) case ACPI_RSC_EXIT_LE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) * control - Exit conversion if less than or equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) if (item_count <= info->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) case ACPI_RSC_EXIT_NE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) * control - Exit conversion if not equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) switch (COMPARE_OPCODE(info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) case ACPI_RSC_COMPARE_VALUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) if (*ACPI_ADD_PTR(u8, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) COMPARE_TARGET(info)) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) COMPARE_VALUE(info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) "Invalid conversion sub-opcode"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) case ACPI_RSC_EXIT_EQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) * control - Exit conversion if equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) if (*ACPI_ADD_PTR(u8, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) COMPARE_TARGET(info)) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) COMPARE_VALUE(info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) info++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) /* Previous resource validations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if (aml->ext_address64.revision_ID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) if (resource->data.start_dpf.performance_robustness >= 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) * polarity/trigger interrupts are allowed (ACPI spec, section
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * "IRQ Format"), so 0x00 and 0x09 are illegal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) "Invalid interrupt polarity/trigger in resource list, 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) aml->irq.flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) return_ACPI_STATUS(AE_BAD_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) resource->data.extended_irq.interrupt_count = temp8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) if (temp8 < 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) /* Must have at least one IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) if (resource->data.dma.transfer == 0x03) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) return_ACPI_STATUS(AE_BAD_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) #endif