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) |
[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) | |||
299 | 299 | ||
300 | /* Point to the next object */ | 300 | /* Point to the next object */ |
301 | 301 | ||
302 | resource = ACPI_PTR_ADD(struct acpi_resource, | 302 | resource = |
303 | resource, resource->length); | 303 | ACPI_PTR_ADD(struct acpi_resource, resource, |
304 | resource->length); | ||
304 | } | 305 | } |
305 | 306 | ||
306 | /* Did not find an END_TAG descriptor */ | 307 | /* Did not find an end_tag resource descriptor */ |
307 | 308 | ||
308 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 309 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
309 | } | 310 | } |
310 | 311 | ||
311 | /******************************************************************************* | 312 | /******************************************************************************* |
@@ -328,185 +329,155 @@ acpi_status | |||
328 | acpi_rs_get_list_length(u8 * aml_buffer, | 329 | acpi_rs_get_list_length(u8 * aml_buffer, |
329 | u32 aml_buffer_length, acpi_size * size_needed) | 330 | u32 aml_buffer_length, acpi_size * size_needed) |
330 | { | 331 | { |
332 | acpi_status status; | ||
333 | u8 *end_aml; | ||
331 | u8 *buffer; | 334 | u8 *buffer; |
332 | struct acpi_resource_info *resource_info; | ||
333 | u32 buffer_size = 0; | 335 | u32 buffer_size = 0; |
334 | u32 bytes_parsed = 0; | ||
335 | u8 resource_type; | ||
336 | u16 temp16; | 336 | u16 temp16; |
337 | u16 resource_length; | 337 | u16 resource_length; |
338 | u16 header_length; | ||
339 | u32 extra_struct_bytes; | 338 | u32 extra_struct_bytes; |
339 | u8 resource_index; | ||
340 | u8 minimum_aml_resource_length; | ||
340 | 341 | ||
341 | ACPI_FUNCTION_TRACE("rs_get_list_length"); | 342 | ACPI_FUNCTION_TRACE("rs_get_list_length"); |
342 | 343 | ||
343 | while (bytes_parsed < aml_buffer_length) { | 344 | end_aml = aml_buffer + aml_buffer_length; |
344 | /* The next byte in the stream is the resource descriptor type */ | ||
345 | 345 | ||
346 | resource_type = acpi_ut_get_resource_type(aml_buffer); | 346 | /* Walk the list of AML resource descriptors */ |
347 | 347 | ||
348 | /* Get the base stream size and structure sizes for the descriptor */ | 348 | while (aml_buffer < end_aml) { |
349 | /* Validate the Resource Type and Resource Length */ | ||
349 | 350 | ||
350 | resource_info = acpi_rs_get_resource_info(resource_type); | 351 | status = acpi_ut_validate_resource(aml_buffer, &resource_index); |
351 | if (!resource_info) { | 352 | if (ACPI_FAILURE(status)) { |
352 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 353 | return_ACPI_STATUS(status); |
353 | } | 354 | } |
354 | 355 | ||
355 | /* Get the Length field from the input resource descriptor */ | 356 | /* Get the resource length and base (minimum) AML size */ |
356 | 357 | ||
357 | resource_length = acpi_ut_get_resource_length(aml_buffer); | 358 | resource_length = acpi_ut_get_resource_length(aml_buffer); |
359 | minimum_aml_resource_length = | ||
360 | acpi_gbl_resource_aml_sizes[resource_index]; | ||
358 | 361 | ||
359 | /* Augment the size for descriptors with optional fields */ | 362 | /* |
360 | 363 | * Augment the size for descriptors with optional | |
364 | * and/or variable length fields | ||
365 | */ | ||
361 | extra_struct_bytes = 0; | 366 | extra_struct_bytes = 0; |
367 | buffer = | ||
368 | aml_buffer + acpi_ut_get_resource_header_length(aml_buffer); | ||
362 | 369 | ||
363 | if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { | 370 | switch (acpi_ut_get_resource_type(aml_buffer)) { |
371 | case ACPI_RESOURCE_NAME_IRQ: | ||
364 | /* | 372 | /* |
365 | * Small resource descriptors | 373 | * IRQ Resource: |
374 | * Get the number of bits set in the 16-bit IRQ mask | ||
366 | */ | 375 | */ |
367 | header_length = | 376 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
368 | sizeof(struct aml_resource_small_header); | 377 | extra_struct_bytes = |
369 | buffer = aml_buffer + header_length; | 378 | acpi_rs_count_set_bits(temp16) * sizeof(u32); |
370 | 379 | break; | |
371 | switch (resource_type) { | ||
372 | case ACPI_RESOURCE_NAME_IRQ: | ||
373 | /* | ||
374 | * IRQ Resource: | ||
375 | * Get the number of bits set in the IRQ word | ||
376 | */ | ||
377 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
378 | extra_struct_bytes = | ||
379 | (acpi_rs_count_set_bits(temp16) * | ||
380 | sizeof(u32)); | ||
381 | break; | ||
382 | |||
383 | case ACPI_RESOURCE_NAME_DMA: | ||
384 | /* | ||
385 | * DMA Resource: | ||
386 | * Get the number of bits set in the DMA channels byte | ||
387 | */ | ||
388 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
389 | extra_struct_bytes = | ||
390 | (acpi_rs_count_set_bits(temp16) * | ||
391 | sizeof(u32)); | ||
392 | break; | ||
393 | |||
394 | case ACPI_RESOURCE_NAME_VENDOR_SMALL: | ||
395 | /* | ||
396 | * Vendor Specific Resource: | ||
397 | * Ensure a 32-bit boundary for the structure | ||
398 | */ | ||
399 | extra_struct_bytes = | ||
400 | ACPI_ROUND_UP_to_32_bITS(resource_length); | ||
401 | break; | ||
402 | 380 | ||
403 | case ACPI_RESOURCE_NAME_END_TAG: | 381 | case ACPI_RESOURCE_NAME_DMA: |
404 | /* | 382 | /* |
405 | * End Tag: | 383 | * DMA Resource: |
406 | * Terminate the loop now | 384 | * Get the number of bits set in the 8-bit DMA mask |
407 | */ | 385 | */ |
408 | aml_buffer_length = bytes_parsed; | 386 | extra_struct_bytes = |
409 | break; | 387 | acpi_rs_count_set_bits(*buffer) * sizeof(u32); |
388 | break; | ||
410 | 389 | ||
411 | default: | 390 | case ACPI_RESOURCE_NAME_VENDOR_SMALL: |
412 | break; | ||
413 | } | ||
414 | } else { | ||
415 | /* | 391 | /* |
416 | * Large resource descriptors | 392 | * Vendor Resource: |
393 | * Ensure a 32-bit boundary for the structure | ||
417 | */ | 394 | */ |
418 | header_length = | 395 | extra_struct_bytes = |
419 | sizeof(struct aml_resource_large_header); | 396 | ACPI_ROUND_UP_to_32_bITS(resource_length) - |
420 | buffer = aml_buffer + header_length; | 397 | resource_length; |
398 | break; | ||
421 | 399 | ||
422 | switch (resource_type) { | 400 | case ACPI_RESOURCE_NAME_END_TAG: |
423 | case ACPI_RESOURCE_NAME_VENDOR_LARGE: | 401 | /* |
424 | /* | 402 | * End Tag: This is the normal exit |
425 | * Vendor Defined Resource: | 403 | */ |
426 | * Add vendor data and ensure a 32-bit boundary for the structure | 404 | *size_needed = buffer_size; |
427 | */ | 405 | return_ACPI_STATUS(AE_OK); |
428 | extra_struct_bytes = | ||
429 | ACPI_ROUND_UP_to_32_bITS(resource_length); | ||
430 | break; | ||
431 | 406 | ||
432 | case ACPI_RESOURCE_NAME_ADDRESS32: | 407 | case ACPI_RESOURCE_NAME_VENDOR_LARGE: |
433 | case ACPI_RESOURCE_NAME_ADDRESS16: | 408 | /* |
434 | /* | 409 | * Vendor Resource: |
435 | * 32-Bit or 16-bit Address Resource: | 410 | * Add vendor data and ensure a 32-bit boundary for the structure |
436 | * Add the size of any optional data (resource_source) | 411 | */ |
437 | */ | 412 | extra_struct_bytes = |
438 | extra_struct_bytes = | 413 | ACPI_ROUND_UP_to_32_bITS(resource_length) - |
439 | acpi_rs_stream_option_length | 414 | resource_length; |
440 | (resource_length, | 415 | break; |
441 | resource_info-> | ||
442 | minimum_aml_resource_length); | ||
443 | break; | ||
444 | |||
445 | case ACPI_RESOURCE_NAME_EXTENDED_IRQ: | ||
446 | /* | ||
447 | * Extended IRQ: | ||
448 | * Point past the interrupt_vector_flags to get the | ||
449 | * interrupt_table_length. | ||
450 | */ | ||
451 | buffer++; | ||
452 | 416 | ||
453 | /* | 417 | case ACPI_RESOURCE_NAME_ADDRESS32: |
454 | * Add 4 bytes for each additional interrupt. Note: at least one | 418 | case ACPI_RESOURCE_NAME_ADDRESS16: |
455 | * interrupt is required and is included in the minimum | 419 | /* |
456 | * descriptor size | 420 | * 32-Bit or 16-bit Address Resource: |
457 | */ | 421 | * Add the size of any optional data (resource_source) |
458 | extra_struct_bytes = | 422 | */ |
459 | ((*buffer - 1) * sizeof(u32)); | 423 | extra_struct_bytes = |
424 | acpi_rs_stream_option_length(resource_length, | ||
425 | minimum_aml_resource_length); | ||
426 | break; | ||
460 | 427 | ||
461 | /* Add the size of any optional data (resource_source) */ | 428 | case ACPI_RESOURCE_NAME_EXTENDED_IRQ: |
429 | /* | ||
430 | * Extended IRQ: | ||
431 | * Point past the interrupt_vector_flags to get the | ||
432 | * interrupt_table_length. | ||
433 | */ | ||
434 | buffer++; | ||
435 | |||
436 | extra_struct_bytes = | ||
437 | /* | ||
438 | * Add 4 bytes for each additional interrupt. Note: at | ||
439 | * least one interrupt is required and is included in | ||
440 | * the minimum descriptor size | ||
441 | */ | ||
442 | ((*buffer - 1) * sizeof(u32)) + | ||
443 | /* Add the size of any optional data (resource_source) */ | ||
444 | acpi_rs_stream_option_length(resource_length - | ||
445 | extra_struct_bytes, | ||
446 | minimum_aml_resource_length); | ||
447 | break; | ||
462 | 448 | ||
463 | extra_struct_bytes += | 449 | case ACPI_RESOURCE_NAME_ADDRESS64: |
464 | acpi_rs_stream_option_length(resource_length | 450 | /* |
465 | - | 451 | * 64-Bit Address Resource: |
466 | extra_struct_bytes, | 452 | * Add the size of any optional data (resource_source) |
467 | resource_info-> | 453 | * Ensure a 64-bit boundary for the structure |
468 | minimum_aml_resource_length); | 454 | */ |
469 | break; | 455 | extra_struct_bytes = |
456 | ACPI_ROUND_UP_to_64_bITS | ||
457 | (acpi_rs_stream_option_length | ||
458 | (resource_length, minimum_aml_resource_length)); | ||
459 | break; | ||
470 | 460 | ||
471 | case ACPI_RESOURCE_NAME_ADDRESS64: | 461 | default: |
472 | /* | 462 | break; |
473 | * 64-Bit Address Resource: | ||
474 | * Add the size of any optional data (resource_source) | ||
475 | * Ensure a 64-bit boundary for the structure | ||
476 | */ | ||
477 | extra_struct_bytes = | ||
478 | ACPI_ROUND_UP_to_64_bITS | ||
479 | (acpi_rs_stream_option_length | ||
480 | (resource_length, | ||
481 | resource_info-> | ||
482 | minimum_aml_resource_length)); | ||
483 | break; | ||
484 | |||
485 | default: | ||
486 | break; | ||
487 | } | ||
488 | } | 463 | } |
489 | 464 | ||
490 | /* Update the required buffer size for the internal descriptor structs */ | 465 | /* Update the required buffer size for the internal descriptor structs */ |
491 | 466 | ||
492 | temp16 = | 467 | temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + |
493 | (u16) (resource_info->minimum_internal_struct_length + | 468 | extra_struct_bytes); |
494 | extra_struct_bytes); | ||
495 | buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); | 469 | buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); |
496 | 470 | ||
497 | /* | 471 | /* |
498 | * Update byte count and point to the next resource within the stream | 472 | * Point to the next resource within the stream |
499 | * using the size of the header plus the length contained in the header | 473 | * using the size of the header plus the length contained in the header |
500 | */ | 474 | */ |
501 | temp16 = (u16) (header_length + resource_length); | 475 | aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); |
502 | bytes_parsed += temp16; | ||
503 | aml_buffer += temp16; | ||
504 | } | 476 | } |
505 | 477 | ||
506 | /* This is the data the caller needs */ | 478 | /* Did not find an end_tag resource descriptor */ |
507 | 479 | ||
508 | *size_needed = buffer_size; | 480 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
509 | return_ACPI_STATUS(AE_OK); | ||
510 | } | 481 | } |
511 | 482 | ||
512 | /******************************************************************************* | 483 | /******************************************************************************* |
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] = { | |||
324 | 324 | ||
325 | static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { | 325 | static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { |
326 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), | 326 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), |
327 | "Resource Type", "Memory Range"}, | 327 | "Resource Type", (void *)"Memory Range"}, |
328 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), | 328 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), |
329 | "Write Protect", acpi_gbl_RWdecode}, | 329 | "Write Protect", acpi_gbl_RWdecode}, |
330 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), | 330 | {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] = { | |||
337 | 337 | ||
338 | static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { | 338 | static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { |
339 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), | 339 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), |
340 | "Resource Type", "I/O Range"}, | 340 | "Resource Type", (void *)"I/O Range"}, |
341 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), | 341 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), |
342 | "Range Type", acpi_gbl_RNGdecode}, | 342 | "Range Type", acpi_gbl_RNGdecode}, |
343 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), | 343 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), |
@@ -372,8 +372,8 @@ static struct acpi_rsdump_info acpi_rs_dump_prt[5] = { | |||
372 | static void | 372 | static void |
373 | acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | 373 | acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) |
374 | { | 374 | { |
375 | void *target = NULL; | 375 | u8 *target = NULL; |
376 | void *previous_target; | 376 | u8 *previous_target; |
377 | char *name; | 377 | char *name; |
378 | u8 count; | 378 | u8 count; |
379 | 379 | ||
@@ -399,43 +399,49 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
399 | /* Strings */ | 399 | /* Strings */ |
400 | 400 | ||
401 | case ACPI_RSD_LITERAL: | 401 | case ACPI_RSD_LITERAL: |
402 | acpi_rs_out_string(name, (char *)table->pointer); | 402 | acpi_rs_out_string(name, |
403 | ACPI_CAST_PTR(char, table->pointer)); | ||
403 | break; | 404 | break; |
404 | 405 | ||
405 | case ACPI_RSD_STRING: | 406 | case ACPI_RSD_STRING: |
406 | acpi_rs_out_string(name, (char *)target); | 407 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); |
407 | break; | 408 | break; |
408 | 409 | ||
409 | /* Data items, 8/16/32/64 bit */ | 410 | /* Data items, 8/16/32/64 bit */ |
410 | 411 | ||
411 | case ACPI_RSD_UINT8: | 412 | case ACPI_RSD_UINT8: |
412 | acpi_rs_out_integer8(name, *(u8 *) target); | 413 | acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); |
413 | break; | 414 | break; |
414 | 415 | ||
415 | case ACPI_RSD_UINT16: | 416 | case ACPI_RSD_UINT16: |
416 | acpi_rs_out_integer16(name, *(u16 *) target); | 417 | acpi_rs_out_integer16(name, |
418 | *ACPI_CAST_PTR(u16, target)); | ||
417 | break; | 419 | break; |
418 | 420 | ||
419 | case ACPI_RSD_UINT32: | 421 | case ACPI_RSD_UINT32: |
420 | acpi_rs_out_integer32(name, *(u32 *) target); | 422 | acpi_rs_out_integer32(name, |
423 | *ACPI_CAST_PTR(u32, target)); | ||
421 | break; | 424 | break; |
422 | 425 | ||
423 | case ACPI_RSD_UINT64: | 426 | case ACPI_RSD_UINT64: |
424 | acpi_rs_out_integer64(name, *(u64 *) target); | 427 | acpi_rs_out_integer64(name, |
428 | *ACPI_CAST_PTR(u64, target)); | ||
425 | break; | 429 | break; |
426 | 430 | ||
427 | /* Flags: 1-bit and 2-bit flags supported */ | 431 | /* Flags: 1-bit and 2-bit flags supported */ |
428 | 432 | ||
429 | case ACPI_RSD_1BITFLAG: | 433 | case ACPI_RSD_1BITFLAG: |
430 | acpi_rs_out_string(name, (char *) | 434 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
431 | ((const char **)table-> | 435 | table-> |
432 | pointer)[(*(u8 *) target) & 0x01]); | 436 | pointer[*target & |
437 | 0x01])); | ||
433 | break; | 438 | break; |
434 | 439 | ||
435 | case ACPI_RSD_2BITFLAG: | 440 | case ACPI_RSD_2BITFLAG: |
436 | acpi_rs_out_string(name, (char *) | 441 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
437 | ((const char **)table-> | 442 | table-> |
438 | pointer)[(*(u8 *) target) & 0x03]); | 443 | pointer[*target & |
444 | 0x03])); | ||
439 | break; | 445 | break; |
440 | 446 | ||
441 | case ACPI_RSD_SHORTLIST: | 447 | case ACPI_RSD_SHORTLIST: |
@@ -445,10 +451,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
445 | */ | 451 | */ |
446 | if (previous_target) { | 452 | if (previous_target) { |
447 | acpi_rs_out_title(name); | 453 | acpi_rs_out_title(name); |
448 | acpi_rs_dump_short_byte_list(* | 454 | acpi_rs_dump_short_byte_list(*previous_target, |
449 | ((u8 *) | 455 | target); |
450 | previous_target), | ||
451 | (u8 *) target); | ||
452 | } | 456 | } |
453 | break; | 457 | break; |
454 | 458 | ||
@@ -458,10 +462,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
458 | * Note: The list length is obtained from the previous table entry | 462 | * Note: The list length is obtained from the previous table entry |
459 | */ | 463 | */ |
460 | if (previous_target) { | 464 | if (previous_target) { |
461 | acpi_rs_dump_byte_list(* | 465 | acpi_rs_dump_byte_list(*ACPI_CAST_PTR |
462 | ((u16 *) | 466 | (u16, previous_target), |
463 | previous_target), | 467 | target); |
464 | (u8 *) target); | ||
465 | } | 468 | } |
466 | break; | 469 | break; |
467 | 470 | ||
@@ -471,10 +474,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
471 | * Note: The list length is obtained from the previous table entry | 474 | * Note: The list length is obtained from the previous table entry |
472 | */ | 475 | */ |
473 | if (previous_target) { | 476 | if (previous_target) { |
474 | acpi_rs_dump_dword_list(* | 477 | acpi_rs_dump_dword_list(*previous_target, |
475 | ((u8 *) | 478 | ACPI_CAST_PTR(u32, |
476 | previous_target), | 479 | target)); |
477 | (u32 *) target); | ||
478 | } | 480 | } |
479 | break; | 481 | break; |
480 | 482 | ||
@@ -482,17 +484,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
482 | /* | 484 | /* |
483 | * Common flags for all Address resources | 485 | * Common flags for all Address resources |
484 | */ | 486 | */ |
485 | acpi_rs_dump_address_common((union acpi_resource_data *) | 487 | acpi_rs_dump_address_common(ACPI_CAST_PTR |
486 | target); | 488 | (union acpi_resource_data, |
489 | target)); | ||
487 | break; | 490 | break; |
488 | 491 | ||
489 | case ACPI_RSD_SOURCE: | 492 | case ACPI_RSD_SOURCE: |
490 | /* | 493 | /* |
491 | * Optional resource_source for Address resources | 494 | * Optional resource_source for Address resources |
492 | */ | 495 | */ |
493 | acpi_rs_dump_resource_source((struct | 496 | acpi_rs_dump_resource_source(ACPI_CAST_PTR |
494 | acpi_resource_source *) | 497 | (struct |
495 | target); | 498 | acpi_resource_source, |
499 | target)); | ||
496 | break; | 500 | break; |
497 | 501 | ||
498 | default: | 502 | 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[] = { | |||
80 | 80 | ||
81 | /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ | 81 | /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ |
82 | 82 | ||
83 | struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { | 83 | struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = { |
84 | /* Small descriptors */ | ||
85 | |||
84 | NULL, /* 0x00, Reserved */ | 86 | NULL, /* 0x00, Reserved */ |
85 | NULL, /* 0x01, Reserved */ | 87 | NULL, /* 0x01, Reserved */ |
86 | NULL, /* 0x02, Reserved */ | 88 | NULL, /* 0x02, Reserved */ |
@@ -96,10 +98,10 @@ struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { | |||
96 | NULL, /* 0x0C, Reserved */ | 98 | NULL, /* 0x0C, Reserved */ |
97 | NULL, /* 0x0D, Reserved */ | 99 | NULL, /* 0x0D, Reserved */ |
98 | acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ | 100 | acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ |
99 | acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ | 101 | acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ |
100 | }; | 102 | |
103 | /* Large descriptors */ | ||
101 | 104 | ||
102 | struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = { | ||
103 | NULL, /* 0x00, Reserved */ | 105 | NULL, /* 0x00, Reserved */ |
104 | acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ | 106 | acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ |
105 | acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ | 107 | acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ |
@@ -138,7 +140,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { | |||
138 | acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ | 140 | acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ |
139 | acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ | 141 | acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ |
140 | }; | 142 | }; |
141 | |||
142 | #endif | 143 | #endif |
143 | #endif /* ACPI_FUTURE_USAGE */ | 144 | #endif /* ACPI_FUTURE_USAGE */ |
144 | /* | 145 | /* |
@@ -166,62 +167,38 @@ const u8 acpi_gbl_aml_resource_sizes[] = { | |||
166 | sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ | 167 | sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ |
167 | }; | 168 | }; |
168 | 169 | ||
169 | /* Macros used in the tables below */ | 170 | const u8 acpi_gbl_resource_struct_sizes[] = { |
171 | /* Small descriptors */ | ||
170 | 172 | ||
171 | #define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) | 173 | 0, |
172 | #define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) | 174 | 0, |
175 | 0, | ||
176 | 0, | ||
177 | ACPI_RS_SIZE(struct acpi_resource_irq), | ||
178 | ACPI_RS_SIZE(struct acpi_resource_dma), | ||
179 | ACPI_RS_SIZE(struct acpi_resource_start_dependent), | ||
180 | ACPI_RS_SIZE_MIN, | ||
181 | ACPI_RS_SIZE(struct acpi_resource_io), | ||
182 | ACPI_RS_SIZE(struct acpi_resource_fixed_io), | ||
183 | 0, | ||
184 | 0, | ||
185 | 0, | ||
186 | 0, | ||
187 | ACPI_RS_SIZE(struct acpi_resource_vendor), | ||
188 | ACPI_RS_SIZE_MIN, | ||
173 | 189 | ||
174 | /* | 190 | /* Large descriptors */ |
175 | * Base sizes of resource descriptors, both the AML stream resource length | ||
176 | * (minus size of header and length fields),and the size of the internal | ||
177 | * struct representation. | ||
178 | */ | ||
179 | struct acpi_resource_info acpi_gbl_sm_resource_info[] = { | ||
180 | {0, 0, 0}, | ||
181 | {0, 0, 0}, | ||
182 | {0, 0, 0}, | ||
183 | {0, 0, 0}, | ||
184 | {2, ACPI_RSMALL(struct aml_resource_irq), | ||
185 | ACPI_RS_SIZE(struct acpi_resource_irq)}, | ||
186 | {0, ACPI_RSMALL(struct aml_resource_dma), | ||
187 | ACPI_RS_SIZE(struct acpi_resource_dma)}, | ||
188 | {2, ACPI_RSMALL(struct aml_resource_start_dependent), | ||
189 | ACPI_RS_SIZE(struct acpi_resource_start_dependent)}, | ||
190 | {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN}, | ||
191 | {0, ACPI_RSMALL(struct aml_resource_io), | ||
192 | ACPI_RS_SIZE(struct acpi_resource_io)}, | ||
193 | {0, ACPI_RSMALL(struct aml_resource_fixed_io), | ||
194 | ACPI_RS_SIZE(struct acpi_resource_fixed_io)}, | ||
195 | {0, 0, 0}, | ||
196 | {0, 0, 0}, | ||
197 | {0, 0, 0}, | ||
198 | {0, 0, 0}, | ||
199 | {1, ACPI_RSMALL(struct aml_resource_vendor_small), | ||
200 | ACPI_RS_SIZE(struct acpi_resource_vendor)}, | ||
201 | {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN} | ||
202 | }; | ||
203 | 191 | ||
204 | struct acpi_resource_info acpi_gbl_lg_resource_info[] = { | 192 | 0, |
205 | {0, 0, 0}, | 193 | ACPI_RS_SIZE(struct acpi_resource_memory24), |
206 | {0, ACPI_RLARGE(struct aml_resource_memory24), | 194 | ACPI_RS_SIZE(struct acpi_resource_generic_register), |
207 | ACPI_RS_SIZE(struct acpi_resource_memory24)}, | 195 | 0, |
208 | {0, ACPI_RLARGE(struct aml_resource_generic_register), | 196 | ACPI_RS_SIZE(struct acpi_resource_vendor), |
209 | ACPI_RS_SIZE(struct acpi_resource_generic_register)}, | 197 | ACPI_RS_SIZE(struct acpi_resource_memory32), |
210 | {0, 0, 0}, | 198 | ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), |
211 | {1, ACPI_RLARGE(struct aml_resource_vendor_large), | 199 | ACPI_RS_SIZE(struct acpi_resource_address32), |
212 | ACPI_RS_SIZE(struct acpi_resource_vendor)}, | 200 | ACPI_RS_SIZE(struct acpi_resource_address16), |
213 | {0, ACPI_RLARGE(struct aml_resource_memory32), | 201 | ACPI_RS_SIZE(struct acpi_resource_extended_irq), |
214 | ACPI_RS_SIZE(struct acpi_resource_memory32)}, | 202 | ACPI_RS_SIZE(struct acpi_resource_address64), |
215 | {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), | 203 | ACPI_RS_SIZE(struct acpi_resource_extended_address64) |
216 | ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)}, | ||
217 | {1, ACPI_RLARGE(struct aml_resource_address32), | ||
218 | ACPI_RS_SIZE(struct acpi_resource_address32)}, | ||
219 | {1, ACPI_RLARGE(struct aml_resource_address16), | ||
220 | ACPI_RS_SIZE(struct acpi_resource_address16)}, | ||
221 | {1, ACPI_RLARGE(struct aml_resource_extended_irq), | ||
222 | ACPI_RS_SIZE(struct acpi_resource_extended_irq)}, | ||
223 | {1, ACPI_RLARGE(struct aml_resource_address64), | ||
224 | ACPI_RS_SIZE(struct acpi_resource_address64)}, | ||
225 | {0, ACPI_RLARGE(struct aml_resource_extended_address64), | ||
226 | ACPI_RS_SIZE(struct acpi_resource_extended_address64)} | ||
227 | }; | 204 | }; |
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 @@ | |||
47 | #define _COMPONENT ACPI_RESOURCES | 47 | #define _COMPONENT ACPI_RESOURCES |
48 | ACPI_MODULE_NAME("rslist") | 48 | ACPI_MODULE_NAME("rslist") |
49 | 49 | ||
50 | /* Local prototypes */ | ||
51 | static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 | ||
52 | resource_type); | ||
53 | |||
54 | static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); | ||
55 | |||
56 | /******************************************************************************* | ||
57 | * | ||
58 | * FUNCTION: acpi_rs_validate_resource_length | ||
59 | * | ||
60 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
61 | * | ||
62 | * RETURN: Status - AE_OK if the resource length appears valid | ||
63 | * | ||
64 | * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must | ||
65 | * have the exact length; variable-length descriptors must be | ||
66 | * at least as long as the minimum. Certain Small descriptors | ||
67 | * can vary in size by at most one byte. | ||
68 | * | ||
69 | ******************************************************************************/ | ||
70 | |||
71 | static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) | ||
72 | { | ||
73 | struct acpi_resource_info *resource_info; | ||
74 | u16 minimum_aml_resource_length; | ||
75 | u16 resource_length; | ||
76 | |||
77 | ACPI_FUNCTION_ENTRY(); | ||
78 | |||
79 | /* Get the size and type info about this resource descriptor */ | ||
80 | |||
81 | resource_info = | ||
82 | acpi_rs_get_resource_info(aml->small_header.descriptor_type); | ||
83 | if (!resource_info) { | ||
84 | return (AE_AML_INVALID_RESOURCE_TYPE); | ||
85 | } | ||
86 | |||
87 | resource_length = acpi_ut_get_resource_length(aml); | ||
88 | minimum_aml_resource_length = | ||
89 | resource_info->minimum_aml_resource_length; | ||
90 | |||
91 | /* Validate based upon the type of resource, fixed length or variable */ | ||
92 | |||
93 | if (resource_info->length_type == ACPI_FIXED_LENGTH) { | ||
94 | /* Fixed length resource, length must match exactly */ | ||
95 | |||
96 | if (resource_length != minimum_aml_resource_length) { | ||
97 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
98 | } | ||
99 | } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { | ||
100 | /* Variable length resource, must be at least the minimum */ | ||
101 | |||
102 | if (resource_length < minimum_aml_resource_length) { | ||
103 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
104 | } | ||
105 | } else { | ||
106 | /* Small variable length resource, allowed to be (Min) or (Min-1) */ | ||
107 | |||
108 | if ((resource_length > minimum_aml_resource_length) || | ||
109 | (resource_length < (minimum_aml_resource_length - 1))) { | ||
110 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | return (AE_OK); | ||
115 | } | ||
116 | |||
117 | /******************************************************************************* | ||
118 | * | ||
119 | * FUNCTION: acpi_rs_get_conversion_info | ||
120 | * | ||
121 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
122 | * | ||
123 | * RETURN: Pointer to the resource conversion info table | ||
124 | * | ||
125 | * DESCRIPTION: Get the conversion table associated with this resource type | ||
126 | * | ||
127 | ******************************************************************************/ | ||
128 | |||
129 | static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) | ||
130 | { | ||
131 | ACPI_FUNCTION_ENTRY(); | ||
132 | |||
133 | /* Determine if this is a small or large resource */ | ||
134 | |||
135 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
136 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
137 | |||
138 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { | ||
139 | return (NULL); | ||
140 | } | ||
141 | |||
142 | return (acpi_gbl_lg_get_resource_dispatch[(resource_type & | ||
143 | ACPI_RESOURCE_NAME_LARGE_MASK)]); | ||
144 | } else { | ||
145 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
146 | |||
147 | return (acpi_gbl_sm_get_resource_dispatch[((resource_type & | ||
148 | ACPI_RESOURCE_NAME_SMALL_MASK) | ||
149 | >> 3)]); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /******************************************************************************* | 50 | /******************************************************************************* |
154 | * | 51 | * |
155 | * FUNCTION: acpi_rs_convert_aml_to_resources | 52 | * FUNCTION: acpi_rs_convert_aml_to_resources |
156 | * | 53 | * |
157 | * PARAMETERS: aml_buffer - Pointer to the resource byte stream | 54 | * PARAMETERS: Aml - Pointer to the resource byte stream |
158 | * aml_buffer_length - Length of aml_buffer | 55 | * aml_length - Length of Aml |
159 | * output_buffer - Pointer to the buffer that will | 56 | * output_buffer - Pointer to the buffer that will |
160 | * contain the output structures | 57 | * contain the output structures |
161 | * | 58 | * |
@@ -165,42 +62,24 @@ static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) | |||
165 | * linked list of resources in the caller's output buffer | 62 | * linked list of resources in the caller's output buffer |
166 | * | 63 | * |
167 | ******************************************************************************/ | 64 | ******************************************************************************/ |
168 | |||
169 | acpi_status | 65 | acpi_status |
170 | acpi_rs_convert_aml_to_resources(u8 * aml_buffer, | 66 | acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) |
171 | u32 aml_buffer_length, u8 * output_buffer) | ||
172 | { | 67 | { |
173 | u8 *buffer = output_buffer; | 68 | struct acpi_resource *resource = (void *)output_buffer; |
174 | acpi_status status; | 69 | acpi_status status; |
175 | acpi_size bytes_parsed = 0; | 70 | u8 resource_index; |
176 | struct acpi_resource *resource; | 71 | u8 *end_aml; |
177 | acpi_rsdesc_size descriptor_length; | ||
178 | struct acpi_rsconvert_info *info; | ||
179 | 72 | ||
180 | ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); | 73 | ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); |
181 | 74 | ||
182 | /* Loop until end-of-buffer or an end_tag is found */ | 75 | end_aml = aml + aml_length; |
183 | |||
184 | while (bytes_parsed < aml_buffer_length) { | ||
185 | /* Get the conversion table associated with this Descriptor Type */ | ||
186 | |||
187 | info = acpi_rs_get_conversion_info(*aml_buffer); | ||
188 | if (!info) { | ||
189 | /* No table indicates an invalid resource type */ | ||
190 | 76 | ||
191 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 77 | /* Loop until end-of-buffer or an end_tag is found */ |
192 | } | ||
193 | 78 | ||
194 | descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); | 79 | while (aml < end_aml) { |
80 | /* Validate the Resource Type and Resource Length */ | ||
195 | 81 | ||
196 | /* | 82 | status = acpi_ut_validate_resource(aml, &resource_index); |
197 | * Perform limited validation of the resource length, based upon | ||
198 | * what we know about the resource type | ||
199 | */ | ||
200 | status = | ||
201 | acpi_rs_validate_resource_length(ACPI_CAST_PTR | ||
202 | (union aml_resource, | ||
203 | aml_buffer)); | ||
204 | if (ACPI_FAILURE(status)) { | 83 | if (ACPI_FAILURE(status)) { |
205 | return_ACPI_STATUS(status); | 84 | return_ACPI_STATUS(status); |
206 | } | 85 | } |
@@ -208,42 +87,36 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, | |||
208 | /* Convert the AML byte stream resource to a local resource struct */ | 87 | /* Convert the AML byte stream resource to a local resource struct */ |
209 | 88 | ||
210 | status = | 89 | status = |
211 | acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR | 90 | acpi_rs_convert_aml_to_resource(resource, |
212 | (struct acpi_resource, | ||
213 | buffer), | ||
214 | ACPI_CAST_PTR(union | 91 | ACPI_CAST_PTR(union |
215 | aml_resource, | 92 | aml_resource, |
216 | aml_buffer), | 93 | aml), |
217 | info); | 94 | acpi_gbl_get_resource_dispatch |
95 | [resource_index]); | ||
218 | if (ACPI_FAILURE(status)) { | 96 | if (ACPI_FAILURE(status)) { |
219 | ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); | 97 | ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status))); |
220 | return_ACPI_STATUS(status); | 98 | return_ACPI_STATUS(status); |
221 | } | 99 | } |
222 | 100 | ||
223 | /* Set the aligned length of the new resource descriptor */ | ||
224 | |||
225 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer); | ||
226 | resource->length = | ||
227 | (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length); | ||
228 | |||
229 | /* Normal exit on completion of an end_tag resource descriptor */ | 101 | /* Normal exit on completion of an end_tag resource descriptor */ |
230 | 102 | ||
231 | if (acpi_ut_get_resource_type(aml_buffer) == | 103 | if (acpi_ut_get_resource_type(aml) == |
232 | ACPI_RESOURCE_NAME_END_TAG) { | 104 | ACPI_RESOURCE_NAME_END_TAG) { |
233 | return_ACPI_STATUS(AE_OK); | 105 | return_ACPI_STATUS(AE_OK); |
234 | } | 106 | } |
235 | 107 | ||
236 | /* Update counter and point to the next input resource */ | 108 | /* Point to the next input AML resource */ |
237 | 109 | ||
238 | bytes_parsed += descriptor_length; | 110 | aml += acpi_ut_get_descriptor_length(aml); |
239 | aml_buffer += descriptor_length; | ||
240 | 111 | ||
241 | /* Point to the next structure in the output buffer */ | 112 | /* Point to the next structure in the output buffer */ |
242 | 113 | ||
243 | buffer += resource->length; | 114 | resource = |
115 | ACPI_PTR_ADD(struct acpi_resource, resource, | ||
116 | resource->length); | ||
244 | } | 117 | } |
245 | 118 | ||
246 | /* Completed buffer, but did not find an end_tag resource descriptor */ | 119 | /* Did not find an end_tag resource descriptor */ |
247 | 120 | ||
248 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); | 121 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
249 | } | 122 | } |
@@ -271,16 +144,16 @@ acpi_status | |||
271 | acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | 144 | acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, |
272 | acpi_size aml_size_needed, u8 * output_buffer) | 145 | acpi_size aml_size_needed, u8 * output_buffer) |
273 | { | 146 | { |
274 | u8 *aml_buffer = output_buffer; | 147 | u8 *aml = output_buffer; |
275 | u8 *end_aml_buffer = output_buffer + aml_size_needed; | 148 | u8 *end_aml = output_buffer + aml_size_needed; |
276 | acpi_status status; | 149 | acpi_status status; |
277 | 150 | ||
278 | ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); | 151 | ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); |
279 | 152 | ||
280 | /* Walk the resource descriptor list, convert each descriptor */ | 153 | /* Walk the resource descriptor list, convert each descriptor */ |
281 | 154 | ||
282 | while (aml_buffer < end_aml_buffer) { | 155 | while (aml < end_aml) { |
283 | /* Validate the Resource Type */ | 156 | /* Validate the (internal) Resource Type */ |
284 | 157 | ||
285 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | 158 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
286 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 159 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
@@ -294,7 +167,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
294 | status = acpi_rs_convert_resource_to_aml(resource, | 167 | status = acpi_rs_convert_resource_to_aml(resource, |
295 | ACPI_CAST_PTR(union | 168 | ACPI_CAST_PTR(union |
296 | aml_resource, | 169 | aml_resource, |
297 | aml_buffer), | 170 | aml), |
298 | acpi_gbl_set_resource_dispatch | 171 | acpi_gbl_set_resource_dispatch |
299 | [resource->type]); | 172 | [resource->type]); |
300 | if (ACPI_FAILURE(status)) { | 173 | if (ACPI_FAILURE(status)) { |
@@ -305,9 +178,8 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
305 | /* Perform final sanity check on the new AML resource descriptor */ | 178 | /* Perform final sanity check on the new AML resource descriptor */ |
306 | 179 | ||
307 | status = | 180 | status = |
308 | acpi_rs_validate_resource_length(ACPI_CAST_PTR | 181 | acpi_ut_validate_resource(ACPI_CAST_PTR |
309 | (union aml_resource, | 182 | (union aml_resource, aml), NULL); |
310 | aml_buffer)); | ||
311 | if (ACPI_FAILURE(status)) { | 183 | if (ACPI_FAILURE(status)) { |
312 | return_ACPI_STATUS(status); | 184 | return_ACPI_STATUS(status); |
313 | } | 185 | } |
@@ -322,18 +194,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
322 | 194 | ||
323 | /* | 195 | /* |
324 | * Extract the total length of the new descriptor and set the | 196 | * Extract the total length of the new descriptor and set the |
325 | * aml_buffer to point to the next (output) resource descriptor | 197 | * Aml to point to the next (output) resource descriptor |
326 | */ | 198 | */ |
327 | aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); | 199 | aml += acpi_ut_get_descriptor_length(aml); |
328 | 200 | ||
329 | /* Point to the next input resource descriptor */ | 201 | /* Point to the next input resource descriptor */ |
330 | 202 | ||
331 | resource = | 203 | resource = |
332 | ACPI_PTR_ADD(struct acpi_resource, resource, | 204 | ACPI_PTR_ADD(struct acpi_resource, resource, |
333 | resource->length); | 205 | resource->length); |
334 | |||
335 | /* Check for end-of-list, normal exit */ | ||
336 | |||
337 | } | 206 | } |
338 | 207 | ||
339 | /* Completed buffer, but did not find an end_tag resource descriptor */ | 208 | /* 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) | |||
65 | acpi_native_uint i; | 65 | acpi_native_uint i; |
66 | u8 bit_count; | 66 | u8 bit_count; |
67 | 67 | ||
68 | ACPI_FUNCTION_ENTRY(); | ||
69 | |||
68 | /* Decode the mask bits */ | 70 | /* Decode the mask bits */ |
69 | 71 | ||
70 | for (i = 0, bit_count = 0; mask; i++) { | 72 | for (i = 0, bit_count = 0; mask; i++) { |
@@ -97,6 +99,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) | |||
97 | acpi_native_uint i; | 99 | acpi_native_uint i; |
98 | u16 mask; | 100 | u16 mask; |
99 | 101 | ||
102 | ACPI_FUNCTION_ENTRY(); | ||
103 | |||
100 | /* Encode the list into a single bitmask */ | 104 | /* Encode the list into a single bitmask */ |
101 | 105 | ||
102 | for (i = 0, mask = 0; i < count; i++) { | 106 | 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) | |||
128 | { | 132 | { |
129 | acpi_native_uint i; | 133 | acpi_native_uint i; |
130 | 134 | ||
135 | ACPI_FUNCTION_ENTRY(); | ||
136 | |||
131 | /* One move per item */ | 137 | /* One move per item */ |
132 | 138 | ||
133 | for (i = 0; i < item_count; i++) { | 139 | 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) | |||
168 | 174 | ||
169 | /******************************************************************************* | 175 | /******************************************************************************* |
170 | * | 176 | * |
171 | * FUNCTION: acpi_rs_get_resource_info | ||
172 | * | ||
173 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
174 | * | ||
175 | * RETURN: Pointer to the resource conversion handler | ||
176 | * | ||
177 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
178 | * a resource descriptor. | ||
179 | * | ||
180 | ******************************************************************************/ | ||
181 | |||
182 | struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) | ||
183 | { | ||
184 | struct acpi_resource_info *size_info; | ||
185 | |||
186 | ACPI_FUNCTION_ENTRY(); | ||
187 | |||
188 | /* Determine if this is a small or large resource */ | ||
189 | |||
190 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
191 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
192 | |||
193 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { | ||
194 | return (NULL); | ||
195 | } | ||
196 | |||
197 | size_info = &acpi_gbl_lg_resource_info[(resource_type & | ||
198 | ACPI_RESOURCE_NAME_LARGE_MASK)]; | ||
199 | } else { | ||
200 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
201 | |||
202 | size_info = &acpi_gbl_sm_resource_info[((resource_type & | ||
203 | ACPI_RESOURCE_NAME_SMALL_MASK) | ||
204 | >> 3)]; | ||
205 | } | ||
206 | |||
207 | /* Zero entry indicates an invalid resource type */ | ||
208 | |||
209 | if (!size_info->minimum_internal_struct_length) { | ||
210 | return (NULL); | ||
211 | } | ||
212 | |||
213 | return (size_info); | ||
214 | } | ||
215 | |||
216 | /******************************************************************************* | ||
217 | * | ||
218 | * FUNCTION: acpi_rs_set_resource_length | 177 | * FUNCTION: acpi_rs_set_resource_length |
219 | * | 178 | * |
220 | * PARAMETERS: total_length - Length of the AML descriptor, including | 179 | * PARAMETERS: total_length - Length of the AML descriptor, including |
@@ -238,25 +197,20 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length, | |||
238 | 197 | ||
239 | ACPI_FUNCTION_ENTRY(); | 198 | ACPI_FUNCTION_ENTRY(); |
240 | 199 | ||
241 | /* Determine if this is a small or large resource */ | 200 | /* Length is the total descriptor length minus the header length */ |
242 | 201 | ||
243 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | 202 | resource_length = (acpi_rs_length) |
244 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | 203 | (total_length - acpi_ut_get_resource_header_length(aml)); |
245 | 204 | ||
246 | resource_length = (acpi_rs_length) | 205 | /* Length is stored differently for large and small descriptors */ |
247 | (total_length - sizeof(struct aml_resource_large_header)); | ||
248 | 206 | ||
249 | /* Insert length into the Large descriptor length field */ | 207 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
208 | /* Large descriptor -- bytes 1-2 contain the 16-bit length */ | ||
250 | 209 | ||
251 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, | 210 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, |
252 | &resource_length); | 211 | &resource_length); |
253 | } else { | 212 | } else { |
254 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | 213 | /* Small descriptor -- bits 2:0 of byte 0 contain the length */ |
255 | |||
256 | resource_length = (acpi_rs_length) | ||
257 | (total_length - sizeof(struct aml_resource_small_header)); | ||
258 | |||
259 | /* Insert length into the descriptor type byte */ | ||
260 | 214 | ||
261 | aml->small_header.descriptor_type = (u8) | 215 | aml->small_header.descriptor_type = (u8) |
262 | 216 | ||
@@ -292,7 +246,7 @@ acpi_rs_set_resource_header(u8 descriptor_type, | |||
292 | { | 246 | { |
293 | ACPI_FUNCTION_ENTRY(); | 247 | ACPI_FUNCTION_ENTRY(); |
294 | 248 | ||
295 | /* Set the Descriptor Type */ | 249 | /* Set the Resource Type */ |
296 | 250 | ||
297 | aml->small_header.descriptor_type = descriptor_type; | 251 | aml->small_header.descriptor_type = descriptor_type; |
298 | 252 | ||
@@ -409,14 +363,14 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, | |||
409 | (char *)&aml_resource_source[1]); | 363 | (char *)&aml_resource_source[1]); |
410 | 364 | ||
411 | return ((acpi_rs_length) total_length); | 365 | return ((acpi_rs_length) total_length); |
412 | } else { | ||
413 | /* resource_source is not present */ | ||
414 | |||
415 | resource_source->index = 0; | ||
416 | resource_source->string_length = 0; | ||
417 | resource_source->string_ptr = NULL; | ||
418 | return (0); | ||
419 | } | 366 | } |
367 | |||
368 | /* resource_source is not present */ | ||
369 | |||
370 | resource_source->index = 0; | ||
371 | resource_source->string_length = 0; | ||
372 | resource_source->string_ptr = NULL; | ||
373 | return (0); | ||
420 | } | 374 | } |
421 | 375 | ||
422 | /******************************************************************************* | 376 | /******************************************************************************* |