1 /*******************************************************************************
3 * Module Name: utmisc - common utility procedures
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2009, 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 *****************************************************************************/
119 #include <contrib/dev/acpica/include/acpi.h>
120 #include <contrib/dev/acpica/include/accommon.h>
121 #include <contrib/dev/acpica/include/acnamesp.h>
124 #define _COMPONENT ACPI_UTILITIES
125 ACPI_MODULE_NAME ("utmisc")
128 /*******************************************************************************
130 * FUNCTION: AcpiUtValidateException
132 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
134 * RETURN: A string containing the exception text. NULL if exception is
137 * DESCRIPTION: This function validates and translates an ACPI exception into
140 ******************************************************************************/
143 AcpiUtValidateException (
147 const char *Exception = NULL;
150 ACPI_FUNCTION_ENTRY ();
154 * Status is composed of two parts, a "type" and an actual code
156 SubStatus = (Status & ~AE_CODE_MASK);
158 switch (Status & AE_CODE_MASK)
160 case AE_CODE_ENVIRONMENTAL:
162 if (SubStatus <= AE_CODE_ENV_MAX)
164 Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
168 case AE_CODE_PROGRAMMER:
170 if (SubStatus <= AE_CODE_PGM_MAX)
172 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
176 case AE_CODE_ACPI_TABLES:
178 if (SubStatus <= AE_CODE_TBL_MAX)
180 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
186 if (SubStatus <= AE_CODE_AML_MAX)
188 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
192 case AE_CODE_CONTROL:
194 if (SubStatus <= AE_CODE_CTRL_MAX)
196 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
204 return (ACPI_CAST_PTR (const char, Exception));
208 /*******************************************************************************
210 * FUNCTION: AcpiUtIsAmlTable
212 * PARAMETERS: Table - An ACPI table
214 * RETURN: TRUE if table contains executable AML; FALSE otherwise
216 * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
217 * Currently, these are DSDT,SSDT,PSDT. All other table types are
218 * data tables that do not contain AML code.
220 ******************************************************************************/
224 ACPI_TABLE_HEADER *Table)
227 /* These are the only tables that contain executable AML */
229 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
230 ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
231 ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
240 /*******************************************************************************
242 * FUNCTION: AcpiUtAllocateOwnerId
244 * PARAMETERS: OwnerId - Where the new owner ID is returned
248 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
249 * track objects created by the table or method, to be deleted
250 * when the method exits or the table is unloaded.
252 ******************************************************************************/
255 AcpiUtAllocateOwnerId (
256 ACPI_OWNER_ID *OwnerId)
264 ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
267 /* Guard against multiple allocations of ID to the same location */
271 ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId));
272 return_ACPI_STATUS (AE_ALREADY_EXISTS);
275 /* Mutex for the global ID mask */
277 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
278 if (ACPI_FAILURE (Status))
280 return_ACPI_STATUS (Status);
284 * Find a free owner ID, cycle through all possible IDs on repeated
285 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
286 * to be scanned twice.
288 for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
289 i < (ACPI_NUM_OWNERID_MASKS + 1);
292 if (j >= ACPI_NUM_OWNERID_MASKS)
294 j = 0; /* Wraparound to start of mask array */
297 for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
299 if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
301 /* There are no free IDs in this mask */
306 if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
309 * Found a free ID. The actual ID is the bit index plus one,
310 * making zero an invalid Owner ID. Save this as the last ID
311 * allocated and update the global ID mask.
313 AcpiGbl_OwnerIdMask[j] |= (1 << k);
315 AcpiGbl_LastOwnerIdIndex = (UINT8) j;
316 AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
319 * Construct encoded ID from the index and bit position
321 * Note: Last [j].k (bit 255) is never used and is marked
322 * permanently allocated (prevents +1 overflow)
324 *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
326 ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
327 "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
332 AcpiGbl_NextOwnerIdOffset = 0;
336 * All OwnerIds have been allocated. This typically should
337 * not happen since the IDs are reused after deallocation. The IDs are
338 * allocated upon table load (one per table) and method execution, and
339 * they are released when a table is unloaded or a method completes
342 * If this error happens, there may be very deep nesting of invoked control
343 * methods, or there may be a bug where the IDs are not released.
345 Status = AE_OWNER_ID_LIMIT;
346 ACPI_ERROR ((AE_INFO,
347 "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
350 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
351 return_ACPI_STATUS (Status);
355 /*******************************************************************************
357 * FUNCTION: AcpiUtReleaseOwnerId
359 * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID
361 * RETURN: None. No error is returned because we are either exiting a
362 * control method or unloading a table. Either way, we would
363 * ignore any error anyway.
365 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
367 ******************************************************************************/
370 AcpiUtReleaseOwnerId (
371 ACPI_OWNER_ID *OwnerIdPtr)
373 ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
379 ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
382 /* Always clear the input OwnerId (zero is an invalid ID) */
386 /* Zero is not a valid OwnerID */
390 ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId));
394 /* Mutex for the global ID mask */
396 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
397 if (ACPI_FAILURE (Status))
402 /* Normalize the ID to zero */
406 /* Decode ID to index/offset pair */
408 Index = ACPI_DIV_32 (OwnerId);
409 Bit = 1 << ACPI_MOD_32 (OwnerId);
411 /* Free the owner ID only if it is valid */
413 if (AcpiGbl_OwnerIdMask[Index] & Bit)
415 AcpiGbl_OwnerIdMask[Index] ^= Bit;
419 ACPI_ERROR ((AE_INFO,
420 "Release of non-allocated OwnerId: %2.2X", OwnerId + 1));
423 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
428 /*******************************************************************************
430 * FUNCTION: AcpiUtStrupr (strupr)
432 * PARAMETERS: SrcString - The source string to convert
436 * DESCRIPTION: Convert string to uppercase
438 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
440 ******************************************************************************/
449 ACPI_FUNCTION_ENTRY ();
457 /* Walk entire string, uppercasing the letters */
459 for (String = SrcString; *String; String++)
461 *String = (char) ACPI_TOUPPER (*String);
468 /*******************************************************************************
470 * FUNCTION: AcpiUtPrintString
472 * PARAMETERS: String - Null terminated ASCII string
473 * MaxLength - Maximum output length
477 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
480 ******************************************************************************/
492 AcpiOsPrintf ("<\"NULL STRING PTR\">");
497 for (i = 0; String[i] && (i < MaxLength); i++)
499 /* Escape sequences */
504 AcpiOsPrintf ("\\a"); /* BELL */
508 AcpiOsPrintf ("\\b"); /* BACKSPACE */
512 AcpiOsPrintf ("\\f"); /* FORMFEED */
516 AcpiOsPrintf ("\\n"); /* LINEFEED */
520 AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/
524 AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */
528 AcpiOsPrintf ("\\v"); /* VERTICAL TAB */
531 case '\'': /* Single Quote */
532 case '\"': /* Double Quote */
533 case '\\': /* Backslash */
534 AcpiOsPrintf ("\\%c", (int) String[i]);
539 /* Check for printable character or hex escape */
541 if (ACPI_IS_PRINT (String[i]))
543 /* This is a normal character */
545 AcpiOsPrintf ("%c", (int) String[i]);
549 /* All others will be Hex escapes */
551 AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
558 if (i == MaxLength && String[i])
560 AcpiOsPrintf ("...");
565 /*******************************************************************************
567 * FUNCTION: AcpiUtDwordByteSwap
569 * PARAMETERS: Value - Value to be converted
571 * RETURN: UINT32 integer with bytes swapped
573 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
575 ******************************************************************************/
578 AcpiUtDwordByteSwap (
593 ACPI_FUNCTION_ENTRY ();
598 Out.Bytes[0] = In.Bytes[3];
599 Out.Bytes[1] = In.Bytes[2];
600 Out.Bytes[2] = In.Bytes[1];
601 Out.Bytes[3] = In.Bytes[0];
607 /*******************************************************************************
609 * FUNCTION: AcpiUtSetIntegerWidth
611 * PARAMETERS: Revision From DSDT header
615 * DESCRIPTION: Set the global integer bit width based upon the revision
616 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
617 * For Revision 2 and above, Integers are 64 bits. Yes, this
618 * makes a difference.
620 ******************************************************************************/
623 AcpiUtSetIntegerWidth (
631 AcpiGbl_IntegerBitWidth = 32;
632 AcpiGbl_IntegerNybbleWidth = 8;
633 AcpiGbl_IntegerByteWidth = 4;
637 /* 64-bit case (ACPI 2.0+) */
639 AcpiGbl_IntegerBitWidth = 64;
640 AcpiGbl_IntegerNybbleWidth = 16;
641 AcpiGbl_IntegerByteWidth = 8;
646 #ifdef ACPI_DEBUG_OUTPUT
647 /*******************************************************************************
649 * FUNCTION: AcpiUtDisplayInitPathname
651 * PARAMETERS: Type - Object type of the node
652 * ObjHandle - Handle whose pathname will be displayed
653 * Path - Additional path string to be appended.
654 * (NULL if no extra path)
656 * RETURN: ACPI_STATUS
658 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
660 ******************************************************************************/
663 AcpiUtDisplayInitPathname (
665 ACPI_NAMESPACE_NODE *ObjHandle,
672 ACPI_FUNCTION_ENTRY ();
675 /* Only print the path if the appropriate debug level is enabled */
677 if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
682 /* Get the full pathname to the node */
684 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
685 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
686 if (ACPI_FAILURE (Status))
691 /* Print what we're doing */
695 case ACPI_TYPE_METHOD:
696 AcpiOsPrintf ("Executing ");
700 AcpiOsPrintf ("Initializing ");
704 /* Print the object type and pathname */
706 AcpiOsPrintf ("%-12s %s",
707 AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
709 /* Extra path is used to append names like _STA, _INI, etc. */
713 AcpiOsPrintf (".%s", Path);
717 ACPI_FREE (Buffer.Pointer);
722 /*******************************************************************************
724 * FUNCTION: AcpiUtValidAcpiChar
726 * PARAMETERS: Char - The character to be examined
727 * Position - Byte position (0-3)
729 * RETURN: TRUE if the character is valid, FALSE otherwise
731 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
732 * 1) Upper case alpha
736 * We allow a '!' as the last character because of the ASF! table
738 ******************************************************************************/
741 AcpiUtValidAcpiChar (
746 if (!((Character >= 'A' && Character <= 'Z') ||
747 (Character >= '0' && Character <= '9') ||
750 /* Allow a '!' in the last position */
752 if (Character == '!' && Position == 3)
764 /*******************************************************************************
766 * FUNCTION: AcpiUtValidAcpiName
768 * PARAMETERS: Name - The name to be examined
770 * RETURN: TRUE if the name is valid, FALSE otherwise
772 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
773 * 1) Upper case alpha
777 ******************************************************************************/
780 AcpiUtValidAcpiName (
786 ACPI_FUNCTION_ENTRY ();
789 for (i = 0; i < ACPI_NAME_SIZE; i++)
791 if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
801 /*******************************************************************************
803 * FUNCTION: AcpiUtRepairName
805 * PARAMETERS: Name - The ACPI name to be repaired
807 * RETURN: Repaired version of the name
809 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
810 * return the new name. NOTE: the Name parameter must reside in
811 * read/write memory, cannot be a const.
813 * An ACPI Name must consist of valid ACPI characters. We will repair the name
814 * if necessary because we don't want to abort because of this, but we want
815 * all namespace names to be printable. A warning message is appropriate.
817 * This issue came up because there are in fact machines that exhibit
818 * this problem, and we want to be able to enable ACPI support for them,
819 * even though there are a few bad names.
821 ******************************************************************************/
828 BOOLEAN FoundBadChar = FALSE;
831 ACPI_FUNCTION_NAME (UtRepairName);
834 /* Check each character in the name */
836 for (i = 0; i < ACPI_NAME_SIZE; i++)
838 if (AcpiUtValidAcpiChar (Name[i], i))
844 * Replace a bad character with something printable, yet technically
845 * still invalid. This prevents any collisions with existing "good"
846 * names in the namespace.
854 /* Report warning only if in strict mode or debug mode */
856 if (!AcpiGbl_EnableInterpreterSlack)
858 ACPI_WARNING ((AE_INFO,
859 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
863 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
864 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
870 /*******************************************************************************
872 * FUNCTION: AcpiUtStrtoul64
874 * PARAMETERS: String - Null terminated string
875 * Base - Radix of the string: 16 or ACPI_ANY_BASE;
876 * ACPI_ANY_BASE means 'in behalf of ToInteger'
877 * RetInteger - Where the converted integer is returned
879 * RETURN: Status and Converted value
881 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
882 * 32-bit or 64-bit conversion, depending on the current mode
883 * of the interpreter.
884 * NOTE: Does not support Octal strings, not needed.
886 ******************************************************************************/
892 ACPI_INTEGER *RetInteger)
894 UINT32 ThisDigit = 0;
895 ACPI_INTEGER ReturnValue = 0;
896 ACPI_INTEGER Quotient;
897 ACPI_INTEGER Dividend;
898 UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE);
899 UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4);
900 UINT8 ValidDigits = 0;
905 ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
916 return_ACPI_STATUS (AE_BAD_PARAMETER);
924 /* Skip over any white space in the buffer */
926 while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
934 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
935 * We need to determine if it is decimal or hexadecimal.
937 if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
942 /* Skip over the leading '0x' */
951 /* Any string left? Check that '0x' is not followed by white space. */
953 if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
966 * Perform a 32-bit or 64-bit conversion, depending upon the current
967 * execution mode of the interpreter
969 Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
971 /* Main loop: convert the string to a 32- or 64-bit integer */
975 if (ACPI_IS_DIGIT (*String))
977 /* Convert ASCII 0-9 to Decimal value */
979 ThisDigit = ((UINT8) *String) - '0';
983 /* Digit is out of range; possible in ToInteger case only */
989 ThisDigit = (UINT8) ACPI_TOUPPER (*String);
990 if (ACPI_IS_XDIGIT ((char) ThisDigit))
992 /* Convert ASCII Hex char to value */
994 ThisDigit = ThisDigit - 'A' + 10;
1013 else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
1022 if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
1025 * This is ToInteger operation case.
1026 * No any restrictions for string-to-integer conversion,
1032 /* Divide the digit into the correct position */
1034 (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit),
1035 Base, &Quotient, NULL);
1037 if (ReturnValue > Quotient)
1049 ReturnValue *= Base;
1050 ReturnValue += ThisDigit;
1054 /* All done, normal exit */
1058 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
1059 ACPI_FORMAT_UINT64 (ReturnValue)));
1061 *RetInteger = ReturnValue;
1062 return_ACPI_STATUS (AE_OK);
1066 /* Base was set/validated above */
1070 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
1074 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
1079 /*******************************************************************************
1081 * FUNCTION: AcpiUtCreateUpdateStateAndPush
1083 * PARAMETERS: Object - Object to be added to the new state
1084 * Action - Increment/Decrement
1085 * StateList - List the state will be added to
1089 * DESCRIPTION: Create a new state and push it
1091 ******************************************************************************/
1094 AcpiUtCreateUpdateStateAndPush (
1095 ACPI_OPERAND_OBJECT *Object,
1097 ACPI_GENERIC_STATE **StateList)
1099 ACPI_GENERIC_STATE *State;
1102 ACPI_FUNCTION_ENTRY ();
1105 /* Ignore null objects; these are expected */
1112 State = AcpiUtCreateUpdateState (Object, Action);
1115 return (AE_NO_MEMORY);
1118 AcpiUtPushGenericState (StateList, State);
1123 /*******************************************************************************
1125 * FUNCTION: AcpiUtWalkPackageTree
1127 * PARAMETERS: SourceObject - The package to walk
1128 * TargetObject - Target object (if package is being copied)
1129 * WalkCallback - Called once for each package element
1130 * Context - Passed to the callback function
1134 * DESCRIPTION: Walk through a package
1136 ******************************************************************************/
1139 AcpiUtWalkPackageTree (
1140 ACPI_OPERAND_OBJECT *SourceObject,
1142 ACPI_PKG_CALLBACK WalkCallback,
1145 ACPI_STATUS Status = AE_OK;
1146 ACPI_GENERIC_STATE *StateList = NULL;
1147 ACPI_GENERIC_STATE *State;
1149 ACPI_OPERAND_OBJECT *ThisSourceObj;
1152 ACPI_FUNCTION_TRACE (UtWalkPackageTree);
1155 State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
1158 return_ACPI_STATUS (AE_NO_MEMORY);
1163 /* Get one element of the package */
1165 ThisIndex = State->Pkg.Index;
1166 ThisSourceObj = (ACPI_OPERAND_OBJECT *)
1167 State->Pkg.SourceObject->Package.Elements[ThisIndex];
1171 * 1) An uninitialized package element. It is completely
1172 * legal to declare a package and leave it uninitialized
1173 * 2) Not an internal object - can be a namespace node instead
1174 * 3) Any type other than a package. Packages are handled in else
1177 if ((!ThisSourceObj) ||
1178 (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
1179 (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
1181 Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
1183 if (ACPI_FAILURE (Status))
1185 return_ACPI_STATUS (Status);
1189 while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
1192 * We've handled all of the objects at this level, This means
1193 * that we have just completed a package. That package may
1194 * have contained one or more packages itself.
1196 * Delete this state and pop the previous state (package).
1198 AcpiUtDeleteGenericState (State);
1199 State = AcpiUtPopGenericState (&StateList);
1201 /* Finished when there are no more states */
1206 * We have handled all of the objects in the top level
1207 * package just add the length of the package objects
1210 return_ACPI_STATUS (AE_OK);
1214 * Go back up a level and move the index past the just
1215 * completed package object.
1222 /* This is a subobject of type package */
1224 Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
1226 if (ACPI_FAILURE (Status))
1228 return_ACPI_STATUS (Status);
1232 * Push the current state and create a new one
1233 * The callback above returned a new target package object.
1235 AcpiUtPushGenericState (&StateList, State);
1236 State = AcpiUtCreatePkgState (ThisSourceObj,
1237 State->Pkg.ThisTargetObj, 0);
1240 /* Free any stacked Update State objects */
1244 State = AcpiUtPopGenericState (&StateList);
1245 AcpiUtDeleteGenericState (State);
1247 return_ACPI_STATUS (AE_NO_MEMORY);
1252 /* We should never get here */
1254 return_ACPI_STATUS (AE_AML_INTERNAL);
1258 /*******************************************************************************
1260 * FUNCTION: AcpiError, AcpiException, AcpiWarning, AcpiInfo
1262 * PARAMETERS: ModuleName - Caller's module name (for error output)
1263 * LineNumber - Caller's line number (for error output)
1264 * Format - Printf format string + additional args
1268 * DESCRIPTION: Print message with module/line/version info
1270 ******************************************************************************/
1272 void ACPI_INTERNAL_VAR_XFACE
1274 const char *ModuleName,
1282 AcpiOsPrintf ("ACPI Error: ");
1284 va_start (args, Format);
1285 AcpiOsVprintf (Format, args);
1286 AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber);
1290 void ACPI_INTERNAL_VAR_XFACE
1292 const char *ModuleName,
1301 AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status));
1303 va_start (args, Format);
1304 AcpiOsVprintf (Format, args);
1305 AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber);
1309 void ACPI_INTERNAL_VAR_XFACE
1311 const char *ModuleName,
1319 AcpiOsPrintf ("ACPI Warning: ");
1321 va_start (args, Format);
1322 AcpiOsVprintf (Format, args);
1323 AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber);
1327 void ACPI_INTERNAL_VAR_XFACE
1329 const char *ModuleName,
1337 /* Temporarily hide too verbose printfs. */
1342 AcpiOsPrintf ("ACPI: ");
1344 va_start (args, Format);
1345 AcpiOsVprintf (Format, args);
1346 AcpiOsPrintf ("\n");
1350 ACPI_EXPORT_SYMBOL (AcpiError)
1351 ACPI_EXPORT_SYMBOL (AcpiException)
1352 ACPI_EXPORT_SYMBOL (AcpiWarning)
1353 ACPI_EXPORT_SYMBOL (AcpiInfo)