1 /*******************************************************************************
3 * Module Name: utmisc - common utility procedures
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
120 #include <contrib/dev/acpica/acpi.h>
121 #include <contrib/dev/acpica/acnamesp.h>
122 #include <contrib/dev/acpica/amlresrc.h>
125 #define _COMPONENT ACPI_UTILITIES
126 ACPI_MODULE_NAME ("utmisc")
129 /*******************************************************************************
131 * FUNCTION: AcpiUtAllocateOwnerId
133 * PARAMETERS: OwnerId - Where the new owner ID is returned
137 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
138 * track objects created by the table or method, to be deleted
139 * when the method exits or the table is unloaded.
141 ******************************************************************************/
144 AcpiUtAllocateOwnerId (
145 ACPI_OWNER_ID *OwnerId)
151 ACPI_FUNCTION_TRACE ("UtAllocateOwnerId");
154 /* Guard against multiple allocations of ID to the same location */
158 ACPI_REPORT_ERROR (("Owner ID [%2.2X] already exists\n", *OwnerId));
159 return_ACPI_STATUS (AE_ALREADY_EXISTS);
162 /* Mutex for the global ID mask */
164 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
165 if (ACPI_FAILURE (Status))
167 return_ACPI_STATUS (Status);
170 /* Find a free owner ID */
172 for (i = 0; i < 32; i++)
174 if (!(AcpiGbl_OwnerIdMask & (1 << i)))
176 ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
177 "Current OwnerId mask: %8.8X New ID: %2.2X\n",
178 AcpiGbl_OwnerIdMask, (unsigned int) (i + 1)));
180 AcpiGbl_OwnerIdMask |= (1 << i);
181 *OwnerId = (ACPI_OWNER_ID) (i + 1);
187 * If we are here, all OwnerIds have been allocated. This probably should
188 * not happen since the IDs are reused after deallocation. The IDs are
189 * allocated upon table load (one per table) and method execution, and
190 * they are released when a table is unloaded or a method completes
194 Status = AE_OWNER_ID_LIMIT;
196 "Could not allocate new OwnerId (32 max), AE_OWNER_ID_LIMIT\n"));
199 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
200 return_ACPI_STATUS (Status);
204 /*******************************************************************************
206 * FUNCTION: AcpiUtReleaseOwnerId
208 * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID
210 * RETURN: None. No error is returned because we are either exiting a
211 * control method or unloading a table. Either way, we would
212 * ignore any error anyway.
214 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32
216 ******************************************************************************/
219 AcpiUtReleaseOwnerId (
220 ACPI_OWNER_ID *OwnerIdPtr)
222 ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
226 ACPI_FUNCTION_TRACE_U32 ("UtReleaseOwnerId", OwnerId);
229 /* Always clear the input OwnerId (zero is an invalid ID) */
233 /* Zero is not a valid OwnerID */
235 if ((OwnerId == 0) || (OwnerId > 32))
237 ACPI_REPORT_ERROR (("Invalid OwnerId: %2.2X\n", OwnerId));
241 /* Mutex for the global ID mask */
243 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
244 if (ACPI_FAILURE (Status))
249 /* Normalize the ID to zero */
253 /* Free the owner ID only if it is valid */
255 if (AcpiGbl_OwnerIdMask & (1 << OwnerId))
257 AcpiGbl_OwnerIdMask ^= (1 << OwnerId);
260 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
265 /*******************************************************************************
267 * FUNCTION: AcpiUtStrupr (strupr)
269 * PARAMETERS: SrcString - The source string to convert
273 * DESCRIPTION: Convert string to uppercase
275 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
277 ******************************************************************************/
286 ACPI_FUNCTION_ENTRY ();
294 /* Walk entire string, uppercasing the letters */
296 for (String = SrcString; *String; String++)
298 *String = (char) ACPI_TOUPPER (*String);
305 /*******************************************************************************
307 * FUNCTION: AcpiUtPrintString
309 * PARAMETERS: String - Null terminated ASCII string
310 * MaxLength - Maximum output length
314 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
317 ******************************************************************************/
329 AcpiOsPrintf ("<\"NULL STRING PTR\">");
334 for (i = 0; String[i] && (i < MaxLength); i++)
336 /* Escape sequences */
341 AcpiOsPrintf ("\\a"); /* BELL */
345 AcpiOsPrintf ("\\b"); /* BACKSPACE */
349 AcpiOsPrintf ("\\f"); /* FORMFEED */
353 AcpiOsPrintf ("\\n"); /* LINEFEED */
357 AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/
361 AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */
365 AcpiOsPrintf ("\\v"); /* VERTICAL TAB */
368 case '\'': /* Single Quote */
369 case '\"': /* Double Quote */
370 case '\\': /* Backslash */
371 AcpiOsPrintf ("\\%c", (int) String[i]);
376 /* Check for printable character or hex escape */
378 if (ACPI_IS_PRINT (String[i]))
380 /* This is a normal character */
382 AcpiOsPrintf ("%c", (int) String[i]);
386 /* All others will be Hex escapes */
388 AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
395 if (i == MaxLength && String[i])
397 AcpiOsPrintf ("...");
402 /*******************************************************************************
404 * FUNCTION: AcpiUtDwordByteSwap
406 * PARAMETERS: Value - Value to be converted
408 * RETURN: UINT32 integer with bytes swapped
410 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
412 ******************************************************************************/
415 AcpiUtDwordByteSwap (
430 ACPI_FUNCTION_ENTRY ();
435 Out.Bytes[0] = In.Bytes[3];
436 Out.Bytes[1] = In.Bytes[2];
437 Out.Bytes[2] = In.Bytes[1];
438 Out.Bytes[3] = In.Bytes[0];
444 /*******************************************************************************
446 * FUNCTION: AcpiUtSetIntegerWidth
448 * PARAMETERS: Revision From DSDT header
452 * DESCRIPTION: Set the global integer bit width based upon the revision
453 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
454 * For Revision 2 and above, Integers are 64 bits. Yes, this
455 * makes a difference.
457 ******************************************************************************/
460 AcpiUtSetIntegerWidth (
466 AcpiGbl_IntegerBitWidth = 32;
467 AcpiGbl_IntegerNybbleWidth = 8;
468 AcpiGbl_IntegerByteWidth = 4;
472 AcpiGbl_IntegerBitWidth = 64;
473 AcpiGbl_IntegerNybbleWidth = 16;
474 AcpiGbl_IntegerByteWidth = 8;
479 #ifdef ACPI_DEBUG_OUTPUT
480 /*******************************************************************************
482 * FUNCTION: AcpiUtDisplayInitPathname
484 * PARAMETERS: Type - Object type of the node
485 * ObjHandle - Handle whose pathname will be displayed
486 * Path - Additional path string to be appended.
487 * (NULL if no extra path)
489 * RETURN: ACPI_STATUS
491 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
493 ******************************************************************************/
496 AcpiUtDisplayInitPathname (
498 ACPI_NAMESPACE_NODE *ObjHandle,
505 ACPI_FUNCTION_ENTRY ();
508 /* Only print the path if the appropriate debug level is enabled */
510 if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
515 /* Get the full pathname to the node */
517 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
518 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
519 if (ACPI_FAILURE (Status))
524 /* Print what we're doing */
528 case ACPI_TYPE_METHOD:
529 AcpiOsPrintf ("Executing ");
533 AcpiOsPrintf ("Initializing ");
537 /* Print the object type and pathname */
539 AcpiOsPrintf ("%-12s %s",
540 AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
542 /* Extra path is used to append names like _STA, _INI, etc. */
546 AcpiOsPrintf (".%s", Path);
550 ACPI_MEM_FREE (Buffer.Pointer);
555 /*******************************************************************************
557 * FUNCTION: AcpiUtValidAcpiName
559 * PARAMETERS: Name - The name to be examined
561 * RETURN: TRUE if the name is valid, FALSE otherwise
563 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
564 * 1) Upper case alpha
568 ******************************************************************************/
571 AcpiUtValidAcpiName (
574 char *NamePtr = (char *) &Name;
579 ACPI_FUNCTION_ENTRY ();
582 for (i = 0; i < ACPI_NAME_SIZE; i++)
584 Character = *NamePtr;
587 if (!((Character == '_') ||
588 (Character >= 'A' && Character <= 'Z') ||
589 (Character >= '0' && Character <= '9')))
599 /*******************************************************************************
601 * FUNCTION: AcpiUtValidAcpiCharacter
603 * PARAMETERS: Character - The character to be examined
605 * RETURN: 1 if Character may appear in a name, else 0
607 * DESCRIPTION: Check for a printable character
609 ******************************************************************************/
612 AcpiUtValidAcpiCharacter (
616 ACPI_FUNCTION_ENTRY ();
618 return ((BOOLEAN) ((Character == '_') ||
619 (Character >= 'A' && Character <= 'Z') ||
620 (Character >= '0' && Character <= '9')));
624 /*******************************************************************************
626 * FUNCTION: AcpiUtStrtoul64
628 * PARAMETERS: String - Null terminated string
629 * Base - Radix of the string: 10, 16, or ACPI_ANY_BASE
630 * RetInteger - Where the converted integer is returned
632 * RETURN: Status and Converted value
634 * DESCRIPTION: Convert a string into an unsigned value.
635 * NOTE: Does not support Octal strings, not needed.
637 ******************************************************************************/
643 ACPI_INTEGER *RetInteger)
645 UINT32 ThisDigit = 0;
646 ACPI_INTEGER ReturnValue = 0;
647 ACPI_INTEGER Quotient;
650 ACPI_FUNCTION_TRACE ("UtStroul64");
653 if ((!String) || !(*String))
667 return_ACPI_STATUS (AE_BAD_PARAMETER);
670 /* Skip over any white space in the buffer */
672 while (ACPI_IS_SPACE (*String) || *String == '\t')
678 * If the input parameter Base is zero, then we need to
679 * determine if it is decimal or hexadecimal:
683 if ((*String == '0') &&
684 (ACPI_TOLOWER (*(String + 1)) == 'x'))
696 * For hexadecimal base, skip over the leading
697 * 0 or 0x, if they are present.
701 (ACPI_TOLOWER (*(String + 1)) == 'x'))
706 /* Any string left? */
713 /* Main loop: convert the string to a 64-bit integer */
717 if (ACPI_IS_DIGIT (*String))
719 /* Convert ASCII 0-9 to Decimal value */
721 ThisDigit = ((UINT8) *String) - '0';
727 /* Digit is out of range */
732 ThisDigit = (UINT8) ACPI_TOUPPER (*String);
733 if (ACPI_IS_XDIGIT ((char) ThisDigit))
735 /* Convert ASCII Hex char to value */
737 ThisDigit = ThisDigit - 'A' + 10;
742 * We allow non-hex chars, just stop now, same as end-of-string.
743 * See ACPI spec, string-to-integer conversion.
749 /* Divide the digit into the correct position */
751 (void) AcpiUtShortDivide ((ACPI_INTEGER_MAX - (ACPI_INTEGER) ThisDigit),
752 Base, &Quotient, NULL);
753 if (ReturnValue > Quotient)
759 ReturnValue += ThisDigit;
763 /* All done, normal exit */
765 *RetInteger = ReturnValue;
766 return_ACPI_STATUS (AE_OK);
770 /* Base was set/validated above */
774 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
778 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
783 /*******************************************************************************
785 * FUNCTION: AcpiUtCreateUpdateStateAndPush
787 * PARAMETERS: Object - Object to be added to the new state
788 * Action - Increment/Decrement
789 * StateList - List the state will be added to
793 * DESCRIPTION: Create a new state and push it
795 ******************************************************************************/
798 AcpiUtCreateUpdateStateAndPush (
799 ACPI_OPERAND_OBJECT *Object,
801 ACPI_GENERIC_STATE **StateList)
803 ACPI_GENERIC_STATE *State;
806 ACPI_FUNCTION_ENTRY ();
809 /* Ignore null objects; these are expected */
816 State = AcpiUtCreateUpdateState (Object, Action);
819 return (AE_NO_MEMORY);
822 AcpiUtPushGenericState (StateList, State);
827 /*******************************************************************************
829 * FUNCTION: AcpiUtWalkPackageTree
831 * PARAMETERS: SourceObject - The package to walk
832 * TargetObject - Target object (if package is being copied)
833 * WalkCallback - Called once for each package element
834 * Context - Passed to the callback function
838 * DESCRIPTION: Walk through a package
840 ******************************************************************************/
843 AcpiUtWalkPackageTree (
844 ACPI_OPERAND_OBJECT *SourceObject,
846 ACPI_PKG_CALLBACK WalkCallback,
849 ACPI_STATUS Status = AE_OK;
850 ACPI_GENERIC_STATE *StateList = NULL;
851 ACPI_GENERIC_STATE *State;
853 ACPI_OPERAND_OBJECT *ThisSourceObj;
856 ACPI_FUNCTION_TRACE ("UtWalkPackageTree");
859 State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
862 return_ACPI_STATUS (AE_NO_MEMORY);
867 /* Get one element of the package */
869 ThisIndex = State->Pkg.Index;
870 ThisSourceObj = (ACPI_OPERAND_OBJECT *)
871 State->Pkg.SourceObject->Package.Elements[ThisIndex];
875 * 1) An uninitialized package element. It is completely
876 * legal to declare a package and leave it uninitialized
877 * 2) Not an internal object - can be a namespace node instead
878 * 3) Any type other than a package. Packages are handled in else
881 if ((!ThisSourceObj) ||
882 (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
883 (ACPI_GET_OBJECT_TYPE (ThisSourceObj) != ACPI_TYPE_PACKAGE))
885 Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
887 if (ACPI_FAILURE (Status))
889 return_ACPI_STATUS (Status);
893 while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
896 * We've handled all of the objects at this level, This means
897 * that we have just completed a package. That package may
898 * have contained one or more packages itself.
900 * Delete this state and pop the previous state (package).
902 AcpiUtDeleteGenericState (State);
903 State = AcpiUtPopGenericState (&StateList);
905 /* Finished when there are no more states */
910 * We have handled all of the objects in the top level
911 * package just add the length of the package objects
914 return_ACPI_STATUS (AE_OK);
918 * Go back up a level and move the index past the just
919 * completed package object.
926 /* This is a subobject of type package */
928 Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
930 if (ACPI_FAILURE (Status))
932 return_ACPI_STATUS (Status);
936 * Push the current state and create a new one
937 * The callback above returned a new target package object.
939 AcpiUtPushGenericState (&StateList, State);
940 State = AcpiUtCreatePkgState (ThisSourceObj,
941 State->Pkg.ThisTargetObj, 0);
944 return_ACPI_STATUS (AE_NO_MEMORY);
949 /* We should never get here */
951 return_ACPI_STATUS (AE_AML_INTERNAL);
955 /*******************************************************************************
957 * FUNCTION: AcpiUtGenerateChecksum
959 * PARAMETERS: Buffer - Buffer to be scanned
960 * Length - number of bytes to examine
962 * RETURN: The generated checksum
964 * DESCRIPTION: Generate a checksum on a raw buffer
966 ******************************************************************************/
969 AcpiUtGenerateChecksum (
977 for (i = 0; i < Length; i++)
979 Sum = (signed char) (Sum + Buffer[i]);
982 return ((UINT8) (0 - Sum));
986 /*******************************************************************************
988 * FUNCTION: AcpiUtGetResourceType
990 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
992 * RETURN: The Resource Type with no extraneous bits (except the
993 * Large/Small descriptor bit -- this is left alone)
995 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
996 * a resource descriptor.
998 ******************************************************************************/
1001 AcpiUtGetResourceType (
1004 ACPI_FUNCTION_ENTRY ();
1008 * Byte 0 contains the descriptor name (Resource Type)
1009 * Determine if this is a small or large resource
1011 if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE)
1013 /* Large Resource Type -- bits 6:0 contain the name */
1015 return (*((UINT8 *) Aml));
1019 /* Small Resource Type -- bits 6:3 contain the name */
1021 return ((UINT8) (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
1026 /*******************************************************************************
1028 * FUNCTION: AcpiUtGetResourceLength
1030 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
1032 * RETURN: Byte Length
1034 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
1035 * definition, this does not include the size of the descriptor
1036 * header or the length field itself.
1038 ******************************************************************************/
1041 AcpiUtGetResourceLength (
1044 UINT16 ResourceLength;
1047 ACPI_FUNCTION_ENTRY ();
1051 * Byte 0 contains the descriptor name (Resource Type)
1052 * Determine if this is a small or large resource
1054 if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE)
1056 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
1058 ACPI_MOVE_16_TO_16 (&ResourceLength, &((UINT8 *) Aml)[1]);
1063 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
1065 ResourceLength = (UINT16) (*((UINT8 *) Aml) &
1066 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
1069 return (ResourceLength);
1073 /*******************************************************************************
1075 * FUNCTION: AcpiUtGetDescriptorLength
1077 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
1079 * RETURN: Byte length
1081 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
1082 * length of the descriptor header and the length field itself.
1083 * Used to walk descriptor lists.
1085 ******************************************************************************/
1088 AcpiUtGetDescriptorLength (
1091 UINT32 DescriptorLength;
1094 ACPI_FUNCTION_ENTRY ();
1097 /* First get the Resource Length (Does not include header length) */
1099 DescriptorLength = AcpiUtGetResourceLength (Aml);
1101 /* Determine if this is a small or large resource */
1103 if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE)
1105 DescriptorLength += sizeof (AML_RESOURCE_LARGE_HEADER);
1109 DescriptorLength += sizeof (AML_RESOURCE_SMALL_HEADER);
1112 return (DescriptorLength);
1116 /*******************************************************************************
1118 * FUNCTION: AcpiUtGetResourceEndTag
1120 * PARAMETERS: ObjDesc - The resource template buffer object
1122 * RETURN: Pointer to the end tag
1124 * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template
1126 ******************************************************************************/
1130 AcpiUtGetResourceEndTag (
1131 ACPI_OPERAND_OBJECT *ObjDesc)
1137 Aml = ObjDesc->Buffer.Pointer;
1138 EndAml = Aml + ObjDesc->Buffer.Length;
1140 /* Walk the resource template, one descriptor per loop */
1142 while (Aml < EndAml)
1144 if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
1146 /* Found the end_tag descriptor, all done */
1151 /* Point to the next resource descriptor */
1153 Aml += AcpiUtGetResourceLength (Aml);
1156 /* End tag was not found */
1162 /*******************************************************************************
1164 * FUNCTION: AcpiUtReportError
1166 * PARAMETERS: ModuleName - Caller's module name (for error output)
1167 * LineNumber - Caller's line number (for error output)
1168 * ComponentId - Caller's component ID (for error output)
1172 * DESCRIPTION: Print error message
1174 ******************************************************************************/
1183 AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
1187 /*******************************************************************************
1189 * FUNCTION: AcpiUtReportWarning
1191 * PARAMETERS: ModuleName - Caller's module name (for error output)
1192 * LineNumber - Caller's line number (for error output)
1193 * ComponentId - Caller's component ID (for error output)
1197 * DESCRIPTION: Print warning message
1199 ******************************************************************************/
1202 AcpiUtReportWarning (
1208 AcpiOsPrintf ("%8s-%04d: *** Warning: ", ModuleName, LineNumber);
1212 /*******************************************************************************
1214 * FUNCTION: AcpiUtReportInfo
1216 * PARAMETERS: ModuleName - Caller's module name (for error output)
1217 * LineNumber - Caller's line number (for error output)
1218 * ComponentId - Caller's component ID (for error output)
1222 * DESCRIPTION: Print information message
1224 ******************************************************************************/
1233 AcpiOsPrintf ("%8s-%04d: *** Info: ", ModuleName, LineNumber);