diff options
Diffstat (limited to 'drivers/acpi/resources/rsutils.c')
-rw-r--r-- | drivers/acpi/resources/rsutils.c | 155 |
1 files changed, 87 insertions, 68 deletions
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 | } |