1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
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 *****************************************************************************/
118 #define __DSWSTATE_C__
121 #include "acparser.h"
122 #include "acdispat.h"
123 #include "acnamesp.h"
125 #define _COMPONENT ACPI_DISPATCHER
126 ACPI_MODULE_NAME ("dswstate")
129 /*******************************************************************************
131 * FUNCTION: AcpiDsResultInsert
133 * PARAMETERS: Object - Object to push
134 * Index - Where to insert the object
135 * WalkState - Current Walk state
139 * DESCRIPTION: Insert an object onto this walk's result stack
141 ******************************************************************************/
147 ACPI_WALK_STATE *WalkState)
149 ACPI_GENERIC_STATE *State;
152 ACPI_FUNCTION_NAME ("DsResultInsert");
155 State = WalkState->Results;
158 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
160 return (AE_NOT_EXIST);
163 if (Index >= ACPI_OBJ_NUM_OPERANDS)
165 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
166 "Index out of range: %X Obj=%p State=%p Num=%X\n",
167 Index, Object, WalkState, State->Results.NumResults));
168 return (AE_BAD_PARAMETER);
173 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
174 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
175 Index, Object, WalkState, State->Results.NumResults));
176 return (AE_BAD_PARAMETER);
179 State->Results.ObjDesc [Index] = Object;
180 State->Results.NumResults++;
182 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
183 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
184 Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL",
185 WalkState, State->Results.NumResults, WalkState->CurrentResult));
191 /*******************************************************************************
193 * FUNCTION: AcpiDsResultRemove
195 * PARAMETERS: Object - Where to return the popped object
196 * Index - Where to extract the object
197 * WalkState - Current Walk state
201 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
202 * other words, this is a FIFO.
204 ******************************************************************************/
208 ACPI_OPERAND_OBJECT **Object,
210 ACPI_WALK_STATE *WalkState)
212 ACPI_GENERIC_STATE *State;
215 ACPI_FUNCTION_NAME ("DsResultRemove");
218 State = WalkState->Results;
221 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
223 return (AE_NOT_EXIST);
226 if (Index >= ACPI_OBJ_MAX_OPERAND)
228 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
229 "Index out of range: %X State=%p Num=%X\n",
230 Index, WalkState, State->Results.NumResults));
233 /* Check for a valid result object */
235 if (!State->Results.ObjDesc [Index])
237 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
238 "Null operand! State=%p #Ops=%X, Index=%X\n",
239 WalkState, State->Results.NumResults, Index));
240 return (AE_AML_NO_RETURN_VALUE);
243 /* Remove the object */
245 State->Results.NumResults--;
247 *Object = State->Results.ObjDesc [Index];
248 State->Results.ObjDesc [Index] = NULL;
250 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
251 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
252 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
253 Index, WalkState, State->Results.NumResults));
259 /*******************************************************************************
261 * FUNCTION: AcpiDsResultPop
263 * PARAMETERS: Object - Where to return the popped object
264 * WalkState - Current Walk state
268 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
269 * other words, this is a FIFO.
271 ******************************************************************************/
275 ACPI_OPERAND_OBJECT **Object,
276 ACPI_WALK_STATE *WalkState)
278 ACPI_NATIVE_UINT Index;
279 ACPI_GENERIC_STATE *State;
282 ACPI_FUNCTION_NAME ("DsResultPop");
285 State = WalkState->Results;
291 if (!State->Results.NumResults)
293 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n",
295 return (AE_AML_NO_RETURN_VALUE);
298 /* Remove top element */
300 State->Results.NumResults--;
302 for (Index = ACPI_OBJ_NUM_OPERANDS; Index; Index--)
304 /* Check for a valid result object */
306 if (State->Results.ObjDesc [Index -1])
308 *Object = State->Results.ObjDesc [Index -1];
309 State->Results.ObjDesc [Index -1] = NULL;
311 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
312 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
313 (UINT32) Index -1, WalkState, State->Results.NumResults));
319 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
320 return (AE_AML_NO_RETURN_VALUE);
324 /*******************************************************************************
326 * FUNCTION: AcpiDsResultPopFromBottom
328 * PARAMETERS: Object - Where to return the popped object
329 * WalkState - Current Walk state
333 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
334 * other words, this is a FIFO.
336 ******************************************************************************/
339 AcpiDsResultPopFromBottom (
340 ACPI_OPERAND_OBJECT **Object,
341 ACPI_WALK_STATE *WalkState)
343 ACPI_NATIVE_UINT Index;
344 ACPI_GENERIC_STATE *State;
347 ACPI_FUNCTION_NAME ("DsResultPopFromBottom");
350 State = WalkState->Results;
353 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
354 "Warning: No result object pushed! State=%p\n", WalkState));
355 return (AE_NOT_EXIST);
358 if (!State->Results.NumResults)
360 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
361 return (AE_AML_NO_RETURN_VALUE);
364 /* Remove Bottom element */
366 *Object = State->Results.ObjDesc [0];
368 /* Push entire stack down one element */
370 for (Index = 0; Index < State->Results.NumResults; Index++)
372 State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1];
375 State->Results.NumResults--;
377 /* Check for a valid result object */
381 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
382 WalkState, State->Results.NumResults, (UINT32) Index));
383 return (AE_AML_NO_RETURN_VALUE);
386 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
387 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
394 /*******************************************************************************
396 * FUNCTION: AcpiDsResultPush
398 * PARAMETERS: Object - Where to return the popped object
399 * WalkState - Current Walk state
403 * DESCRIPTION: Push an object onto the current result stack
405 ******************************************************************************/
409 ACPI_OPERAND_OBJECT *Object,
410 ACPI_WALK_STATE *WalkState)
412 ACPI_GENERIC_STATE *State;
415 ACPI_FUNCTION_NAME ("DsResultPush");
418 State = WalkState->Results;
421 ACPI_REPORT_ERROR (("No result stack frame during push\n"));
422 return (AE_AML_INTERNAL);
425 if (State->Results.NumResults == ACPI_OBJ_NUM_OPERANDS)
427 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
428 "Result stack overflow: Obj=%p State=%p Num=%X\n",
429 Object, WalkState, State->Results.NumResults));
430 return (AE_STACK_OVERFLOW);
435 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n",
436 Object, WalkState, State->Results.NumResults));
437 return (AE_BAD_PARAMETER);
440 State->Results.ObjDesc [State->Results.NumResults] = Object;
441 State->Results.NumResults++;
443 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
444 Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL",
445 WalkState, State->Results.NumResults, WalkState->CurrentResult));
451 /*******************************************************************************
453 * FUNCTION: AcpiDsResultStackPush
455 * PARAMETERS: WalkState - Current Walk state
459 * DESCRIPTION: Push an object onto the WalkState result stack.
461 ******************************************************************************/
464 AcpiDsResultStackPush (
465 ACPI_WALK_STATE *WalkState)
467 ACPI_GENERIC_STATE *State;
469 ACPI_FUNCTION_NAME ("DsResultStackPush");
472 State = AcpiUtCreateGenericState ();
475 return (AE_NO_MEMORY);
478 State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT;
479 AcpiUtPushGenericState (&WalkState->Results, State);
481 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n",
488 /*******************************************************************************
490 * FUNCTION: AcpiDsResultStackPop
492 * PARAMETERS: WalkState - Current Walk state
496 * DESCRIPTION: Pop an object off of the WalkState result stack.
498 ******************************************************************************/
501 AcpiDsResultStackPop (
502 ACPI_WALK_STATE *WalkState)
504 ACPI_GENERIC_STATE *State;
506 ACPI_FUNCTION_NAME ("DsResultStackPop");
509 /* Check for stack underflow */
511 if (WalkState->Results == NULL)
513 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n",
515 return (AE_AML_NO_OPERAND);
518 State = AcpiUtPopGenericState (&WalkState->Results);
520 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
521 "Result=%p RemainingResults=%X State=%p\n",
522 State, State->Results.NumResults, WalkState));
524 AcpiUtDeleteGenericState (State);
530 /*******************************************************************************
532 * FUNCTION: AcpiDsObjStackDeleteAll
534 * PARAMETERS: WalkState - Current Walk state
538 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
539 * Should be used with great care, if at all!
541 ******************************************************************************/
544 AcpiDsObjStackDeleteAll (
545 ACPI_WALK_STATE *WalkState)
550 ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState);
553 /* The stack size is configurable, but fixed */
555 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++)
557 if (WalkState->Operands[i])
559 AcpiUtRemoveReference (WalkState->Operands[i]);
560 WalkState->Operands[i] = NULL;
564 return_ACPI_STATUS (AE_OK);
568 /*******************************************************************************
570 * FUNCTION: AcpiDsObjStackPush
572 * PARAMETERS: Object - Object to push
573 * WalkState - Current Walk state
577 * DESCRIPTION: Push an object onto this walk's object/operand stack
579 ******************************************************************************/
584 ACPI_WALK_STATE *WalkState)
586 ACPI_FUNCTION_NAME ("DsObjStackPush");
589 /* Check for stack overflow */
591 if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS)
593 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
594 "overflow! Obj=%p State=%p #Ops=%X\n",
595 Object, WalkState, WalkState->NumOperands));
596 return (AE_STACK_OVERFLOW);
599 /* Put the object onto the stack */
601 WalkState->Operands [WalkState->NumOperands] = Object;
602 WalkState->NumOperands++;
604 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
605 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object),
606 WalkState, WalkState->NumOperands));
613 /*******************************************************************************
615 * FUNCTION: AcpiDsObjStackPopObject
617 * PARAMETERS: PopCount - Number of objects/entries to pop
618 * WalkState - Current Walk state
622 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
623 * deleted by this routine.
625 ******************************************************************************/
628 AcpiDsObjStackPopObject (
629 ACPI_OPERAND_OBJECT **Object,
630 ACPI_WALK_STATE *WalkState)
632 ACPI_FUNCTION_NAME ("DsObjStackPopObject");
635 /* Check for stack underflow */
637 if (WalkState->NumOperands == 0)
639 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
640 "Missing operand/stack empty! State=%p #Ops=%X\n",
641 WalkState, WalkState->NumOperands));
643 return (AE_AML_NO_OPERAND);
648 WalkState->NumOperands--;
650 /* Check for a valid operand */
652 if (!WalkState->Operands [WalkState->NumOperands])
654 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
655 "Null operand! State=%p #Ops=%X\n",
656 WalkState, WalkState->NumOperands));
658 return (AE_AML_NO_OPERAND);
661 /* Get operand and set stack entry to null */
663 *Object = WalkState->Operands [WalkState->NumOperands];
664 WalkState->Operands [WalkState->NumOperands] = NULL;
666 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
667 *Object, AcpiUtGetObjectTypeName (*Object),
668 WalkState, WalkState->NumOperands));
675 /*******************************************************************************
677 * FUNCTION: AcpiDsObjStackPop
679 * PARAMETERS: PopCount - Number of objects/entries to pop
680 * WalkState - Current Walk state
684 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
685 * deleted by this routine.
687 ******************************************************************************/
692 ACPI_WALK_STATE *WalkState)
696 ACPI_FUNCTION_NAME ("DsObjStackPop");
699 for (i = 0; i < PopCount; i++)
701 /* Check for stack underflow */
703 if (WalkState->NumOperands == 0)
705 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
706 "Underflow! Count=%X State=%p #Ops=%X\n",
707 PopCount, WalkState, WalkState->NumOperands));
708 return (AE_STACK_UNDERFLOW);
711 /* Just set the stack entry to null */
713 WalkState->NumOperands--;
714 WalkState->Operands [WalkState->NumOperands] = NULL;
717 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
718 PopCount, WalkState, WalkState->NumOperands));
724 /*******************************************************************************
726 * FUNCTION: AcpiDsObjStackPopAndDelete
728 * PARAMETERS: PopCount - Number of objects/entries to pop
729 * WalkState - Current Walk state
733 * DESCRIPTION: Pop this walk's object stack and delete each object that is
736 ******************************************************************************/
739 AcpiDsObjStackPopAndDelete (
741 ACPI_WALK_STATE *WalkState)
744 ACPI_OPERAND_OBJECT *ObjDesc;
747 ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete");
750 for (i = 0; i < PopCount; i++)
752 /* Check for stack underflow */
754 if (WalkState->NumOperands == 0)
756 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
757 "Underflow! Count=%X State=%p #Ops=%X\n",
758 PopCount, WalkState, WalkState->NumOperands));
759 return (AE_STACK_UNDERFLOW);
762 /* Pop the stack and delete an object if present in this stack entry */
764 WalkState->NumOperands--;
765 ObjDesc = WalkState->Operands [WalkState->NumOperands];
768 AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]);
769 WalkState->Operands [WalkState->NumOperands] = NULL;
773 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
774 PopCount, WalkState, WalkState->NumOperands));
780 /*******************************************************************************
782 * FUNCTION: AcpiDsObjStackGetValue
784 * PARAMETERS: Index - Stack index whose value is desired. Based
785 * on the top of the stack (index=0 == top)
786 * WalkState - Current Walk state
790 * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
791 * be within the range of the current stack pointer.
793 ******************************************************************************/
796 AcpiDsObjStackGetValue (
798 ACPI_WALK_STATE *WalkState)
801 ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState);
804 /* Can't do it if the stack is empty */
806 if (WalkState->NumOperands == 0)
811 /* or if the index is past the top of the stack */
813 if (Index > (WalkState->NumOperands - (UINT32) 1))
818 return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) -
823 /*******************************************************************************
825 * FUNCTION: AcpiDsGetCurrentWalkState
827 * PARAMETERS: Thread - Get current active state for this Thread
829 * RETURN: Pointer to the current walk state
831 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
834 ******************************************************************************/
837 AcpiDsGetCurrentWalkState (
838 ACPI_THREAD_STATE *Thread)
841 ACPI_FUNCTION_NAME ("DsGetCurrentWalkState");
849 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n",
850 Thread->WalkStateList));
852 return (Thread->WalkStateList);
856 /*******************************************************************************
858 * FUNCTION: AcpiDsPushWalkState
860 * PARAMETERS: WalkState - State to push
861 * WalkList - The list that owns the walk stack
865 * DESCRIPTION: Place the WalkState at the head of the state list.
867 ******************************************************************************/
870 AcpiDsPushWalkState (
871 ACPI_WALK_STATE *WalkState,
872 ACPI_THREAD_STATE *Thread)
874 ACPI_FUNCTION_TRACE ("DsPushWalkState");
877 WalkState->Next = Thread->WalkStateList;
878 Thread->WalkStateList = WalkState;
884 /*******************************************************************************
886 * FUNCTION: AcpiDsPopWalkState
888 * PARAMETERS: WalkList - The list that owns the walk stack
890 * RETURN: A WalkState object popped from the stack
892 * DESCRIPTION: Remove and return the walkstate object that is at the head of
893 * the walk stack for the given walk list. NULL indicates that
896 ******************************************************************************/
900 ACPI_THREAD_STATE *Thread)
902 ACPI_WALK_STATE *WalkState;
905 ACPI_FUNCTION_TRACE ("DsPopWalkState");
908 WalkState = Thread->WalkStateList;
912 /* Next walk state becomes the current walk state */
914 Thread->WalkStateList = WalkState->Next;
917 * Don't clear the NEXT field, this serves as an indicator
918 * that there is a parent WALK STATE
919 * NO: WalkState->Next = NULL;
923 return_PTR (WalkState);
927 /*******************************************************************************
929 * FUNCTION: AcpiDsCreateWalkState
931 * PARAMETERS: Origin - Starting point for this walk
932 * Thread - Current thread state
934 * RETURN: Pointer to the new walk state.
936 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
937 * state is set to this new state.
939 ******************************************************************************/
942 AcpiDsCreateWalkState (
943 ACPI_OWNER_ID OwnerId,
944 ACPI_PARSE_OBJECT *Origin,
945 ACPI_OPERAND_OBJECT *MthDesc,
946 ACPI_THREAD_STATE *Thread)
948 ACPI_WALK_STATE *WalkState;
952 ACPI_FUNCTION_TRACE ("DsCreateWalkState");
955 WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK);
961 WalkState->DataType = ACPI_DESC_TYPE_WALK;
962 WalkState->OwnerId = OwnerId;
963 WalkState->Origin = Origin;
964 WalkState->MethodDesc = MthDesc;
965 WalkState->Thread = Thread;
967 WalkState->ParserState.StartOp = Origin;
969 /* Init the method args/local */
971 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
972 AcpiDsMethodDataInit (WalkState);
975 /* Create an initial result stack entry */
977 Status = AcpiDsResultStackPush (WalkState);
978 if (ACPI_FAILURE (Status))
980 AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState);
984 /* Put the new state at the head of the walk list */
988 AcpiDsPushWalkState (WalkState, Thread);
991 return_PTR (WalkState);
995 /*******************************************************************************
997 * FUNCTION: AcpiDsInitAmlWalk
999 * PARAMETERS: WalkState - New state to be initialized
1000 * Op - Current parse op
1001 * MethodNode - Control method NS node, if any
1002 * AmlStart - Start of AML
1003 * AmlLength - Length of AML
1004 * Params - Method args, if any
1005 * ReturnObjDesc - Where to store a return object, if any
1006 * PassNumber - 1, 2, or 3
1010 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
1012 ******************************************************************************/
1016 ACPI_WALK_STATE *WalkState,
1017 ACPI_PARSE_OBJECT *Op,
1018 ACPI_NAMESPACE_NODE *MethodNode,
1021 ACPI_PARAMETER_INFO *Info,
1025 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
1026 ACPI_PARSE_OBJECT *ExtraOp;
1029 ACPI_FUNCTION_TRACE ("DsInitAmlWalk");
1032 WalkState->ParserState.Aml =
1033 WalkState->ParserState.AmlStart = AmlStart;
1034 WalkState->ParserState.AmlEnd =
1035 WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
1037 /* The NextOp of the NextWalk will be the beginning of the method */
1039 WalkState->NextOp = NULL;
1043 if (Info->ParameterType == ACPI_PARAM_GPE)
1045 WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO,
1050 WalkState->Params = Info->Parameters;
1051 WalkState->CallerReturnDesc = &Info->ReturnObject;
1055 Status = AcpiPsInitScope (&WalkState->ParserState, Op);
1056 if (ACPI_FAILURE (Status))
1058 return_ACPI_STATUS (Status);
1063 WalkState->ParserState.StartNode = MethodNode;
1064 WalkState->WalkType = ACPI_WALK_METHOD;
1065 WalkState->MethodNode = MethodNode;
1066 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode);
1068 /* Push start scope on scope stack and make it current */
1070 Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState);
1071 if (ACPI_FAILURE (Status))
1073 return_ACPI_STATUS (Status);
1076 /* Init the method arguments */
1078 Status = AcpiDsMethodDataInitArgs (WalkState->Params, ACPI_METHOD_NUM_ARGS, WalkState);
1079 if (ACPI_FAILURE (Status))
1081 return_ACPI_STATUS (Status);
1087 * Setup the current scope.
1088 * Find a Named Op that has a namespace node associated with it.
1089 * search upwards from this Op. Current scope is the first
1090 * Op with a namespace node.
1092 ExtraOp = ParserState->StartOp;
1093 while (ExtraOp && !ExtraOp->Common.Node)
1095 ExtraOp = ExtraOp->Common.Parent;
1100 ParserState->StartNode = NULL;
1104 ParserState->StartNode = ExtraOp->Common.Node;
1107 if (ParserState->StartNode)
1109 /* Push start scope on scope stack and make it current */
1111 Status = AcpiDsScopeStackPush (ParserState->StartNode,
1112 ParserState->StartNode->Type, WalkState);
1113 if (ACPI_FAILURE (Status))
1115 return_ACPI_STATUS (Status);
1120 Status = AcpiDsInitCallbacks (WalkState, PassNumber);
1121 return_ACPI_STATUS (Status);
1125 /*******************************************************************************
1127 * FUNCTION: AcpiDsDeleteWalkState
1129 * PARAMETERS: WalkState - State to delete
1133 * DESCRIPTION: Delete a walk state including all internal data structures
1135 ******************************************************************************/
1138 AcpiDsDeleteWalkState (
1139 ACPI_WALK_STATE *WalkState)
1141 ACPI_GENERIC_STATE *State;
1144 ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState);
1152 if (WalkState->DataType != ACPI_DESC_TYPE_WALK)
1154 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState));
1158 if (WalkState->ParserState.Scope)
1160 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState));
1163 /* Always must free any linked control states */
1165 while (WalkState->ControlState)
1167 State = WalkState->ControlState;
1168 WalkState->ControlState = State->Common.Next;
1170 AcpiUtDeleteGenericState (State);
1173 /* Always must free any linked parse states */
1175 while (WalkState->ScopeInfo)
1177 State = WalkState->ScopeInfo;
1178 WalkState->ScopeInfo = State->Common.Next;
1180 AcpiUtDeleteGenericState (State);
1183 /* Always must free any stacked result states */
1185 while (WalkState->Results)
1187 State = WalkState->Results;
1188 WalkState->Results = State->Common.Next;
1190 AcpiUtDeleteGenericState (State);
1193 AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState);
1198 #ifdef ACPI_ENABLE_OBJECT_CACHE
1199 /******************************************************************************
1201 * FUNCTION: AcpiDsDeleteWalkStateCache
1207 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1210 ******************************************************************************/
1213 AcpiDsDeleteWalkStateCache (
1216 ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache");
1219 AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK);