Deleted Added
sdiff udiff text old ( 241973 ) new ( 243347 )
full compact
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};
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
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
443
444/*******************************************************************************
445 *
446 * FUNCTION: AcpiUtWalkAmlResources
447 *
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
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 (
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
496 Status = AcpiUtValidateResource (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
556 (void) AcpiUtValidateResource (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 *
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.
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 (
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 {
699 ACPI_RESOURCE_ERROR ((AE_INFO,
700 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
701 AmlResource->CommonSerialBus.Type));
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
718 ACPI_RESOURCE_ERROR ((AE_INFO,
719 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
720 ResourceType));
721 return (AE_AML_INVALID_RESOURCE_TYPE);
722
723BadResourceLength:
724
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));
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
917 Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer,
918 ObjDesc->Buffer.Length, NULL, EndTag);
919
920 return_ACPI_STATUS (Status);
921}