1/******************************************************************************* 2 * 3 * Module Name: utresrc - Resource management utilities 4 * 5 ******************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2012, Intel Corp. --- 134 unchanged lines hidden (view full) --- 143{ 144 "ReadOnly", 145 "ReadWrite" 146}; 147 148const char *AcpiGbl_ShrDecode[] = 149{ 150 "Exclusive", |
151 "Shared", 152 "ExclusiveAndWake", /* ACPI 5.0 */ 153 "SharedAndWake" /* ACPI 5.0 */ |
154}; 155 156const char *AcpiGbl_SizDecode[] = 157{ 158 "Transfer8", 159 "Transfer8_16", 160 "Transfer16", 161 "InvalidSize" --- 264 unchanged lines hidden (view full) --- 426 ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */ 427 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */ 428 ACPI_FIXED_LENGTH, /* 0B Extended* address */ 429 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */ 430 0, 431 ACPI_VARIABLE_LENGTH /* 0E *SerialBus */ 432}; 433 |
434 |
435/******************************************************************************* 436 * 437 * FUNCTION: AcpiUtWalkAmlResources 438 * |
439 * PARAMETERS: WalkState - Current walk info 440 * PARAMETERS: Aml - Pointer to the raw AML resource template 441 * AmlLength - Length of the entire template 442 * UserFunction - Called once for each descriptor found. If 443 * NULL, a pointer to the EndTag is returned 444 * Context - Passed to UserFunction |
445 * 446 * RETURN: Status 447 * 448 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called 449 * once for each resource found. 450 * 451 ******************************************************************************/ 452 453ACPI_STATUS 454AcpiUtWalkAmlResources ( |
455 ACPI_WALK_STATE *WalkState, |
456 UINT8 *Aml, 457 ACPI_SIZE AmlLength, 458 ACPI_WALK_AML_CALLBACK UserFunction, 459 void *Context) 460{ 461 ACPI_STATUS Status; 462 UINT8 *EndAml; 463 UINT8 ResourceIndex; --- 17 unchanged lines hidden (view full) --- 481 EndAml = Aml + AmlLength; 482 483 /* Walk the byte list, abort on any invalid descriptor type or length */ 484 485 while (Aml < EndAml) 486 { 487 /* Validate the Resource Type and Resource Length */ 488 |
489 Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex); |
490 if (ACPI_FAILURE (Status)) 491 { 492 /* 493 * Exit on failure. Cannot continue because the descriptor length 494 * may be bogus also. 495 */ 496 return_ACPI_STATUS (Status); 497 } --- 43 unchanged lines hidden (view full) --- 541 } 542 543 /* Did not find an EndTag descriptor */ 544 545 if (UserFunction) 546 { 547 /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */ 548 |
549 (void) AcpiUtValidateResource (WalkState, EndTag, &ResourceIndex); |
550 Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context); 551 if (ACPI_FAILURE (Status)) 552 { 553 return_ACPI_STATUS (Status); 554 } 555 } 556 557 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 558} 559 560 561/******************************************************************************* 562 * 563 * FUNCTION: AcpiUtValidateResource 564 * |
565 * PARAMETERS: WalkState - Current walk info 566 * Aml - Pointer to the raw AML resource descriptor 567 * ReturnIndex - Where the resource index is returned. NULL 568 * if the index is not required. |
569 * 570 * RETURN: Status, and optionally the Index into the global resource tables 571 * 572 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource 573 * Type and Resource Length. Returns an index into the global 574 * resource information/dispatch tables for later use. 575 * 576 ******************************************************************************/ 577 578ACPI_STATUS 579AcpiUtValidateResource ( |
580 ACPI_WALK_STATE *WalkState, |
581 void *Aml, 582 UINT8 *ReturnIndex) 583{ 584 AML_RESOURCE *AmlResource; 585 UINT8 ResourceType; 586 UINT8 ResourceIndex; 587 ACPI_RS_LENGTH ResourceLength; 588 ACPI_RS_LENGTH MinimumResourceLength; --- 97 unchanged lines hidden (view full) --- 686 AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml); 687 if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS) 688 { 689 /* Validate the BusType field */ 690 691 if ((AmlResource->CommonSerialBus.Type == 0) || 692 (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)) 693 { |
694 if (WalkState) 695 { 696 ACPI_ERROR ((AE_INFO, 697 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", 698 AmlResource->CommonSerialBus.Type)); 699 } |
700 return (AE_AML_INVALID_RESOURCE_TYPE); 701 } 702 } 703 704 /* Optionally return the resource table index */ 705 706 if (ReturnIndex) 707 { 708 *ReturnIndex = ResourceIndex; 709 } 710 711 return (AE_OK); 712 713 714InvalidResource: 715 |
716 if (WalkState) 717 { 718 ACPI_ERROR ((AE_INFO, 719 "Invalid/unsupported resource descriptor: Type 0x%2.2X", 720 ResourceType)); 721 } |
722 return (AE_AML_INVALID_RESOURCE_TYPE); 723 724BadResourceLength: 725 |
726 if (WalkState) 727 { 728 ACPI_ERROR ((AE_INFO, 729 "Invalid resource descriptor length: Type " 730 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", 731 ResourceType, ResourceLength, MinimumResourceLength)); 732 } |
733 return (AE_AML_BAD_RESOURCE_LENGTH); 734} 735 736 737/******************************************************************************* 738 * 739 * FUNCTION: AcpiUtGetResourceType 740 * --- 172 unchanged lines hidden (view full) --- 913 if (!ObjDesc->Buffer.Length) 914 { 915 *EndTag = ObjDesc->Buffer.Pointer; 916 return_ACPI_STATUS (AE_OK); 917 } 918 919 /* Validate the template and get a pointer to the EndTag */ 920 |
921 Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer, |
922 ObjDesc->Buffer.Length, NULL, EndTag); 923 924 return_ACPI_STATUS (Status); 925} |