···4545#define _ACUTILS_H46464747extern const u8 acpi_gbl_resource_aml_sizes[];4848+extern const u8 acpi_gbl_resource_aml_serial_bus_sizes[];48494950/* Strings used by the disassembler and debugger resource dump routines */5051
···264264 AML_OFFSET(dma.dma_channel_mask),265265 ACPI_RS_OFFSET(data.dma.channel_count)}266266};267267+268268+/*******************************************************************************269269+ *270270+ * acpi_rs_convert_fixed_dma271271+ *272272+ ******************************************************************************/273273+274274+struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {275275+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_DMA,276276+ ACPI_RS_SIZE(struct acpi_resource_fixed_dma),277277+ ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_dma)},278278+279279+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_DMA,280280+ sizeof(struct aml_resource_fixed_dma),281281+ 0},282282+283283+ /*284284+ * These fields are contiguous in both the source and destination:285285+ * request_lines286286+ * Channels287287+ */288288+289289+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines),290290+ AML_OFFSET(fixed_dma.request_lines),291291+ 2},292292+293293+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width),294294+ AML_OFFSET(fixed_dma.width),295295+ 1},296296+297297+};
+61-14
drivers/acpi/acpica/rslist.c
···7070 struct acpi_resource **resource_ptr =7171 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context);7272 struct acpi_resource *resource;7373+ union aml_resource *aml_resource;7474+ struct acpi_rsconvert_info *conversion_table;7375 acpi_status status;74767577 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources);···8684 "Misaligned resource pointer %p", resource));8785 }88868787+ /* Get the appropriate conversion info table */8888+8989+ aml_resource = ACPI_CAST_PTR(union aml_resource, aml);9090+ if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_SERIAL_BUS) {9191+ if (aml_resource->common_serial_bus.type >9292+ AML_RESOURCE_MAX_SERIALBUSTYPE) {9393+ conversion_table = NULL;9494+ } else {9595+ /* This is an I2C, SPI, or UART serial_bus descriptor */9696+9797+ conversion_table =9898+ acpi_gbl_convert_resource_serial_bus_dispatch9999+ [aml_resource->common_serial_bus.type];100100+ }101101+ } else {102102+ conversion_table =103103+ acpi_gbl_get_resource_dispatch[resource_index];104104+ }105105+106106+ if (!conversion_table) {107107+ ACPI_ERROR((AE_INFO,108108+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",109109+ resource_index));110110+ return (AE_AML_INVALID_RESOURCE_TYPE);111111+ }112112+89113 /* Convert the AML byte stream resource to a local resource struct */9011491115 status =9292- acpi_rs_convert_aml_to_resource(resource,9393- ACPI_CAST_PTR(union aml_resource,9494- aml),9595- acpi_gbl_get_resource_dispatch9696- [resource_index]);116116+ acpi_rs_convert_aml_to_resource(resource, aml_resource,117117+ conversion_table);97118 if (ACPI_FAILURE(status)) {98119 ACPI_EXCEPTION((AE_INFO, status,99120 "Could not convert AML resource (Type 0x%X)",···131106132107 /* Point to the next structure in the output buffer */133108134134- *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length);109109+ *resource_ptr = ACPI_NEXT_RESOURCE(resource);135110 return_ACPI_STATUS(AE_OK);136111}137112···160135{161136 u8 *aml = output_buffer;162137 u8 *end_aml = output_buffer + aml_size_needed;138138+ struct acpi_rsconvert_info *conversion_table;163139 acpi_status status;164140165141 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml);···180154181155 /* Perform the conversion */182156183183- status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union184184- aml_resource,185185- aml),186186- acpi_gbl_set_resource_dispatch187187- [resource->type]);157157+ if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {158158+ if (resource->data.common_serial_bus.type >159159+ AML_RESOURCE_MAX_SERIALBUSTYPE) {160160+ conversion_table = NULL;161161+ } else {162162+ /* This is an I2C, SPI, or UART serial_bus descriptor */163163+164164+ conversion_table =165165+ acpi_gbl_convert_resource_serial_bus_dispatch166166+ [resource->data.common_serial_bus.type];167167+ }168168+ } else {169169+ conversion_table =170170+ acpi_gbl_set_resource_dispatch[resource->type];171171+ }172172+173173+ if (!conversion_table) {174174+ ACPI_ERROR((AE_INFO,175175+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",176176+ resource->type));177177+ return (AE_AML_INVALID_RESOURCE_TYPE);178178+ }179179+180180+ status = acpi_rs_convert_resource_to_aml(resource,181181+ ACPI_CAST_PTR(union182182+ aml_resource,183183+ aml),184184+ conversion_table);188185 if (ACPI_FAILURE(status)) {189186 ACPI_EXCEPTION((AE_INFO, status,190187 "Could not convert resource (type 0x%X) to AML",···241192242193 /* Point to the next input resource descriptor */243194244244- resource =245245- ACPI_ADD_PTR(struct acpi_resource, resource,246246- resource->length);195195+ resource = ACPI_NEXT_RESOURCE(resource);247196 }248197249198 /* Completed buffer, but did not find an end_tag resource descriptor */
+262-5
drivers/acpi/acpica/rsmisc.c
···83838484 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);85858686+ if (!info) {8787+ return_ACPI_STATUS(AE_BAD_PARAMETER);8888+ }8989+8690 if (((acpi_size) resource) & 0x3) {87918892 /* Each internal resource struct is expected to be 32-bit aligned */···105101 * table length (# of table entries)106102 */107103 count = INIT_TABLE_LENGTH(info);108108-109104 while (count) {110105 /*111106 * Source is the external AML byte stream buffer,···148145 ((ACPI_GET8(source) >> info->value) & 0x03);149146 break;150147148148+ case ACPI_RSC_3BITFLAG:149149+ /*150150+ * Mask and shift the flag bits151151+ */152152+ ACPI_SET8(destination) = (u8)153153+ ((ACPI_GET8(source) >> info->value) & 0x07);154154+ break;155155+151156 case ACPI_RSC_COUNT:152157153158 item_count = ACPI_GET8(source);···172161173162 resource->length = resource->length +174163 (info->value * (item_count - 1));164164+ break;165165+166166+ case ACPI_RSC_COUNT_GPIO_PIN:167167+168168+ target = ACPI_ADD_PTR(void, aml, info->value);169169+ item_count = ACPI_GET16(target) - ACPI_GET16(source);170170+171171+ resource->length = resource->length + item_count;172172+ item_count = item_count / 2;173173+ ACPI_SET16(destination) = item_count;174174+ break;175175+176176+ case ACPI_RSC_COUNT_GPIO_VEN:177177+178178+ item_count = ACPI_GET8(source);179179+ ACPI_SET8(destination) = (u8)item_count;180180+181181+ resource->length = resource->length +182182+ (info->value * item_count);183183+ break;184184+185185+ case ACPI_RSC_COUNT_GPIO_RES:186186+187187+ /*188188+ * Vendor data is optional (length/offset may both be zero)189189+ * Examine vendor data length field first190190+ */191191+ target = ACPI_ADD_PTR(void, aml, (info->value + 2));192192+ if (ACPI_GET16(target)) {193193+194194+ /* Use vendor offset to get resource source length */195195+196196+ target = ACPI_ADD_PTR(void, aml, info->value);197197+ item_count =198198+ ACPI_GET16(target) - ACPI_GET16(source);199199+ } else {200200+ /* No vendor data to worry about */201201+202202+ item_count = aml->large_header.resource_length +203203+ sizeof(struct aml_resource_large_header) -204204+ ACPI_GET16(source);205205+ }206206+207207+ resource->length = resource->length + item_count;208208+ ACPI_SET16(destination) = item_count;209209+ break;210210+211211+ case ACPI_RSC_COUNT_SERIAL_VEN:212212+213213+ item_count = ACPI_GET16(source) - info->value;214214+215215+ resource->length = resource->length + item_count;216216+ ACPI_SET16(destination) = item_count;217217+ break;218218+219219+ case ACPI_RSC_COUNT_SERIAL_RES:220220+221221+ item_count = (aml_resource_length +222222+ sizeof(struct aml_resource_large_header))223223+ - ACPI_GET16(source) - info->value;224224+225225+ resource->length = resource->length + item_count;226226+ ACPI_SET16(destination) = item_count;175227 break;176228177229 case ACPI_RSC_LENGTH:···254180 item_count = info->value;255181 }256182 acpi_rs_move_data(destination, source, item_count,183183+ info->opcode);184184+ break;185185+186186+ case ACPI_RSC_MOVE_GPIO_PIN:187187+188188+ /* Generate and set the PIN data pointer */189189+190190+ target = (char *)ACPI_ADD_PTR(void, resource,191191+ (resource->length -192192+ item_count * 2));193193+ *(u16 **)destination = ACPI_CAST_PTR(u16, target);194194+195195+ /* Copy the PIN data */196196+197197+ source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));198198+ acpi_rs_move_data(target, source, item_count,199199+ info->opcode);200200+ break;201201+202202+ case ACPI_RSC_MOVE_GPIO_RES:203203+204204+ /* Generate and set the resource_source string pointer */205205+206206+ target = (char *)ACPI_ADD_PTR(void, resource,207207+ (resource->length -208208+ item_count));209209+ *(u8 **)destination = ACPI_CAST_PTR(u8, target);210210+211211+ /* Copy the resource_source string */212212+213213+ source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));214214+ acpi_rs_move_data(target, source, item_count,215215+ info->opcode);216216+ break;217217+218218+ case ACPI_RSC_MOVE_SERIAL_VEN:219219+220220+ /* Generate and set the Vendor Data pointer */221221+222222+ target = (char *)ACPI_ADD_PTR(void, resource,223223+ (resource->length -224224+ item_count));225225+ *(u8 **)destination = ACPI_CAST_PTR(u8, target);226226+227227+ /* Copy the Vendor Data */228228+229229+ source = ACPI_ADD_PTR(void, aml, info->value);230230+ acpi_rs_move_data(target, source, item_count,231231+ info->opcode);232232+ break;233233+234234+ case ACPI_RSC_MOVE_SERIAL_RES:235235+236236+ /* Generate and set the resource_source string pointer */237237+238238+ target = (char *)ACPI_ADD_PTR(void, resource,239239+ (resource->length -240240+ item_count));241241+ *(u8 **)destination = ACPI_CAST_PTR(u8, target);242242+243243+ /* Copy the resource_source string */244244+245245+ source =246246+ ACPI_ADD_PTR(void, aml,247247+ (ACPI_GET16(source) + info->value));248248+ acpi_rs_move_data(target, source, item_count,257249 info->opcode);258250 break;259251···359219 * Optional resource_source (Index and String). This is the more360220 * complicated case used by the Interrupt() macro361221 */362362- target =363363- ACPI_ADD_PTR(char, resource,364364- info->aml_offset + (item_count * 4));222222+ target = ACPI_ADD_PTR(char, resource,223223+ info->aml_offset +224224+ (item_count * 4));365225366226 resource->length +=367227 acpi_rs_get_resource_source(aml_resource_length,368368- (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target);228228+ (acpi_rs_length)229229+ (((item_count -230230+ 1) * sizeof(u32)) +231231+ info->value),232232+ destination, aml,233233+ target);369234 break;370235371236 case ACPI_RSC_BITMASK:···472327{473328 void *source = NULL;474329 void *destination;330330+ char *target;475331 acpi_rsdesc_size aml_length = 0;476332 u8 count;477333 u16 temp16 = 0;478334 u16 item_count = 0;479335480336 ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);337337+338338+ if (!info) {339339+ return_ACPI_STATUS(AE_BAD_PARAMETER);340340+ }481341482342 /*483343 * First table entry must be ACPI_RSC_INITxxx and must contain the···533383 ((ACPI_GET8(source) & 0x03) << info->value);534384 break;535385386386+ case ACPI_RSC_3BITFLAG:387387+ /*388388+ * Mask and shift the flag bits389389+ */390390+ ACPI_SET8(destination) |= (u8)391391+ ((ACPI_GET8(source) & 0x07) << info->value);392392+ break;393393+536394 case ACPI_RSC_COUNT:537395538396 item_count = ACPI_GET8(source);···558400 acpi_rs_set_resource_length(aml_length, aml);559401 break;560402403403+ case ACPI_RSC_COUNT_GPIO_PIN:404404+405405+ item_count = ACPI_GET16(source);406406+ ACPI_SET16(destination) = (u16)aml_length;407407+408408+ aml_length = (u16)(aml_length + item_count * 2);409409+ target = ACPI_ADD_PTR(void, aml, info->value);410410+ ACPI_SET16(target) = (u16)aml_length;411411+ acpi_rs_set_resource_length(aml_length, aml);412412+ break;413413+414414+ case ACPI_RSC_COUNT_GPIO_VEN:415415+416416+ item_count = ACPI_GET16(source);417417+ ACPI_SET16(destination) = (u16)item_count;418418+419419+ aml_length =420420+ (u16)(aml_length + (info->value * item_count));421421+ acpi_rs_set_resource_length(aml_length, aml);422422+ break;423423+424424+ case ACPI_RSC_COUNT_GPIO_RES:425425+426426+ /* Set resource source string length */427427+428428+ item_count = ACPI_GET16(source);429429+ ACPI_SET16(destination) = (u16)aml_length;430430+431431+ /* Compute offset for the Vendor Data */432432+433433+ aml_length = (u16)(aml_length + item_count);434434+ target = ACPI_ADD_PTR(void, aml, info->value);435435+436436+ /* Set vendor offset only if there is vendor data */437437+438438+ if (resource->data.gpio.vendor_length) {439439+ ACPI_SET16(target) = (u16)aml_length;440440+ }441441+442442+ acpi_rs_set_resource_length(aml_length, aml);443443+ break;444444+445445+ case ACPI_RSC_COUNT_SERIAL_VEN:446446+447447+ item_count = ACPI_GET16(source);448448+ ACPI_SET16(destination) = item_count + info->value;449449+ aml_length = (u16)(aml_length + item_count);450450+ acpi_rs_set_resource_length(aml_length, aml);451451+ break;452452+453453+ case ACPI_RSC_COUNT_SERIAL_RES:454454+455455+ item_count = ACPI_GET16(source);456456+ aml_length = (u16)(aml_length + item_count);457457+ acpi_rs_set_resource_length(aml_length, aml);458458+ break;459459+561460 case ACPI_RSC_LENGTH:562461563462 acpi_rs_set_resource_length(info->value, aml);···628413 if (info->value) {629414 item_count = info->value;630415 }416416+ acpi_rs_move_data(destination, source, item_count,417417+ info->opcode);418418+ break;419419+420420+ case ACPI_RSC_MOVE_GPIO_PIN:421421+422422+ destination = (char *)ACPI_ADD_PTR(void, aml,423423+ ACPI_GET16424424+ (destination));425425+ source = *(u16 **)source;426426+ acpi_rs_move_data(destination, source, item_count,427427+ info->opcode);428428+ break;429429+430430+ case ACPI_RSC_MOVE_GPIO_RES:431431+432432+ /* Used for both resource_source string and vendor_data */433433+434434+ destination = (char *)ACPI_ADD_PTR(void, aml,435435+ ACPI_GET16436436+ (destination));437437+ source = *(u8 **)source;438438+ acpi_rs_move_data(destination, source, item_count,439439+ info->opcode);440440+ break;441441+442442+ case ACPI_RSC_MOVE_SERIAL_VEN:443443+444444+ destination = (char *)ACPI_ADD_PTR(void, aml,445445+ (aml_length -446446+ item_count));447447+ source = *(u8 **)source;448448+ acpi_rs_move_data(destination, source, item_count,449449+ info->opcode);450450+ break;451451+452452+ case ACPI_RSC_MOVE_SERIAL_RES:453453+454454+ destination = (char *)ACPI_ADD_PTR(void, aml,455455+ (aml_length -456456+ item_count));457457+ source = *(u8 **)source;631458 acpi_rs_move_data(destination, source, item_count,632459 info->opcode);633460 break;
+441
drivers/acpi/acpica/rsserial.c
···11+/*******************************************************************************22+ *33+ * Module Name: rsserial - GPIO/serial_bus resource descriptors44+ *55+ ******************************************************************************/66+77+/*88+ * Copyright (C) 2000 - 2011, Intel Corp.99+ * All rights reserved.1010+ *1111+ * Redistribution and use in source and binary forms, with or without1212+ * modification, are permitted provided that the following conditions1313+ * are met:1414+ * 1. Redistributions of source code must retain the above copyright1515+ * notice, this list of conditions, and the following disclaimer,1616+ * without modification.1717+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer1818+ * substantially similar to the "NO WARRANTY" disclaimer below1919+ * ("Disclaimer") and any redistribution must be conditioned upon2020+ * including a substantially similar Disclaimer requirement for further2121+ * binary redistribution.2222+ * 3. Neither the names of the above-listed copyright holders nor the names2323+ * of any contributors may be used to endorse or promote products derived2424+ * from this software without specific prior written permission.2525+ *2626+ * Alternatively, this software may be distributed under the terms of the2727+ * GNU General Public License ("GPL") version 2 as published by the Free2828+ * Software Foundation.2929+ *3030+ * NO WARRANTY3131+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS3232+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT3333+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR3434+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT3535+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL3636+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS3737+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)3838+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,3939+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING4040+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE4141+ * POSSIBILITY OF SUCH DAMAGES.4242+ */4343+4444+#include <acpi/acpi.h>4545+#include "accommon.h"4646+#include "acresrc.h"4747+4848+#define _COMPONENT ACPI_RESOURCES4949+ACPI_MODULE_NAME("rsserial")5050+5151+/*******************************************************************************5252+ *5353+ * acpi_rs_convert_gpio5454+ *5555+ ******************************************************************************/5656+struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = {5757+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,5858+ ACPI_RS_SIZE(struct acpi_resource_gpio),5959+ ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},6060+6161+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,6262+ sizeof(struct aml_resource_gpio),6363+ 0},6464+6565+ /*6666+ * These fields are contiguous in both the source and destination:6767+ * revision_id6868+ * connection_type6969+ */7070+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.revision_id),7171+ AML_OFFSET(gpio.revision_id),7272+ 2},7373+7474+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.producer_consumer),7575+ AML_OFFSET(gpio.flags),7676+ 0},7777+7878+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),7979+ AML_OFFSET(gpio.int_flags),8080+ 3},8181+8282+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),8383+ AML_OFFSET(gpio.int_flags),8484+ 0},8585+8686+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.triggering),8787+ AML_OFFSET(gpio.int_flags),8888+ 0},8989+9090+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.polarity),9191+ AML_OFFSET(gpio.int_flags),9292+ 1},9393+9494+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.pin_config),9595+ AML_OFFSET(gpio.pin_config),9696+ 1},9797+9898+ /*9999+ * These fields are contiguous in both the source and destination:100100+ * drive_strength101101+ * debounce_timeout102102+ */103103+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.gpio.drive_strength),104104+ AML_OFFSET(gpio.drive_strength),105105+ 2},106106+107107+ /* Pin Table */108108+109109+ {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table_length),110110+ AML_OFFSET(gpio.pin_table_offset),111111+ AML_OFFSET(gpio.res_source_offset)},112112+113113+ {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table),114114+ AML_OFFSET(gpio.pin_table_offset),115115+ 0},116116+117117+ /* Resource Source */118118+119119+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.resource_source.index),120120+ AML_OFFSET(gpio.res_source_index),121121+ 1},122122+123123+ {ACPI_RSC_COUNT_GPIO_RES,124124+ ACPI_RS_OFFSET(data.gpio.resource_source.string_length),125125+ AML_OFFSET(gpio.res_source_offset),126126+ AML_OFFSET(gpio.vendor_offset)},127127+128128+ {ACPI_RSC_MOVE_GPIO_RES,129129+ ACPI_RS_OFFSET(data.gpio.resource_source.string_ptr),130130+ AML_OFFSET(gpio.res_source_offset),131131+ 0},132132+133133+ /* Vendor Data */134134+135135+ {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET(data.gpio.vendor_length),136136+ AML_OFFSET(gpio.vendor_length),137137+ 1},138138+139139+ {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET(data.gpio.vendor_data),140140+ AML_OFFSET(gpio.vendor_offset),141141+ 0},142142+};143143+144144+/*******************************************************************************145145+ *146146+ * acpi_rs_convert_i2c_serial_bus147147+ *148148+ ******************************************************************************/149149+150150+struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = {151151+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,152152+ ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),153153+ ACPI_RSC_TABLE_SIZE(acpi_rs_convert_i2c_serial_bus)},154154+155155+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,156156+ sizeof(struct aml_resource_i2c_serialbus),157157+ 0},158158+159159+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),160160+ AML_OFFSET(common_serial_bus.revision_id),161161+ 1},162162+163163+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),164164+ AML_OFFSET(common_serial_bus.type),165165+ 1},166166+167167+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),168168+ AML_OFFSET(common_serial_bus.flags),169169+ 0},170170+171171+ {ACPI_RSC_1BITFLAG,172172+ ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),173173+ AML_OFFSET(common_serial_bus.flags),174174+ 1},175175+176176+ {ACPI_RSC_MOVE8,177177+ ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),178178+ AML_OFFSET(common_serial_bus.type_revision_id),179179+ 1},180180+181181+ {ACPI_RSC_MOVE16,182182+ ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),183183+ AML_OFFSET(common_serial_bus.type_data_length),184184+ 1},185185+186186+ /* Vendor data */187187+188188+ {ACPI_RSC_COUNT_SERIAL_VEN,189189+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),190190+ AML_OFFSET(common_serial_bus.type_data_length),191191+ AML_RESOURCE_I2C_MIN_DATA_LEN},192192+193193+ {ACPI_RSC_MOVE_SERIAL_VEN,194194+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),195195+ 0,196196+ sizeof(struct aml_resource_i2c_serialbus)},197197+198198+ /* Resource Source */199199+200200+ {ACPI_RSC_MOVE8,201201+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),202202+ AML_OFFSET(common_serial_bus.res_source_index),203203+ 1},204204+205205+ {ACPI_RSC_COUNT_SERIAL_RES,206206+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),207207+ AML_OFFSET(common_serial_bus.type_data_length),208208+ sizeof(struct aml_resource_common_serialbus)},209209+210210+ {ACPI_RSC_MOVE_SERIAL_RES,211211+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),212212+ AML_OFFSET(common_serial_bus.type_data_length),213213+ sizeof(struct aml_resource_common_serialbus)},214214+215215+ /* I2C bus type specific */216216+217217+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.i2c_serial_bus.access_mode),218218+ AML_OFFSET(i2c_serial_bus.type_specific_flags),219219+ 0},220220+221221+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.i2c_serial_bus.connection_speed),222222+ AML_OFFSET(i2c_serial_bus.connection_speed),223223+ 1},224224+225225+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.i2c_serial_bus.slave_address),226226+ AML_OFFSET(i2c_serial_bus.slave_address),227227+ 1},228228+};229229+230230+/*******************************************************************************231231+ *232232+ * acpi_rs_convert_spi_serial_bus233233+ *234234+ ******************************************************************************/235235+236236+struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = {237237+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,238238+ ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),239239+ ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)},240240+241241+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,242242+ sizeof(struct aml_resource_spi_serialbus),243243+ 0},244244+245245+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),246246+ AML_OFFSET(common_serial_bus.revision_id),247247+ 1},248248+249249+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),250250+ AML_OFFSET(common_serial_bus.type),251251+ 1},252252+253253+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),254254+ AML_OFFSET(common_serial_bus.flags),255255+ 0},256256+257257+ {ACPI_RSC_1BITFLAG,258258+ ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),259259+ AML_OFFSET(common_serial_bus.flags),260260+ 1},261261+262262+ {ACPI_RSC_MOVE8,263263+ ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),264264+ AML_OFFSET(common_serial_bus.type_revision_id),265265+ 1},266266+267267+ {ACPI_RSC_MOVE16,268268+ ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),269269+ AML_OFFSET(common_serial_bus.type_data_length),270270+ 1},271271+272272+ /* Vendor data */273273+274274+ {ACPI_RSC_COUNT_SERIAL_VEN,275275+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),276276+ AML_OFFSET(common_serial_bus.type_data_length),277277+ AML_RESOURCE_SPI_MIN_DATA_LEN},278278+279279+ {ACPI_RSC_MOVE_SERIAL_VEN,280280+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),281281+ 0,282282+ sizeof(struct aml_resource_spi_serialbus)},283283+284284+ /* Resource Source */285285+286286+ {ACPI_RSC_MOVE8,287287+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),288288+ AML_OFFSET(common_serial_bus.res_source_index),289289+ 1},290290+291291+ {ACPI_RSC_COUNT_SERIAL_RES,292292+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),293293+ AML_OFFSET(common_serial_bus.type_data_length),294294+ sizeof(struct aml_resource_common_serialbus)},295295+296296+ {ACPI_RSC_MOVE_SERIAL_RES,297297+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),298298+ AML_OFFSET(common_serial_bus.type_data_length),299299+ sizeof(struct aml_resource_common_serialbus)},300300+301301+ /* Spi bus type specific */302302+303303+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.wire_mode),304304+ AML_OFFSET(spi_serial_bus.type_specific_flags),305305+ 0},306306+307307+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.device_polarity),308308+ AML_OFFSET(spi_serial_bus.type_specific_flags),309309+ 1},310310+311311+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.data_bit_length),312312+ AML_OFFSET(spi_serial_bus.data_bit_length),313313+ 1},314314+315315+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_phase),316316+ AML_OFFSET(spi_serial_bus.clock_phase),317317+ 1},318318+319319+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_polarity),320320+ AML_OFFSET(spi_serial_bus.clock_polarity),321321+ 1},322322+323323+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.spi_serial_bus.device_selection),324324+ AML_OFFSET(spi_serial_bus.device_selection),325325+ 1},326326+327327+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.spi_serial_bus.connection_speed),328328+ AML_OFFSET(spi_serial_bus.connection_speed),329329+ 1},330330+};331331+332332+/*******************************************************************************333333+ *334334+ * acpi_rs_convert_uart_serial_bus335335+ *336336+ ******************************************************************************/337337+338338+struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = {339339+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,340340+ ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),341341+ ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)},342342+343343+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,344344+ sizeof(struct aml_resource_uart_serialbus),345345+ 0},346346+347347+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),348348+ AML_OFFSET(common_serial_bus.revision_id),349349+ 1},350350+351351+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),352352+ AML_OFFSET(common_serial_bus.type),353353+ 1},354354+355355+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),356356+ AML_OFFSET(common_serial_bus.flags),357357+ 0},358358+359359+ {ACPI_RSC_1BITFLAG,360360+ ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),361361+ AML_OFFSET(common_serial_bus.flags),362362+ 1},363363+364364+ {ACPI_RSC_MOVE8,365365+ ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),366366+ AML_OFFSET(common_serial_bus.type_revision_id),367367+ 1},368368+369369+ {ACPI_RSC_MOVE16,370370+ ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),371371+ AML_OFFSET(common_serial_bus.type_data_length),372372+ 1},373373+374374+ /* Vendor data */375375+376376+ {ACPI_RSC_COUNT_SERIAL_VEN,377377+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),378378+ AML_OFFSET(common_serial_bus.type_data_length),379379+ AML_RESOURCE_UART_MIN_DATA_LEN},380380+381381+ {ACPI_RSC_MOVE_SERIAL_VEN,382382+ ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),383383+ 0,384384+ sizeof(struct aml_resource_uart_serialbus)},385385+386386+ /* Resource Source */387387+388388+ {ACPI_RSC_MOVE8,389389+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),390390+ AML_OFFSET(common_serial_bus.res_source_index),391391+ 1},392392+393393+ {ACPI_RSC_COUNT_SERIAL_RES,394394+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),395395+ AML_OFFSET(common_serial_bus.type_data_length),396396+ sizeof(struct aml_resource_common_serialbus)},397397+398398+ {ACPI_RSC_MOVE_SERIAL_RES,399399+ ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),400400+ AML_OFFSET(common_serial_bus.type_data_length),401401+ sizeof(struct aml_resource_common_serialbus)},402402+403403+ /* Uart bus type specific */404404+405405+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.flow_control),406406+ AML_OFFSET(uart_serial_bus.type_specific_flags),407407+ 0},408408+409409+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.stop_bits),410410+ AML_OFFSET(uart_serial_bus.type_specific_flags),411411+ 2},412412+413413+ {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.data_bits),414414+ AML_OFFSET(uart_serial_bus.type_specific_flags),415415+ 4},416416+417417+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.endian),418418+ AML_OFFSET(uart_serial_bus.type_specific_flags),419419+ 7},420420+421421+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.parity),422422+ AML_OFFSET(uart_serial_bus.parity),423423+ 1},424424+425425+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.lines_enabled),426426+ AML_OFFSET(uart_serial_bus.lines_enabled),427427+ 1},428428+429429+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.rx_fifo_size),430430+ AML_OFFSET(uart_serial_bus.rx_fifo_size),431431+ 1},432432+433433+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.tx_fifo_size),434434+ AML_OFFSET(uart_serial_bus.tx_fifo_size),435435+ 1},436436+437437+ {ACPI_RSC_MOVE32,438438+ ACPI_RS_OFFSET(data.uart_serial_bus.default_baud_rate),439439+ AML_OFFSET(uart_serial_bus.default_baud_rate),440440+ 1},441441+};
+4
drivers/acpi/acpica/rsutils.c
···144144 * since there are no alignment or endian issues145145 */146146 case ACPI_RSC_MOVE8:147147+ case ACPI_RSC_MOVE_GPIO_RES:148148+ case ACPI_RSC_MOVE_SERIAL_VEN:149149+ case ACPI_RSC_MOVE_SERIAL_RES:147150 ACPI_MEMCPY(destination, source, item_count);148151 return;149152···156153 * misaligned memory transfers157154 */158155 case ACPI_RSC_MOVE16:156156+ case ACPI_RSC_MOVE_GPIO_PIN:159157 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],160158 &ACPI_CAST_PTR(u16, source)[i]);161159 break;
+242-34
drivers/acpi/acpica/utresrc.c
···43434444#include <acpi/acpi.h>4545#include "accommon.h"4646-#include "amlresrc.h"4646+#include "acresrc.h"47474848#define _COMPONENT ACPI_UTILITIES4949ACPI_MODULE_NAME("utresrc")···154154 "TypeF"155155};156156157157+const char *acpi_gbl_ppc_decode[] = {158158+ "PullDefault",159159+ "PullUp",160160+ "PullDown",161161+ "PullNone"162162+};163163+164164+const char *acpi_gbl_ior_decode[] = {165165+ "IoRestrictionNone",166166+ "IoRestrictionInputOnly",167167+ "IoRestrictionOutputOnly",168168+ "IoRestrictionNoneAndPreserve"169169+};170170+171171+const char *acpi_gbl_dts_decode[] = {172172+ "Width8bit",173173+ "Width16bit",174174+ "Width32bit",175175+ "Width64bit",176176+ "Width128bit",177177+ "Width256bit",178178+};179179+180180+/* GPIO connection type */181181+182182+const char *acpi_gbl_ct_decode[] = {183183+ "Interrupt",184184+ "I/O"185185+};186186+187187+/* Serial bus type */188188+189189+const char *acpi_gbl_sbt_decode[] = {190190+ "/* UNKNOWN serial bus type */",191191+ "I2C",192192+ "SPI",193193+ "UART"194194+};195195+196196+/* I2C serial bus access mode */197197+198198+const char *acpi_gbl_am_decode[] = {199199+ "AddressingMode7Bit",200200+ "AddressingMode10Bit"201201+};202202+203203+/* I2C serial bus slave mode */204204+205205+const char *acpi_gbl_sm_decode[] = {206206+ "ControllerInitiated",207207+ "DeviceInitiated"208208+};209209+210210+/* SPI serial bus wire mode */211211+212212+const char *acpi_gbl_wm_decode[] = {213213+ "FourWireMode",214214+ "ThreeWireMode"215215+};216216+217217+/* SPI serial clock phase */218218+219219+const char *acpi_gbl_cph_decode[] = {220220+ "ClockPhaseFirst",221221+ "ClockPhaseSecond"222222+};223223+224224+/* SPI serial bus clock polarity */225225+226226+const char *acpi_gbl_cpo_decode[] = {227227+ "ClockPolarityLow",228228+ "ClockPolarityHigh"229229+};230230+231231+/* SPI serial bus device polarity */232232+233233+const char *acpi_gbl_dp_decode[] = {234234+ "PolarityLow",235235+ "PolarityHigh"236236+};237237+238238+/* UART serial bus endian */239239+240240+const char *acpi_gbl_ed_decode[] = {241241+ "LittleEndian",242242+ "BigEndian"243243+};244244+245245+/* UART serial bus bits per byte */246246+247247+const char *acpi_gbl_bpb_decode[] = {248248+ "DataBitsFive",249249+ "DataBitsSix",250250+ "DataBitsSeven",251251+ "DataBitsEight",252252+ "DataBitsNine",253253+ "/* UNKNOWN Bits per byte */",254254+ "/* UNKNOWN Bits per byte */",255255+ "/* UNKNOWN Bits per byte */"256256+};257257+258258+/* UART serial bus stop bits */259259+260260+const char *acpi_gbl_sb_decode[] = {261261+ "StopBitsNone",262262+ "StopBitsOne",263263+ "StopBitsOnePlusHalf",264264+ "StopBitsTwo"265265+};266266+267267+/* UART serial bus flow control */268268+269269+const char *acpi_gbl_fc_decode[] = {270270+ "FlowControlNone",271271+ "FlowControlHardware",272272+ "FlowControlXON",273273+ "/* UNKNOWN flow control keyword */"274274+};275275+276276+/* UART serial bus parity type */277277+278278+const char *acpi_gbl_pt_decode[] = {279279+ "ParityTypeNone",280280+ "ParityTypeEven",281281+ "ParityTypeOdd",282282+ "ParityTypeMark",283283+ "ParityTypeSpace",284284+ "/* UNKNOWN parity keyword */",285285+ "/* UNKNOWN parity keyword */",286286+ "/* UNKNOWN parity keyword */"287287+};288288+157289#endif158290159291/*···305173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),306174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),307175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),308308- 0,176176+ ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_dma),309177 0,310178 0,311179 0,···325193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),326194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),327195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),328328- ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)196196+ ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64),197197+ ACPI_AML_SIZE_LARGE(struct aml_resource_gpio),198198+ 0,199199+ ACPI_AML_SIZE_LARGE(struct aml_resource_common_serialbus),200200+};201201+202202+const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = {203203+ 0,204204+ ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus),205205+ ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus),206206+ ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus),329207};330208331209/*···351209 0,352210 0,353211 0,354354- ACPI_SMALL_VARIABLE_LENGTH,355355- ACPI_FIXED_LENGTH,356356- ACPI_SMALL_VARIABLE_LENGTH,357357- ACPI_FIXED_LENGTH,358358- ACPI_FIXED_LENGTH,359359- ACPI_FIXED_LENGTH,212212+ ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */213213+ ACPI_FIXED_LENGTH, /* 05 DMA */214214+ ACPI_SMALL_VARIABLE_LENGTH, /* 06 start_dependent_functions */215215+ ACPI_FIXED_LENGTH, /* 07 end_dependent_functions */216216+ ACPI_FIXED_LENGTH, /* 08 IO */217217+ ACPI_FIXED_LENGTH, /* 09 fixed_iO */218218+ ACPI_FIXED_LENGTH, /* 0_a fixed_dMA */360219 0,361220 0,362221 0,363363- 0,364364- ACPI_VARIABLE_LENGTH,365365- ACPI_FIXED_LENGTH,222222+ ACPI_VARIABLE_LENGTH, /* 0_e vendor_short */223223+ ACPI_FIXED_LENGTH, /* 0_f end_tag */366224367225 /* Large descriptors */368226369227 0,370370- ACPI_FIXED_LENGTH,371371- ACPI_FIXED_LENGTH,228228+ ACPI_FIXED_LENGTH, /* 01 Memory24 */229229+ ACPI_FIXED_LENGTH, /* 02 generic_register */372230 0,373373- ACPI_VARIABLE_LENGTH,374374- ACPI_FIXED_LENGTH,375375- ACPI_FIXED_LENGTH,376376- ACPI_VARIABLE_LENGTH,377377- ACPI_VARIABLE_LENGTH,378378- ACPI_VARIABLE_LENGTH,379379- ACPI_VARIABLE_LENGTH,380380- ACPI_FIXED_LENGTH231231+ ACPI_VARIABLE_LENGTH, /* 04 vendor_long */232232+ ACPI_FIXED_LENGTH, /* 05 Memory32 */233233+ ACPI_FIXED_LENGTH, /* 06 memory32_fixed */234234+ ACPI_VARIABLE_LENGTH, /* 07 Dword* address */235235+ ACPI_VARIABLE_LENGTH, /* 08 Word* address */236236+ ACPI_VARIABLE_LENGTH, /* 09 extended_iRQ */237237+ ACPI_VARIABLE_LENGTH, /* 0_a Qword* address */238238+ ACPI_FIXED_LENGTH, /* 0_b Extended* address */239239+ ACPI_VARIABLE_LENGTH, /* 0_c Gpio* */240240+ 0,241241+ ACPI_VARIABLE_LENGTH /* 0_e *serial_bus */381242};243243+244244+/*245245+ * For the i_aSL compiler/disassembler, we don't want any error messages246246+ * because the disassembler uses the resource validation code to determine247247+ * if Buffer objects are actually Resource Templates.248248+ */249249+#ifdef ACPI_ASL_COMPILER250250+#define ACPI_RESOURCE_ERROR(plist)251251+#else252252+#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)253253+#endif382254383255/*******************************************************************************384256 *···421265 u8 resource_index;422266 u32 length;423267 u32 offset = 0;268268+ u8 end_tag[2] = { 0x79, 0x00 };424269425270 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);426271···443286444287 status = acpi_ut_validate_resource(aml, &resource_index);445288 if (ACPI_FAILURE(status)) {289289+ /*290290+ * Exit on failure. Cannot continue because the descriptor length291291+ * may be bogus also.292292+ */446293 return_ACPI_STATUS(status);447294 }448295···461300 user_function(aml, length, offset, resource_index,462301 context);463302 if (ACPI_FAILURE(status)) {464464- return (status);303303+ return_ACPI_STATUS(status);465304 }466305 }467306···494333495334 /* Did not find an end_tag descriptor */496335497497- return (AE_AML_NO_RESOURCE_END_TAG);336336+ if (user_function) {337337+338338+ /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */339339+340340+ (void)acpi_ut_validate_resource(end_tag, &resource_index);341341+ status =342342+ user_function(end_tag, 2, offset, resource_index, context);343343+ if (ACPI_FAILURE(status)) {344344+ return_ACPI_STATUS(status);345345+ }346346+ }347347+348348+ return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);498349}499350500351/*******************************************************************************···527354528355acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)529356{357357+ union aml_resource *aml_resource;530358 u8 resource_type;531359 u8 resource_index;532360 acpi_rs_length resource_length;···549375 /* Verify the large resource type (name) against the max */550376551377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {552552- return (AE_AML_INVALID_RESOURCE_TYPE);378378+ goto invalid_resource;553379 }554380555381 /*···566392 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);567393 }568394569569- /* Check validity of the resource type, zero indicates name is invalid */570570-395395+ /*396396+ * Check validity of the resource type, via acpi_gbl_resource_types. Zero397397+ * indicates an invalid resource.398398+ */571399 if (!acpi_gbl_resource_types[resource_index]) {572572- return (AE_AML_INVALID_RESOURCE_TYPE);400400+ goto invalid_resource;573401 }574402575403 /*576576- * 2) Validate the resource_length field. This ensures that the length577577- * is at least reasonable, and guarantees that it is non-zero.404404+ * Validate the resource_length field. This ensures that the length405405+ * is at least reasonable, and guarantees that it is non-zero.578406 */579407 resource_length = acpi_ut_get_resource_length(aml);580408 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];···589413 /* Fixed length resource, length must match exactly */590414591415 if (resource_length != minimum_resource_length) {592592- return (AE_AML_BAD_RESOURCE_LENGTH);416416+ goto bad_resource_length;593417 }594418 break;595419···598422 /* Variable length resource, length must be at least the minimum */599423600424 if (resource_length < minimum_resource_length) {601601- return (AE_AML_BAD_RESOURCE_LENGTH);425425+ goto bad_resource_length;602426 }603427 break;604428···608432609433 if ((resource_length > minimum_resource_length) ||610434 (resource_length < (minimum_resource_length - 1))) {611611- return (AE_AML_BAD_RESOURCE_LENGTH);435435+ goto bad_resource_length;612436 }613437 break;614438···616440617441 /* Shouldn't happen (because of validation earlier), but be sure */618442619619- return (AE_AML_INVALID_RESOURCE_TYPE);443443+ goto invalid_resource;444444+ }445445+446446+ aml_resource = ACPI_CAST_PTR(union aml_resource, aml);447447+ if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) {448448+449449+ /* Validate the bus_type field */450450+451451+ if ((aml_resource->common_serial_bus.type == 0) ||452452+ (aml_resource->common_serial_bus.type >453453+ AML_RESOURCE_MAX_SERIALBUSTYPE)) {454454+ ACPI_RESOURCE_ERROR((AE_INFO,455455+ "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",456456+ aml_resource->common_serial_bus.457457+ type));458458+ return (AE_AML_INVALID_RESOURCE_TYPE);459459+ }620460 }621461622462 /* Optionally return the resource table index */···642450 }643451644452 return (AE_OK);453453+454454+ invalid_resource:455455+456456+ ACPI_RESOURCE_ERROR((AE_INFO,457457+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",458458+ resource_type));459459+ return (AE_AML_INVALID_RESOURCE_TYPE);460460+461461+ bad_resource_length:462462+463463+ ACPI_RESOURCE_ERROR((AE_INFO,464464+ "Invalid resource descriptor length: Type "465465+ "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",466466+ resource_type, resource_length,467467+ minimum_resource_length));468468+ return (AE_AML_BAD_RESOURCE_LENGTH);645469}646470647471/*******************************************************************************