1 /*******************************************************************************
3 * Module Name: utresrc - Resource management utilities
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2019, 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 *****************************************************************************/
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acresrc.h>
157 #define _COMPONENT ACPI_UTILITIES
158 ACPI_MODULE_NAME ("utresrc")
162 * Base sizes of the raw AML resource descriptors, indexed by resource type.
163 * Zero indicates a reserved (and therefore invalid) resource type.
165 const UINT8 AcpiGbl_ResourceAmlSizes[] =
167 /* Small descriptors */
173 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
174 ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
175 ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
176 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
177 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
178 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
179 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_DMA),
183 ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
184 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
186 /* Large descriptors */
189 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
190 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
192 ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
193 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
194 ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
195 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
196 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
197 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
198 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
199 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64),
200 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO),
201 ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_FUNCTION),
202 ACPI_AML_SIZE_LARGE (AML_RESOURCE_COMMON_SERIALBUS),
203 ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_CONFIG),
204 ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP),
205 ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP_FUNCTION),
206 ACPI_AML_SIZE_LARGE (AML_RESOURCE_PIN_GROUP_CONFIG),
209 const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[] =
212 ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS),
213 ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS),
214 ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS),
219 * Resource types, used to validate the resource length field.
220 * The length of fixed-length types must match exactly, variable
221 * lengths must meet the minimum required length, etc.
222 * Zero indicates a reserved (and therefore invalid) resource type.
224 static const UINT8 AcpiGbl_ResourceTypes[] =
226 /* Small descriptors */
232 ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */
233 ACPI_FIXED_LENGTH, /* 05 DMA */
234 ACPI_SMALL_VARIABLE_LENGTH, /* 06 StartDependentFunctions */
235 ACPI_FIXED_LENGTH, /* 07 EndDependentFunctions */
236 ACPI_FIXED_LENGTH, /* 08 IO */
237 ACPI_FIXED_LENGTH, /* 09 FixedIO */
238 ACPI_FIXED_LENGTH, /* 0A FixedDMA */
242 ACPI_VARIABLE_LENGTH, /* 0E VendorShort */
243 ACPI_FIXED_LENGTH, /* 0F EndTag */
245 /* Large descriptors */
248 ACPI_FIXED_LENGTH, /* 01 Memory24 */
249 ACPI_FIXED_LENGTH, /* 02 GenericRegister */
251 ACPI_VARIABLE_LENGTH, /* 04 VendorLong */
252 ACPI_FIXED_LENGTH, /* 05 Memory32 */
253 ACPI_FIXED_LENGTH, /* 06 Memory32Fixed */
254 ACPI_VARIABLE_LENGTH, /* 07 Dword* address */
255 ACPI_VARIABLE_LENGTH, /* 08 Word* address */
256 ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */
257 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */
258 ACPI_FIXED_LENGTH, /* 0B Extended* address */
259 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
260 ACPI_VARIABLE_LENGTH, /* 0D PinFunction */
261 ACPI_VARIABLE_LENGTH, /* 0E *SerialBus */
262 ACPI_VARIABLE_LENGTH, /* 0F PinConfig */
263 ACPI_VARIABLE_LENGTH, /* 10 PinGroup */
264 ACPI_VARIABLE_LENGTH, /* 11 PinGroupFunction */
265 ACPI_VARIABLE_LENGTH, /* 12 PinGroupConfig */
269 /*******************************************************************************
271 * FUNCTION: AcpiUtWalkAmlResources
273 * PARAMETERS: WalkState - Current walk info
274 * PARAMETERS: Aml - Pointer to the raw AML resource template
275 * AmlLength - Length of the entire template
276 * UserFunction - Called once for each descriptor found. If
277 * NULL, a pointer to the EndTag is returned
278 * Context - Passed to UserFunction
282 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
283 * once for each resource found.
285 ******************************************************************************/
288 AcpiUtWalkAmlResources (
289 ACPI_WALK_STATE *WalkState,
292 ACPI_WALK_AML_CALLBACK UserFunction,
300 UINT8 EndTag[2] = {0x79, 0x00};
303 ACPI_FUNCTION_TRACE (UtWalkAmlResources);
306 /* The absolute minimum resource template is one EndTag descriptor */
308 if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
310 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
313 /* Point to the end of the resource template buffer */
315 EndAml = Aml + AmlLength;
317 /* Walk the byte list, abort on any invalid descriptor type or length */
321 /* Validate the Resource Type and Resource Length */
323 Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex);
324 if (ACPI_FAILURE (Status))
327 * Exit on failure. Cannot continue because the descriptor
328 * length may be bogus also.
330 return_ACPI_STATUS (Status);
333 /* Get the length of this descriptor */
335 Length = AcpiUtGetDescriptorLength (Aml);
337 /* Invoke the user function */
341 Status = UserFunction (
342 Aml, Length, Offset, ResourceIndex, Context);
343 if (ACPI_FAILURE (Status))
345 return_ACPI_STATUS (Status);
349 /* An EndTag descriptor terminates this resource template */
351 if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
354 * There must be at least one more byte in the buffer for
355 * the 2nd byte of the EndTag
357 if ((Aml + 1) >= EndAml)
359 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
363 * Don't attempt to perform any validation on the 2nd byte.
364 * Although all known ASL compilers insert a zero for the 2nd
365 * byte, it can also be a checksum (as per the ACPI spec),
366 * and this is occasionally seen in the field. July 2017.
369 /* Return the pointer to the EndTag if requested */
378 return_ACPI_STATUS (AE_OK);
385 /* Did not find an EndTag descriptor */
389 /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */
391 (void) AcpiUtValidateResource (WalkState, EndTag, &ResourceIndex);
392 Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context);
393 if (ACPI_FAILURE (Status))
395 return_ACPI_STATUS (Status);
399 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
403 /*******************************************************************************
405 * FUNCTION: AcpiUtValidateResource
407 * PARAMETERS: WalkState - Current walk info
408 * Aml - Pointer to the raw AML resource descriptor
409 * ReturnIndex - Where the resource index is returned. NULL
410 * if the index is not required.
412 * RETURN: Status, and optionally the Index into the global resource tables
414 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
415 * Type and Resource Length. Returns an index into the global
416 * resource information/dispatch tables for later use.
418 ******************************************************************************/
421 AcpiUtValidateResource (
422 ACPI_WALK_STATE *WalkState,
426 AML_RESOURCE *AmlResource;
429 ACPI_RS_LENGTH ResourceLength;
430 ACPI_RS_LENGTH MinimumResourceLength;
433 ACPI_FUNCTION_ENTRY ();
437 * 1) Validate the ResourceType field (Byte 0)
439 ResourceType = ACPI_GET8 (Aml);
442 * Byte 0 contains the descriptor name (Resource Type)
443 * Examine the large/small bit in the resource header
445 if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
447 /* Verify the large resource type (name) against the max */
449 if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
451 goto InvalidResource;
455 * Large Resource Type -- bits 6:0 contain the name
456 * Translate range 0x80-0x8B to index range 0x10-0x1B
458 ResourceIndex = (UINT8) (ResourceType - 0x70);
463 * Small Resource Type -- bits 6:3 contain the name
464 * Shift range to index range 0x00-0x0F
466 ResourceIndex = (UINT8)
467 ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
471 * Check validity of the resource type, via AcpiGbl_ResourceTypes.
472 * Zero indicates an invalid resource.
474 if (!AcpiGbl_ResourceTypes[ResourceIndex])
476 goto InvalidResource;
480 * Validate the ResourceLength field. This ensures that the length
481 * is at least reasonable, and guarantees that it is non-zero.
483 ResourceLength = AcpiUtGetResourceLength (Aml);
484 MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
486 /* Validate based upon the type of resource - fixed length or variable */
488 switch (AcpiGbl_ResourceTypes[ResourceIndex])
490 case ACPI_FIXED_LENGTH:
492 /* Fixed length resource, length must match exactly */
494 if (ResourceLength != MinimumResourceLength)
496 goto BadResourceLength;
500 case ACPI_VARIABLE_LENGTH:
502 /* Variable length resource, length must be at least the minimum */
504 if (ResourceLength < MinimumResourceLength)
506 goto BadResourceLength;
510 case ACPI_SMALL_VARIABLE_LENGTH:
512 /* Small variable length resource, length can be (Min) or (Min-1) */
514 if ((ResourceLength > MinimumResourceLength) ||
515 (ResourceLength < (MinimumResourceLength - 1)))
517 goto BadResourceLength;
523 /* Shouldn't happen (because of validation earlier), but be sure */
525 goto InvalidResource;
528 AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
529 if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
531 /* Validate the BusType field */
533 if ((AmlResource->CommonSerialBus.Type == 0) ||
534 (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
538 ACPI_ERROR ((AE_INFO,
539 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
540 AmlResource->CommonSerialBus.Type));
542 return (AE_AML_INVALID_RESOURCE_TYPE);
546 /* Optionally return the resource table index */
550 *ReturnIndex = ResourceIndex;
560 ACPI_ERROR ((AE_INFO,
561 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
564 return (AE_AML_INVALID_RESOURCE_TYPE);
570 ACPI_ERROR ((AE_INFO,
571 "Invalid resource descriptor length: Type "
572 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
573 ResourceType, ResourceLength, MinimumResourceLength));
575 return (AE_AML_BAD_RESOURCE_LENGTH);
579 /*******************************************************************************
581 * FUNCTION: AcpiUtGetResourceType
583 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
585 * RETURN: The Resource Type with no extraneous bits (except the
586 * Large/Small descriptor bit -- this is left alone)
588 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
589 * a resource descriptor.
591 ******************************************************************************/
594 AcpiUtGetResourceType (
597 ACPI_FUNCTION_ENTRY ();
601 * Byte 0 contains the descriptor name (Resource Type)
602 * Examine the large/small bit in the resource header
604 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
606 /* Large Resource Type -- bits 6:0 contain the name */
608 return (ACPI_GET8 (Aml));
612 /* Small Resource Type -- bits 6:3 contain the name */
614 return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
619 /*******************************************************************************
621 * FUNCTION: AcpiUtGetResourceLength
623 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
625 * RETURN: Byte Length
627 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
628 * definition, this does not include the size of the descriptor
629 * header or the length field itself.
631 ******************************************************************************/
634 AcpiUtGetResourceLength (
637 ACPI_RS_LENGTH ResourceLength;
640 ACPI_FUNCTION_ENTRY ();
644 * Byte 0 contains the descriptor name (Resource Type)
645 * Examine the large/small bit in the resource header
647 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
649 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
651 ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
656 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
658 ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
659 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
662 return (ResourceLength);
666 /*******************************************************************************
668 * FUNCTION: AcpiUtGetResourceHeaderLength
670 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
672 * RETURN: Length of the AML header (depends on large/small descriptor)
674 * DESCRIPTION: Get the length of the header for this resource.
676 ******************************************************************************/
679 AcpiUtGetResourceHeaderLength (
682 ACPI_FUNCTION_ENTRY ();
685 /* Examine the large/small bit in the resource header */
687 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
689 return (sizeof (AML_RESOURCE_LARGE_HEADER));
693 return (sizeof (AML_RESOURCE_SMALL_HEADER));
698 /*******************************************************************************
700 * FUNCTION: AcpiUtGetDescriptorLength
702 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
704 * RETURN: Byte length
706 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
707 * length of the descriptor header and the length field itself.
708 * Used to walk descriptor lists.
710 ******************************************************************************/
713 AcpiUtGetDescriptorLength (
716 ACPI_FUNCTION_ENTRY ();
720 * Get the Resource Length (does not include header length) and add
721 * the header length (depends on if this is a small or large resource)
723 return (AcpiUtGetResourceLength (Aml) +
724 AcpiUtGetResourceHeaderLength (Aml));
728 /*******************************************************************************
730 * FUNCTION: AcpiUtGetResourceEndTag
732 * PARAMETERS: ObjDesc - The resource template buffer object
733 * EndTag - Where the pointer to the EndTag is returned
735 * RETURN: Status, pointer to the end tag
737 * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
738 * Note: allows a buffer length of zero.
740 ******************************************************************************/
743 AcpiUtGetResourceEndTag (
744 ACPI_OPERAND_OBJECT *ObjDesc,
750 ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
753 /* Allow a buffer length of zero */
755 if (!ObjDesc->Buffer.Length)
757 *EndTag = ObjDesc->Buffer.Pointer;
758 return_ACPI_STATUS (AE_OK);
761 /* Validate the template and get a pointer to the EndTag */
763 Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer,
764 ObjDesc->Buffer.Length, NULL, (void **) EndTag);
766 return_ACPI_STATUS (Status);