utresrc.c (241973) | utresrc.c (243347) |
---|---|
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", | 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" | 151 "Shared", 152 "ExclusiveAndWake", /* ACPI 5.0 */ 153 "SharedAndWake" /* ACPI 5.0 */ |
152}; 153 154const char *AcpiGbl_SizDecode[] = 155{ 156 "Transfer8", 157 "Transfer8_16", 158 "Transfer16", 159 "InvalidSize" --- 264 unchanged lines hidden (view full) --- 424 ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */ 425 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */ 426 ACPI_FIXED_LENGTH, /* 0B Extended* address */ 427 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */ 428 0, 429 ACPI_VARIABLE_LENGTH /* 0E *SerialBus */ 430}; 431 | 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 |
432/* 433 * For the iASL compiler/disassembler, we don't want any error messages 434 * because the disassembler uses the resource validation code to determine 435 * if Buffer objects are actually Resource Templates. 436 */ 437#ifdef ACPI_ASL_COMPILER 438#define ACPI_RESOURCE_ERROR(plist) 439#else 440#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist) 441#endif | |
442 | 434 |
443 | |
444/******************************************************************************* 445 * 446 * FUNCTION: AcpiUtWalkAmlResources 447 * | 435/******************************************************************************* 436 * 437 * FUNCTION: AcpiUtWalkAmlResources 438 * |
448 * PARAMETERS: Aml - Pointer to the raw AML resource template 449 * AmlLength - Length of the entire template 450 * UserFunction - Called once for each descriptor found. If 451 * NULL, a pointer to the EndTag is returned 452 * Context - Passed to UserFunction | 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 |
453 * 454 * RETURN: Status 455 * 456 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called 457 * once for each resource found. 458 * 459 ******************************************************************************/ 460 461ACPI_STATUS 462AcpiUtWalkAmlResources ( | 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, |
|
463 UINT8 *Aml, 464 ACPI_SIZE AmlLength, 465 ACPI_WALK_AML_CALLBACK UserFunction, 466 void *Context) 467{ 468 ACPI_STATUS Status; 469 UINT8 *EndAml; 470 UINT8 ResourceIndex; --- 17 unchanged lines hidden (view full) --- 488 EndAml = Aml + AmlLength; 489 490 /* Walk the byte list, abort on any invalid descriptor type or length */ 491 492 while (Aml < EndAml) 493 { 494 /* Validate the Resource Type and Resource Length */ 495 | 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 |
496 Status = AcpiUtValidateResource (Aml, &ResourceIndex); | 489 Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex); |
497 if (ACPI_FAILURE (Status)) 498 { 499 /* 500 * Exit on failure. Cannot continue because the descriptor length 501 * may be bogus also. 502 */ 503 return_ACPI_STATUS (Status); 504 } --- 43 unchanged lines hidden (view full) --- 548 } 549 550 /* Did not find an EndTag descriptor */ 551 552 if (UserFunction) 553 { 554 /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */ 555 | 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 |
556 (void) AcpiUtValidateResource (EndTag, &ResourceIndex); | 549 (void) AcpiUtValidateResource (WalkState, EndTag, &ResourceIndex); |
557 Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context); 558 if (ACPI_FAILURE (Status)) 559 { 560 return_ACPI_STATUS (Status); 561 } 562 } 563 564 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 565} 566 567 568/******************************************************************************* 569 * 570 * FUNCTION: AcpiUtValidateResource 571 * | 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 * |
572 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 573 * ReturnIndex - Where the resource index is returned. NULL 574 * if the index is not required. | 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. |
575 * 576 * RETURN: Status, and optionally the Index into the global resource tables 577 * 578 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource 579 * Type and Resource Length. Returns an index into the global 580 * resource information/dispatch tables for later use. 581 * 582 ******************************************************************************/ 583 584ACPI_STATUS 585AcpiUtValidateResource ( | 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, |
|
586 void *Aml, 587 UINT8 *ReturnIndex) 588{ 589 AML_RESOURCE *AmlResource; 590 UINT8 ResourceType; 591 UINT8 ResourceIndex; 592 ACPI_RS_LENGTH ResourceLength; 593 ACPI_RS_LENGTH MinimumResourceLength; --- 97 unchanged lines hidden (view full) --- 691 AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml); 692 if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS) 693 { 694 /* Validate the BusType field */ 695 696 if ((AmlResource->CommonSerialBus.Type == 0) || 697 (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)) 698 { | 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 { |
699 ACPI_RESOURCE_ERROR ((AE_INFO, 700 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", 701 AmlResource->CommonSerialBus.Type)); | 694 if (WalkState) 695 { 696 ACPI_ERROR ((AE_INFO, 697 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", 698 AmlResource->CommonSerialBus.Type)); 699 } |
702 return (AE_AML_INVALID_RESOURCE_TYPE); 703 } 704 } 705 706 /* Optionally return the resource table index */ 707 708 if (ReturnIndex) 709 { 710 *ReturnIndex = ResourceIndex; 711 } 712 713 return (AE_OK); 714 715 716InvalidResource: 717 | 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 |
718 ACPI_RESOURCE_ERROR ((AE_INFO, 719 "Invalid/unsupported resource descriptor: Type 0x%2.2X", 720 ResourceType)); | 716 if (WalkState) 717 { 718 ACPI_ERROR ((AE_INFO, 719 "Invalid/unsupported resource descriptor: Type 0x%2.2X", 720 ResourceType)); 721 } |
721 return (AE_AML_INVALID_RESOURCE_TYPE); 722 723BadResourceLength: 724 | 722 return (AE_AML_INVALID_RESOURCE_TYPE); 723 724BadResourceLength: 725 |
725 ACPI_RESOURCE_ERROR ((AE_INFO, 726 "Invalid resource descriptor length: Type " 727 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", 728 ResourceType, ResourceLength, MinimumResourceLength)); | 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 } |
729 return (AE_AML_BAD_RESOURCE_LENGTH); 730} 731 732 733/******************************************************************************* 734 * 735 * FUNCTION: AcpiUtGetResourceType 736 * --- 172 unchanged lines hidden (view full) --- 909 if (!ObjDesc->Buffer.Length) 910 { 911 *EndTag = ObjDesc->Buffer.Pointer; 912 return_ACPI_STATUS (AE_OK); 913 } 914 915 /* Validate the template and get a pointer to the EndTag */ 916 | 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 |
917 Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, | 921 Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer, |
918 ObjDesc->Buffer.Length, NULL, EndTag); 919 920 return_ACPI_STATUS (Status); 921} | 922 ObjDesc->Buffer.Length, NULL, EndTag); 923 924 return_ACPI_STATUS (Status); 925} |