diff options
author | Bob Moore <robert.moore@intel.com> | 2005-11-02 00:00:00 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-12-10 00:26:05 -0500 |
commit | 96db255c8f014ae3497507104e8df809785a619f (patch) | |
tree | 79d2c506644370fd6c10d94bd40c419cd3bad148 /drivers/acpi/resources | |
parent | 0897831bb54eb36fd9e2a22da7f0f64be1b20d09 (diff) | |
download | talos-op-linux-96db255c8f014ae3497507104e8df809785a619f.tar.gz talos-op-linux-96db255c8f014ae3497507104e8df809785a619f.zip |
[ACPI] ACPICA 20051102
Modified the subsystem initialization sequence to improve
GPE support. The GPE initialization has been split into
two parts in order to defer execution of the _PRW methods
(Power Resources for Wake) until after the hardware is
fully initialized and the SCI handler is installed. This
allows the _PRW methods to access fields protected by the
Global Lock. This will fix systems where a NO_GLOBAL_LOCK
exception has been seen during initialization.
Fixed a regression with the ConcatenateResTemplate()
ASL operator introduced in the 20051021 release.
Implemented support for "local" internal ACPI object
types within the debugger "Object" command and the
acpi_walk_namespace() external interfaces. These local
types include RegionFields, BankFields, IndexFields, Alias,
and reference objects.
Moved common AML resource handling code into a new file,
"utresrc.c". This code is shared by both the Resource
Manager and the AML Debugger.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources')
-rw-r--r-- | drivers/acpi/resources/rscalc.c | 253 | ||||
-rw-r--r-- | drivers/acpi/resources/rsdump.c | 70 | ||||
-rw-r--r-- | drivers/acpi/resources/rsinfo.c | 97 | ||||
-rw-r--r-- | drivers/acpi/resources/rslist.c | 195 | ||||
-rw-r--r-- | drivers/acpi/resources/rsutils.c | 88 |
5 files changed, 239 insertions, 464 deletions
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index c29d3a447278..eca7439ee9da 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -299,13 +299,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Point to the next object */ - resource = ACPI_PTR_ADD(struct acpi_resource, - resource, resource->length); + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } - /* Did not find an END_TAG descriptor */ + /* Did not find an end_tag resource descriptor */ - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } /******************************************************************************* @@ -328,185 +329,155 @@ acpi_status acpi_rs_get_list_length(u8 * aml_buffer, u32 aml_buffer_length, acpi_size * size_needed) { + acpi_status status; + u8 *end_aml; u8 *buffer; - struct acpi_resource_info *resource_info; u32 buffer_size = 0; - u32 bytes_parsed = 0; - u8 resource_type; u16 temp16; u16 resource_length; - u16 header_length; u32 extra_struct_bytes; + u8 resource_index; + u8 minimum_aml_resource_length; ACPI_FUNCTION_TRACE("rs_get_list_length"); - while (bytes_parsed < aml_buffer_length) { - /* The next byte in the stream is the resource descriptor type */ + end_aml = aml_buffer + aml_buffer_length; - resource_type = acpi_ut_get_resource_type(aml_buffer); + /* Walk the list of AML resource descriptors */ - /* Get the base stream size and structure sizes for the descriptor */ + while (aml_buffer < end_aml) { + /* Validate the Resource Type and Resource Length */ - resource_info = acpi_rs_get_resource_info(resource_type); - if (!resource_info) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + status = acpi_ut_validate_resource(aml_buffer, &resource_index); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - /* Get the Length field from the input resource descriptor */ + /* Get the resource length and base (minimum) AML size */ resource_length = acpi_ut_get_resource_length(aml_buffer); + minimum_aml_resource_length = + acpi_gbl_resource_aml_sizes[resource_index]; - /* Augment the size for descriptors with optional fields */ - + /* + * Augment the size for descriptors with optional + * and/or variable length fields + */ extra_struct_bytes = 0; + buffer = + aml_buffer + acpi_ut_get_resource_header_length(aml_buffer); - if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { + switch (acpi_ut_get_resource_type(aml_buffer)) { + case ACPI_RESOURCE_NAME_IRQ: /* - * Small resource descriptors + * IRQ Resource: + * Get the number of bits set in the 16-bit IRQ mask */ - header_length = - sizeof(struct aml_resource_small_header); - buffer = aml_buffer + header_length; - - switch (resource_type) { - case ACPI_RESOURCE_NAME_IRQ: - /* - * IRQ Resource: - * Get the number of bits set in the IRQ word - */ - ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = - (acpi_rs_count_set_bits(temp16) * - sizeof(u32)); - break; - - case ACPI_RESOURCE_NAME_DMA: - /* - * DMA Resource: - * Get the number of bits set in the DMA channels byte - */ - ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = - (acpi_rs_count_set_bits(temp16) * - sizeof(u32)); - break; - - case ACPI_RESOURCE_NAME_VENDOR_SMALL: - /* - * Vendor Specific Resource: - * Ensure a 32-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); - break; + ACPI_MOVE_16_TO_16(&temp16, buffer); + extra_struct_bytes = + acpi_rs_count_set_bits(temp16) * sizeof(u32); + break; - case ACPI_RESOURCE_NAME_END_TAG: - /* - * End Tag: - * Terminate the loop now - */ - aml_buffer_length = bytes_parsed; - break; + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the 8-bit DMA mask + */ + extra_struct_bytes = + acpi_rs_count_set_bits(*buffer) * sizeof(u32); + break; - default: - break; - } - } else { + case ACPI_RESOURCE_NAME_VENDOR_SMALL: /* - * Large resource descriptors + * Vendor Resource: + * Ensure a 32-bit boundary for the structure */ - header_length = - sizeof(struct aml_resource_large_header); - buffer = aml_buffer + header_length; + extra_struct_bytes = + ACPI_ROUND_UP_to_32_bITS(resource_length) - + resource_length; + break; - switch (resource_type) { - case ACPI_RESOURCE_NAME_VENDOR_LARGE: - /* - * Vendor Defined Resource: - * Add vendor data and ensure a 32-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); - break; + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: This is the normal exit + */ + *size_needed = buffer_size; + return_ACPI_STATUS(AE_OK); - case ACPI_RESOURCE_NAME_ADDRESS32: - case ACPI_RESOURCE_NAME_ADDRESS16: - /* - * 32-Bit or 16-bit Address Resource: - * Add the size of any optional data (resource_source) - */ - extra_struct_bytes = - acpi_rs_stream_option_length - (resource_length, - resource_info-> - minimum_aml_resource_length); - break; - - case ACPI_RESOURCE_NAME_EXTENDED_IRQ: - /* - * Extended IRQ: - * Point past the interrupt_vector_flags to get the - * interrupt_table_length. - */ - buffer++; + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Resource: + * Add vendor data and ensure a 32-bit boundary for the structure + */ + extra_struct_bytes = + ACPI_ROUND_UP_to_32_bITS(resource_length) - + resource_length; + break; - /* - * Add 4 bytes for each additional interrupt. Note: at least one - * interrupt is required and is included in the minimum - * descriptor size - */ - extra_struct_bytes = - ((*buffer - 1) * sizeof(u32)); + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + /* + * 32-Bit or 16-bit Address Resource: + * Add the size of any optional data (resource_source) + */ + extra_struct_bytes = + acpi_rs_stream_option_length(resource_length, + minimum_aml_resource_length); + break; - /* Add the size of any optional data (resource_source) */ + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ: + * Point past the interrupt_vector_flags to get the + * interrupt_table_length. + */ + buffer++; + + extra_struct_bytes = + /* + * Add 4 bytes for each additional interrupt. Note: at + * least one interrupt is required and is included in + * the minimum descriptor size + */ + ((*buffer - 1) * sizeof(u32)) + + /* Add the size of any optional data (resource_source) */ + acpi_rs_stream_option_length(resource_length - + extra_struct_bytes, + minimum_aml_resource_length); + break; - extra_struct_bytes += - acpi_rs_stream_option_length(resource_length - - - extra_struct_bytes, - resource_info-> - minimum_aml_resource_length); - break; + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of any optional data (resource_source) + * Ensure a 64-bit boundary for the structure + */ + extra_struct_bytes = + ACPI_ROUND_UP_to_64_bITS + (acpi_rs_stream_option_length + (resource_length, minimum_aml_resource_length)); + break; - case ACPI_RESOURCE_NAME_ADDRESS64: - /* - * 64-Bit Address Resource: - * Add the size of any optional data (resource_source) - * Ensure a 64-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_64_bITS - (acpi_rs_stream_option_length - (resource_length, - resource_info-> - minimum_aml_resource_length)); - break; - - default: - break; - } + default: + break; } /* Update the required buffer size for the internal descriptor structs */ - temp16 = - (u16) (resource_info->minimum_internal_struct_length + - extra_struct_bytes); + temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + + extra_struct_bytes); buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); /* - * Update byte count and point to the next resource within the stream + * Point to the next resource within the stream * using the size of the header plus the length contained in the header */ - temp16 = (u16) (header_length + resource_length); - bytes_parsed += temp16; - aml_buffer += temp16; + aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); } - /* This is the data the caller needs */ + /* Did not find an end_tag resource descriptor */ - *size_needed = buffer_size; - return_ACPI_STATUS(AE_OK); + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } /******************************************************************************* diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 27172a3d55d7..f617ca80c5a6 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -324,7 +324,7 @@ static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), - "Resource Type", "Memory Range"}, + "Resource Type", (void *)"Memory Range"}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), "Write Protect", acpi_gbl_RWdecode}, {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), @@ -337,7 +337,7 @@ static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), - "Resource Type", "I/O Range"}, + "Resource Type", (void *)"I/O Range"}, {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), "Range Type", acpi_gbl_RNGdecode}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), @@ -372,8 +372,8 @@ static struct acpi_rsdump_info acpi_rs_dump_prt[5] = { static void acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) { - void *target = NULL; - void *previous_target; + u8 *target = NULL; + u8 *previous_target; char *name; u8 count; @@ -399,43 +399,49 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) /* Strings */ case ACPI_RSD_LITERAL: - acpi_rs_out_string(name, (char *)table->pointer); + acpi_rs_out_string(name, + ACPI_CAST_PTR(char, table->pointer)); break; case ACPI_RSD_STRING: - acpi_rs_out_string(name, (char *)target); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); break; /* Data items, 8/16/32/64 bit */ case ACPI_RSD_UINT8: - acpi_rs_out_integer8(name, *(u8 *) target); + acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); break; case ACPI_RSD_UINT16: - acpi_rs_out_integer16(name, *(u16 *) target); + acpi_rs_out_integer16(name, + *ACPI_CAST_PTR(u16, target)); break; case ACPI_RSD_UINT32: - acpi_rs_out_integer32(name, *(u32 *) target); + acpi_rs_out_integer32(name, + *ACPI_CAST_PTR(u32, target)); break; case ACPI_RSD_UINT64: - acpi_rs_out_integer64(name, *(u64 *) target); + acpi_rs_out_integer64(name, + *ACPI_CAST_PTR(u64, target)); break; /* Flags: 1-bit and 2-bit flags supported */ case ACPI_RSD_1BITFLAG: - acpi_rs_out_string(name, (char *) - ((const char **)table-> - pointer)[(*(u8 *) target) & 0x01]); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, + table-> + pointer[*target & + 0x01])); break; case ACPI_RSD_2BITFLAG: - acpi_rs_out_string(name, (char *) - ((const char **)table-> - pointer)[(*(u8 *) target) & 0x03]); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, + table-> + pointer[*target & + 0x03])); break; case ACPI_RSD_SHORTLIST: @@ -445,10 +451,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) */ if (previous_target) { acpi_rs_out_title(name); - acpi_rs_dump_short_byte_list(* - ((u8 *) - previous_target), - (u8 *) target); + acpi_rs_dump_short_byte_list(*previous_target, + target); } break; @@ -458,10 +462,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) * Note: The list length is obtained from the previous table entry */ if (previous_target) { - acpi_rs_dump_byte_list(* - ((u16 *) - previous_target), - (u8 *) target); + acpi_rs_dump_byte_list(*ACPI_CAST_PTR + (u16, previous_target), + target); } break; @@ -471,10 +474,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) * Note: The list length is obtained from the previous table entry */ if (previous_target) { - acpi_rs_dump_dword_list(* - ((u8 *) - previous_target), - (u32 *) target); + acpi_rs_dump_dword_list(*previous_target, + ACPI_CAST_PTR(u32, + target)); } break; @@ -482,17 +484,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) /* * Common flags for all Address resources */ - acpi_rs_dump_address_common((union acpi_resource_data *) - target); + acpi_rs_dump_address_common(ACPI_CAST_PTR + (union acpi_resource_data, + target)); break; case ACPI_RSD_SOURCE: /* * Optional resource_source for Address resources */ - acpi_rs_dump_resource_source((struct - acpi_resource_source *) - target); + acpi_rs_dump_resource_source(ACPI_CAST_PTR + (struct + acpi_resource_source, + target)); break; default: diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 973fc2834cbb..623b06689336 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -80,7 +80,9 @@ struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = { /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ -struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { +struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = { + /* Small descriptors */ + NULL, /* 0x00, Reserved */ NULL, /* 0x01, Reserved */ NULL, /* 0x02, Reserved */ @@ -96,10 +98,10 @@ struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { NULL, /* 0x0C, Reserved */ NULL, /* 0x0D, Reserved */ acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ - acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ -}; + acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + + /* Large descriptors */ -struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = { NULL, /* 0x00, Reserved */ acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ @@ -138,7 +140,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; - #endif #endif /* ACPI_FUTURE_USAGE */ /* @@ -166,62 +167,38 @@ const u8 acpi_gbl_aml_resource_sizes[] = { sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; -/* Macros used in the tables below */ +const u8 acpi_gbl_resource_struct_sizes[] = { + /* Small descriptors */ -#define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) -#define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) + 0, + 0, + 0, + 0, + ACPI_RS_SIZE(struct acpi_resource_irq), + ACPI_RS_SIZE(struct acpi_resource_dma), + ACPI_RS_SIZE(struct acpi_resource_start_dependent), + ACPI_RS_SIZE_MIN, + ACPI_RS_SIZE(struct acpi_resource_io), + ACPI_RS_SIZE(struct acpi_resource_fixed_io), + 0, + 0, + 0, + 0, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RS_SIZE_MIN, -/* - * Base sizes of resource descriptors, both the AML stream resource length - * (minus size of header and length fields),and the size of the internal - * struct representation. - */ -struct acpi_resource_info acpi_gbl_sm_resource_info[] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {2, ACPI_RSMALL(struct aml_resource_irq), - ACPI_RS_SIZE(struct acpi_resource_irq)}, - {0, ACPI_RSMALL(struct aml_resource_dma), - ACPI_RS_SIZE(struct acpi_resource_dma)}, - {2, ACPI_RSMALL(struct aml_resource_start_dependent), - ACPI_RS_SIZE(struct acpi_resource_start_dependent)}, - {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN}, - {0, ACPI_RSMALL(struct aml_resource_io), - ACPI_RS_SIZE(struct acpi_resource_io)}, - {0, ACPI_RSMALL(struct aml_resource_fixed_io), - ACPI_RS_SIZE(struct acpi_resource_fixed_io)}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {1, ACPI_RSMALL(struct aml_resource_vendor_small), - ACPI_RS_SIZE(struct acpi_resource_vendor)}, - {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN} -}; + /* Large descriptors */ -struct acpi_resource_info acpi_gbl_lg_resource_info[] = { - {0, 0, 0}, - {0, ACPI_RLARGE(struct aml_resource_memory24), - ACPI_RS_SIZE(struct acpi_resource_memory24)}, - {0, ACPI_RLARGE(struct aml_resource_generic_register), - ACPI_RS_SIZE(struct acpi_resource_generic_register)}, - {0, 0, 0}, - {1, ACPI_RLARGE(struct aml_resource_vendor_large), - ACPI_RS_SIZE(struct acpi_resource_vendor)}, - {0, ACPI_RLARGE(struct aml_resource_memory32), - ACPI_RS_SIZE(struct acpi_resource_memory32)}, - {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), - ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)}, - {1, ACPI_RLARGE(struct aml_resource_address32), - ACPI_RS_SIZE(struct acpi_resource_address32)}, - {1, ACPI_RLARGE(struct aml_resource_address16), - ACPI_RS_SIZE(struct acpi_resource_address16)}, - {1, ACPI_RLARGE(struct aml_resource_extended_irq), - ACPI_RS_SIZE(struct acpi_resource_extended_irq)}, - {1, ACPI_RLARGE(struct aml_resource_address64), - ACPI_RS_SIZE(struct acpi_resource_address64)}, - {0, ACPI_RLARGE(struct aml_resource_extended_address64), - ACPI_RS_SIZE(struct acpi_resource_extended_address64)} + 0, + ACPI_RS_SIZE(struct acpi_resource_memory24), + ACPI_RS_SIZE(struct acpi_resource_generic_register), + 0, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RS_SIZE(struct acpi_resource_memory32), + ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), + ACPI_RS_SIZE(struct acpi_resource_address32), + ACPI_RS_SIZE(struct acpi_resource_address16), + ACPI_RS_SIZE(struct acpi_resource_extended_irq), + ACPI_RS_SIZE(struct acpi_resource_address64), + ACPI_RS_SIZE(struct acpi_resource_extended_address64) }; diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index ee17ef3315f8..b83996233c1d 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -47,115 +47,12 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rslist") -/* Local prototypes */ -static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 - resource_type); - -static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); - -/******************************************************************************* - * - * FUNCTION: acpi_rs_validate_resource_length - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * - * RETURN: Status - AE_OK if the resource length appears valid - * - * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must - * have the exact length; variable-length descriptors must be - * at least as long as the minimum. Certain Small descriptors - * can vary in size by at most one byte. - * - ******************************************************************************/ - -static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) -{ - struct acpi_resource_info *resource_info; - u16 minimum_aml_resource_length; - u16 resource_length; - - ACPI_FUNCTION_ENTRY(); - - /* Get the size and type info about this resource descriptor */ - - resource_info = - acpi_rs_get_resource_info(aml->small_header.descriptor_type); - if (!resource_info) { - return (AE_AML_INVALID_RESOURCE_TYPE); - } - - resource_length = acpi_ut_get_resource_length(aml); - minimum_aml_resource_length = - resource_info->minimum_aml_resource_length; - - /* Validate based upon the type of resource, fixed length or variable */ - - if (resource_info->length_type == ACPI_FIXED_LENGTH) { - /* Fixed length resource, length must match exactly */ - - if (resource_length != minimum_aml_resource_length) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { - /* Variable length resource, must be at least the minimum */ - - if (resource_length < minimum_aml_resource_length) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } else { - /* Small variable length resource, allowed to be (Min) or (Min-1) */ - - if ((resource_length > minimum_aml_resource_length) || - (resource_length < (minimum_aml_resource_length - 1))) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } - - return (AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_conversion_info - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: Pointer to the resource conversion info table - * - * DESCRIPTION: Get the conversion table associated with this resource type - * - ******************************************************************************/ - -static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) -{ - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { - return (NULL); - } - - return (acpi_gbl_lg_get_resource_dispatch[(resource_type & - ACPI_RESOURCE_NAME_LARGE_MASK)]); - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - return (acpi_gbl_sm_get_resource_dispatch[((resource_type & - ACPI_RESOURCE_NAME_SMALL_MASK) - >> 3)]); - } -} - /******************************************************************************* * * FUNCTION: acpi_rs_convert_aml_to_resources * - * PARAMETERS: aml_buffer - Pointer to the resource byte stream - * aml_buffer_length - Length of aml_buffer + * PARAMETERS: Aml - Pointer to the resource byte stream + * aml_length - Length of Aml * output_buffer - Pointer to the buffer that will * contain the output structures * @@ -165,42 +62,24 @@ static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) * linked list of resources in the caller's output buffer * ******************************************************************************/ - acpi_status -acpi_rs_convert_aml_to_resources(u8 * aml_buffer, - u32 aml_buffer_length, u8 * output_buffer) +acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) { - u8 *buffer = output_buffer; + struct acpi_resource *resource = (void *)output_buffer; acpi_status status; - acpi_size bytes_parsed = 0; - struct acpi_resource *resource; - acpi_rsdesc_size descriptor_length; - struct acpi_rsconvert_info *info; + u8 resource_index; + u8 *end_aml; ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); - /* Loop until end-of-buffer or an end_tag is found */ - - while (bytes_parsed < aml_buffer_length) { - /* Get the conversion table associated with this Descriptor Type */ - - info = acpi_rs_get_conversion_info(*aml_buffer); - if (!info) { - /* No table indicates an invalid resource type */ + end_aml = aml + aml_length; - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } + /* Loop until end-of-buffer or an end_tag is found */ - descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); + while (aml < end_aml) { + /* Validate the Resource Type and Resource Length */ - /* - * Perform limited validation of the resource length, based upon - * what we know about the resource type - */ - status = - acpi_rs_validate_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + status = acpi_ut_validate_resource(aml, &resource_index); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -208,42 +87,36 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, /* Convert the AML byte stream resource to a local resource struct */ status = - acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR - (struct acpi_resource, - buffer), + acpi_rs_convert_aml_to_resource(resource, ACPI_CAST_PTR(union aml_resource, - aml_buffer), - info); + aml), + acpi_gbl_get_resource_dispatch + [resource_index]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status))); return_ACPI_STATUS(status); } - /* Set the aligned length of the new resource descriptor */ - - resource = ACPI_CAST_PTR(struct acpi_resource, buffer); - resource->length = - (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length); - /* Normal exit on completion of an end_tag resource descriptor */ - if (acpi_ut_get_resource_type(aml_buffer) == + if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_END_TAG) { return_ACPI_STATUS(AE_OK); } - /* Update counter and point to the next input resource */ + /* Point to the next input AML resource */ - bytes_parsed += descriptor_length; - aml_buffer += descriptor_length; + aml += acpi_ut_get_descriptor_length(aml); /* Point to the next structure in the output buffer */ - buffer += resource->length; + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } - /* Completed buffer, but did not find an end_tag resource descriptor */ + /* Did not find an end_tag resource descriptor */ return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } @@ -271,16 +144,16 @@ acpi_status acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, acpi_size aml_size_needed, u8 * output_buffer) { - u8 *aml_buffer = output_buffer; - u8 *end_aml_buffer = output_buffer + aml_size_needed; + u8 *aml = output_buffer; + u8 *end_aml = output_buffer + aml_size_needed; acpi_status status; ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); /* Walk the resource descriptor list, convert each descriptor */ - while (aml_buffer < end_aml_buffer) { - /* Validate the Resource Type */ + while (aml < end_aml) { + /* Validate the (internal) Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, @@ -294,7 +167,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union aml_resource, - aml_buffer), + aml), acpi_gbl_set_resource_dispatch [resource->type]); if (ACPI_FAILURE(status)) { @@ -305,9 +178,8 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* Perform final sanity check on the new AML resource descriptor */ status = - acpi_rs_validate_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + acpi_ut_validate_resource(ACPI_CAST_PTR + (union aml_resource, aml), NULL); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -322,18 +194,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* * Extract the total length of the new descriptor and set the - * aml_buffer to point to the next (output) resource descriptor + * Aml to point to the next (output) resource descriptor */ - aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); + aml += acpi_ut_get_descriptor_length(aml); /* Point to the next input resource descriptor */ resource = ACPI_PTR_ADD(struct acpi_resource, resource, resource->length); - - /* Check for end-of-list, normal exit */ - } /* Completed buffer, but did not find an end_tag resource descriptor */ diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 7613033f5dcf..a1eac0f1df54 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -65,6 +65,8 @@ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list) acpi_native_uint i; u8 bit_count; + ACPI_FUNCTION_ENTRY(); + /* Decode the mask bits */ for (i = 0, bit_count = 0; mask; i++) { @@ -97,6 +99,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) acpi_native_uint i; u16 mask; + ACPI_FUNCTION_ENTRY(); + /* Encode the list into a single bitmask */ for (i = 0, mask = 0; i < count; i++) { @@ -128,6 +132,8 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) { acpi_native_uint i; + ACPI_FUNCTION_ENTRY(); + /* One move per item */ for (i = 0; i < item_count; i++) { @@ -168,53 +174,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) /******************************************************************************* * - * FUNCTION: acpi_rs_get_resource_info - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: Pointer to the resource conversion handler - * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. - * - ******************************************************************************/ - -struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) -{ - struct acpi_resource_info *size_info; - - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { - return (NULL); - } - - size_info = &acpi_gbl_lg_resource_info[(resource_type & - ACPI_RESOURCE_NAME_LARGE_MASK)]; - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - size_info = &acpi_gbl_sm_resource_info[((resource_type & - ACPI_RESOURCE_NAME_SMALL_MASK) - >> 3)]; - } - - /* Zero entry indicates an invalid resource type */ - - if (!size_info->minimum_internal_struct_length) { - return (NULL); - } - - return (size_info); -} - -/******************************************************************************* - * * FUNCTION: acpi_rs_set_resource_length * * PARAMETERS: total_length - Length of the AML descriptor, including @@ -238,25 +197,20 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length, ACPI_FUNCTION_ENTRY(); - /* Determine if this is a small or large resource */ + /* Length is the total descriptor length minus the header length */ - if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + resource_length = (acpi_rs_length) + (total_length - acpi_ut_get_resource_header_length(aml)); - resource_length = (acpi_rs_length) - (total_length - sizeof(struct aml_resource_large_header)); + /* Length is stored differently for large and small descriptors */ - /* Insert length into the Large descriptor length field */ + if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, &resource_length); } else { - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - - resource_length = (acpi_rs_length) - (total_length - sizeof(struct aml_resource_small_header)); - - /* Insert length into the descriptor type byte */ + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ aml->small_header.descriptor_type = (u8) @@ -292,7 +246,7 @@ acpi_rs_set_resource_header(u8 descriptor_type, { ACPI_FUNCTION_ENTRY(); - /* Set the Descriptor Type */ + /* Set the Resource Type */ aml->small_header.descriptor_type = descriptor_type; @@ -409,14 +363,14 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, (char *)&aml_resource_source[1]); return ((acpi_rs_length) total_length); - } else { - /* resource_source is not present */ - - resource_source->index = 0; - resource_source->string_length = 0; - resource_source->string_ptr = NULL; - return (0); } + + /* resource_source is not present */ + + resource_source->index = 0; + resource_source->string_length = 0; + resource_source->string_ptr = NULL; + return (0); } /******************************************************************************* |