1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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__
122 #include "acparser.h"
123 #include "acdispat.h"
124 #include "acnamesp.h"
125 #include "acinterp.h"
127 #define _COMPONENT ACPI_DISPATCHER
128 MODULE_NAME ("dswstate")
131 /*******************************************************************************
133 * FUNCTION: AcpiDsResultInsert
135 * PARAMETERS: Object - Object to push
136 * WalkState - Current Walk state
140 * DESCRIPTION: Push an object onto this walk's result stack
142 ******************************************************************************/
148 ACPI_WALK_STATE *WalkState)
150 ACPI_GENERIC_STATE *State;
153 PROC_NAME ("DsResultInsert");
156 State = WalkState->Results;
159 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
161 return (AE_NOT_EXIST);
164 if (Index >= OBJ_NUM_OPERANDS)
166 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
167 "Index out of range: %X Obj=%p State=%p Num=%X\n",
168 Index, Object, WalkState, State->Results.NumResults));
169 return (AE_BAD_PARAMETER);
174 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
175 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
176 Index, Object, WalkState, State->Results.NumResults));
177 return (AE_BAD_PARAMETER);
180 State->Results.ObjDesc [Index] = Object;
181 State->Results.NumResults++;
183 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
184 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
185 Object, Object ? AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type) : "NULL",
186 WalkState, State->Results.NumResults, WalkState->CurrentResult));
192 /*******************************************************************************
194 * FUNCTION: AcpiDsResultRemove
196 * PARAMETERS: Object - Where to return the popped 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 PROC_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 >= OBJ_NUM_OPERANDS)
228 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
229 "Index out of range: %X State=%p Num=%X\n",
230 Index, WalkState, State->Results.NumResults));
234 /* Check for a valid result object */
236 if (!State->Results.ObjDesc [Index])
238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
239 "Null operand! State=%p #Ops=%X, Index=%X\n",
240 WalkState, State->Results.NumResults, Index));
241 return (AE_AML_NO_RETURN_VALUE);
244 /* Remove the object */
246 State->Results.NumResults--;
248 *Object = State->Results.ObjDesc [Index];
249 State->Results.ObjDesc [Index] = NULL;
251 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
252 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
253 *Object, (*Object) ? AcpiUtGetTypeName ((*Object)->Common.Type) : "NULL",
254 Index, WalkState, State->Results.NumResults));
260 /*******************************************************************************
262 * FUNCTION: AcpiDsResultPop
264 * PARAMETERS: Object - Where to return the popped object
265 * WalkState - Current Walk state
269 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
270 * other words, this is a FIFO.
272 ******************************************************************************/
276 ACPI_OPERAND_OBJECT **Object,
277 ACPI_WALK_STATE *WalkState)
280 ACPI_GENERIC_STATE *State;
283 PROC_NAME ("DsResultPop");
286 State = WalkState->Results;
292 if (!State->Results.NumResults)
294 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n",
296 return (AE_AML_NO_RETURN_VALUE);
299 /* Remove top element */
301 State->Results.NumResults--;
303 for (Index = OBJ_NUM_OPERANDS; Index; Index--)
305 /* Check for a valid result object */
307 if (State->Results.ObjDesc [Index -1])
309 *Object = State->Results.ObjDesc [Index -1];
310 State->Results.ObjDesc [Index -1] = NULL;
312 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
313 *Object, (*Object) ? AcpiUtGetTypeName ((*Object)->Common.Type) : "NULL",
314 Index -1, WalkState, State->Results.NumResults));
320 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
321 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)
344 ACPI_GENERIC_STATE *State;
347 PROC_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);
359 if (!State->Results.NumResults)
361 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
362 return (AE_AML_NO_RETURN_VALUE);
365 /* Remove Bottom element */
367 *Object = State->Results.ObjDesc [0];
369 /* Push entire stack down one element */
371 for (Index = 0; Index < State->Results.NumResults; Index++)
373 State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1];
376 State->Results.NumResults--;
378 /* Check for a valid result object */
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
383 WalkState, State->Results.NumResults, Index));
384 return (AE_AML_NO_RETURN_VALUE);
387 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
388 *Object, (*Object) ? AcpiUtGetTypeName ((*Object)->Common.Type) : "NULL",
396 /*******************************************************************************
398 * FUNCTION: AcpiDsResultPush
400 * PARAMETERS: Object - Where to return the popped object
401 * WalkState - Current Walk state
405 * DESCRIPTION: Push an object onto the current result stack
407 ******************************************************************************/
411 ACPI_OPERAND_OBJECT *Object,
412 ACPI_WALK_STATE *WalkState)
414 ACPI_GENERIC_STATE *State;
417 PROC_NAME ("DsResultPush");
420 State = WalkState->Results;
423 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n"));
424 return (AE_AML_INTERNAL);
427 if (State->Results.NumResults == OBJ_NUM_OPERANDS)
429 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
430 "Result stack overflow: Obj=%p State=%p Num=%X\n",
431 Object, WalkState, State->Results.NumResults));
432 return (AE_STACK_OVERFLOW);
437 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n",
438 Object, WalkState, State->Results.NumResults));
439 return (AE_BAD_PARAMETER);
443 State->Results.ObjDesc [State->Results.NumResults] = Object;
444 State->Results.NumResults++;
446 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
447 Object, Object ? AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type) : "NULL",
448 WalkState, State->Results.NumResults, WalkState->CurrentResult));
454 /*******************************************************************************
456 * FUNCTION: AcpiDsResultStackPush
458 * PARAMETERS: Object - Object to push
459 * WalkState - Current Walk state
465 ******************************************************************************/
468 AcpiDsResultStackPush (
469 ACPI_WALK_STATE *WalkState)
471 ACPI_GENERIC_STATE *State;
473 PROC_NAME ("DsResultStackPush");
476 State = AcpiUtCreateGenericState ();
479 return (AE_NO_MEMORY);
482 State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT;
483 AcpiUtPushGenericState (&WalkState->Results, State);
485 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n",
492 /*******************************************************************************
494 * FUNCTION: AcpiDsResultStackPop
496 * PARAMETERS: WalkState - Current Walk state
502 ******************************************************************************/
505 AcpiDsResultStackPop (
506 ACPI_WALK_STATE *WalkState)
508 ACPI_GENERIC_STATE *State;
510 PROC_NAME ("DsResultStackPop");
513 /* Check for stack underflow */
515 if (WalkState->Results == NULL)
517 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n",
519 return (AE_AML_NO_OPERAND);
523 State = AcpiUtPopGenericState (&WalkState->Results);
525 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
526 "Result=%p RemainingResults=%X State=%p\n",
527 State, State->Results.NumResults, WalkState));
529 AcpiUtDeleteGenericState (State);
535 /*******************************************************************************
537 * FUNCTION: AcpiDsObjStackDeleteAll
539 * PARAMETERS: WalkState - Current Walk state
543 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
544 * Should be used with great care, if at all!
546 ******************************************************************************/
549 AcpiDsObjStackDeleteAll (
550 ACPI_WALK_STATE *WalkState)
555 FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState);
558 /* The stack size is configurable, but fixed */
560 for (i = 0; i < OBJ_NUM_OPERANDS; i++)
562 if (WalkState->Operands[i])
564 AcpiUtRemoveReference (WalkState->Operands[i]);
565 WalkState->Operands[i] = NULL;
569 return_ACPI_STATUS (AE_OK);
573 /*******************************************************************************
575 * FUNCTION: AcpiDsObjStackPush
577 * PARAMETERS: Object - Object to push
578 * WalkState - Current Walk state
582 * DESCRIPTION: Push an object onto this walk's object/operand stack
584 ******************************************************************************/
589 ACPI_WALK_STATE *WalkState)
591 PROC_NAME ("DsObjStackPush");
594 /* Check for stack overflow */
596 if (WalkState->NumOperands >= OBJ_NUM_OPERANDS)
598 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
599 "overflow! Obj=%p State=%p #Ops=%X\n",
600 Object, WalkState, WalkState->NumOperands));
601 return (AE_STACK_OVERFLOW);
604 /* Put the object onto the stack */
606 WalkState->Operands [WalkState->NumOperands] = Object;
607 WalkState->NumOperands++;
609 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
610 Object, AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type),
611 WalkState, WalkState->NumOperands));
618 /*******************************************************************************
620 * FUNCTION: AcpiDsObjStackPopObject
622 * PARAMETERS: PopCount - Number of objects/entries to pop
623 * WalkState - Current Walk state
627 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
628 * deleted by this routine.
630 ******************************************************************************/
633 AcpiDsObjStackPopObject (
634 ACPI_OPERAND_OBJECT **Object,
635 ACPI_WALK_STATE *WalkState)
637 PROC_NAME ("DsObjStackPopObject");
640 /* Check for stack underflow */
642 if (WalkState->NumOperands == 0)
644 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
645 "Missing operand/stack empty! State=%p #Ops=%X\n",
646 WalkState, WalkState->NumOperands));
648 return (AE_AML_NO_OPERAND);
653 WalkState->NumOperands--;
655 /* Check for a valid operand */
657 if (!WalkState->Operands [WalkState->NumOperands])
659 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
660 "Null operand! State=%p #Ops=%X\n",
661 WalkState, WalkState->NumOperands));
663 return (AE_AML_NO_OPERAND);
666 /* Get operand and set stack entry to null */
668 *Object = WalkState->Operands [WalkState->NumOperands];
669 WalkState->Operands [WalkState->NumOperands] = NULL;
671 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
672 *Object, AcpiUtGetTypeName ((*Object)->Common.Type),
673 WalkState, WalkState->NumOperands));
679 /*******************************************************************************
681 * FUNCTION: AcpiDsObjStackPop
683 * PARAMETERS: PopCount - Number of objects/entries to pop
684 * WalkState - Current Walk state
688 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
689 * deleted by this routine.
691 ******************************************************************************/
696 ACPI_WALK_STATE *WalkState)
700 PROC_NAME ("DsObjStackPop");
703 for (i = 0; i < PopCount; i++)
705 /* Check for stack underflow */
707 if (WalkState->NumOperands == 0)
709 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
710 "Underflow! Count=%X State=%p #Ops=%X\n",
711 PopCount, WalkState, WalkState->NumOperands));
712 return (AE_STACK_UNDERFLOW);
715 /* Just set the stack entry to null */
717 WalkState->NumOperands--;
718 WalkState->Operands [WalkState->NumOperands] = NULL;
721 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
722 PopCount, WalkState, WalkState->NumOperands));
728 /*******************************************************************************
730 * FUNCTION: AcpiDsObjStackPopAndDelete
732 * PARAMETERS: PopCount - Number of objects/entries to pop
733 * WalkState - Current Walk state
737 * DESCRIPTION: Pop this walk's object stack and delete each object that is
740 ******************************************************************************/
743 AcpiDsObjStackPopAndDelete (
745 ACPI_WALK_STATE *WalkState)
748 ACPI_OPERAND_OBJECT *ObjDesc;
750 PROC_NAME ("DsObjStackPopAndDelete");
753 for (i = 0; i < PopCount; i++)
755 /* Check for stack underflow */
757 if (WalkState->NumOperands == 0)
759 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
760 "Underflow! Count=%X State=%p #Ops=%X\n",
761 PopCount, WalkState, WalkState->NumOperands));
762 return (AE_STACK_UNDERFLOW);
765 /* Pop the stack and delete an object if present in this stack entry */
767 WalkState->NumOperands--;
768 ObjDesc = WalkState->Operands [WalkState->NumOperands];
771 AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]);
772 WalkState->Operands [WalkState->NumOperands] = NULL;
776 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
777 PopCount, WalkState, WalkState->NumOperands));
783 /*******************************************************************************
785 * FUNCTION: AcpiDsObjStackGetValue
787 * PARAMETERS: Index - Stack index whose value is desired. Based
788 * on the top of the stack (index=0 == top)
789 * WalkState - Current Walk state
793 * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
794 * be within the range of the current stack pointer.
796 ******************************************************************************/
799 AcpiDsObjStackGetValue (
801 ACPI_WALK_STATE *WalkState)
804 FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState);
807 /* Can't do it if the stack is empty */
809 if (WalkState->NumOperands == 0)
814 /* or if the index is past the top of the stack */
816 if (Index > (WalkState->NumOperands - (UINT32) 1))
822 return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) -
827 /*******************************************************************************
829 * FUNCTION: AcpiDsGetCurrentWalkState
831 * PARAMETERS: Thread - Get current active state for this Thread
833 * RETURN: Pointer to the current walk state
835 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
838 ******************************************************************************/
841 AcpiDsGetCurrentWalkState (
842 ACPI_THREAD_STATE *Thread)
845 PROC_NAME ("DsGetCurrentWalkState");
853 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "DsGetCurrentWalkState, =%p\n",
854 Thread->WalkStateList));
857 return (Thread->WalkStateList);
861 /*******************************************************************************
863 * FUNCTION: AcpiDsPushWalkState
865 * PARAMETERS: WalkState - State to push
866 * WalkList - The list that owns the walk stack
870 * DESCRIPTION: Place the WalkState at the head of the state list.
872 ******************************************************************************/
875 AcpiDsPushWalkState (
876 ACPI_WALK_STATE *WalkState,
877 ACPI_THREAD_STATE *Thread)
879 FUNCTION_TRACE ("DsPushWalkState");
882 WalkState->Next = Thread->WalkStateList;
883 Thread->WalkStateList = WalkState;
889 /*******************************************************************************
891 * FUNCTION: AcpiDsPopWalkState
893 * PARAMETERS: WalkList - The list that owns the walk stack
895 * RETURN: A WalkState object popped from the stack
897 * DESCRIPTION: Remove and return the walkstate object that is at the head of
898 * the walk stack for the given walk list. NULL indicates that
901 ******************************************************************************/
905 ACPI_THREAD_STATE *Thread)
907 ACPI_WALK_STATE *WalkState;
910 FUNCTION_TRACE ("DsPopWalkState");
913 WalkState = Thread->WalkStateList;
917 /* Next walk state becomes the current walk state */
919 Thread->WalkStateList = WalkState->Next;
922 * Don't clear the NEXT field, this serves as an indicator
923 * that there is a parent WALK STATE
924 * NO: WalkState->Next = NULL;
928 return_PTR (WalkState);
932 /*******************************************************************************
934 * FUNCTION: AcpiDsCreateWalkState
936 * PARAMETERS: Origin - Starting point for this walk
937 * Thread - Current thread state
939 * RETURN: Pointer to the new walk state.
941 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
942 * state is set to this new state.
944 ******************************************************************************/
947 AcpiDsCreateWalkState (
948 ACPI_OWNER_ID OwnerId,
949 ACPI_PARSE_OBJECT *Origin,
950 ACPI_OPERAND_OBJECT *MthDesc,
951 ACPI_THREAD_STATE *Thread)
953 ACPI_WALK_STATE *WalkState;
957 FUNCTION_TRACE ("DsCreateWalkState");
960 WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK);
966 WalkState->DataType = ACPI_DESC_TYPE_WALK;
967 WalkState->OwnerId = OwnerId;
968 WalkState->Origin = Origin;
969 WalkState->MethodDesc = MthDesc;
970 WalkState->Thread = Thread;
972 /* Init the method args/local */
974 #ifndef _ACPI_ASL_COMPILER
975 AcpiDsMethodDataInit (WalkState);
978 /* Create an initial result stack entry */
980 Status = AcpiDsResultStackPush (WalkState);
981 if (ACPI_FAILURE (Status))
986 /* Put the new state at the head of the walk list */
990 AcpiDsPushWalkState (WalkState, Thread);
993 return_PTR (WalkState);
997 #ifndef _ACPI_ASL_COMPILER
998 /*******************************************************************************
1000 * FUNCTION: AcpiDsInitAmlWalk
1002 * PARAMETERS: WalkState - New state to be initialized
1006 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
1008 ******************************************************************************/
1012 ACPI_WALK_STATE *WalkState,
1013 ACPI_PARSE_OBJECT *Op,
1014 ACPI_NAMESPACE_NODE *MethodNode,
1017 ACPI_OPERAND_OBJECT **Params,
1018 ACPI_OPERAND_OBJECT **ReturnObjDesc,
1022 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
1025 FUNCTION_TRACE ("DsInitAmlWalk");
1028 WalkState->ParserState.Aml =
1029 WalkState->ParserState.AmlStart = AmlStart;
1030 WalkState->ParserState.AmlEnd =
1031 WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
1033 /* The NextOp of the NextWalk will be the beginning of the method */
1035 WalkState->NextOp = NULL;
1036 WalkState->Params = Params;
1037 WalkState->CallerReturnDesc = ReturnObjDesc;
1039 Status = AcpiPsInitScope (&WalkState->ParserState, Op);
1040 if (ACPI_FAILURE (Status))
1042 return_ACPI_STATUS (Status);
1047 WalkState->ParserState.StartNode = MethodNode;
1048 WalkState->WalkType = WALK_METHOD;
1049 WalkState->MethodNode = MethodNode;
1050 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode);
1053 /* Push start scope on scope stack and make it current */
1055 Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState);
1056 if (ACPI_FAILURE (Status))
1058 return_ACPI_STATUS (Status);
1061 /* Init the method arguments */
1063 AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState);
1068 /* Setup the current scope */
1070 ParserState->StartNode = ParserState->StartOp->Node;
1071 if (ParserState->StartNode)
1073 /* Push start scope on scope stack and make it current */
1075 Status = AcpiDsScopeStackPush (ParserState->StartNode,
1076 ParserState->StartNode->Type, WalkState);
1077 if (ACPI_FAILURE (Status))
1079 return_ACPI_STATUS (Status);
1084 AcpiDsInitCallbacks (WalkState, PassNumber);
1086 return_ACPI_STATUS (AE_OK);
1091 /*******************************************************************************
1093 * FUNCTION: AcpiDsDeleteWalkState
1095 * PARAMETERS: WalkState - State to delete
1099 * DESCRIPTION: Delete a walk state including all internal data structures
1101 ******************************************************************************/
1104 AcpiDsDeleteWalkState (
1105 ACPI_WALK_STATE *WalkState)
1107 ACPI_GENERIC_STATE *State;
1110 FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState);
1118 if (WalkState->DataType != ACPI_DESC_TYPE_WALK)
1120 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState));
1125 if (WalkState->ParserState.Scope)
1127 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState));
1130 /* Always must free any linked control states */
1132 while (WalkState->ControlState)
1134 State = WalkState->ControlState;
1135 WalkState->ControlState = State->Common.Next;
1137 AcpiUtDeleteGenericState (State);
1140 /* Always must free any linked parse states */
1142 while (WalkState->ScopeInfo)
1144 State = WalkState->ScopeInfo;
1145 WalkState->ScopeInfo = State->Common.Next;
1147 AcpiUtDeleteGenericState (State);
1150 /* Always must free any stacked result states */
1152 while (WalkState->Results)
1154 State = WalkState->Results;
1155 WalkState->Results = State->Common.Next;
1157 AcpiUtDeleteGenericState (State);
1160 AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState);
1165 /******************************************************************************
1167 * FUNCTION: AcpiDsDeleteWalkStateCache
1173 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1176 ******************************************************************************/
1179 AcpiDsDeleteWalkStateCache (
1182 FUNCTION_TRACE ("DsDeleteWalkStateCache");
1185 AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK);