1 /*******************************************************************************
3 * Module Name: utresrc - Resource management utilities
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
153 #include "accommon.h"
157 #define _COMPONENT ACPI_UTILITIES
158 ACPI_MODULE_NAME ("utresrc")
161 #if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
164 * Strings used to decode resource descriptors.
165 * Used by both the disassembler and the debugger resource dump routines
167 const char *AcpiGbl_BmDecode[] =
173 const char *AcpiGbl_ConfigDecode[] =
175 "0 - Good Configuration",
176 "1 - Acceptable Configuration",
177 "2 - Suboptimal Configuration",
178 "3 - ***Invalid Configuration***",
181 const char *AcpiGbl_ConsumeDecode[] =
187 const char *AcpiGbl_DecDecode[] =
193 const char *AcpiGbl_HeDecode[] =
199 const char *AcpiGbl_IoDecode[] =
205 const char *AcpiGbl_LlDecode[] =
213 const char *AcpiGbl_MaxDecode[] =
219 const char *AcpiGbl_MemDecode[] =
227 const char *AcpiGbl_MinDecode[] =
233 const char *AcpiGbl_MtpDecode[] =
235 "AddressRangeMemory",
236 "AddressRangeReserved",
241 const char *AcpiGbl_RngDecode[] =
249 const char *AcpiGbl_RwDecode[] =
255 const char *AcpiGbl_ShrDecode[] =
259 "ExclusiveAndWake", /* ACPI 5.0 */
260 "SharedAndWake" /* ACPI 5.0 */
263 const char *AcpiGbl_SizDecode[] =
271 const char *AcpiGbl_TrsDecode[] =
277 const char *AcpiGbl_TtpDecode[] =
283 const char *AcpiGbl_TypDecode[] =
291 const char *AcpiGbl_PpcDecode[] =
299 const char *AcpiGbl_IorDecode[] =
302 "IoRestrictionInputOnly",
303 "IoRestrictionOutputOnly",
304 "IoRestrictionNoneAndPreserve"
307 const char *AcpiGbl_DtsDecode[] =
317 /* GPIO connection type */
319 const char *AcpiGbl_CtDecode[] =
325 /* Serial bus type */
327 const char *AcpiGbl_SbtDecode[] =
329 "/* UNKNOWN serial bus type */",
335 /* I2C serial bus access mode */
337 const char *AcpiGbl_AmDecode[] =
339 "AddressingMode7Bit",
340 "AddressingMode10Bit"
343 /* I2C serial bus slave mode */
345 const char *AcpiGbl_SmDecode[] =
347 "ControllerInitiated",
351 /* SPI serial bus wire mode */
353 const char *AcpiGbl_WmDecode[] =
359 /* SPI serial clock phase */
361 const char *AcpiGbl_CphDecode[] =
367 /* SPI serial bus clock polarity */
369 const char *AcpiGbl_CpoDecode[] =
375 /* SPI serial bus device polarity */
377 const char *AcpiGbl_DpDecode[] =
383 /* UART serial bus endian */
385 const char *AcpiGbl_EdDecode[] =
391 /* UART serial bus bits per byte */
393 const char *AcpiGbl_BpbDecode[] =
400 "/* UNKNOWN Bits per byte */",
401 "/* UNKNOWN Bits per byte */",
402 "/* UNKNOWN Bits per byte */"
405 /* UART serial bus stop bits */
407 const char *AcpiGbl_SbDecode[] =
411 "StopBitsOnePlusHalf",
415 /* UART serial bus flow control */
417 const char *AcpiGbl_FcDecode[] =
420 "FlowControlHardware",
422 "/* UNKNOWN flow control keyword */"
425 /* UART serial bus parity type */
427 const char *AcpiGbl_PtDecode[] =
434 "/* UNKNOWN parity keyword */",
435 "/* UNKNOWN parity keyword */",
436 "/* UNKNOWN parity keyword */"
443 * Base sizes of the raw AML resource descriptors, indexed by resource type.
444 * Zero indicates a reserved (and therefore invalid) resource type.
446 const UINT8 AcpiGbl_ResourceAmlSizes[] =
448 /* Small descriptors */
454 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
455 ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
456 ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
457 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
458 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
459 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
460 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_DMA),
464 ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
465 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
467 /* Large descriptors */
470 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
471 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
473 ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
474 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
475 ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
476 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
477 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
478 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
479 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
480 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64),
481 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO),
483 ACPI_AML_SIZE_LARGE (AML_RESOURCE_COMMON_SERIALBUS),
486 const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[] =
489 ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS),
490 ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS),
491 ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS),
496 * Resource types, used to validate the resource length field.
497 * The length of fixed-length types must match exactly, variable
498 * lengths must meet the minimum required length, etc.
499 * Zero indicates a reserved (and therefore invalid) resource type.
501 static const UINT8 AcpiGbl_ResourceTypes[] =
503 /* Small descriptors */
509 ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */
510 ACPI_FIXED_LENGTH, /* 05 DMA */
511 ACPI_SMALL_VARIABLE_LENGTH, /* 06 StartDependentFunctions */
512 ACPI_FIXED_LENGTH, /* 07 EndDependentFunctions */
513 ACPI_FIXED_LENGTH, /* 08 IO */
514 ACPI_FIXED_LENGTH, /* 09 FixedIO */
515 ACPI_FIXED_LENGTH, /* 0A FixedDMA */
519 ACPI_VARIABLE_LENGTH, /* 0E VendorShort */
520 ACPI_FIXED_LENGTH, /* 0F EndTag */
522 /* Large descriptors */
525 ACPI_FIXED_LENGTH, /* 01 Memory24 */
526 ACPI_FIXED_LENGTH, /* 02 GenericRegister */
528 ACPI_VARIABLE_LENGTH, /* 04 VendorLong */
529 ACPI_FIXED_LENGTH, /* 05 Memory32 */
530 ACPI_FIXED_LENGTH, /* 06 Memory32Fixed */
531 ACPI_VARIABLE_LENGTH, /* 07 Dword* address */
532 ACPI_VARIABLE_LENGTH, /* 08 Word* address */
533 ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */
534 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */
535 ACPI_FIXED_LENGTH, /* 0B Extended* address */
536 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
538 ACPI_VARIABLE_LENGTH /* 0E *SerialBus */
542 /*******************************************************************************
544 * FUNCTION: AcpiUtWalkAmlResources
546 * PARAMETERS: WalkState - Current walk info
547 * PARAMETERS: Aml - Pointer to the raw AML resource template
548 * AmlLength - Length of the entire template
549 * UserFunction - Called once for each descriptor found. If
550 * NULL, a pointer to the EndTag is returned
551 * Context - Passed to UserFunction
555 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
556 * once for each resource found.
558 ******************************************************************************/
561 AcpiUtWalkAmlResources (
562 ACPI_WALK_STATE *WalkState,
565 ACPI_WALK_AML_CALLBACK UserFunction,
573 UINT8 EndTag[2] = {0x79, 0x00};
576 ACPI_FUNCTION_TRACE (UtWalkAmlResources);
580 * The absolute minimum resource template is one EndTag descriptor.
581 * However, we will treat a lone EndTag as just a simple buffer.
583 if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
585 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
588 /* Point to the end of the resource template buffer */
590 EndAml = Aml + AmlLength;
592 /* Walk the byte list, abort on any invalid descriptor type or length */
596 /* Validate the Resource Type and Resource Length */
598 Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex);
599 if (ACPI_FAILURE (Status))
602 * Exit on failure. Cannot continue because the descriptor
603 * length may be bogus also.
605 return_ACPI_STATUS (Status);
608 /* Get the length of this descriptor */
610 Length = AcpiUtGetDescriptorLength (Aml);
612 /* Invoke the user function */
616 Status = UserFunction (Aml, Length, Offset,
617 ResourceIndex, Context);
618 if (ACPI_FAILURE (Status))
620 return_ACPI_STATUS (Status);
624 /* An EndTag descriptor terminates this resource template */
626 if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
629 * There must be at least one more byte in the buffer for
630 * the 2nd byte of the EndTag
632 if ((Aml + 1) >= EndAml)
634 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
638 * The EndTag opcode must be followed by a zero byte.
639 * Although this byte is technically defined to be a checksum,
640 * in practice, all ASL compilers set this byte to zero.
644 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
647 /* Return the pointer to the EndTag if requested */
654 /* Check if buffer is defined to be longer than the resource length */
656 if (AmlLength > (Offset + Length))
658 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
663 return_ACPI_STATUS (AE_OK);
670 /* Did not find an EndTag descriptor */
674 /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */
676 (void) AcpiUtValidateResource (WalkState, EndTag, &ResourceIndex);
677 Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context);
678 if (ACPI_FAILURE (Status))
680 return_ACPI_STATUS (Status);
684 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
688 /*******************************************************************************
690 * FUNCTION: AcpiUtValidateResource
692 * PARAMETERS: WalkState - Current walk info
693 * Aml - Pointer to the raw AML resource descriptor
694 * ReturnIndex - Where the resource index is returned. NULL
695 * if the index is not required.
697 * RETURN: Status, and optionally the Index into the global resource tables
699 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
700 * Type and Resource Length. Returns an index into the global
701 * resource information/dispatch tables for later use.
703 ******************************************************************************/
706 AcpiUtValidateResource (
707 ACPI_WALK_STATE *WalkState,
711 AML_RESOURCE *AmlResource;
714 ACPI_RS_LENGTH ResourceLength;
715 ACPI_RS_LENGTH MinimumResourceLength;
718 ACPI_FUNCTION_ENTRY ();
722 * 1) Validate the ResourceType field (Byte 0)
724 ResourceType = ACPI_GET8 (Aml);
727 *ReturnIndex = 0; /* silence bogus gcc warning */
731 * Byte 0 contains the descriptor name (Resource Type)
732 * Examine the large/small bit in the resource header
734 if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
736 /* Verify the large resource type (name) against the max */
738 if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
740 goto InvalidResource;
744 * Large Resource Type -- bits 6:0 contain the name
745 * Translate range 0x80-0x8B to index range 0x10-0x1B
747 ResourceIndex = (UINT8) (ResourceType - 0x70);
752 * Small Resource Type -- bits 6:3 contain the name
753 * Shift range to index range 0x00-0x0F
755 ResourceIndex = (UINT8)
756 ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
760 * Check validity of the resource type, via AcpiGbl_ResourceTypes.
761 * Zero indicates an invalid resource.
763 if (!AcpiGbl_ResourceTypes[ResourceIndex])
765 goto InvalidResource;
769 * Validate the ResourceLength field. This ensures that the length
770 * is at least reasonable, and guarantees that it is non-zero.
772 ResourceLength = AcpiUtGetResourceLength (Aml);
773 MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
775 /* Validate based upon the type of resource - fixed length or variable */
777 switch (AcpiGbl_ResourceTypes[ResourceIndex])
779 case ACPI_FIXED_LENGTH:
781 /* Fixed length resource, length must match exactly */
783 if (ResourceLength != MinimumResourceLength)
785 goto BadResourceLength;
789 case ACPI_VARIABLE_LENGTH:
791 /* Variable length resource, length must be at least the minimum */
793 if (ResourceLength < MinimumResourceLength)
795 goto BadResourceLength;
799 case ACPI_SMALL_VARIABLE_LENGTH:
801 /* Small variable length resource, length can be (Min) or (Min-1) */
803 if ((ResourceLength > MinimumResourceLength) ||
804 (ResourceLength < (MinimumResourceLength - 1)))
806 goto BadResourceLength;
812 /* Shouldn't happen (because of validation earlier), but be sure */
814 goto InvalidResource;
817 AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
818 if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
820 /* Validate the BusType field */
822 if ((AmlResource->CommonSerialBus.Type == 0) ||
823 (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
827 ACPI_ERROR ((AE_INFO,
828 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
829 AmlResource->CommonSerialBus.Type));
831 return (AE_AML_INVALID_RESOURCE_TYPE);
835 /* Optionally return the resource table index */
839 *ReturnIndex = ResourceIndex;
849 ACPI_ERROR ((AE_INFO,
850 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
853 return (AE_AML_INVALID_RESOURCE_TYPE);
859 ACPI_ERROR ((AE_INFO,
860 "Invalid resource descriptor length: Type "
861 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
862 ResourceType, ResourceLength, MinimumResourceLength));
864 return (AE_AML_BAD_RESOURCE_LENGTH);
868 /*******************************************************************************
870 * FUNCTION: AcpiUtGetResourceType
872 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
874 * RETURN: The Resource Type with no extraneous bits (except the
875 * Large/Small descriptor bit -- this is left alone)
877 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
878 * a resource descriptor.
880 ******************************************************************************/
883 AcpiUtGetResourceType (
886 ACPI_FUNCTION_ENTRY ();
890 * Byte 0 contains the descriptor name (Resource Type)
891 * Examine the large/small bit in the resource header
893 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
895 /* Large Resource Type -- bits 6:0 contain the name */
897 return (ACPI_GET8 (Aml));
901 /* Small Resource Type -- bits 6:3 contain the name */
903 return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
908 /*******************************************************************************
910 * FUNCTION: AcpiUtGetResourceLength
912 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
914 * RETURN: Byte Length
916 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
917 * definition, this does not include the size of the descriptor
918 * header or the length field itself.
920 ******************************************************************************/
923 AcpiUtGetResourceLength (
926 ACPI_RS_LENGTH ResourceLength;
929 ACPI_FUNCTION_ENTRY ();
933 * Byte 0 contains the descriptor name (Resource Type)
934 * Examine the large/small bit in the resource header
936 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
938 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
940 ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
945 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
947 ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
948 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
951 return (ResourceLength);
955 /*******************************************************************************
957 * FUNCTION: AcpiUtGetResourceHeaderLength
959 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
961 * RETURN: Length of the AML header (depends on large/small descriptor)
963 * DESCRIPTION: Get the length of the header for this resource.
965 ******************************************************************************/
968 AcpiUtGetResourceHeaderLength (
971 ACPI_FUNCTION_ENTRY ();
974 /* Examine the large/small bit in the resource header */
976 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
978 return (sizeof (AML_RESOURCE_LARGE_HEADER));
982 return (sizeof (AML_RESOURCE_SMALL_HEADER));
987 /*******************************************************************************
989 * FUNCTION: AcpiUtGetDescriptorLength
991 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
993 * RETURN: Byte length
995 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
996 * length of the descriptor header and the length field itself.
997 * Used to walk descriptor lists.
999 ******************************************************************************/
1002 AcpiUtGetDescriptorLength (
1005 ACPI_FUNCTION_ENTRY ();
1009 * Get the Resource Length (does not include header length) and add
1010 * the header length (depends on if this is a small or large resource)
1012 return (AcpiUtGetResourceLength (Aml) +
1013 AcpiUtGetResourceHeaderLength (Aml));
1017 /*******************************************************************************
1019 * FUNCTION: AcpiUtGetResourceEndTag
1021 * PARAMETERS: ObjDesc - The resource template buffer object
1022 * EndTag - Where the pointer to the EndTag is returned
1024 * RETURN: Status, pointer to the end tag
1026 * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
1027 * Note: allows a buffer length of zero.
1029 ******************************************************************************/
1032 AcpiUtGetResourceEndTag (
1033 ACPI_OPERAND_OBJECT *ObjDesc,
1039 ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
1042 /* Allow a buffer length of zero */
1044 if (!ObjDesc->Buffer.Length)
1046 *EndTag = ObjDesc->Buffer.Pointer;
1047 return_ACPI_STATUS (AE_OK);
1050 /* Validate the template and get a pointer to the EndTag */
1052 Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer,
1053 ObjDesc->Buffer.Length, NULL, (void **) EndTag);
1055 return_ACPI_STATUS (Status);