diff options
Diffstat (limited to 'drivers/acpi/resources')
| -rw-r--r-- | drivers/acpi/resources/rscalc.c | 108 | ||||
| -rw-r--r-- | drivers/acpi/resources/rscreate.c | 33 | ||||
| -rw-r--r-- | drivers/acpi/resources/rsdump.c | 42 | ||||
| -rw-r--r-- | drivers/acpi/resources/rsinfo.c | 1 | ||||
| -rw-r--r-- | drivers/acpi/resources/rslist.c | 102 | ||||
| -rw-r--r-- | drivers/acpi/resources/rsmisc.c | 12 | ||||
| -rw-r--r-- | drivers/acpi/resources/rsutils.c | 155 | ||||
| -rw-r--r-- | drivers/acpi/resources/rsxface.c | 395 |
8 files changed, 454 insertions, 394 deletions
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 4038dbfa63a0..cf87b0230026 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c | |||
| @@ -78,6 +78,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field) | |||
| 78 | ACPI_FUNCTION_ENTRY(); | 78 | ACPI_FUNCTION_ENTRY(); |
| 79 | 79 | ||
| 80 | for (bits_set = 0; bit_field; bits_set++) { | 80 | for (bits_set = 0; bit_field; bits_set++) { |
| 81 | |||
| 81 | /* Zero the least significant bit that is set */ | 82 | /* Zero the least significant bit that is set */ |
| 82 | 83 | ||
| 83 | bit_field &= (bit_field - 1); | 84 | bit_field &= (bit_field - 1); |
| @@ -154,15 +155,18 @@ acpi_rs_stream_option_length(u32 resource_length, | |||
| 154 | * length, minus one byte for the resource_source_index itself. | 155 | * length, minus one byte for the resource_source_index itself. |
| 155 | */ | 156 | */ |
| 156 | if (resource_length > minimum_aml_resource_length) { | 157 | if (resource_length > minimum_aml_resource_length) { |
| 158 | |||
| 157 | /* Compute the length of the optional string */ | 159 | /* Compute the length of the optional string */ |
| 158 | 160 | ||
| 159 | string_length = | 161 | string_length = |
| 160 | resource_length - minimum_aml_resource_length - 1; | 162 | resource_length - minimum_aml_resource_length - 1; |
| 161 | } | 163 | } |
| 162 | 164 | ||
| 163 | /* Round up length to 32 bits for internal structure alignment */ | 165 | /* |
| 164 | 166 | * Round the length up to a multiple of the native word in order to | |
| 165 | return (ACPI_ROUND_UP_to_32_bITS(string_length)); | 167 | * guarantee that the entire resource descriptor is native word aligned |
| 168 | */ | ||
| 169 | return ((u32) ACPI_ROUND_UP_TO_NATIVE_WORD(string_length)); | ||
| 166 | } | 170 | } |
| 167 | 171 | ||
| 168 | /******************************************************************************* | 172 | /******************************************************************************* |
| @@ -186,11 +190,12 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | |||
| 186 | acpi_size aml_size_needed = 0; | 190 | acpi_size aml_size_needed = 0; |
| 187 | acpi_rs_length total_size; | 191 | acpi_rs_length total_size; |
| 188 | 192 | ||
| 189 | ACPI_FUNCTION_TRACE("rs_get_aml_length"); | 193 | ACPI_FUNCTION_TRACE(rs_get_aml_length); |
| 190 | 194 | ||
| 191 | /* Traverse entire list of internal resource descriptors */ | 195 | /* Traverse entire list of internal resource descriptors */ |
| 192 | 196 | ||
| 193 | while (resource) { | 197 | while (resource) { |
| 198 | |||
| 194 | /* Validate the descriptor type */ | 199 | /* Validate the descriptor type */ |
| 195 | 200 | ||
| 196 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | 201 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
| @@ -214,6 +219,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | |||
| 214 | * is a Large Resource data type. | 219 | * is a Large Resource data type. |
| 215 | */ | 220 | */ |
| 216 | if (resource->data.vendor.byte_length > 7) { | 221 | if (resource->data.vendor.byte_length > 7) { |
| 222 | |||
| 217 | /* Base size of a Large resource descriptor */ | 223 | /* Base size of a Large resource descriptor */ |
| 218 | 224 | ||
| 219 | total_size = | 225 | total_size = |
| @@ -332,20 +338,22 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
| 332 | acpi_status status; | 338 | acpi_status status; |
| 333 | u8 *end_aml; | 339 | u8 *end_aml; |
| 334 | u8 *buffer; | 340 | u8 *buffer; |
| 335 | u32 buffer_size = 0; | 341 | u32 buffer_size; |
| 336 | u16 temp16; | 342 | u16 temp16; |
| 337 | u16 resource_length; | 343 | u16 resource_length; |
| 338 | u32 extra_struct_bytes; | 344 | u32 extra_struct_bytes; |
| 339 | u8 resource_index; | 345 | u8 resource_index; |
| 340 | u8 minimum_aml_resource_length; | 346 | u8 minimum_aml_resource_length; |
| 341 | 347 | ||
| 342 | ACPI_FUNCTION_TRACE("rs_get_list_length"); | 348 | ACPI_FUNCTION_TRACE(rs_get_list_length); |
| 343 | 349 | ||
| 350 | *size_needed = 0; | ||
| 344 | end_aml = aml_buffer + aml_buffer_length; | 351 | end_aml = aml_buffer + aml_buffer_length; |
| 345 | 352 | ||
| 346 | /* Walk the list of AML resource descriptors */ | 353 | /* Walk the list of AML resource descriptors */ |
| 347 | 354 | ||
| 348 | while (aml_buffer < end_aml) { | 355 | while (aml_buffer < end_aml) { |
| 356 | |||
| 349 | /* Validate the Resource Type and Resource Length */ | 357 | /* Validate the Resource Type and Resource Length */ |
| 350 | 358 | ||
| 351 | status = acpi_ut_validate_resource(aml_buffer, &resource_index); | 359 | status = acpi_ut_validate_resource(aml_buffer, &resource_index); |
| @@ -386,35 +394,28 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
| 386 | break; | 394 | break; |
| 387 | 395 | ||
| 388 | case ACPI_RESOURCE_NAME_VENDOR_SMALL: | 396 | case ACPI_RESOURCE_NAME_VENDOR_SMALL: |
| 397 | case ACPI_RESOURCE_NAME_VENDOR_LARGE: | ||
| 389 | /* | 398 | /* |
| 390 | * Vendor Resource: | 399 | * Vendor Resource: |
| 391 | * Ensure a 32-bit boundary for the structure | 400 | * Get the number of vendor data bytes |
| 392 | */ | 401 | */ |
| 393 | extra_struct_bytes = | 402 | extra_struct_bytes = resource_length; |
| 394 | ACPI_ROUND_UP_to_32_bITS(resource_length); | ||
| 395 | break; | 403 | break; |
| 396 | 404 | ||
| 397 | case ACPI_RESOURCE_NAME_END_TAG: | 405 | case ACPI_RESOURCE_NAME_END_TAG: |
| 398 | /* | 406 | /* |
| 399 | * End Tag: This is the normal exit, add size of end_tag | 407 | * End Tag: |
| 408 | * This is the normal exit, add size of end_tag | ||
| 400 | */ | 409 | */ |
| 401 | *size_needed = buffer_size + ACPI_RS_SIZE_MIN; | 410 | *size_needed += ACPI_RS_SIZE_MIN; |
| 402 | return_ACPI_STATUS(AE_OK); | 411 | return_ACPI_STATUS(AE_OK); |
| 403 | 412 | ||
| 404 | case ACPI_RESOURCE_NAME_VENDOR_LARGE: | ||
| 405 | /* | ||
| 406 | * Vendor Resource: | ||
| 407 | * Add vendor data and ensure a 32-bit boundary for the structure | ||
| 408 | */ | ||
| 409 | extra_struct_bytes = | ||
| 410 | ACPI_ROUND_UP_to_32_bITS(resource_length); | ||
| 411 | break; | ||
| 412 | |||
| 413 | case ACPI_RESOURCE_NAME_ADDRESS32: | 413 | case ACPI_RESOURCE_NAME_ADDRESS32: |
| 414 | case ACPI_RESOURCE_NAME_ADDRESS16: | 414 | case ACPI_RESOURCE_NAME_ADDRESS16: |
| 415 | case ACPI_RESOURCE_NAME_ADDRESS64: | ||
| 415 | /* | 416 | /* |
| 416 | * 32-Bit or 16-bit Address Resource: | 417 | * Address Resource: |
| 417 | * Add the size of any optional data (resource_source) | 418 | * Add the size of the optional resource_source |
| 418 | */ | 419 | */ |
| 419 | extra_struct_bytes = | 420 | extra_struct_bytes = |
| 420 | acpi_rs_stream_option_length(resource_length, | 421 | acpi_rs_stream_option_length(resource_length, |
| @@ -423,50 +424,46 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
| 423 | 424 | ||
| 424 | case ACPI_RESOURCE_NAME_EXTENDED_IRQ: | 425 | case ACPI_RESOURCE_NAME_EXTENDED_IRQ: |
| 425 | /* | 426 | /* |
| 426 | * Extended IRQ: | 427 | * Extended IRQ Resource: |
| 427 | * Point past the interrupt_vector_flags to get the | 428 | * Using the interrupt_table_length, add 4 bytes for each additional |
| 428 | * interrupt_table_length. | 429 | * interrupt. Note: at least one interrupt is required and is |
| 430 | * included in the minimum descriptor size (reason for the -1) | ||
| 429 | */ | 431 | */ |
| 430 | buffer++; | 432 | extra_struct_bytes = (buffer[1] - 1) * sizeof(u32); |
| 431 | 433 | ||
| 432 | extra_struct_bytes = | 434 | /* Add the size of the optional resource_source */ |
| 433 | /* | 435 | |
| 434 | * Add 4 bytes for each additional interrupt. Note: at | 436 | extra_struct_bytes += |
| 435 | * least one interrupt is required and is included in | ||
| 436 | * the minimum descriptor size | ||
| 437 | */ | ||
| 438 | ((*buffer - 1) * sizeof(u32)) + | ||
| 439 | /* Add the size of any optional data (resource_source) */ | ||
| 440 | acpi_rs_stream_option_length(resource_length - | 437 | acpi_rs_stream_option_length(resource_length - |
| 441 | extra_struct_bytes, | 438 | extra_struct_bytes, |
| 442 | minimum_aml_resource_length); | 439 | minimum_aml_resource_length); |
| 443 | break; | 440 | break; |
| 444 | 441 | ||
| 445 | case ACPI_RESOURCE_NAME_ADDRESS64: | ||
| 446 | /* | ||
| 447 | * 64-Bit Address Resource: | ||
| 448 | * Add the size of any optional data (resource_source) | ||
| 449 | * Ensure a 64-bit boundary for the structure | ||
| 450 | */ | ||
| 451 | extra_struct_bytes = | ||
| 452 | ACPI_ROUND_UP_to_64_bITS | ||
| 453 | (acpi_rs_stream_option_length | ||
| 454 | (resource_length, minimum_aml_resource_length)); | ||
| 455 | break; | ||
| 456 | |||
| 457 | default: | 442 | default: |
| 458 | break; | 443 | break; |
| 459 | } | 444 | } |
| 460 | 445 | ||
| 461 | /* Update the required buffer size for the internal descriptor structs */ | 446 | /* |
| 447 | * Update the required buffer size for the internal descriptor structs | ||
| 448 | * | ||
| 449 | * Important: Round the size up for the appropriate alignment. This | ||
| 450 | * is a requirement on IA64. | ||
| 451 | */ | ||
| 452 | buffer_size = acpi_gbl_resource_struct_sizes[resource_index] + | ||
| 453 | extra_struct_bytes; | ||
| 454 | buffer_size = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size); | ||
| 462 | 455 | ||
| 463 | temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + | 456 | *size_needed += buffer_size; |
| 464 | extra_struct_bytes); | 457 | |
| 465 | buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16); | 458 | ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, |
| 459 | "Type %.2X, AmlLength %.2X InternalLength %.2X\n", | ||
| 460 | acpi_ut_get_resource_type(aml_buffer), | ||
| 461 | acpi_ut_get_descriptor_length(aml_buffer), | ||
| 462 | buffer_size)); | ||
| 466 | 463 | ||
| 467 | /* | 464 | /* |
| 468 | * Point to the next resource within the stream | 465 | * Point to the next resource within the AML stream using the length |
| 469 | * using the size of the header plus the length contained in the header | 466 | * contained in the resource descriptor header |
| 470 | */ | 467 | */ |
| 471 | aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); | 468 | aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); |
| 472 | } | 469 | } |
| @@ -506,7 +503,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
| 506 | u8 name_found; | 503 | u8 name_found; |
| 507 | u32 table_index; | 504 | u32 table_index; |
| 508 | 505 | ||
| 509 | ACPI_FUNCTION_TRACE("rs_get_pci_routing_table_length"); | 506 | ACPI_FUNCTION_TRACE(rs_get_pci_routing_table_length); |
| 510 | 507 | ||
| 511 | number_of_elements = package_object->package.count; | 508 | number_of_elements = package_object->package.count; |
| 512 | 509 | ||
| @@ -523,6 +520,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
| 523 | top_object_list = package_object->package.elements; | 520 | top_object_list = package_object->package.elements; |
| 524 | 521 | ||
| 525 | for (index = 0; index < number_of_elements; index++) { | 522 | for (index = 0; index < number_of_elements; index++) { |
| 523 | |||
| 526 | /* Dereference the sub-package */ | 524 | /* Dereference the sub-package */ |
| 527 | 525 | ||
| 528 | package_element = *top_object_list; | 526 | package_element = *top_object_list; |
| @@ -581,7 +579,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
| 581 | 579 | ||
| 582 | /* Round up the size since each element must be aligned */ | 580 | /* Round up the size since each element must be aligned */ |
| 583 | 581 | ||
| 584 | temp_size_needed = ACPI_ROUND_UP_to_64_bITS(temp_size_needed); | 582 | temp_size_needed = ACPI_ROUND_UP_TO_64BIT(temp_size_needed); |
| 585 | 583 | ||
| 586 | /* Point to the next union acpi_operand_object */ | 584 | /* Point to the next union acpi_operand_object */ |
| 587 | 585 | ||
| @@ -589,7 +587,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
| 589 | } | 587 | } |
| 590 | 588 | ||
| 591 | /* | 589 | /* |
| 592 | * Adding an extra element to the end of the list, essentially a | 590 | * Add an extra element to the end of the list, essentially a |
| 593 | * NULL terminator | 591 | * NULL terminator |
| 594 | */ | 592 | */ |
| 595 | *buffer_size_needed = | 593 | *buffer_size_needed = |
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 8c128dea3252..008058acdd39 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c | |||
| @@ -75,10 +75,11 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, | |||
| 75 | u8 *aml_start; | 75 | u8 *aml_start; |
| 76 | acpi_size list_size_needed = 0; | 76 | acpi_size list_size_needed = 0; |
| 77 | u32 aml_buffer_length; | 77 | u32 aml_buffer_length; |
| 78 | void *resource; | ||
| 78 | 79 | ||
| 79 | ACPI_FUNCTION_TRACE("rs_create_resource_list"); | 80 | ACPI_FUNCTION_TRACE(rs_create_resource_list); |
| 80 | 81 | ||
| 81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer)); | 82 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlBuffer = %p\n", aml_buffer)); |
| 82 | 83 | ||
| 83 | /* Params already validated, so we don't re-validate here */ | 84 | /* Params already validated, so we don't re-validate here */ |
| 84 | 85 | ||
| @@ -92,7 +93,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, | |||
| 92 | status = acpi_rs_get_list_length(aml_start, aml_buffer_length, | 93 | status = acpi_rs_get_list_length(aml_start, aml_buffer_length, |
| 93 | &list_size_needed); | 94 | &list_size_needed); |
| 94 | 95 | ||
| 95 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", | 96 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", |
| 96 | status, (u32) list_size_needed)); | 97 | status, (u32) list_size_needed)); |
| 97 | if (ACPI_FAILURE(status)) { | 98 | if (ACPI_FAILURE(status)) { |
| 98 | return_ACPI_STATUS(status); | 99 | return_ACPI_STATUS(status); |
| @@ -107,13 +108,15 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, | |||
| 107 | 108 | ||
| 108 | /* Do the conversion */ | 109 | /* Do the conversion */ |
| 109 | 110 | ||
| 110 | status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, | 111 | resource = output_buffer->pointer; |
| 111 | output_buffer->pointer); | 112 | status = acpi_ut_walk_aml_resources(aml_start, aml_buffer_length, |
| 113 | acpi_rs_convert_aml_to_resources, | ||
| 114 | &resource); | ||
| 112 | if (ACPI_FAILURE(status)) { | 115 | if (ACPI_FAILURE(status)) { |
| 113 | return_ACPI_STATUS(status); | 116 | return_ACPI_STATUS(status); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", | 119 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", |
| 117 | output_buffer->pointer, (u32) output_buffer->length)); | 120 | output_buffer->pointer, (u32) output_buffer->length)); |
| 118 | return_ACPI_STATUS(AE_OK); | 121 | return_ACPI_STATUS(AE_OK); |
| 119 | } | 122 | } |
| @@ -155,7 +158,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 155 | acpi_status status; | 158 | acpi_status status; |
| 156 | struct acpi_buffer path_buffer; | 159 | struct acpi_buffer path_buffer; |
| 157 | 160 | ||
| 158 | ACPI_FUNCTION_TRACE("rs_create_pci_routing_table"); | 161 | ACPI_FUNCTION_TRACE(rs_create_pci_routing_table); |
| 159 | 162 | ||
| 160 | /* Params already validated, so we don't re-validate here */ | 163 | /* Params already validated, so we don't re-validate here */ |
| 161 | 164 | ||
| @@ -167,7 +170,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 167 | return_ACPI_STATUS(status); | 170 | return_ACPI_STATUS(status); |
| 168 | } | 171 | } |
| 169 | 172 | ||
| 170 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "buffer_size_needed = %X\n", | 173 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", |
| 171 | (u32) buffer_size_needed)); | 174 | (u32) buffer_size_needed)); |
| 172 | 175 | ||
| 173 | /* Validate/Allocate/Clear caller buffer */ | 176 | /* Validate/Allocate/Clear caller buffer */ |
| @@ -332,7 +335,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 332 | /* Now align the current length */ | 335 | /* Now align the current length */ |
| 333 | 336 | ||
| 334 | user_prt->length = | 337 | user_prt->length = |
| 335 | (u32) ACPI_ROUND_UP_to_64_bITS(user_prt->length); | 338 | (u32) ACPI_ROUND_UP_TO_64BIT(user_prt->length); |
| 336 | 339 | ||
| 337 | /* 4) Fourth subobject: Dereference the PRT.source_index */ | 340 | /* 4) Fourth subobject: Dereference the PRT.source_index */ |
| 338 | 341 | ||
| @@ -341,7 +344,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 341 | user_prt->source_index = (u32) obj_desc->integer.value; | 344 | user_prt->source_index = (u32) obj_desc->integer.value; |
| 342 | } else { | 345 | } else { |
| 343 | ACPI_ERROR((AE_INFO, | 346 | ACPI_ERROR((AE_INFO, |
| 344 | "(PRT[%X].source_index) Need Integer, found %s", | 347 | "(PRT[%X].SourceIndex) Need Integer, found %s", |
| 345 | index, | 348 | index, |
| 346 | acpi_ut_get_object_type_name(obj_desc))); | 349 | acpi_ut_get_object_type_name(obj_desc))); |
| 347 | return_ACPI_STATUS(AE_BAD_DATA); | 350 | return_ACPI_STATUS(AE_BAD_DATA); |
| @@ -352,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 352 | top_object_list++; | 355 | top_object_list++; |
| 353 | } | 356 | } |
| 354 | 357 | ||
| 355 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", | 358 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", |
| 356 | output_buffer->pointer, (u32) output_buffer->length)); | 359 | output_buffer->pointer, (u32) output_buffer->length)); |
| 357 | return_ACPI_STATUS(AE_OK); | 360 | return_ACPI_STATUS(AE_OK); |
| 358 | } | 361 | } |
| @@ -382,9 +385,9 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
| 382 | acpi_status status; | 385 | acpi_status status; |
| 383 | acpi_size aml_size_needed = 0; | 386 | acpi_size aml_size_needed = 0; |
| 384 | 387 | ||
| 385 | ACPI_FUNCTION_TRACE("rs_create_aml_resources"); | 388 | ACPI_FUNCTION_TRACE(rs_create_aml_resources); |
| 386 | 389 | ||
| 387 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", | 390 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "LinkedListBuffer = %p\n", |
| 388 | linked_list_buffer)); | 391 | linked_list_buffer)); |
| 389 | 392 | ||
| 390 | /* | 393 | /* |
| @@ -395,7 +398,7 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
| 395 | */ | 398 | */ |
| 396 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); | 399 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); |
| 397 | 400 | ||
| 398 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n", | 401 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", |
| 399 | (u32) aml_size_needed, | 402 | (u32) aml_size_needed, |
| 400 | acpi_format_exception(status))); | 403 | acpi_format_exception(status))); |
| 401 | if (ACPI_FAILURE(status)) { | 404 | if (ACPI_FAILURE(status)) { |
| @@ -419,7 +422,7 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
| 419 | return_ACPI_STATUS(status); | 422 | return_ACPI_STATUS(status); |
| 420 | } | 423 | } |
| 421 | 424 | ||
| 422 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", | 425 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", |
| 423 | output_buffer->pointer, (u32) output_buffer->length)); | 426 | output_buffer->pointer, (u32) output_buffer->length)); |
| 424 | return_ACPI_STATUS(AE_OK); | 427 | return_ACPI_STATUS(AE_OK); |
| 425 | } | 428 | } |
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index e7de061cf883..9c99a723a860 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c | |||
| @@ -91,11 +91,11 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); | |||
| 91 | struct acpi_rsdump_info acpi_rs_dump_irq[6] = { | 91 | struct acpi_rsdump_info acpi_rs_dump_irq[6] = { |
| 92 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL}, | 92 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL}, |
| 93 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering", | 93 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering", |
| 94 | acpi_gbl_HEdecode}, | 94 | acpi_gbl_he_decode}, |
| 95 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity", | 95 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity", |
| 96 | acpi_gbl_LLdecode}, | 96 | acpi_gbl_ll_decode}, |
| 97 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing", | 97 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing", |
| 98 | acpi_gbl_SHRdecode}, | 98 | acpi_gbl_shr_decode}, |
| 99 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count), | 99 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count), |
| 100 | "Interrupt Count", NULL}, | 100 | "Interrupt Count", NULL}, |
| 101 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]), | 101 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]), |
| @@ -105,11 +105,11 @@ struct acpi_rsdump_info acpi_rs_dump_irq[6] = { | |||
| 105 | struct acpi_rsdump_info acpi_rs_dump_dma[6] = { | 105 | struct acpi_rsdump_info acpi_rs_dump_dma[6] = { |
| 106 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL}, | 106 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL}, |
| 107 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed", | 107 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed", |
| 108 | acpi_gbl_TYPdecode}, | 108 | acpi_gbl_typ_decode}, |
| 109 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering", | 109 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering", |
| 110 | acpi_gbl_BMdecode}, | 110 | acpi_gbl_bm_decode}, |
| 111 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type", | 111 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type", |
| 112 | acpi_gbl_SIZdecode}, | 112 | acpi_gbl_siz_decode}, |
| 113 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count", | 113 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count", |
| 114 | NULL}, | 114 | NULL}, |
| 115 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List", | 115 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List", |
| @@ -158,7 +158,7 @@ struct acpi_rsdump_info acpi_rs_dump_vendor[3] = { | |||
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = { | 160 | struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = { |
| 161 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag", | 161 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag", |
| 162 | NULL} | 162 | NULL} |
| 163 | }; | 163 | }; |
| 164 | 164 | ||
| @@ -166,7 +166,7 @@ struct acpi_rsdump_info acpi_rs_dump_memory24[6] = { | |||
| 166 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24), | 166 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24), |
| 167 | "24-Bit Memory Range", NULL}, | 167 | "24-Bit Memory Range", NULL}, |
| 168 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect), | 168 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect), |
| 169 | "Write Protect", acpi_gbl_RWdecode}, | 169 | "Write Protect", acpi_gbl_rw_decode}, |
| 170 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum", | 170 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum", |
| 171 | NULL}, | 171 | NULL}, |
| 172 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum", | 172 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum", |
| @@ -181,7 +181,7 @@ struct acpi_rsdump_info acpi_rs_dump_memory32[6] = { | |||
| 181 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32), | 181 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32), |
| 182 | "32-Bit Memory Range", NULL}, | 182 | "32-Bit Memory Range", NULL}, |
| 183 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect), | 183 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect), |
| 184 | "Write Protect", acpi_gbl_RWdecode}, | 184 | "Write Protect", acpi_gbl_rw_decode}, |
| 185 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum", | 185 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum", |
| 186 | NULL}, | 186 | NULL}, |
| 187 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum", | 187 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum", |
| @@ -196,7 +196,7 @@ struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = { | |||
| 196 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32), | 196 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32), |
| 197 | "32-Bit Fixed Memory Range", NULL}, | 197 | "32-Bit Fixed Memory Range", NULL}, |
| 198 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect), | 198 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect), |
| 199 | "Write Protect", acpi_gbl_RWdecode}, | 199 | "Write Protect", acpi_gbl_rw_decode}, |
| 200 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address", | 200 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address", |
| 201 | NULL}, | 201 | NULL}, |
| 202 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length), | 202 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length), |
| @@ -278,11 +278,11 @@ struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = { | |||
| 278 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer), | 278 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer), |
| 279 | "Type", acpi_gbl_consume_decode}, | 279 | "Type", acpi_gbl_consume_decode}, |
| 280 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering), | 280 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering), |
| 281 | "Triggering", acpi_gbl_HEdecode}, | 281 | "Triggering", acpi_gbl_he_decode}, |
| 282 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity", | 282 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity", |
| 283 | acpi_gbl_LLdecode}, | 283 | acpi_gbl_ll_decode}, |
| 284 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing", | 284 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing", |
| 285 | acpi_gbl_SHRdecode}, | 285 | acpi_gbl_shr_decode}, |
| 286 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL, | 286 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL, |
| 287 | NULL}, | 287 | NULL}, |
| 288 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count), | 288 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count), |
| @@ -314,7 +314,7 @@ static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { | |||
| 314 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer), | 314 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer), |
| 315 | "Consumer/Producer", acpi_gbl_consume_decode}, | 315 | "Consumer/Producer", acpi_gbl_consume_decode}, |
| 316 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode", | 316 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode", |
| 317 | acpi_gbl_DECdecode}, | 317 | acpi_gbl_dec_decode}, |
| 318 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed), | 318 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed), |
| 319 | "Min Relocatability", acpi_gbl_min_decode}, | 319 | "Min Relocatability", acpi_gbl_min_decode}, |
| 320 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed), | 320 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed), |
| @@ -325,24 +325,24 @@ static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { | |||
| 325 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), | 325 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), |
| 326 | "Resource Type", (void *)"Memory Range"}, | 326 | "Resource Type", (void *)"Memory Range"}, |
| 327 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), | 327 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), |
| 328 | "Write Protect", acpi_gbl_RWdecode}, | 328 | "Write Protect", acpi_gbl_rw_decode}, |
| 329 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), | 329 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), |
| 330 | "Caching", acpi_gbl_MEMdecode}, | 330 | "Caching", acpi_gbl_mem_decode}, |
| 331 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type), | 331 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type), |
| 332 | "Range Type", acpi_gbl_MTPdecode}, | 332 | "Range Type", acpi_gbl_mtp_decode}, |
| 333 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation), | 333 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation), |
| 334 | "Translation", acpi_gbl_TTPdecode} | 334 | "Translation", acpi_gbl_ttp_decode} |
| 335 | }; | 335 | }; |
| 336 | 336 | ||
| 337 | static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { | 337 | static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { |
| 338 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), | 338 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), |
| 339 | "Resource Type", (void *)"I/O Range"}, | 339 | "Resource Type", (void *)"I/O Range"}, |
| 340 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), | 340 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), |
| 341 | "Range Type", acpi_gbl_RNGdecode}, | 341 | "Range Type", acpi_gbl_rng_decode}, |
| 342 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), | 342 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), |
| 343 | "Translation", acpi_gbl_TTPdecode}, | 343 | "Translation", acpi_gbl_ttp_decode}, |
| 344 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type), | 344 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type), |
| 345 | "Translation Type", acpi_gbl_TRSdecode} | 345 | "Translation Type", acpi_gbl_trs_decode} |
| 346 | }; | 346 | }; |
| 347 | 347 | ||
| 348 | /* | 348 | /* |
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index d9ae64b77bd9..9e7ae2f8a1d3 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c | |||
| @@ -141,6 +141,7 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { | |||
| 141 | acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ | 141 | acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ |
| 142 | }; | 142 | }; |
| 143 | #endif | 143 | #endif |
| 144 | |||
| 144 | #endif /* ACPI_FUTURE_USAGE */ | 145 | #endif /* ACPI_FUTURE_USAGE */ |
| 145 | /* | 146 | /* |
| 146 | * Base sizes for external AML resource descriptors, indexed by internal type. | 147 | * Base sizes for external AML resource descriptors, indexed by internal type. |
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index 1434e786477e..29423ce030ca 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c | |||
| @@ -51,76 +51,62 @@ ACPI_MODULE_NAME("rslist") | |||
| 51 | * | 51 | * |
| 52 | * FUNCTION: acpi_rs_convert_aml_to_resources | 52 | * FUNCTION: acpi_rs_convert_aml_to_resources |
| 53 | * | 53 | * |
| 54 | * PARAMETERS: Aml - Pointer to the resource byte stream | 54 | * PARAMETERS: acpi_walk_aml_callback |
| 55 | * aml_length - Length of Aml | 55 | * resource_ptr - Pointer to the buffer that will |
| 56 | * output_buffer - Pointer to the buffer that will | 56 | * contain the output structures |
| 57 | * contain the output structures | ||
| 58 | * | 57 | * |
| 59 | * RETURN: Status | 58 | * RETURN: Status |
| 60 | * | 59 | * |
| 61 | * DESCRIPTION: Takes the resource byte stream and parses it, creating a | 60 | * DESCRIPTION: Convert an AML resource to an internal representation of the |
| 62 | * linked list of resources in the caller's output buffer | 61 | * resource that is aligned and easier to access. |
| 63 | * | 62 | * |
| 64 | ******************************************************************************/ | 63 | ******************************************************************************/ |
| 65 | acpi_status | 64 | acpi_status |
| 66 | acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) | 65 | acpi_rs_convert_aml_to_resources(u8 * aml, |
| 66 | u32 length, | ||
| 67 | u32 offset, u8 resource_index, void **context) | ||
| 67 | { | 68 | { |
| 68 | struct acpi_resource *resource = (void *)output_buffer; | 69 | struct acpi_resource **resource_ptr = |
| 70 | ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context); | ||
| 71 | struct acpi_resource *resource; | ||
| 69 | acpi_status status; | 72 | acpi_status status; |
| 70 | u8 resource_index; | ||
| 71 | u8 *end_aml; | ||
| 72 | |||
| 73 | ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); | ||
| 74 | |||
| 75 | end_aml = aml + aml_length; | ||
| 76 | |||
| 77 | /* Loop until end-of-buffer or an end_tag is found */ | ||
| 78 | |||
| 79 | while (aml < end_aml) { | ||
| 80 | /* Validate the Resource Type and Resource Length */ | ||
| 81 | |||
| 82 | status = acpi_ut_validate_resource(aml, &resource_index); | ||
| 83 | if (ACPI_FAILURE(status)) { | ||
| 84 | return_ACPI_STATUS(status); | ||
| 85 | } | ||
| 86 | 73 | ||
| 87 | /* Convert the AML byte stream resource to a local resource struct */ | 74 | ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources); |
| 88 | |||
| 89 | status = | ||
| 90 | acpi_rs_convert_aml_to_resource(resource, | ||
| 91 | ACPI_CAST_PTR(union | ||
| 92 | aml_resource, | ||
| 93 | aml), | ||
| 94 | acpi_gbl_get_resource_dispatch | ||
| 95 | [resource_index]); | ||
| 96 | if (ACPI_FAILURE(status)) { | ||
| 97 | ACPI_EXCEPTION((AE_INFO, status, | ||
| 98 | "Could not convert AML resource (Type %X)", | ||
| 99 | *aml)); | ||
| 100 | return_ACPI_STATUS(status); | ||
| 101 | } | ||
| 102 | 75 | ||
| 103 | /* Normal exit on completion of an end_tag resource descriptor */ | 76 | /* |
| 104 | 77 | * Check that the input buffer and all subsequent pointers into it | |
| 105 | if (acpi_ut_get_resource_type(aml) == | 78 | * are aligned on a native word boundary. Most important on IA64 |
| 106 | ACPI_RESOURCE_NAME_END_TAG) { | 79 | */ |
| 107 | return_ACPI_STATUS(AE_OK); | 80 | resource = *resource_ptr; |
| 108 | } | 81 | if (ACPI_IS_MISALIGNED(resource)) { |
| 109 | 82 | ACPI_WARNING((AE_INFO, | |
| 110 | /* Point to the next input AML resource */ | 83 | "Misaligned resource pointer %p", resource)); |
| 111 | 84 | } | |
| 112 | aml += acpi_ut_get_descriptor_length(aml); | ||
| 113 | |||
| 114 | /* Point to the next structure in the output buffer */ | ||
| 115 | 85 | ||
| 116 | resource = | 86 | /* Convert the AML byte stream resource to a local resource struct */ |
| 117 | ACPI_ADD_PTR(struct acpi_resource, resource, | 87 | |
| 118 | resource->length); | 88 | status = |
| 89 | acpi_rs_convert_aml_to_resource(resource, | ||
| 90 | ACPI_CAST_PTR(union aml_resource, | ||
| 91 | aml), | ||
| 92 | acpi_gbl_get_resource_dispatch | ||
| 93 | [resource_index]); | ||
| 94 | if (ACPI_FAILURE(status)) { | ||
| 95 | ACPI_EXCEPTION((AE_INFO, status, | ||
| 96 | "Could not convert AML resource (Type %X)", | ||
| 97 | *aml)); | ||
| 98 | return_ACPI_STATUS(status); | ||
| 119 | } | 99 | } |
| 120 | 100 | ||
| 121 | /* Did not find an end_tag resource descriptor */ | 101 | ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, |
| 102 | "Type %.2X, AmlLength %.2X InternalLength %.2X\n", | ||
| 103 | acpi_ut_get_resource_type(aml), length, | ||
| 104 | resource->length)); | ||
| 122 | 105 | ||
| 123 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); | 106 | /* Point to the next structure in the output buffer */ |
| 107 | |||
| 108 | *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length); | ||
| 109 | return_ACPI_STATUS(AE_OK); | ||
| 124 | } | 110 | } |
| 125 | 111 | ||
| 126 | /******************************************************************************* | 112 | /******************************************************************************* |
| @@ -150,11 +136,12 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
| 150 | u8 *end_aml = output_buffer + aml_size_needed; | 136 | u8 *end_aml = output_buffer + aml_size_needed; |
| 151 | acpi_status status; | 137 | acpi_status status; |
| 152 | 138 | ||
| 153 | ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); | 139 | ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml); |
| 154 | 140 | ||
| 155 | /* Walk the resource descriptor list, convert each descriptor */ | 141 | /* Walk the resource descriptor list, convert each descriptor */ |
| 156 | 142 | ||
| 157 | while (aml < end_aml) { | 143 | while (aml < end_aml) { |
| 144 | |||
| 158 | /* Validate the (internal) Resource Type */ | 145 | /* Validate the (internal) Resource Type */ |
| 159 | 146 | ||
| 160 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | 147 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
| @@ -191,6 +178,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
| 191 | /* Check for end-of-list, normal exit */ | 178 | /* Check for end-of-list, normal exit */ |
| 192 | 179 | ||
| 193 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { | 180 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { |
| 181 | |||
| 194 | /* An End Tag indicates the end of the input Resource Template */ | 182 | /* An End Tag indicates the end of the input Resource Template */ |
| 195 | 183 | ||
| 196 | return_ACPI_STATUS(AE_OK); | 184 | return_ACPI_STATUS(AE_OK); |
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index ed866cf1c6d2..faf6e106b785 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c | |||
| @@ -81,9 +81,10 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
| 81 | u16 item_count = 0; | 81 | u16 item_count = 0; |
| 82 | u16 temp16 = 0; | 82 | u16 temp16 = 0; |
| 83 | 83 | ||
| 84 | ACPI_FUNCTION_TRACE("rs_get_resource"); | 84 | ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource); |
| 85 | 85 | ||
| 86 | if (((acpi_native_uint) resource) & 0x3) { | 86 | if (((acpi_native_uint) resource) & 0x3) { |
| 87 | |||
| 87 | /* Each internal resource struct is expected to be 32-bit aligned */ | 88 | /* Each internal resource struct is expected to be 32-bit aligned */ |
| 88 | 89 | ||
| 89 | ACPI_WARNING((AE_INFO, | 90 | ACPI_WARNING((AE_INFO, |
| @@ -295,9 +296,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
| 295 | 296 | ||
| 296 | exit: | 297 | exit: |
| 297 | if (!flags_mode) { | 298 | if (!flags_mode) { |
| 298 | /* Round the resource struct length up to the next 32-bit boundary */ | ||
| 299 | 299 | ||
| 300 | resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length); | 300 | /* Round the resource struct length up to the next boundary (32 or 64) */ |
| 301 | |||
| 302 | resource->length = | ||
| 303 | (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length); | ||
| 301 | } | 304 | } |
| 302 | return_ACPI_STATUS(AE_OK); | 305 | return_ACPI_STATUS(AE_OK); |
| 303 | } | 306 | } |
| @@ -329,7 +332,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
| 329 | u16 temp16 = 0; | 332 | u16 temp16 = 0; |
| 330 | u16 item_count = 0; | 333 | u16 item_count = 0; |
| 331 | 334 | ||
| 332 | ACPI_FUNCTION_TRACE("rs_convert_resource_to_aml"); | 335 | ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml); |
| 333 | 336 | ||
| 334 | /* | 337 | /* |
| 335 | * First table entry must be ACPI_RSC_INITxxx and must contain the | 338 | * First table entry must be ACPI_RSC_INITxxx and must contain the |
| @@ -535,6 +538,7 @@ if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) { | |||
| 535 | 538 | ||
| 536 | resource->data.extended_irq.interrupt_count = temp8; | 539 | resource->data.extended_irq.interrupt_count = temp8; |
| 537 | if (temp8 < 1) { | 540 | if (temp8 < 1) { |
| 541 | |||
| 538 | /* Must have at least one IRQ */ | 542 | /* Must have at least one IRQ */ |
| 539 | 543 | ||
| 540 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | 544 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); |
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 25b5aedd6612..a9cbee8e8b44 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c | |||
| @@ -205,6 +205,7 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length, | |||
| 205 | /* Length is stored differently for large and small descriptors */ | 205 | /* Length is stored differently for large and small descriptors */ |
| 206 | 206 | ||
| 207 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | 207 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
| 208 | |||
| 208 | /* Large descriptor -- bytes 1-2 contain the 16-bit length */ | 209 | /* Large descriptor -- bytes 1-2 contain the 16-bit length */ |
| 209 | 210 | ||
| 210 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, | 211 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, |
| @@ -298,7 +299,8 @@ static u16 acpi_rs_strcpy(char *destination, char *source) | |||
| 298 | * string_ptr - (optional) where to store the actual | 299 | * string_ptr - (optional) where to store the actual |
| 299 | * resource_source string | 300 | * resource_source string |
| 300 | * | 301 | * |
| 301 | * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit | 302 | * RETURN: Length of the string plus NULL terminator, rounded up to native |
| 303 | * word boundary | ||
| 302 | * | 304 | * |
| 303 | * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor | 305 | * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor |
| 304 | * to an internal resource descriptor | 306 | * to an internal resource descriptor |
| @@ -328,6 +330,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, | |||
| 328 | * we add 1 to the minimum length. | 330 | * we add 1 to the minimum length. |
| 329 | */ | 331 | */ |
| 330 | if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { | 332 | if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { |
| 333 | |||
| 331 | /* Get the resource_source_index */ | 334 | /* Get the resource_source_index */ |
| 332 | 335 | ||
| 333 | resource_source->index = aml_resource_source[0]; | 336 | resource_source->index = aml_resource_source[0]; |
| @@ -344,23 +347,26 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, | |||
| 344 | } | 347 | } |
| 345 | 348 | ||
| 346 | /* | 349 | /* |
| 347 | * In order for the struct_size to fall on a 32-bit boundary, calculate | 350 | * In order for the Resource length to be a multiple of the native |
| 348 | * the length of the string (+1 for the NULL terminator) and expand the | 351 | * word, calculate the length of the string (+1 for NULL terminator) |
| 349 | * struct_size to the next 32-bit boundary. | 352 | * and expand to the next word multiple. |
| 350 | * | 353 | * |
| 351 | * Zero the entire area of the buffer. | 354 | * Zero the entire area of the buffer. |
| 352 | */ | 355 | */ |
| 353 | total_length = | 356 | total_length = |
| 354 | ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN | 357 | (u32) |
| 355 | ((char *)&aml_resource_source[1]) + | 358 | ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + |
| 356 | 1); | 359 | 1; |
| 360 | total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); | ||
| 361 | |||
| 357 | ACPI_MEMSET(resource_source->string_ptr, 0, total_length); | 362 | ACPI_MEMSET(resource_source->string_ptr, 0, total_length); |
| 358 | 363 | ||
| 359 | /* Copy the resource_source string to the destination */ | 364 | /* Copy the resource_source string to the destination */ |
| 360 | 365 | ||
| 361 | resource_source->string_length = | 366 | resource_source->string_length = |
| 362 | acpi_rs_strcpy(resource_source->string_ptr, | 367 | acpi_rs_strcpy(resource_source->string_ptr, |
| 363 | (char *)&aml_resource_source[1]); | 368 | ACPI_CAST_PTR(char, |
| 369 | &aml_resource_source[1])); | ||
| 364 | 370 | ||
| 365 | return ((acpi_rs_length) total_length); | 371 | return ((acpi_rs_length) total_length); |
| 366 | } | 372 | } |
| @@ -405,6 +411,7 @@ acpi_rs_set_resource_source(union aml_resource * aml, | |||
| 405 | /* Non-zero string length indicates presence of a resource_source */ | 411 | /* Non-zero string length indicates presence of a resource_source */ |
| 406 | 412 | ||
| 407 | if (resource_source->string_length) { | 413 | if (resource_source->string_length) { |
| 414 | |||
| 408 | /* Point to the end of the AML descriptor */ | 415 | /* Point to the end of the AML descriptor */ |
| 409 | 416 | ||
| 410 | aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); | 417 | aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); |
| @@ -415,7 +422,7 @@ acpi_rs_set_resource_source(union aml_resource * aml, | |||
| 415 | 422 | ||
| 416 | /* Copy the resource_source string */ | 423 | /* Copy the resource_source string */ |
| 417 | 424 | ||
| 418 | ACPI_STRCPY((char *)&aml_resource_source[1], | 425 | ACPI_STRCPY(ACPI_CAST_PTR(char, &aml_resource_source[1]), |
| 419 | resource_source->string_ptr); | 426 | resource_source->string_ptr); |
| 420 | 427 | ||
| 421 | /* | 428 | /* |
| @@ -435,9 +442,9 @@ acpi_rs_set_resource_source(union aml_resource * aml, | |||
| 435 | * | 442 | * |
| 436 | * FUNCTION: acpi_rs_get_prt_method_data | 443 | * FUNCTION: acpi_rs_get_prt_method_data |
| 437 | * | 444 | * |
| 438 | * PARAMETERS: Handle - a handle to the containing object | 445 | * PARAMETERS: Node - Device node |
| 439 | * ret_buffer - a pointer to a buffer structure for the | 446 | * ret_buffer - Pointer to a buffer structure for the |
| 440 | * results | 447 | * results |
| 441 | * | 448 | * |
| 442 | * RETURN: Status | 449 | * RETURN: Status |
| 443 | * | 450 | * |
| @@ -450,18 +457,19 @@ acpi_rs_set_resource_source(union aml_resource * aml, | |||
| 450 | ******************************************************************************/ | 457 | ******************************************************************************/ |
| 451 | 458 | ||
| 452 | acpi_status | 459 | acpi_status |
| 453 | acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) | 460 | acpi_rs_get_prt_method_data(struct acpi_namespace_node * node, |
| 461 | struct acpi_buffer * ret_buffer) | ||
| 454 | { | 462 | { |
| 455 | union acpi_operand_object *obj_desc; | 463 | union acpi_operand_object *obj_desc; |
| 456 | acpi_status status; | 464 | acpi_status status; |
| 457 | 465 | ||
| 458 | ACPI_FUNCTION_TRACE("rs_get_prt_method_data"); | 466 | ACPI_FUNCTION_TRACE(rs_get_prt_method_data); |
| 459 | 467 | ||
| 460 | /* Parameters guaranteed valid by caller */ | 468 | /* Parameters guaranteed valid by caller */ |
| 461 | 469 | ||
| 462 | /* Execute the method, no parameters */ | 470 | /* Execute the method, no parameters */ |
| 463 | 471 | ||
| 464 | status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRT, | 472 | status = acpi_ut_evaluate_object(node, METHOD_NAME__PRT, |
| 465 | ACPI_BTYPE_PACKAGE, &obj_desc); | 473 | ACPI_BTYPE_PACKAGE, &obj_desc); |
| 466 | if (ACPI_FAILURE(status)) { | 474 | if (ACPI_FAILURE(status)) { |
| 467 | return_ACPI_STATUS(status); | 475 | return_ACPI_STATUS(status); |
| @@ -483,9 +491,9 @@ acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) | |||
| 483 | * | 491 | * |
| 484 | * FUNCTION: acpi_rs_get_crs_method_data | 492 | * FUNCTION: acpi_rs_get_crs_method_data |
| 485 | * | 493 | * |
| 486 | * PARAMETERS: Handle - a handle to the containing object | 494 | * PARAMETERS: Node - Device node |
| 487 | * ret_buffer - a pointer to a buffer structure for the | 495 | * ret_buffer - Pointer to a buffer structure for the |
| 488 | * results | 496 | * results |
| 489 | * | 497 | * |
| 490 | * RETURN: Status | 498 | * RETURN: Status |
| 491 | * | 499 | * |
| @@ -498,18 +506,19 @@ acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) | |||
| 498 | ******************************************************************************/ | 506 | ******************************************************************************/ |
| 499 | 507 | ||
| 500 | acpi_status | 508 | acpi_status |
| 501 | acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | 509 | acpi_rs_get_crs_method_data(struct acpi_namespace_node *node, |
| 510 | struct acpi_buffer *ret_buffer) | ||
| 502 | { | 511 | { |
| 503 | union acpi_operand_object *obj_desc; | 512 | union acpi_operand_object *obj_desc; |
| 504 | acpi_status status; | 513 | acpi_status status; |
| 505 | 514 | ||
| 506 | ACPI_FUNCTION_TRACE("rs_get_crs_method_data"); | 515 | ACPI_FUNCTION_TRACE(rs_get_crs_method_data); |
| 507 | 516 | ||
| 508 | /* Parameters guaranteed valid by caller */ | 517 | /* Parameters guaranteed valid by caller */ |
| 509 | 518 | ||
| 510 | /* Execute the method, no parameters */ | 519 | /* Execute the method, no parameters */ |
| 511 | 520 | ||
| 512 | status = acpi_ut_evaluate_object(handle, METHOD_NAME__CRS, | 521 | status = acpi_ut_evaluate_object(node, METHOD_NAME__CRS, |
| 513 | ACPI_BTYPE_BUFFER, &obj_desc); | 522 | ACPI_BTYPE_BUFFER, &obj_desc); |
| 514 | if (ACPI_FAILURE(status)) { | 523 | if (ACPI_FAILURE(status)) { |
| 515 | return_ACPI_STATUS(status); | 524 | return_ACPI_STATUS(status); |
| @@ -522,7 +531,7 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | |||
| 522 | */ | 531 | */ |
| 523 | status = acpi_rs_create_resource_list(obj_desc, ret_buffer); | 532 | status = acpi_rs_create_resource_list(obj_desc, ret_buffer); |
| 524 | 533 | ||
| 525 | /* on exit, we must delete the object returned by evaluate_object */ | 534 | /* On exit, we must delete the object returned by evaluate_object */ |
| 526 | 535 | ||
| 527 | acpi_ut_remove_reference(obj_desc); | 536 | acpi_ut_remove_reference(obj_desc); |
| 528 | return_ACPI_STATUS(status); | 537 | return_ACPI_STATUS(status); |
| @@ -532,9 +541,9 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | |||
| 532 | * | 541 | * |
| 533 | * FUNCTION: acpi_rs_get_prs_method_data | 542 | * FUNCTION: acpi_rs_get_prs_method_data |
| 534 | * | 543 | * |
| 535 | * PARAMETERS: Handle - a handle to the containing object | 544 | * PARAMETERS: Node - Device node |
| 536 | * ret_buffer - a pointer to a buffer structure for the | 545 | * ret_buffer - Pointer to a buffer structure for the |
| 537 | * results | 546 | * results |
| 538 | * | 547 | * |
| 539 | * RETURN: Status | 548 | * RETURN: Status |
| 540 | * | 549 | * |
| @@ -548,18 +557,19 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | |||
| 548 | 557 | ||
| 549 | #ifdef ACPI_FUTURE_USAGE | 558 | #ifdef ACPI_FUTURE_USAGE |
| 550 | acpi_status | 559 | acpi_status |
| 551 | acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | 560 | acpi_rs_get_prs_method_data(struct acpi_namespace_node *node, |
| 561 | struct acpi_buffer *ret_buffer) | ||
| 552 | { | 562 | { |
| 553 | union acpi_operand_object *obj_desc; | 563 | union acpi_operand_object *obj_desc; |
| 554 | acpi_status status; | 564 | acpi_status status; |
| 555 | 565 | ||
| 556 | ACPI_FUNCTION_TRACE("rs_get_prs_method_data"); | 566 | ACPI_FUNCTION_TRACE(rs_get_prs_method_data); |
| 557 | 567 | ||
| 558 | /* Parameters guaranteed valid by caller */ | 568 | /* Parameters guaranteed valid by caller */ |
| 559 | 569 | ||
| 560 | /* Execute the method, no parameters */ | 570 | /* Execute the method, no parameters */ |
| 561 | 571 | ||
| 562 | status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRS, | 572 | status = acpi_ut_evaluate_object(node, METHOD_NAME__PRS, |
| 563 | ACPI_BTYPE_BUFFER, &obj_desc); | 573 | ACPI_BTYPE_BUFFER, &obj_desc); |
| 564 | if (ACPI_FAILURE(status)) { | 574 | if (ACPI_FAILURE(status)) { |
| 565 | return_ACPI_STATUS(status); | 575 | return_ACPI_STATUS(status); |
| @@ -572,7 +582,7 @@ acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | |||
| 572 | */ | 582 | */ |
| 573 | status = acpi_rs_create_resource_list(obj_desc, ret_buffer); | 583 | status = acpi_rs_create_resource_list(obj_desc, ret_buffer); |
| 574 | 584 | ||
| 575 | /* on exit, we must delete the object returned by evaluate_object */ | 585 | /* On exit, we must delete the object returned by evaluate_object */ |
| 576 | 586 | ||
| 577 | acpi_ut_remove_reference(obj_desc); | 587 | acpi_ut_remove_reference(obj_desc); |
| 578 | return_ACPI_STATUS(status); | 588 | return_ACPI_STATUS(status); |
| @@ -583,10 +593,10 @@ acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | |||
| 583 | * | 593 | * |
| 584 | * FUNCTION: acpi_rs_get_method_data | 594 | * FUNCTION: acpi_rs_get_method_data |
| 585 | * | 595 | * |
| 586 | * PARAMETERS: Handle - a handle to the containing object | 596 | * PARAMETERS: Handle - Handle to the containing object |
| 587 | * Path - Path to method, relative to Handle | 597 | * Path - Path to method, relative to Handle |
| 588 | * ret_buffer - a pointer to a buffer structure for the | 598 | * ret_buffer - Pointer to a buffer structure for the |
| 589 | * results | 599 | * results |
| 590 | * | 600 | * |
| 591 | * RETURN: Status | 601 | * RETURN: Status |
| 592 | * | 602 | * |
| @@ -605,7 +615,7 @@ acpi_rs_get_method_data(acpi_handle handle, | |||
| 605 | union acpi_operand_object *obj_desc; | 615 | union acpi_operand_object *obj_desc; |
| 606 | acpi_status status; | 616 | acpi_status status; |
| 607 | 617 | ||
| 608 | ACPI_FUNCTION_TRACE("rs_get_method_data"); | 618 | ACPI_FUNCTION_TRACE(rs_get_method_data); |
| 609 | 619 | ||
| 610 | /* Parameters guaranteed valid by caller */ | 620 | /* Parameters guaranteed valid by caller */ |
| 611 | 621 | ||
| @@ -634,9 +644,9 @@ acpi_rs_get_method_data(acpi_handle handle, | |||
| 634 | * | 644 | * |
| 635 | * FUNCTION: acpi_rs_set_srs_method_data | 645 | * FUNCTION: acpi_rs_set_srs_method_data |
| 636 | * | 646 | * |
| 637 | * PARAMETERS: Handle - a handle to the containing object | 647 | * PARAMETERS: Node - Device node |
| 638 | * in_buffer - a pointer to a buffer structure of the | 648 | * in_buffer - Pointer to a buffer structure of the |
| 639 | * parameter | 649 | * parameter |
| 640 | * | 650 | * |
| 641 | * RETURN: Status | 651 | * RETURN: Status |
| 642 | * | 652 | * |
| @@ -646,23 +656,37 @@ acpi_rs_get_method_data(acpi_handle handle, | |||
| 646 | * If the function fails an appropriate status will be returned | 656 | * If the function fails an appropriate status will be returned |
| 647 | * and the contents of the callers buffer is undefined. | 657 | * and the contents of the callers buffer is undefined. |
| 648 | * | 658 | * |
| 659 | * Note: Parameters guaranteed valid by caller | ||
| 660 | * | ||
| 649 | ******************************************************************************/ | 661 | ******************************************************************************/ |
| 650 | 662 | ||
| 651 | acpi_status | 663 | acpi_status |
| 652 | acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) | 664 | acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, |
| 665 | struct acpi_buffer *in_buffer) | ||
| 653 | { | 666 | { |
| 654 | struct acpi_parameter_info info; | 667 | struct acpi_evaluate_info *info; |
| 655 | union acpi_operand_object *params[2]; | 668 | union acpi_operand_object *args[2]; |
| 656 | acpi_status status; | 669 | acpi_status status; |
| 657 | struct acpi_buffer buffer; | 670 | struct acpi_buffer buffer; |
| 658 | 671 | ||
| 659 | ACPI_FUNCTION_TRACE("rs_set_srs_method_data"); | 672 | ACPI_FUNCTION_TRACE(rs_set_srs_method_data); |
| 660 | 673 | ||
| 661 | /* Parameters guaranteed valid by caller */ | 674 | /* Allocate and initialize the evaluation information block */ |
| 675 | |||
| 676 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | ||
| 677 | if (!info) { | ||
| 678 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 679 | } | ||
| 680 | |||
| 681 | info->prefix_node = node; | ||
| 682 | info->pathname = METHOD_NAME__SRS; | ||
| 683 | info->parameters = args; | ||
| 684 | info->parameter_type = ACPI_PARAM_ARGS; | ||
| 685 | info->flags = ACPI_IGNORE_RETURN_VALUE; | ||
| 662 | 686 | ||
| 663 | /* | 687 | /* |
| 664 | * The in_buffer parameter will point to a linked list of | 688 | * The in_buffer parameter will point to a linked list of |
| 665 | * resource parameters. It needs to be formatted into a | 689 | * resource parameters. It needs to be formatted into a |
| 666 | * byte stream to be sent in as an input parameter to _SRS | 690 | * byte stream to be sent in as an input parameter to _SRS |
| 667 | * | 691 | * |
| 668 | * Convert the linked list into a byte stream | 692 | * Convert the linked list into a byte stream |
| @@ -670,41 +694,36 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) | |||
| 670 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 694 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
| 671 | status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); | 695 | status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); |
| 672 | if (ACPI_FAILURE(status)) { | 696 | if (ACPI_FAILURE(status)) { |
| 673 | return_ACPI_STATUS(status); | 697 | goto cleanup; |
| 674 | } | 698 | } |
| 675 | 699 | ||
| 676 | /* Init the param object */ | 700 | /* Create and initialize the method parameter object */ |
| 677 | 701 | ||
| 678 | params[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); | 702 | args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); |
| 679 | if (!params[0]) { | 703 | if (!args[0]) { |
| 680 | acpi_os_free(buffer.pointer); | 704 | /* |
| 681 | return_ACPI_STATUS(AE_NO_MEMORY); | 705 | * Must free the buffer allocated above (otherwise it is freed |
| 706 | * later) | ||
| 707 | */ | ||
| 708 | ACPI_FREE(buffer.pointer); | ||
| 709 | status = AE_NO_MEMORY; | ||
| 710 | goto cleanup; | ||
| 682 | } | 711 | } |
| 683 | 712 | ||
| 684 | /* Set up the parameter object */ | 713 | args[0]->buffer.length = (u32) buffer.length; |
| 685 | 714 | args[0]->buffer.pointer = buffer.pointer; | |
| 686 | params[0]->buffer.length = (u32) buffer.length; | 715 | args[0]->common.flags = AOPOBJ_DATA_VALID; |
| 687 | params[0]->buffer.pointer = buffer.pointer; | 716 | args[1] = NULL; |
| 688 | params[0]->common.flags = AOPOBJ_DATA_VALID; | ||
| 689 | params[1] = NULL; | ||
| 690 | |||
| 691 | info.node = handle; | ||
| 692 | info.parameters = params; | ||
| 693 | info.parameter_type = ACPI_PARAM_ARGS; | ||
| 694 | 717 | ||
| 695 | /* Execute the method, no return value */ | 718 | /* Execute the method, no return value is expected */ |
| 696 | 719 | ||
| 697 | status = acpi_ns_evaluate_relative(METHOD_NAME__SRS, &info); | 720 | status = acpi_ns_evaluate(info); |
| 698 | if (ACPI_SUCCESS(status)) { | ||
| 699 | /* Delete any return object (especially if implicit_return is enabled) */ | ||
| 700 | 721 | ||
| 701 | if (info.return_object) { | 722 | /* Clean up and return the status from acpi_ns_evaluate */ |
| 702 | acpi_ut_remove_reference(info.return_object); | ||
| 703 | } | ||
| 704 | } | ||
| 705 | 723 | ||
| 706 | /* Clean up and return the status from acpi_ns_evaluate_relative */ | 724 | acpi_ut_remove_reference(args[0]); |
| 707 | 725 | ||
| 708 | acpi_ut_remove_reference(params[0]); | 726 | cleanup: |
| 727 | ACPI_FREE(info); | ||
| 709 | return_ACPI_STATUS(status); | 728 | return_ACPI_STATUS(status); |
| 710 | } | 729 | } |
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 88b67077aeeb..1999e2ab7daa 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c | |||
| @@ -41,10 +41,9 @@ | |||
| 41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | #include <linux/module.h> | ||
| 45 | |||
| 46 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
| 47 | #include <acpi/acresrc.h> | 45 | #include <acpi/acresrc.h> |
| 46 | #include <acpi/acnamesp.h> | ||
| 48 | 47 | ||
| 49 | #define _COMPONENT ACPI_RESOURCES | 48 | #define _COMPONENT ACPI_RESOURCES |
| 50 | ACPI_MODULE_NAME("rsxface") | 49 | ACPI_MODULE_NAME("rsxface") |
| @@ -68,312 +67,262 @@ ACPI_MODULE_NAME("rsxface") | |||
| 68 | static acpi_status | 67 | static acpi_status |
| 69 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); | 68 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); |
| 70 | 69 | ||
| 70 | static acpi_status | ||
| 71 | acpi_rs_validate_parameters(acpi_handle device_handle, | ||
| 72 | struct acpi_buffer *buffer, | ||
| 73 | struct acpi_namespace_node **return_node); | ||
| 74 | |||
| 71 | /******************************************************************************* | 75 | /******************************************************************************* |
| 72 | * | 76 | * |
| 73 | * FUNCTION: acpi_get_irq_routing_table | 77 | * FUNCTION: acpi_rs_validate_parameters |
| 74 | * | 78 | * |
| 75 | * PARAMETERS: device_handle - a handle to the Bus device we are querying | 79 | * PARAMETERS: device_handle - Handle to a device |
| 76 | * ret_buffer - a pointer to a buffer to receive the | 80 | * Buffer - Pointer to a data buffer |
| 77 | * current resources for the device | 81 | * return_node - Pointer to where the device node is returned |
| 78 | * | 82 | * |
| 79 | * RETURN: Status | 83 | * RETURN: Status |
| 80 | * | 84 | * |
| 81 | * DESCRIPTION: This function is called to get the IRQ routing table for a | 85 | * DESCRIPTION: Common parameter validation for resource interfaces |
| 82 | * specific bus. The caller must first acquire a handle for the | ||
| 83 | * desired bus. The routine table is placed in the buffer pointed | ||
| 84 | * to by the ret_buffer variable parameter. | ||
| 85 | * | ||
| 86 | * If the function fails an appropriate status will be returned | ||
| 87 | * and the value of ret_buffer is undefined. | ||
| 88 | * | ||
| 89 | * This function attempts to execute the _PRT method contained in | ||
| 90 | * the object indicated by the passed device_handle. | ||
| 91 | * | 86 | * |
| 92 | ******************************************************************************/ | 87 | ******************************************************************************/ |
| 93 | 88 | ||
| 94 | acpi_status | 89 | static acpi_status |
| 95 | acpi_get_irq_routing_table(acpi_handle device_handle, | 90 | acpi_rs_validate_parameters(acpi_handle device_handle, |
| 96 | struct acpi_buffer *ret_buffer) | 91 | struct acpi_buffer *buffer, |
| 92 | struct acpi_namespace_node **return_node) | ||
| 97 | { | 93 | { |
| 98 | acpi_status status; | 94 | acpi_status status; |
| 95 | struct acpi_namespace_node *node; | ||
| 99 | 96 | ||
| 100 | ACPI_FUNCTION_TRACE("acpi_get_irq_routing_table "); | 97 | ACPI_FUNCTION_TRACE(rs_validate_parameters); |
| 101 | 98 | ||
| 102 | /* | 99 | /* |
| 103 | * Must have a valid handle and buffer, So we have to have a handle | 100 | * Must have a valid handle to an ACPI device |
| 104 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 105 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 106 | * we'll be returning the needed buffer size, so keep going. | ||
| 107 | */ | 101 | */ |
| 108 | if (!device_handle) { | 102 | if (!device_handle) { |
| 109 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 103 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | status = acpi_ut_validate_buffer(ret_buffer); | 106 | node = acpi_ns_map_handle_to_node(device_handle); |
| 107 | if (!node) { | ||
| 108 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 109 | } | ||
| 110 | |||
| 111 | if (node->type != ACPI_TYPE_DEVICE) { | ||
| 112 | return_ACPI_STATUS(AE_TYPE); | ||
| 113 | } | ||
| 114 | |||
| 115 | /* | ||
| 116 | * Validate the user buffer object | ||
| 117 | * | ||
| 118 | * if there is a non-zero buffer length we also need a valid pointer in | ||
| 119 | * the buffer. If it's a zero buffer length, we'll be returning the | ||
| 120 | * needed buffer size (later), so keep going. | ||
| 121 | */ | ||
| 122 | status = acpi_ut_validate_buffer(buffer); | ||
| 113 | if (ACPI_FAILURE(status)) { | 123 | if (ACPI_FAILURE(status)) { |
| 114 | return_ACPI_STATUS(status); | 124 | return_ACPI_STATUS(status); |
| 115 | } | 125 | } |
| 116 | 126 | ||
| 117 | status = acpi_rs_get_prt_method_data(device_handle, ret_buffer); | 127 | *return_node = node; |
| 118 | return_ACPI_STATUS(status); | 128 | return_ACPI_STATUS(AE_OK); |
| 119 | } | 129 | } |
| 120 | 130 | ||
| 121 | /******************************************************************************* | 131 | /******************************************************************************* |
| 122 | * | 132 | * |
| 123 | * FUNCTION: acpi_get_current_resources | 133 | * FUNCTION: acpi_get_irq_routing_table |
| 124 | * | 134 | * |
| 125 | * PARAMETERS: device_handle - a handle to the device object for the | 135 | * PARAMETERS: device_handle - Handle to the Bus device we are querying |
| 126 | * device we are querying | 136 | * ret_buffer - Pointer to a buffer to receive the |
| 127 | * ret_buffer - a pointer to a buffer to receive the | ||
| 128 | * current resources for the device | 137 | * current resources for the device |
| 129 | * | 138 | * |
| 130 | * RETURN: Status | 139 | * RETURN: Status |
| 131 | * | 140 | * |
| 132 | * DESCRIPTION: This function is called to get the current resources for a | 141 | * DESCRIPTION: This function is called to get the IRQ routing table for a |
| 133 | * specific device. The caller must first acquire a handle for | 142 | * specific bus. The caller must first acquire a handle for the |
| 134 | * the desired device. The resource data is placed in the buffer | 143 | * desired bus. The routine table is placed in the buffer pointed |
| 135 | * pointed to by the ret_buffer variable parameter. | 144 | * to by the ret_buffer variable parameter. |
| 136 | * | 145 | * |
| 137 | * If the function fails an appropriate status will be returned | 146 | * If the function fails an appropriate status will be returned |
| 138 | * and the value of ret_buffer is undefined. | 147 | * and the value of ret_buffer is undefined. |
| 139 | * | 148 | * |
| 140 | * This function attempts to execute the _CRS method contained in | 149 | * This function attempts to execute the _PRT method contained in |
| 141 | * the object indicated by the passed device_handle. | 150 | * the object indicated by the passed device_handle. |
| 142 | * | 151 | * |
| 143 | ******************************************************************************/ | 152 | ******************************************************************************/ |
| 144 | 153 | ||
| 145 | acpi_status | 154 | acpi_status |
| 146 | acpi_get_current_resources(acpi_handle device_handle, | 155 | acpi_get_irq_routing_table(acpi_handle device_handle, |
| 147 | struct acpi_buffer *ret_buffer) | 156 | struct acpi_buffer *ret_buffer) |
| 148 | { | 157 | { |
| 149 | acpi_status status; | 158 | acpi_status status; |
| 159 | struct acpi_namespace_node *node; | ||
| 150 | 160 | ||
| 151 | ACPI_FUNCTION_TRACE("acpi_get_current_resources"); | 161 | ACPI_FUNCTION_TRACE(acpi_get_irq_routing_table); |
| 152 | 162 | ||
| 153 | /* | 163 | /* Validate parameters then dispatch to internal routine */ |
| 154 | * Must have a valid handle and buffer, So we have to have a handle | ||
| 155 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 156 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 157 | * we'll be returning the needed buffer size, so keep going. | ||
| 158 | */ | ||
| 159 | if (!device_handle) { | ||
| 160 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 161 | } | ||
| 162 | 164 | ||
| 163 | status = acpi_ut_validate_buffer(ret_buffer); | 165 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
| 164 | if (ACPI_FAILURE(status)) { | 166 | if (ACPI_FAILURE(status)) { |
| 165 | return_ACPI_STATUS(status); | 167 | return_ACPI_STATUS(status); |
| 166 | } | 168 | } |
| 167 | 169 | ||
| 168 | status = acpi_rs_get_crs_method_data(device_handle, ret_buffer); | 170 | status = acpi_rs_get_prt_method_data(node, ret_buffer); |
| 169 | return_ACPI_STATUS(status); | 171 | return_ACPI_STATUS(status); |
| 170 | } | 172 | } |
| 171 | 173 | ||
| 172 | EXPORT_SYMBOL(acpi_get_current_resources); | 174 | ACPI_EXPORT_SYMBOL(acpi_get_irq_routing_table) |
| 173 | 175 | ||
| 174 | /******************************************************************************* | 176 | /******************************************************************************* |
| 175 | * | 177 | * |
| 176 | * FUNCTION: acpi_get_possible_resources | 178 | * FUNCTION: acpi_get_current_resources |
| 177 | * | 179 | * |
| 178 | * PARAMETERS: device_handle - a handle to the device object for the | 180 | * PARAMETERS: device_handle - Handle to the device object for the |
| 179 | * device we are querying | 181 | * device we are querying |
| 180 | * ret_buffer - a pointer to a buffer to receive the | 182 | * ret_buffer - Pointer to a buffer to receive the |
| 181 | * resources for the device | 183 | * current resources for the device |
| 182 | * | 184 | * |
| 183 | * RETURN: Status | 185 | * RETURN: Status |
| 184 | * | 186 | * |
| 185 | * DESCRIPTION: This function is called to get a list of the possible resources | 187 | * DESCRIPTION: This function is called to get the current resources for a |
| 186 | * for a specific device. The caller must first acquire a handle | 188 | * specific device. The caller must first acquire a handle for |
| 187 | * for the desired device. The resource data is placed in the | 189 | * the desired device. The resource data is placed in the buffer |
| 188 | * buffer pointed to by the ret_buffer variable. | 190 | * pointed to by the ret_buffer variable parameter. |
| 189 | * | 191 | * |
| 190 | * If the function fails an appropriate status will be returned | 192 | * If the function fails an appropriate status will be returned |
| 191 | * and the value of ret_buffer is undefined. | 193 | * and the value of ret_buffer is undefined. |
| 192 | * | 194 | * |
| 195 | * This function attempts to execute the _CRS method contained in | ||
| 196 | * the object indicated by the passed device_handle. | ||
| 197 | * | ||
| 193 | ******************************************************************************/ | 198 | ******************************************************************************/ |
| 194 | |||
| 195 | #ifdef ACPI_FUTURE_USAGE | ||
| 196 | acpi_status | 199 | acpi_status |
| 197 | acpi_get_possible_resources(acpi_handle device_handle, | 200 | acpi_get_current_resources(acpi_handle device_handle, |
| 198 | struct acpi_buffer *ret_buffer) | 201 | struct acpi_buffer *ret_buffer) |
| 199 | { | 202 | { |
| 200 | acpi_status status; | 203 | acpi_status status; |
| 204 | struct acpi_namespace_node *node; | ||
| 201 | 205 | ||
| 202 | ACPI_FUNCTION_TRACE("acpi_get_possible_resources"); | 206 | ACPI_FUNCTION_TRACE(acpi_get_current_resources); |
| 203 | 207 | ||
| 204 | /* | 208 | /* Validate parameters then dispatch to internal routine */ |
| 205 | * Must have a valid handle and buffer, So we have to have a handle | ||
| 206 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 207 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 208 | * we'll be returning the needed buffer size, so keep going. | ||
| 209 | */ | ||
| 210 | if (!device_handle) { | ||
| 211 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 212 | } | ||
| 213 | 209 | ||
| 214 | status = acpi_ut_validate_buffer(ret_buffer); | 210 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
| 215 | if (ACPI_FAILURE(status)) { | 211 | if (ACPI_FAILURE(status)) { |
| 216 | return_ACPI_STATUS(status); | 212 | return_ACPI_STATUS(status); |
| 217 | } | 213 | } |
| 218 | 214 | ||
| 219 | status = acpi_rs_get_prs_method_data(device_handle, ret_buffer); | 215 | status = acpi_rs_get_crs_method_data(node, ret_buffer); |
| 220 | return_ACPI_STATUS(status); | 216 | return_ACPI_STATUS(status); |
| 221 | } | 217 | } |
| 222 | 218 | ||
| 223 | EXPORT_SYMBOL(acpi_get_possible_resources); | 219 | ACPI_EXPORT_SYMBOL(acpi_get_current_resources) |
| 224 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 225 | 220 | ||
| 221 | #ifdef ACPI_FUTURE_USAGE | ||
| 226 | /******************************************************************************* | 222 | /******************************************************************************* |
| 227 | * | 223 | * |
| 228 | * FUNCTION: acpi_walk_resources | 224 | * FUNCTION: acpi_get_possible_resources |
| 229 | * | 225 | * |
| 230 | * PARAMETERS: device_handle - Handle to the device object for the | 226 | * PARAMETERS: device_handle - Handle to the device object for the |
| 231 | * device we are querying | 227 | * device we are querying |
| 232 | * Name - Method name of the resources we want | 228 | * ret_buffer - Pointer to a buffer to receive the |
| 233 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | 229 | * resources for the device |
| 234 | * user_function - Called for each resource | ||
| 235 | * Context - Passed to user_function | ||
| 236 | * | 230 | * |
| 237 | * RETURN: Status | 231 | * RETURN: Status |
| 238 | * | 232 | * |
| 239 | * DESCRIPTION: Retrieves the current or possible resource list for the | 233 | * DESCRIPTION: This function is called to get a list of the possible resources |
| 240 | * specified device. The user_function is called once for | 234 | * for a specific device. The caller must first acquire a handle |
| 241 | * each resource in the list. | 235 | * for the desired device. The resource data is placed in the |
| 236 | * buffer pointed to by the ret_buffer variable. | ||
| 237 | * | ||
| 238 | * If the function fails an appropriate status will be returned | ||
| 239 | * and the value of ret_buffer is undefined. | ||
| 242 | * | 240 | * |
| 243 | ******************************************************************************/ | 241 | ******************************************************************************/ |
| 244 | |||
| 245 | acpi_status | 242 | acpi_status |
| 246 | acpi_walk_resources(acpi_handle device_handle, | 243 | acpi_get_possible_resources(acpi_handle device_handle, |
| 247 | char *name, | 244 | struct acpi_buffer *ret_buffer) |
| 248 | ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) | ||
| 249 | { | 245 | { |
| 250 | acpi_status status; | 246 | acpi_status status; |
| 251 | struct acpi_buffer buffer; | 247 | struct acpi_namespace_node *node; |
| 252 | struct acpi_resource *resource; | ||
| 253 | struct acpi_resource *resource_end; | ||
| 254 | |||
| 255 | ACPI_FUNCTION_TRACE("acpi_walk_resources"); | ||
| 256 | |||
| 257 | /* Parameter validation */ | ||
| 258 | 248 | ||
| 259 | if (!device_handle || !user_function || !name || | 249 | ACPI_FUNCTION_TRACE(acpi_get_possible_resources); |
| 260 | (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && | ||
| 261 | ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { | ||
| 262 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 263 | } | ||
| 264 | 250 | ||
| 265 | /* Get the _CRS or _PRS resource list */ | 251 | /* Validate parameters then dispatch to internal routine */ |
| 266 | 252 | ||
| 267 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 253 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
| 268 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
| 269 | if (ACPI_FAILURE(status)) { | 254 | if (ACPI_FAILURE(status)) { |
| 270 | return_ACPI_STATUS(status); | 255 | return_ACPI_STATUS(status); |
| 271 | } | 256 | } |
| 272 | 257 | ||
| 273 | /* Buffer now contains the resource list */ | 258 | status = acpi_rs_get_prs_method_data(node, ret_buffer); |
| 274 | |||
| 275 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); | ||
| 276 | resource_end = | ||
| 277 | ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); | ||
| 278 | |||
| 279 | /* Walk the resource list until the end_tag is found (or buffer end) */ | ||
| 280 | |||
| 281 | while (resource < resource_end) { | ||
| 282 | /* Sanity check the resource */ | ||
| 283 | |||
| 284 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | ||
| 285 | status = AE_AML_INVALID_RESOURCE_TYPE; | ||
| 286 | break; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* Invoke the user function, abort on any error returned */ | ||
| 290 | |||
| 291 | status = user_function(resource, context); | ||
| 292 | if (ACPI_FAILURE(status)) { | ||
| 293 | if (status == AE_CTRL_TERMINATE) { | ||
| 294 | /* This is an OK termination by the user function */ | ||
| 295 | |||
| 296 | status = AE_OK; | ||
| 297 | } | ||
| 298 | break; | ||
| 299 | } | ||
| 300 | |||
| 301 | /* end_tag indicates end-of-list */ | ||
| 302 | |||
| 303 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { | ||
| 304 | break; | ||
| 305 | } | ||
| 306 | |||
| 307 | /* Get the next resource descriptor */ | ||
| 308 | |||
| 309 | resource = | ||
| 310 | ACPI_ADD_PTR(struct acpi_resource, resource, | ||
| 311 | resource->length); | ||
| 312 | } | ||
| 313 | |||
| 314 | ACPI_MEM_FREE(buffer.pointer); | ||
| 315 | return_ACPI_STATUS(status); | 259 | return_ACPI_STATUS(status); |
| 316 | } | 260 | } |
| 317 | 261 | ||
| 318 | EXPORT_SYMBOL(acpi_walk_resources); | 262 | ACPI_EXPORT_SYMBOL(acpi_get_possible_resources) |
| 263 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 319 | 264 | ||
| 320 | /******************************************************************************* | 265 | /******************************************************************************* |
| 321 | * | 266 | * |
| 322 | * FUNCTION: acpi_set_current_resources | 267 | * FUNCTION: acpi_set_current_resources |
| 323 | * | 268 | * |
| 324 | * PARAMETERS: device_handle - a handle to the device object for the | 269 | * PARAMETERS: device_handle - Handle to the device object for the |
| 325 | * device we are changing the resources of | 270 | * device we are setting resources |
| 326 | * in_buffer - a pointer to a buffer containing the | 271 | * in_buffer - Pointer to a buffer containing the |
| 327 | * resources to be set for the device | 272 | * resources to be set for the device |
| 328 | * | 273 | * |
| 329 | * RETURN: Status | 274 | * RETURN: Status |
| 330 | * | 275 | * |
| 331 | * DESCRIPTION: This function is called to set the current resources for a | 276 | * DESCRIPTION: This function is called to set the current resources for a |
| 332 | * specific device. The caller must first acquire a handle for | 277 | * specific device. The caller must first acquire a handle for |
| 333 | * the desired device. The resource data is passed to the routine | 278 | * the desired device. The resource data is passed to the routine |
| 334 | * the buffer pointed to by the in_buffer variable. | 279 | * the buffer pointed to by the in_buffer variable. |
| 335 | * | 280 | * |
| 336 | ******************************************************************************/ | 281 | ******************************************************************************/ |
| 337 | |||
| 338 | acpi_status | 282 | acpi_status |
| 339 | acpi_set_current_resources(acpi_handle device_handle, | 283 | acpi_set_current_resources(acpi_handle device_handle, |
| 340 | struct acpi_buffer *in_buffer) | 284 | struct acpi_buffer *in_buffer) |
| 341 | { | 285 | { |
| 342 | acpi_status status; | 286 | acpi_status status; |
| 287 | struct acpi_namespace_node *node; | ||
| 343 | 288 | ||
| 344 | ACPI_FUNCTION_TRACE("acpi_set_current_resources"); | 289 | ACPI_FUNCTION_TRACE(acpi_set_current_resources); |
| 345 | 290 | ||
| 346 | /* Must have a valid handle and buffer */ | 291 | /* Validate the buffer, don't allow zero length */ |
| 347 | 292 | ||
| 348 | if ((!device_handle) || | 293 | if ((!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) { |
| 349 | (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) { | ||
| 350 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 294 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 351 | } | 295 | } |
| 352 | 296 | ||
| 353 | status = acpi_rs_set_srs_method_data(device_handle, in_buffer); | 297 | /* Validate parameters then dispatch to internal routine */ |
| 298 | |||
| 299 | status = acpi_rs_validate_parameters(device_handle, in_buffer, &node); | ||
| 300 | if (ACPI_FAILURE(status)) { | ||
| 301 | return_ACPI_STATUS(status); | ||
| 302 | } | ||
| 303 | |||
| 304 | status = acpi_rs_set_srs_method_data(node, in_buffer); | ||
| 354 | return_ACPI_STATUS(status); | 305 | return_ACPI_STATUS(status); |
| 355 | } | 306 | } |
| 356 | 307 | ||
| 357 | EXPORT_SYMBOL(acpi_set_current_resources); | 308 | ACPI_EXPORT_SYMBOL(acpi_set_current_resources) |
| 358 | 309 | ||
| 359 | /****************************************************************************** | 310 | /****************************************************************************** |
| 360 | * | 311 | * |
| 361 | * FUNCTION: acpi_resource_to_address64 | 312 | * FUNCTION: acpi_resource_to_address64 |
| 362 | * | 313 | * |
| 363 | * PARAMETERS: Resource - Pointer to a resource | 314 | * PARAMETERS: Resource - Pointer to a resource |
| 364 | * Out - Pointer to the users's return | 315 | * Out - Pointer to the users's return buffer |
| 365 | * buffer (a struct | 316 | * (a struct acpi_resource_address64) |
| 366 | * struct acpi_resource_address64) | ||
| 367 | * | 317 | * |
| 368 | * RETURN: Status | 318 | * RETURN: Status |
| 369 | * | 319 | * |
| 370 | * DESCRIPTION: If the resource is an address16, address32, or address64, | 320 | * DESCRIPTION: If the resource is an address16, address32, or address64, |
| 371 | * copy it to the address64 return buffer. This saves the | 321 | * copy it to the address64 return buffer. This saves the |
| 372 | * caller from having to duplicate code for different-sized | 322 | * caller from having to duplicate code for different-sized |
| 373 | * addresses. | 323 | * addresses. |
| 374 | * | 324 | * |
| 375 | ******************************************************************************/ | 325 | ******************************************************************************/ |
| 376 | |||
| 377 | acpi_status | 326 | acpi_status |
| 378 | acpi_resource_to_address64(struct acpi_resource *resource, | 327 | acpi_resource_to_address64(struct acpi_resource *resource, |
| 379 | struct acpi_resource_address64 *out) | 328 | struct acpi_resource_address64 *out) |
| @@ -415,18 +364,18 @@ acpi_resource_to_address64(struct acpi_resource *resource, | |||
| 415 | return (AE_OK); | 364 | return (AE_OK); |
| 416 | } | 365 | } |
| 417 | 366 | ||
| 418 | EXPORT_SYMBOL(acpi_resource_to_address64); | 367 | ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) |
| 419 | 368 | ||
| 420 | /******************************************************************************* | 369 | /******************************************************************************* |
| 421 | * | 370 | * |
| 422 | * FUNCTION: acpi_get_vendor_resource | 371 | * FUNCTION: acpi_get_vendor_resource |
| 423 | * | 372 | * |
| 424 | * PARAMETERS: device_handle - Handle for the parent device object | 373 | * PARAMETERS: device_handle - Handle for the parent device object |
| 425 | * Name - Method name for the parent resource | 374 | * Name - Method name for the parent resource |
| 426 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | 375 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) |
| 427 | * Uuid - Pointer to the UUID to be matched. | 376 | * Uuid - Pointer to the UUID to be matched. |
| 428 | * includes both subtype and 16-byte UUID | 377 | * includes both subtype and 16-byte UUID |
| 429 | * ret_buffer - Where the vendor resource is returned | 378 | * ret_buffer - Where the vendor resource is returned |
| 430 | * | 379 | * |
| 431 | * RETURN: Status | 380 | * RETURN: Status |
| 432 | * | 381 | * |
| @@ -435,7 +384,6 @@ EXPORT_SYMBOL(acpi_resource_to_address64); | |||
| 435 | * UUID subtype. Returns a struct acpi_resource of type Vendor. | 384 | * UUID subtype. Returns a struct acpi_resource of type Vendor. |
| 436 | * | 385 | * |
| 437 | ******************************************************************************/ | 386 | ******************************************************************************/ |
| 438 | |||
| 439 | acpi_status | 387 | acpi_status |
| 440 | acpi_get_vendor_resource(acpi_handle device_handle, | 388 | acpi_get_vendor_resource(acpi_handle device_handle, |
| 441 | char *name, | 389 | char *name, |
| @@ -467,18 +415,19 @@ acpi_get_vendor_resource(acpi_handle device_handle, | |||
| 467 | return (info.status); | 415 | return (info.status); |
| 468 | } | 416 | } |
| 469 | 417 | ||
| 418 | ACPI_EXPORT_SYMBOL(acpi_get_vendor_resource) | ||
| 419 | |||
| 470 | /******************************************************************************* | 420 | /******************************************************************************* |
| 471 | * | 421 | * |
| 472 | * FUNCTION: acpi_rs_match_vendor_resource | 422 | * FUNCTION: acpi_rs_match_vendor_resource |
| 473 | * | 423 | * |
| 474 | * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK | 424 | * PARAMETERS: acpi_walk_resource_callback |
| 475 | * | 425 | * |
| 476 | * RETURN: Status | 426 | * RETURN: Status |
| 477 | * | 427 | * |
| 478 | * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID | 428 | * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID |
| 479 | * | 429 | * |
| 480 | ******************************************************************************/ | 430 | ******************************************************************************/ |
| 481 | |||
| 482 | static acpi_status | 431 | static acpi_status |
| 483 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) | 432 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) |
| 484 | { | 433 | { |
| @@ -526,3 +475,101 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) | |||
| 526 | info->status = AE_OK; | 475 | info->status = AE_OK; |
| 527 | return (AE_CTRL_TERMINATE); | 476 | return (AE_CTRL_TERMINATE); |
| 528 | } | 477 | } |
| 478 | |||
| 479 | ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource) | ||
| 480 | |||
| 481 | /******************************************************************************* | ||
| 482 | * | ||
| 483 | * FUNCTION: acpi_walk_resources | ||
| 484 | * | ||
| 485 | * PARAMETERS: device_handle - Handle to the device object for the | ||
| 486 | * device we are querying | ||
| 487 | * Name - Method name of the resources we want | ||
| 488 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | ||
| 489 | * user_function - Called for each resource | ||
| 490 | * Context - Passed to user_function | ||
| 491 | * | ||
| 492 | * RETURN: Status | ||
| 493 | * | ||
| 494 | * DESCRIPTION: Retrieves the current or possible resource list for the | ||
| 495 | * specified device. The user_function is called once for | ||
| 496 | * each resource in the list. | ||
| 497 | * | ||
| 498 | ******************************************************************************/ | ||
| 499 | |||
| 500 | acpi_status | ||
| 501 | acpi_walk_resources(acpi_handle device_handle, | ||
| 502 | char *name, | ||
| 503 | acpi_walk_resource_callback user_function, void *context) | ||
| 504 | { | ||
| 505 | acpi_status status; | ||
| 506 | struct acpi_buffer buffer; | ||
| 507 | struct acpi_resource *resource; | ||
| 508 | struct acpi_resource *resource_end; | ||
| 509 | |||
| 510 | ACPI_FUNCTION_TRACE(acpi_walk_resources); | ||
| 511 | |||
| 512 | /* Parameter validation */ | ||
| 513 | |||
| 514 | if (!device_handle || !user_function || !name || | ||
| 515 | (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && | ||
| 516 | !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS))) { | ||
| 517 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 518 | } | ||
| 519 | |||
| 520 | /* Get the _CRS or _PRS resource list */ | ||
| 521 | |||
| 522 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
| 523 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
| 524 | if (ACPI_FAILURE(status)) { | ||
| 525 | return_ACPI_STATUS(status); | ||
| 526 | } | ||
| 527 | |||
| 528 | /* Buffer now contains the resource list */ | ||
| 529 | |||
| 530 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); | ||
| 531 | resource_end = | ||
| 532 | ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); | ||
| 533 | |||
| 534 | /* Walk the resource list until the end_tag is found (or buffer end) */ | ||
| 535 | |||
| 536 | while (resource < resource_end) { | ||
| 537 | |||
| 538 | /* Sanity check the resource */ | ||
| 539 | |||
| 540 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | ||
| 541 | status = AE_AML_INVALID_RESOURCE_TYPE; | ||
| 542 | break; | ||
| 543 | } | ||
| 544 | |||
| 545 | /* Invoke the user function, abort on any error returned */ | ||
| 546 | |||
| 547 | status = user_function(resource, context); | ||
| 548 | if (ACPI_FAILURE(status)) { | ||
| 549 | if (status == AE_CTRL_TERMINATE) { | ||
| 550 | |||
| 551 | /* This is an OK termination by the user function */ | ||
| 552 | |||
| 553 | status = AE_OK; | ||
| 554 | } | ||
| 555 | break; | ||
| 556 | } | ||
| 557 | |||
| 558 | /* end_tag indicates end-of-list */ | ||
| 559 | |||
| 560 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { | ||
| 561 | break; | ||
| 562 | } | ||
| 563 | |||
| 564 | /* Get the next resource descriptor */ | ||
| 565 | |||
| 566 | resource = | ||
| 567 | ACPI_ADD_PTR(struct acpi_resource, resource, | ||
| 568 | resource->length); | ||
| 569 | } | ||
| 570 | |||
| 571 | ACPI_FREE(buffer.pointer); | ||
| 572 | return_ACPI_STATUS(status); | ||
| 573 | } | ||
| 574 | |||
| 575 | ACPI_EXPORT_SYMBOL(acpi_walk_resources) | ||
