1 /*******************************************************************************
3 * Module Name: utmisc - common utility procedures
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2011, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acnamesp.h>
52 #define _COMPONENT ACPI_UTILITIES
53 ACPI_MODULE_NAME ("utmisc")
56 /*******************************************************************************
58 * FUNCTION: AcpiUtValidateException
60 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
62 * RETURN: A string containing the exception text. NULL if exception is
65 * DESCRIPTION: This function validates and translates an ACPI exception into
68 ******************************************************************************/
71 AcpiUtValidateException (
75 const char *Exception = NULL;
78 ACPI_FUNCTION_ENTRY ();
82 * Status is composed of two parts, a "type" and an actual code
84 SubStatus = (Status & ~AE_CODE_MASK);
86 switch (Status & AE_CODE_MASK)
88 case AE_CODE_ENVIRONMENTAL:
90 if (SubStatus <= AE_CODE_ENV_MAX)
92 Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
96 case AE_CODE_PROGRAMMER:
98 if (SubStatus <= AE_CODE_PGM_MAX)
100 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
104 case AE_CODE_ACPI_TABLES:
106 if (SubStatus <= AE_CODE_TBL_MAX)
108 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
114 if (SubStatus <= AE_CODE_AML_MAX)
116 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
120 case AE_CODE_CONTROL:
122 if (SubStatus <= AE_CODE_CTRL_MAX)
124 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
132 return (ACPI_CAST_PTR (const char, Exception));
136 /*******************************************************************************
138 * FUNCTION: AcpiUtIsPciRootBridge
140 * PARAMETERS: Id - The HID/CID in string format
142 * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
144 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
146 ******************************************************************************/
149 AcpiUtIsPciRootBridge (
154 * Check if this is a PCI root bridge.
155 * ACPI 3.0+: check for a PCI Express root also.
157 if (!(ACPI_STRCMP (Id,
158 PCI_ROOT_HID_STRING)) ||
161 PCI_EXPRESS_ROOT_HID_STRING)))
170 /*******************************************************************************
172 * FUNCTION: AcpiUtIsAmlTable
174 * PARAMETERS: Table - An ACPI table
176 * RETURN: TRUE if table contains executable AML; FALSE otherwise
178 * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
179 * Currently, these are DSDT,SSDT,PSDT. All other table types are
180 * data tables that do not contain AML code.
182 ******************************************************************************/
186 ACPI_TABLE_HEADER *Table)
189 /* These are the only tables that contain executable AML */
191 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
192 ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
193 ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
202 /*******************************************************************************
204 * FUNCTION: AcpiUtAllocateOwnerId
206 * PARAMETERS: OwnerId - Where the new owner ID is returned
210 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
211 * track objects created by the table or method, to be deleted
212 * when the method exits or the table is unloaded.
214 ******************************************************************************/
217 AcpiUtAllocateOwnerId (
218 ACPI_OWNER_ID *OwnerId)
226 ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
229 /* Guard against multiple allocations of ID to the same location */
233 ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
234 return_ACPI_STATUS (AE_ALREADY_EXISTS);
237 /* Mutex for the global ID mask */
239 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
240 if (ACPI_FAILURE (Status))
242 return_ACPI_STATUS (Status);
246 * Find a free owner ID, cycle through all possible IDs on repeated
247 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
248 * to be scanned twice.
250 for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
251 i < (ACPI_NUM_OWNERID_MASKS + 1);
254 if (j >= ACPI_NUM_OWNERID_MASKS)
256 j = 0; /* Wraparound to start of mask array */
259 for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
261 if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
263 /* There are no free IDs in this mask */
268 if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
271 * Found a free ID. The actual ID is the bit index plus one,
272 * making zero an invalid Owner ID. Save this as the last ID
273 * allocated and update the global ID mask.
275 AcpiGbl_OwnerIdMask[j] |= (1 << k);
277 AcpiGbl_LastOwnerIdIndex = (UINT8) j;
278 AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
281 * Construct encoded ID from the index and bit position
283 * Note: Last [j].k (bit 255) is never used and is marked
284 * permanently allocated (prevents +1 overflow)
286 *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
288 ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
289 "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
294 AcpiGbl_NextOwnerIdOffset = 0;
298 * All OwnerIds have been allocated. This typically should
299 * not happen since the IDs are reused after deallocation. The IDs are
300 * allocated upon table load (one per table) and method execution, and
301 * they are released when a table is unloaded or a method completes
304 * If this error happens, there may be very deep nesting of invoked control
305 * methods, or there may be a bug where the IDs are not released.
307 Status = AE_OWNER_ID_LIMIT;
308 ACPI_ERROR ((AE_INFO,
309 "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
312 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
313 return_ACPI_STATUS (Status);
317 /*******************************************************************************
319 * FUNCTION: AcpiUtReleaseOwnerId
321 * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID
323 * RETURN: None. No error is returned because we are either exiting a
324 * control method or unloading a table. Either way, we would
325 * ignore any error anyway.
327 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
329 ******************************************************************************/
332 AcpiUtReleaseOwnerId (
333 ACPI_OWNER_ID *OwnerIdPtr)
335 ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
341 ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
344 /* Always clear the input OwnerId (zero is an invalid ID) */
348 /* Zero is not a valid OwnerID */
352 ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
356 /* Mutex for the global ID mask */
358 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
359 if (ACPI_FAILURE (Status))
364 /* Normalize the ID to zero */
368 /* Decode ID to index/offset pair */
370 Index = ACPI_DIV_32 (OwnerId);
371 Bit = 1 << ACPI_MOD_32 (OwnerId);
373 /* Free the owner ID only if it is valid */
375 if (AcpiGbl_OwnerIdMask[Index] & Bit)
377 AcpiGbl_OwnerIdMask[Index] ^= Bit;
381 ACPI_ERROR ((AE_INFO,
382 "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
385 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
390 /*******************************************************************************
392 * FUNCTION: AcpiUtStrupr (strupr)
394 * PARAMETERS: SrcString - The source string to convert
398 * DESCRIPTION: Convert string to uppercase
400 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
402 ******************************************************************************/
411 ACPI_FUNCTION_ENTRY ();
419 /* Walk entire string, uppercasing the letters */
421 for (String = SrcString; *String; String++)
423 *String = (char) ACPI_TOUPPER (*String);
430 #ifdef ACPI_ASL_COMPILER
431 /*******************************************************************************
433 * FUNCTION: AcpiUtStrlwr (strlwr)
435 * PARAMETERS: SrcString - The source string to convert
439 * DESCRIPTION: Convert string to lowercase
441 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
443 ******************************************************************************/
452 ACPI_FUNCTION_ENTRY ();
460 /* Walk entire string, lowercasing the letters */
462 for (String = SrcString; *String; String++)
464 *String = (char) ACPI_TOLOWER (*String);
472 /*******************************************************************************
474 * FUNCTION: AcpiUtPrintString
476 * PARAMETERS: String - Null terminated ASCII string
477 * MaxLength - Maximum output length
481 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
484 ******************************************************************************/
496 AcpiOsPrintf ("<\"NULL STRING PTR\">");
501 for (i = 0; String[i] && (i < MaxLength); i++)
503 /* Escape sequences */
508 AcpiOsPrintf ("\\a"); /* BELL */
512 AcpiOsPrintf ("\\b"); /* BACKSPACE */
516 AcpiOsPrintf ("\\f"); /* FORMFEED */
520 AcpiOsPrintf ("\\n"); /* LINEFEED */
524 AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/
528 AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */
532 AcpiOsPrintf ("\\v"); /* VERTICAL TAB */
535 case '\'': /* Single Quote */
536 case '\"': /* Double Quote */
537 case '\\': /* Backslash */
538 AcpiOsPrintf ("\\%c", (int) String[i]);
543 /* Check for printable character or hex escape */
545 if (ACPI_IS_PRINT (String[i]))
547 /* This is a normal character */
549 AcpiOsPrintf ("%c", (int) String[i]);
553 /* All others will be Hex escapes */
555 AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
562 if (i == MaxLength && String[i])
564 AcpiOsPrintf ("...");
569 /*******************************************************************************
571 * FUNCTION: AcpiUtDwordByteSwap
573 * PARAMETERS: Value - Value to be converted
575 * RETURN: UINT32 integer with bytes swapped
577 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
579 ******************************************************************************/
582 AcpiUtDwordByteSwap (
597 ACPI_FUNCTION_ENTRY ();
602 Out.Bytes[0] = In.Bytes[3];
603 Out.Bytes[1] = In.Bytes[2];
604 Out.Bytes[2] = In.Bytes[1];
605 Out.Bytes[3] = In.Bytes[0];
611 /*******************************************************************************
613 * FUNCTION: AcpiUtSetIntegerWidth
615 * PARAMETERS: Revision From DSDT header
619 * DESCRIPTION: Set the global integer bit width based upon the revision
620 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
621 * For Revision 2 and above, Integers are 64 bits. Yes, this
622 * makes a difference.
624 ******************************************************************************/
627 AcpiUtSetIntegerWidth (
635 AcpiGbl_IntegerBitWidth = 32;
636 AcpiGbl_IntegerNybbleWidth = 8;
637 AcpiGbl_IntegerByteWidth = 4;
641 /* 64-bit case (ACPI 2.0+) */
643 AcpiGbl_IntegerBitWidth = 64;
644 AcpiGbl_IntegerNybbleWidth = 16;
645 AcpiGbl_IntegerByteWidth = 8;
650 #ifdef ACPI_DEBUG_OUTPUT
651 /*******************************************************************************
653 * FUNCTION: AcpiUtDisplayInitPathname
655 * PARAMETERS: Type - Object type of the node
656 * ObjHandle - Handle whose pathname will be displayed
657 * Path - Additional path string to be appended.
658 * (NULL if no extra path)
660 * RETURN: ACPI_STATUS
662 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
664 ******************************************************************************/
667 AcpiUtDisplayInitPathname (
669 ACPI_NAMESPACE_NODE *ObjHandle,
676 ACPI_FUNCTION_ENTRY ();
679 /* Only print the path if the appropriate debug level is enabled */
681 if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
686 /* Get the full pathname to the node */
688 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
689 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
690 if (ACPI_FAILURE (Status))
695 /* Print what we're doing */
699 case ACPI_TYPE_METHOD:
700 AcpiOsPrintf ("Executing ");
704 AcpiOsPrintf ("Initializing ");
708 /* Print the object type and pathname */
710 AcpiOsPrintf ("%-12s %s",
711 AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
713 /* Extra path is used to append names like _STA, _INI, etc. */
717 AcpiOsPrintf (".%s", Path);
721 ACPI_FREE (Buffer.Pointer);
726 /*******************************************************************************
728 * FUNCTION: AcpiUtValidAcpiChar
730 * PARAMETERS: Char - The character to be examined
731 * Position - Byte position (0-3)
733 * RETURN: TRUE if the character is valid, FALSE otherwise
735 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
736 * 1) Upper case alpha
740 * We allow a '!' as the last character because of the ASF! table
742 ******************************************************************************/
745 AcpiUtValidAcpiChar (
750 if (!((Character >= 'A' && Character <= 'Z') ||
751 (Character >= '0' && Character <= '9') ||
754 /* Allow a '!' in the last position */
756 if (Character == '!' && Position == 3)
768 /*******************************************************************************
770 * FUNCTION: AcpiUtValidAcpiName
772 * PARAMETERS: Name - The name to be examined
774 * RETURN: TRUE if the name is valid, FALSE otherwise
776 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
777 * 1) Upper case alpha
781 ******************************************************************************/
784 AcpiUtValidAcpiName (
790 ACPI_FUNCTION_ENTRY ();
793 for (i = 0; i < ACPI_NAME_SIZE; i++)
795 if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
805 /*******************************************************************************
807 * FUNCTION: AcpiUtRepairName
809 * PARAMETERS: Name - The ACPI name to be repaired
811 * RETURN: Repaired version of the name
813 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
814 * return the new name. NOTE: the Name parameter must reside in
815 * read/write memory, cannot be a const.
817 * An ACPI Name must consist of valid ACPI characters. We will repair the name
818 * if necessary because we don't want to abort because of this, but we want
819 * all namespace names to be printable. A warning message is appropriate.
821 * This issue came up because there are in fact machines that exhibit
822 * this problem, and we want to be able to enable ACPI support for them,
823 * even though there are a few bad names.
825 ******************************************************************************/
832 BOOLEAN FoundBadChar = FALSE;
835 ACPI_FUNCTION_NAME (UtRepairName);
838 /* Check each character in the name */
840 for (i = 0; i < ACPI_NAME_SIZE; i++)
842 if (AcpiUtValidAcpiChar (Name[i], i))
848 * Replace a bad character with something printable, yet technically
849 * still invalid. This prevents any collisions with existing "good"
850 * names in the namespace.
858 /* Report warning only if in strict mode or debug mode */
860 if (!AcpiGbl_EnableInterpreterSlack)
862 ACPI_WARNING ((AE_INFO,
863 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
867 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
868 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
874 /*******************************************************************************
876 * FUNCTION: AcpiUtStrtoul64
878 * PARAMETERS: String - Null terminated string
879 * Base - Radix of the string: 16 or ACPI_ANY_BASE;
880 * ACPI_ANY_BASE means 'in behalf of ToInteger'
881 * RetInteger - Where the converted integer is returned
883 * RETURN: Status and Converted value
885 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
886 * 32-bit or 64-bit conversion, depending on the current mode
887 * of the interpreter.
888 * NOTE: Does not support Octal strings, not needed.
890 ******************************************************************************/
898 UINT32 ThisDigit = 0;
899 UINT64 ReturnValue = 0;
902 UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE);
903 UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4);
904 UINT8 ValidDigits = 0;
909 ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
920 return_ACPI_STATUS (AE_BAD_PARAMETER);
928 /* Skip over any white space in the buffer */
930 while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
938 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
939 * We need to determine if it is decimal or hexadecimal.
941 if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
946 /* Skip over the leading '0x' */
955 /* Any string left? Check that '0x' is not followed by white space. */
957 if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
970 * Perform a 32-bit or 64-bit conversion, depending upon the current
971 * execution mode of the interpreter
973 Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
975 /* Main loop: convert the string to a 32- or 64-bit integer */
979 if (ACPI_IS_DIGIT (*String))
981 /* Convert ASCII 0-9 to Decimal value */
983 ThisDigit = ((UINT8) *String) - '0';
987 /* Digit is out of range; possible in ToInteger case only */
993 ThisDigit = (UINT8) ACPI_TOUPPER (*String);
994 if (ACPI_IS_XDIGIT ((char) ThisDigit))
996 /* Convert ASCII Hex char to value */
998 ThisDigit = ThisDigit - 'A' + 10;
1017 else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
1026 if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
1029 * This is ToInteger operation case.
1030 * No any restrictions for string-to-integer conversion,
1036 /* Divide the digit into the correct position */
1038 (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
1039 Base, &Quotient, NULL);
1041 if (ReturnValue > Quotient)
1053 ReturnValue *= Base;
1054 ReturnValue += ThisDigit;
1058 /* All done, normal exit */
1062 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
1063 ACPI_FORMAT_UINT64 (ReturnValue)));
1065 *RetInteger = ReturnValue;
1066 return_ACPI_STATUS (AE_OK);
1070 /* Base was set/validated above */
1074 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
1078 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
1083 /*******************************************************************************
1085 * FUNCTION: AcpiUtCreateUpdateStateAndPush
1087 * PARAMETERS: Object - Object to be added to the new state
1088 * Action - Increment/Decrement
1089 * StateList - List the state will be added to
1093 * DESCRIPTION: Create a new state and push it
1095 ******************************************************************************/
1098 AcpiUtCreateUpdateStateAndPush (
1099 ACPI_OPERAND_OBJECT *Object,
1101 ACPI_GENERIC_STATE **StateList)
1103 ACPI_GENERIC_STATE *State;
1106 ACPI_FUNCTION_ENTRY ();
1109 /* Ignore null objects; these are expected */
1116 State = AcpiUtCreateUpdateState (Object, Action);
1119 return (AE_NO_MEMORY);
1122 AcpiUtPushGenericState (StateList, State);
1127 /*******************************************************************************
1129 * FUNCTION: AcpiUtWalkPackageTree
1131 * PARAMETERS: SourceObject - The package to walk
1132 * TargetObject - Target object (if package is being copied)
1133 * WalkCallback - Called once for each package element
1134 * Context - Passed to the callback function
1138 * DESCRIPTION: Walk through a package
1140 ******************************************************************************/
1143 AcpiUtWalkPackageTree (
1144 ACPI_OPERAND_OBJECT *SourceObject,
1146 ACPI_PKG_CALLBACK WalkCallback,
1149 ACPI_STATUS Status = AE_OK;
1150 ACPI_GENERIC_STATE *StateList = NULL;
1151 ACPI_GENERIC_STATE *State;
1153 ACPI_OPERAND_OBJECT *ThisSourceObj;
1156 ACPI_FUNCTION_TRACE (UtWalkPackageTree);
1159 State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
1162 return_ACPI_STATUS (AE_NO_MEMORY);
1167 /* Get one element of the package */
1169 ThisIndex = State->Pkg.Index;
1170 ThisSourceObj = (ACPI_OPERAND_OBJECT *)
1171 State->Pkg.SourceObject->Package.Elements[ThisIndex];
1175 * 1) An uninitialized package element. It is completely
1176 * legal to declare a package and leave it uninitialized
1177 * 2) Not an internal object - can be a namespace node instead
1178 * 3) Any type other than a package. Packages are handled in else
1181 if ((!ThisSourceObj) ||
1182 (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
1183 (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
1185 Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
1187 if (ACPI_FAILURE (Status))
1189 return_ACPI_STATUS (Status);
1193 while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
1196 * We've handled all of the objects at this level, This means
1197 * that we have just completed a package. That package may
1198 * have contained one or more packages itself.
1200 * Delete this state and pop the previous state (package).
1202 AcpiUtDeleteGenericState (State);
1203 State = AcpiUtPopGenericState (&StateList);
1205 /* Finished when there are no more states */
1210 * We have handled all of the objects in the top level
1211 * package just add the length of the package objects
1214 return_ACPI_STATUS (AE_OK);
1218 * Go back up a level and move the index past the just
1219 * completed package object.
1226 /* This is a subobject of type package */
1228 Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
1230 if (ACPI_FAILURE (Status))
1232 return_ACPI_STATUS (Status);
1236 * Push the current state and create a new one
1237 * The callback above returned a new target package object.
1239 AcpiUtPushGenericState (&StateList, State);
1240 State = AcpiUtCreatePkgState (ThisSourceObj,
1241 State->Pkg.ThisTargetObj, 0);
1244 /* Free any stacked Update State objects */
1248 State = AcpiUtPopGenericState (&StateList);
1249 AcpiUtDeleteGenericState (State);
1251 return_ACPI_STATUS (AE_NO_MEMORY);
1256 /* We should never get here */
1258 return_ACPI_STATUS (AE_AML_INTERNAL);