aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/utresrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpica/utresrc.c')
-rw-r--r--drivers/acpi/acpica/utresrc.c81
1 files changed, 42 insertions, 39 deletions
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index e38bef4980bc..8f8eab98ed79 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -127,7 +127,9 @@ const char *acpi_gbl_rw_decode[] = {
127 127
128const char *acpi_gbl_shr_decode[] = { 128const char *acpi_gbl_shr_decode[] = {
129 "Exclusive", 129 "Exclusive",
130 "Shared" 130 "Shared",
131 "ExclusiveAndWake", /* ACPI 5.0 */
132 "SharedAndWake" /* ACPI 5.0 */
131}; 133};
132 134
133const char *acpi_gbl_siz_decode[] = { 135const char *acpi_gbl_siz_decode[] = {
@@ -383,26 +385,16 @@ static const u8 acpi_gbl_resource_types[] = {
383 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */ 385 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */
384}; 386};
385 387
386/*
387 * For the iASL compiler/disassembler, we don't want any error messages
388 * because the disassembler uses the resource validation code to determine
389 * if Buffer objects are actually Resource Templates.
390 */
391#ifdef ACPI_ASL_COMPILER
392#define ACPI_RESOURCE_ERROR(plist)
393#else
394#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
395#endif
396
397/******************************************************************************* 388/*******************************************************************************
398 * 389 *
399 * FUNCTION: acpi_ut_walk_aml_resources 390 * FUNCTION: acpi_ut_walk_aml_resources
400 * 391 *
401 * PARAMETERS: aml - Pointer to the raw AML resource template 392 * PARAMETERS: walk_state - Current walk info
402 * aml_length - Length of the entire template 393 * PARAMETERS: aml - Pointer to the raw AML resource template
403 * user_function - Called once for each descriptor found. If 394 * aml_length - Length of the entire template
404 * NULL, a pointer to the end_tag is returned 395 * user_function - Called once for each descriptor found. If
405 * context - Passed to user_function 396 * NULL, a pointer to the end_tag is returned
397 * context - Passed to user_function
406 * 398 *
407 * RETURN: Status 399 * RETURN: Status
408 * 400 *
@@ -412,7 +404,8 @@ static const u8 acpi_gbl_resource_types[] = {
412 ******************************************************************************/ 404 ******************************************************************************/
413 405
414acpi_status 406acpi_status
415acpi_ut_walk_aml_resources(u8 * aml, 407acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state,
408 u8 *aml,
416 acpi_size aml_length, 409 acpi_size aml_length,
417 acpi_walk_aml_callback user_function, void **context) 410 acpi_walk_aml_callback user_function, void **context)
418{ 411{
@@ -441,7 +434,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
441 434
442 /* Validate the Resource Type and Resource Length */ 435 /* Validate the Resource Type and Resource Length */
443 436
444 status = acpi_ut_validate_resource(aml, &resource_index); 437 status =
438 acpi_ut_validate_resource(walk_state, aml, &resource_index);
445 if (ACPI_FAILURE(status)) { 439 if (ACPI_FAILURE(status)) {
446 /* 440 /*
447 * Exit on failure. Cannot continue because the descriptor length 441 * Exit on failure. Cannot continue because the descriptor length
@@ -498,7 +492,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
498 492
499 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */ 493 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
500 494
501 (void)acpi_ut_validate_resource(end_tag, &resource_index); 495 (void)acpi_ut_validate_resource(walk_state, end_tag,
496 &resource_index);
502 status = 497 status =
503 user_function(end_tag, 2, offset, resource_index, context); 498 user_function(end_tag, 2, offset, resource_index, context);
504 if (ACPI_FAILURE(status)) { 499 if (ACPI_FAILURE(status)) {
@@ -513,9 +508,10 @@ acpi_ut_walk_aml_resources(u8 * aml,
513 * 508 *
514 * FUNCTION: acpi_ut_validate_resource 509 * FUNCTION: acpi_ut_validate_resource
515 * 510 *
516 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 511 * PARAMETERS: walk_state - Current walk info
517 * return_index - Where the resource index is returned. NULL 512 * aml - Pointer to the raw AML resource descriptor
518 * if the index is not required. 513 * return_index - Where the resource index is returned. NULL
514 * if the index is not required.
519 * 515 *
520 * RETURN: Status, and optionally the Index into the global resource tables 516 * RETURN: Status, and optionally the Index into the global resource tables
521 * 517 *
@@ -525,7 +521,9 @@ acpi_ut_walk_aml_resources(u8 * aml,
525 * 521 *
526 ******************************************************************************/ 522 ******************************************************************************/
527 523
528acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 524acpi_status
525acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
526 void *aml, u8 *return_index)
529{ 527{
530 union aml_resource *aml_resource; 528 union aml_resource *aml_resource;
531 u8 resource_type; 529 u8 resource_type;
@@ -627,10 +625,12 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
627 if ((aml_resource->common_serial_bus.type == 0) || 625 if ((aml_resource->common_serial_bus.type == 0) ||
628 (aml_resource->common_serial_bus.type > 626 (aml_resource->common_serial_bus.type >
629 AML_RESOURCE_MAX_SERIALBUSTYPE)) { 627 AML_RESOURCE_MAX_SERIALBUSTYPE)) {
630 ACPI_RESOURCE_ERROR((AE_INFO, 628 if (walk_state) {
631 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", 629 ACPI_ERROR((AE_INFO,
632 aml_resource->common_serial_bus. 630 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
633 type)); 631 aml_resource->common_serial_bus.
632 type));
633 }
634 return (AE_AML_INVALID_RESOURCE_TYPE); 634 return (AE_AML_INVALID_RESOURCE_TYPE);
635 } 635 }
636 } 636 }
@@ -645,18 +645,22 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
645 645
646 invalid_resource: 646 invalid_resource:
647 647
648 ACPI_RESOURCE_ERROR((AE_INFO, 648 if (walk_state) {
649 "Invalid/unsupported resource descriptor: Type 0x%2.2X", 649 ACPI_ERROR((AE_INFO,
650 resource_type)); 650 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
651 resource_type));
652 }
651 return (AE_AML_INVALID_RESOURCE_TYPE); 653 return (AE_AML_INVALID_RESOURCE_TYPE);
652 654
653 bad_resource_length: 655 bad_resource_length:
654 656
655 ACPI_RESOURCE_ERROR((AE_INFO, 657 if (walk_state) {
656 "Invalid resource descriptor length: Type " 658 ACPI_ERROR((AE_INFO,
657 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", 659 "Invalid resource descriptor length: Type "
658 resource_type, resource_length, 660 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
659 minimum_resource_length)); 661 resource_type, resource_length,
662 minimum_resource_length));
663 }
660 return (AE_AML_BAD_RESOURCE_LENGTH); 664 return (AE_AML_BAD_RESOURCE_LENGTH);
661} 665}
662 666
@@ -800,8 +804,7 @@ u32 acpi_ut_get_descriptor_length(void *aml)
800 ******************************************************************************/ 804 ******************************************************************************/
801 805
802acpi_status 806acpi_status
803acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, 807acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag)
804 u8 ** end_tag)
805{ 808{
806 acpi_status status; 809 acpi_status status;
807 810
@@ -816,7 +819,7 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
816 819
817 /* Validate the template and get a pointer to the end_tag */ 820 /* Validate the template and get a pointer to the end_tag */
818 821
819 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer, 822 status = acpi_ut_walk_aml_resources(NULL, obj_desc->buffer.pointer,
820 obj_desc->buffer.length, NULL, 823 obj_desc->buffer.length, NULL,
821 (void **)end_tag); 824 (void **)end_tag);
822 825