1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, 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 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dswstate.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $ */
119 #define __DSWSTATE_C__
122 #include "acparser.h"
123 #include "acdispat.h"
124 #include "acnamesp.h"
126 #define _COMPONENT ACPI_DISPATCHER
127 ACPI_MODULE_NAME ("dswstate")
130 /*******************************************************************************
132 * FUNCTION: AcpiDsResultInsert
134 * PARAMETERS: Object - Object to push
135 * WalkState - Current Walk state
139 * DESCRIPTION: Push 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 * WalkState - Current Walk state
200 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
201 * other words, this is a FIFO.
203 ******************************************************************************/
207 ACPI_OPERAND_OBJECT **Object,
209 ACPI_WALK_STATE *WalkState)
211 ACPI_GENERIC_STATE *State;
214 ACPI_FUNCTION_NAME ("DsResultRemove");
217 State = WalkState->Results;
220 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
222 return (AE_NOT_EXIST);
225 if (Index >= ACPI_OBJ_MAX_OPERAND)
227 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
228 "Index out of range: %X State=%p Num=%X\n",
229 Index, WalkState, State->Results.NumResults));
232 /* Check for a valid result object */
234 if (!State->Results.ObjDesc [Index])
236 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
237 "Null operand! State=%p #Ops=%X, Index=%X\n",
238 WalkState, State->Results.NumResults, Index));
239 return (AE_AML_NO_RETURN_VALUE);
242 /* Remove the object */
244 State->Results.NumResults--;
246 *Object = State->Results.ObjDesc [Index];
247 State->Results.ObjDesc [Index] = NULL;
249 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
250 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
251 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
252 Index, WalkState, State->Results.NumResults));
258 /*******************************************************************************
260 * FUNCTION: AcpiDsResultPop
262 * PARAMETERS: Object - Where to return the popped object
263 * WalkState - Current Walk state
267 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
268 * other words, this is a FIFO.
270 ******************************************************************************/
274 ACPI_OPERAND_OBJECT **Object,
275 ACPI_WALK_STATE *WalkState)
277 ACPI_NATIVE_UINT Index;
278 ACPI_GENERIC_STATE *State;
281 ACPI_FUNCTION_NAME ("DsResultPop");
284 State = WalkState->Results;
290 if (!State->Results.NumResults)
292 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n",
294 return (AE_AML_NO_RETURN_VALUE);
297 /* Remove top element */
299 State->Results.NumResults--;
301 for (Index = ACPI_OBJ_NUM_OPERANDS; Index; Index--)
303 /* Check for a valid result object */
305 if (State->Results.ObjDesc [Index -1])
307 *Object = State->Results.ObjDesc [Index -1];
308 State->Results.ObjDesc [Index -1] = NULL;
310 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
311 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
312 (UINT32) Index -1, WalkState, State->Results.NumResults));
318 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
319 return (AE_AML_NO_RETURN_VALUE);
322 /*******************************************************************************
324 * FUNCTION: AcpiDsResultPopFromBottom
326 * PARAMETERS: Object - Where to return the popped object
327 * WalkState - Current Walk state
331 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
332 * other words, this is a FIFO.
334 ******************************************************************************/
337 AcpiDsResultPopFromBottom (
338 ACPI_OPERAND_OBJECT **Object,
339 ACPI_WALK_STATE *WalkState)
341 ACPI_NATIVE_UINT Index;
342 ACPI_GENERIC_STATE *State;
345 ACPI_FUNCTION_NAME ("DsResultPopFromBottom");
348 State = WalkState->Results;
351 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
352 "Warning: No result object pushed! State=%p\n", WalkState));
353 return (AE_NOT_EXIST);
356 if (!State->Results.NumResults)
358 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState));
359 return (AE_AML_NO_RETURN_VALUE);
362 /* Remove Bottom element */
364 *Object = State->Results.ObjDesc [0];
366 /* Push entire stack down one element */
368 for (Index = 0; Index < State->Results.NumResults; Index++)
370 State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1];
373 State->Results.NumResults--;
375 /* Check for a valid result object */
379 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
380 WalkState, State->Results.NumResults, (UINT32) Index));
381 return (AE_AML_NO_RETURN_VALUE);
384 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
385 *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL",
393 /*******************************************************************************
395 * FUNCTION: AcpiDsResultPush
397 * PARAMETERS: Object - Where to return the popped object
398 * WalkState - Current Walk state
402 * DESCRIPTION: Push an object onto the current result stack
404 ******************************************************************************/
408 ACPI_OPERAND_OBJECT *Object,
409 ACPI_WALK_STATE *WalkState)
411 ACPI_GENERIC_STATE *State;
414 ACPI_FUNCTION_NAME ("DsResultPush");
417 State = WalkState->Results;
420 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n"));
421 return (AE_AML_INTERNAL);
424 if (State->Results.NumResults == ACPI_OBJ_NUM_OPERANDS)
426 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
427 "Result stack overflow: Obj=%p State=%p Num=%X\n",
428 Object, WalkState, State->Results.NumResults));
429 return (AE_STACK_OVERFLOW);
434 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n",
435 Object, WalkState, State->Results.NumResults));
436 return (AE_BAD_PARAMETER);
439 State->Results.ObjDesc [State->Results.NumResults] = Object;
440 State->Results.NumResults++;
442 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
443 Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL",
444 WalkState, State->Results.NumResults, WalkState->CurrentResult));
450 /*******************************************************************************
452 * FUNCTION: AcpiDsResultStackPush
454 * PARAMETERS: Object - Object to push
455 * 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);
519 State = AcpiUtPopGenericState (&WalkState->Results);
521 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
522 "Result=%p RemainingResults=%X State=%p\n",
523 State, State->Results.NumResults, WalkState));
525 AcpiUtDeleteGenericState (State);
531 /*******************************************************************************
533 * FUNCTION: AcpiDsObjStackDeleteAll
535 * PARAMETERS: WalkState - Current Walk state
539 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
540 * Should be used with great care, if at all!
542 ******************************************************************************/
545 AcpiDsObjStackDeleteAll (
546 ACPI_WALK_STATE *WalkState)
551 ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState);
554 /* The stack size is configurable, but fixed */
556 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++)
558 if (WalkState->Operands[i])
560 AcpiUtRemoveReference (WalkState->Operands[i]);
561 WalkState->Operands[i] = NULL;
565 return_ACPI_STATUS (AE_OK);
569 /*******************************************************************************
571 * FUNCTION: AcpiDsObjStackPush
573 * PARAMETERS: Object - Object to push
574 * WalkState - Current Walk state
578 * DESCRIPTION: Push an object onto this walk's object/operand stack
580 ******************************************************************************/
585 ACPI_WALK_STATE *WalkState)
587 ACPI_FUNCTION_NAME ("DsObjStackPush");
590 /* Check for stack overflow */
592 if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS)
594 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
595 "overflow! Obj=%p State=%p #Ops=%X\n",
596 Object, WalkState, WalkState->NumOperands));
597 return (AE_STACK_OVERFLOW);
600 /* Put the object onto the stack */
602 WalkState->Operands [WalkState->NumOperands] = Object;
603 WalkState->NumOperands++;
605 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
606 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object),
607 WalkState, WalkState->NumOperands));
614 /*******************************************************************************
616 * FUNCTION: AcpiDsObjStackPopObject
618 * PARAMETERS: PopCount - Number of objects/entries to pop
619 * WalkState - Current Walk state
623 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
624 * deleted by this routine.
626 ******************************************************************************/
629 AcpiDsObjStackPopObject (
630 ACPI_OPERAND_OBJECT **Object,
631 ACPI_WALK_STATE *WalkState)
633 ACPI_FUNCTION_NAME ("DsObjStackPopObject");
636 /* Check for stack underflow */
638 if (WalkState->NumOperands == 0)
640 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
641 "Missing operand/stack empty! State=%p #Ops=%X\n",
642 WalkState, WalkState->NumOperands));
644 return (AE_AML_NO_OPERAND);
649 WalkState->NumOperands--;
651 /* Check for a valid operand */
653 if (!WalkState->Operands [WalkState->NumOperands])
655 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
656 "Null operand! State=%p #Ops=%X\n",
657 WalkState, WalkState->NumOperands));
659 return (AE_AML_NO_OPERAND);
662 /* Get operand and set stack entry to null */
664 *Object = WalkState->Operands [WalkState->NumOperands];
665 WalkState->Operands [WalkState->NumOperands] = NULL;
667 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
668 *Object, AcpiUtGetObjectTypeName (*Object),
669 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;
746 ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete");
749 for (i = 0; i < PopCount; i++)
751 /* Check for stack underflow */
753 if (WalkState->NumOperands == 0)
755 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
756 "Underflow! Count=%X State=%p #Ops=%X\n",
757 PopCount, WalkState, WalkState->NumOperands));
758 return (AE_STACK_UNDERFLOW);
761 /* Pop the stack and delete an object if present in this stack entry */
763 WalkState->NumOperands--;
764 ObjDesc = WalkState->Operands [WalkState->NumOperands];
767 AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]);
768 WalkState->Operands [WalkState->NumOperands] = NULL;
772 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
773 PopCount, WalkState, WalkState->NumOperands));
779 /*******************************************************************************
781 * FUNCTION: AcpiDsObjStackGetValue
783 * PARAMETERS: Index - Stack index whose value is desired. Based
784 * on the top of the stack (index=0 == top)
785 * WalkState - Current Walk state
789 * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
790 * be within the range of the current stack pointer.
792 ******************************************************************************/
795 AcpiDsObjStackGetValue (
797 ACPI_WALK_STATE *WalkState)
800 ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState);
803 /* Can't do it if the stack is empty */
805 if (WalkState->NumOperands == 0)
810 /* or if the index is past the top of the stack */
812 if (Index > (WalkState->NumOperands - (UINT32) 1))
817 return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) -
822 /*******************************************************************************
824 * FUNCTION: AcpiDsGetCurrentWalkState
826 * PARAMETERS: Thread - Get current active state for this Thread
828 * RETURN: Pointer to the current walk state
830 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
833 ******************************************************************************/
836 AcpiDsGetCurrentWalkState (
837 ACPI_THREAD_STATE *Thread)
840 ACPI_FUNCTION_NAME ("DsGetCurrentWalkState");
848 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n",
849 Thread->WalkStateList));
851 return (Thread->WalkStateList);
855 /*******************************************************************************
857 * FUNCTION: AcpiDsPushWalkState
859 * PARAMETERS: WalkState - State to push
860 * WalkList - The list that owns the walk stack
864 * DESCRIPTION: Place the WalkState at the head of the state list.
866 ******************************************************************************/
869 AcpiDsPushWalkState (
870 ACPI_WALK_STATE *WalkState,
871 ACPI_THREAD_STATE *Thread)
873 ACPI_FUNCTION_TRACE ("DsPushWalkState");
876 WalkState->Next = Thread->WalkStateList;
877 Thread->WalkStateList = WalkState;
883 /*******************************************************************************
885 * FUNCTION: AcpiDsPopWalkState
887 * PARAMETERS: WalkList - The list that owns the walk stack
889 * RETURN: A WalkState object popped from the stack
891 * DESCRIPTION: Remove and return the walkstate object that is at the head of
892 * the walk stack for the given walk list. NULL indicates that
895 ******************************************************************************/
899 ACPI_THREAD_STATE *Thread)
901 ACPI_WALK_STATE *WalkState;
904 ACPI_FUNCTION_TRACE ("DsPopWalkState");
907 WalkState = Thread->WalkStateList;
911 /* Next walk state becomes the current walk state */
913 Thread->WalkStateList = WalkState->Next;
916 * Don't clear the NEXT field, this serves as an indicator
917 * that there is a parent WALK STATE
918 * NO: WalkState->Next = NULL;
922 return_PTR (WalkState);
926 /*******************************************************************************
928 * FUNCTION: AcpiDsCreateWalkState
930 * PARAMETERS: Origin - Starting point for this walk
931 * Thread - Current thread state
933 * RETURN: Pointer to the new walk state.
935 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
936 * state is set to this new state.
938 ******************************************************************************/
941 AcpiDsCreateWalkState (
942 ACPI_OWNER_ID OwnerId,
943 ACPI_PARSE_OBJECT *Origin,
944 ACPI_OPERAND_OBJECT *MthDesc,
945 ACPI_THREAD_STATE *Thread)
947 ACPI_WALK_STATE *WalkState;
951 ACPI_FUNCTION_TRACE ("DsCreateWalkState");
954 WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK);
960 WalkState->DataType = ACPI_DESC_TYPE_WALK;
961 WalkState->OwnerId = OwnerId;
962 WalkState->Origin = Origin;
963 WalkState->MethodDesc = MthDesc;
964 WalkState->Thread = Thread;
966 WalkState->ParserState.StartOp = Origin;
968 /* Init the method args/local */
970 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
971 AcpiDsMethodDataInit (WalkState);
974 /* Create an initial result stack entry */
976 Status = AcpiDsResultStackPush (WalkState);
977 if (ACPI_FAILURE (Status))
982 /* Put the new state at the head of the walk list */
986 AcpiDsPushWalkState (WalkState, Thread);
989 return_PTR (WalkState);
993 /*******************************************************************************
995 * FUNCTION: AcpiDsInitAmlWalk
997 * PARAMETERS: WalkState - New state to be initialized
1001 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
1003 ******************************************************************************/
1007 ACPI_WALK_STATE *WalkState,
1008 ACPI_PARSE_OBJECT *Op,
1009 ACPI_NAMESPACE_NODE *MethodNode,
1012 ACPI_OPERAND_OBJECT **Params,
1013 ACPI_OPERAND_OBJECT **ReturnObjDesc,
1017 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
1018 ACPI_PARSE_OBJECT *ExtraOp;
1021 ACPI_FUNCTION_TRACE ("DsInitAmlWalk");
1024 WalkState->ParserState.Aml =
1025 WalkState->ParserState.AmlStart = AmlStart;
1026 WalkState->ParserState.AmlEnd =
1027 WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
1029 /* The NextOp of the NextWalk will be the beginning of the method */
1031 WalkState->NextOp = NULL;
1032 WalkState->Params = Params;
1033 WalkState->CallerReturnDesc = ReturnObjDesc;
1035 Status = AcpiPsInitScope (&WalkState->ParserState, Op);
1036 if (ACPI_FAILURE (Status))
1038 return_ACPI_STATUS (Status);
1043 WalkState->ParserState.StartNode = MethodNode;
1044 WalkState->WalkType = ACPI_WALK_METHOD;
1045 WalkState->MethodNode = MethodNode;
1046 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode);
1048 /* Push start scope on scope stack and make it current */
1050 Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState);
1051 if (ACPI_FAILURE (Status))
1053 return_ACPI_STATUS (Status);
1056 /* Init the method arguments */
1058 Status = AcpiDsMethodDataInitArgs (Params, ACPI_METHOD_NUM_ARGS, WalkState);
1059 if (ACPI_FAILURE (Status))
1061 return_ACPI_STATUS (Status);
1067 * Setup the current scope.
1068 * Find a Named Op that has a namespace node associated with it.
1069 * search upwards from this Op. Current scope is the first
1070 * Op with a namespace node.
1072 ExtraOp = ParserState->StartOp;
1073 while (ExtraOp && !ExtraOp->Common.Node)
1075 ExtraOp = ExtraOp->Common.Parent;
1079 ParserState->StartNode = NULL;
1083 ParserState->StartNode = ExtraOp->Common.Node;
1086 if (ParserState->StartNode)
1088 /* Push start scope on scope stack and make it current */
1090 Status = AcpiDsScopeStackPush (ParserState->StartNode,
1091 ParserState->StartNode->Type, WalkState);
1092 if (ACPI_FAILURE (Status))
1094 return_ACPI_STATUS (Status);
1099 Status = AcpiDsInitCallbacks (WalkState, PassNumber);
1100 return_ACPI_STATUS (Status);
1104 /*******************************************************************************
1106 * FUNCTION: AcpiDsDeleteWalkState
1108 * PARAMETERS: WalkState - State to delete
1112 * DESCRIPTION: Delete a walk state including all internal data structures
1114 ******************************************************************************/
1117 AcpiDsDeleteWalkState (
1118 ACPI_WALK_STATE *WalkState)
1120 ACPI_GENERIC_STATE *State;
1123 ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState);
1131 if (WalkState->DataType != ACPI_DESC_TYPE_WALK)
1133 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState));
1137 if (WalkState->ParserState.Scope)
1139 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState));
1142 /* Always must free any linked control states */
1144 while (WalkState->ControlState)
1146 State = WalkState->ControlState;
1147 WalkState->ControlState = State->Common.Next;
1149 AcpiUtDeleteGenericState (State);
1152 /* Always must free any linked parse states */
1154 while (WalkState->ScopeInfo)
1156 State = WalkState->ScopeInfo;
1157 WalkState->ScopeInfo = State->Common.Next;
1159 AcpiUtDeleteGenericState (State);
1162 /* Always must free any stacked result states */
1164 while (WalkState->Results)
1166 State = WalkState->Results;
1167 WalkState->Results = State->Common.Next;
1169 AcpiUtDeleteGenericState (State);
1172 AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState);
1177 /******************************************************************************
1179 * FUNCTION: AcpiDsDeleteWalkStateCache
1185 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1188 ******************************************************************************/
1191 AcpiDsDeleteWalkStateCache (
1194 ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache");
1197 AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK);