1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
153 #include "accommon.h"
154 #include "acparser.h"
155 #include "acdispat.h"
156 #include "acnamesp.h"
158 #define _COMPONENT ACPI_DISPATCHER
159 ACPI_MODULE_NAME ("dswstate")
161 /* Local prototypes */
164 AcpiDsResultStackPush (
165 ACPI_WALK_STATE
*WalkState
);
168 AcpiDsResultStackPop (
169 ACPI_WALK_STATE
*WalkState
);
172 /*******************************************************************************
174 * FUNCTION: AcpiDsResultPop
176 * PARAMETERS: Object - Where to return the popped object
177 * WalkState - Current Walk state
181 * DESCRIPTION: Pop an object off the top of this walk's result stack
183 ******************************************************************************/
187 ACPI_OPERAND_OBJECT
**Object
,
188 ACPI_WALK_STATE
*WalkState
)
191 ACPI_GENERIC_STATE
*State
;
195 ACPI_FUNCTION_NAME (DsResultPop
);
198 State
= WalkState
->Results
;
200 /* Incorrect state of result stack */
202 if (State
&& !WalkState
->ResultCount
)
204 ACPI_ERROR ((AE_INFO
, "No results on result stack"));
205 return (AE_AML_INTERNAL
);
208 if (!State
&& WalkState
->ResultCount
)
210 ACPI_ERROR ((AE_INFO
, "No result state for result stack"));
211 return (AE_AML_INTERNAL
);
214 /* Empty result stack */
218 ACPI_ERROR ((AE_INFO
, "Result stack is empty! State=%p", WalkState
));
219 return (AE_AML_NO_RETURN_VALUE
);
222 /* Return object of the top element and clean that top element result stack */
224 WalkState
->ResultCount
--;
225 Index
= (UINT32
) WalkState
->ResultCount
% ACPI_RESULTS_FRAME_OBJ_NUM
;
227 *Object
= State
->Results
.ObjDesc
[Index
];
230 ACPI_ERROR ((AE_INFO
, "No result objects on result stack, State=%p",
232 return (AE_AML_NO_RETURN_VALUE
);
235 State
->Results
.ObjDesc
[Index
] = NULL
;
238 Status
= AcpiDsResultStackPop (WalkState
);
239 if (ACPI_FAILURE (Status
))
245 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
246 "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object
,
247 AcpiUtGetObjectTypeName (*Object
),
248 Index
, WalkState
, WalkState
->ResultCount
));
254 /*******************************************************************************
256 * FUNCTION: AcpiDsResultPush
258 * PARAMETERS: Object - Where to return the popped object
259 * WalkState - Current Walk state
263 * DESCRIPTION: Push an object onto the current result stack
265 ******************************************************************************/
269 ACPI_OPERAND_OBJECT
*Object
,
270 ACPI_WALK_STATE
*WalkState
)
272 ACPI_GENERIC_STATE
*State
;
277 ACPI_FUNCTION_NAME (DsResultPush
);
280 if (WalkState
->ResultCount
> WalkState
->ResultSize
)
282 ACPI_ERROR ((AE_INFO
, "Result stack is full"));
283 return (AE_AML_INTERNAL
);
285 else if (WalkState
->ResultCount
== WalkState
->ResultSize
)
287 /* Extend the result stack */
289 Status
= AcpiDsResultStackPush (WalkState
);
290 if (ACPI_FAILURE (Status
))
292 ACPI_ERROR ((AE_INFO
, "Failed to extend the result stack"));
297 if (!(WalkState
->ResultCount
< WalkState
->ResultSize
))
299 ACPI_ERROR ((AE_INFO
, "No free elements in result stack"));
300 return (AE_AML_INTERNAL
);
303 State
= WalkState
->Results
;
306 ACPI_ERROR ((AE_INFO
, "No result stack frame during push"));
307 return (AE_AML_INTERNAL
);
312 ACPI_ERROR ((AE_INFO
,
313 "Null Object! Obj=%p State=%p Num=%u",
314 Object
, WalkState
, WalkState
->ResultCount
));
315 return (AE_BAD_PARAMETER
);
318 /* Assign the address of object to the top free element of result stack */
320 Index
= (UINT32
) WalkState
->ResultCount
% ACPI_RESULTS_FRAME_OBJ_NUM
;
321 State
->Results
.ObjDesc
[Index
] = Object
;
322 WalkState
->ResultCount
++;
324 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
325 Object
, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT
*) Object
),
326 WalkState
, WalkState
->ResultCount
, WalkState
->CurrentResult
));
332 /*******************************************************************************
334 * FUNCTION: AcpiDsResultStackPush
336 * PARAMETERS: WalkState - Current Walk state
340 * DESCRIPTION: Push an object onto the WalkState result stack
342 ******************************************************************************/
345 AcpiDsResultStackPush (
346 ACPI_WALK_STATE
*WalkState
)
348 ACPI_GENERIC_STATE
*State
;
351 ACPI_FUNCTION_NAME (DsResultStackPush
);
354 /* Check for stack overflow */
356 if (((UINT32
) WalkState
->ResultSize
+ ACPI_RESULTS_FRAME_OBJ_NUM
) >
357 ACPI_RESULTS_OBJ_NUM_MAX
)
359 ACPI_ERROR ((AE_INFO
, "Result stack overflow: State=%p Num=%u",
360 WalkState
, WalkState
->ResultSize
));
361 return (AE_STACK_OVERFLOW
);
364 State
= AcpiUtCreateGenericState ();
367 return (AE_NO_MEMORY
);
370 State
->Common
.DescriptorType
= ACPI_DESC_TYPE_STATE_RESULT
;
371 AcpiUtPushGenericState (&WalkState
->Results
, State
);
373 /* Increase the length of the result stack by the length of frame */
375 WalkState
->ResultSize
+= ACPI_RESULTS_FRAME_OBJ_NUM
;
377 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Results=%p State=%p\n",
384 /*******************************************************************************
386 * FUNCTION: AcpiDsResultStackPop
388 * PARAMETERS: WalkState - Current Walk state
392 * DESCRIPTION: Pop an object off of the WalkState result stack
394 ******************************************************************************/
397 AcpiDsResultStackPop (
398 ACPI_WALK_STATE
*WalkState
)
400 ACPI_GENERIC_STATE
*State
;
403 ACPI_FUNCTION_NAME (DsResultStackPop
);
406 /* Check for stack underflow */
408 if (WalkState
->Results
== NULL
)
410 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
411 "Result stack underflow - State=%p\n", WalkState
));
412 return (AE_AML_NO_OPERAND
);
415 if (WalkState
->ResultSize
< ACPI_RESULTS_FRAME_OBJ_NUM
)
417 ACPI_ERROR ((AE_INFO
, "Insufficient result stack size"));
418 return (AE_AML_INTERNAL
);
421 State
= AcpiUtPopGenericState (&WalkState
->Results
);
422 AcpiUtDeleteGenericState (State
);
424 /* Decrease the length of result stack by the length of frame */
426 WalkState
->ResultSize
-= ACPI_RESULTS_FRAME_OBJ_NUM
;
428 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
429 "Result=%p RemainingResults=%X State=%p\n",
430 State
, WalkState
->ResultCount
, WalkState
));
436 /*******************************************************************************
438 * FUNCTION: AcpiDsObjStackPush
440 * PARAMETERS: Object - Object to push
441 * WalkState - Current Walk state
445 * DESCRIPTION: Push an object onto this walk's object/operand stack
447 ******************************************************************************/
452 ACPI_WALK_STATE
*WalkState
)
454 ACPI_FUNCTION_NAME (DsObjStackPush
);
457 /* Check for stack overflow */
459 if (WalkState
->NumOperands
>= ACPI_OBJ_NUM_OPERANDS
)
461 ACPI_ERROR ((AE_INFO
,
462 "Object stack overflow! Obj=%p State=%p #Ops=%u",
463 Object
, WalkState
, WalkState
->NumOperands
));
464 return (AE_STACK_OVERFLOW
);
467 /* Put the object onto the stack */
469 WalkState
->Operands
[WalkState
->OperandIndex
] = Object
;
470 WalkState
->NumOperands
++;
472 /* For the usual order of filling the operand stack */
474 WalkState
->OperandIndex
++;
476 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p #Ops=%X\n",
477 Object
, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT
*) Object
),
478 WalkState
, WalkState
->NumOperands
));
484 /*******************************************************************************
486 * FUNCTION: AcpiDsObjStackPop
488 * PARAMETERS: PopCount - Number of objects/entries to pop
489 * WalkState - Current Walk state
493 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
494 * deleted by this routine.
496 ******************************************************************************/
501 ACPI_WALK_STATE
*WalkState
)
506 ACPI_FUNCTION_NAME (DsObjStackPop
);
509 for (i
= 0; i
< PopCount
; i
++)
511 /* Check for stack underflow */
513 if (WalkState
->NumOperands
== 0)
515 ACPI_ERROR ((AE_INFO
,
516 "Object stack underflow! Count=%X State=%p #Ops=%u",
517 PopCount
, WalkState
, WalkState
->NumOperands
));
518 return (AE_STACK_UNDERFLOW
);
521 /* Just set the stack entry to null */
523 WalkState
->NumOperands
--;
524 WalkState
->Operands
[WalkState
->NumOperands
] = NULL
;
527 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%u\n",
528 PopCount
, WalkState
, WalkState
->NumOperands
));
534 /*******************************************************************************
536 * FUNCTION: AcpiDsObjStackPopAndDelete
538 * PARAMETERS: PopCount - Number of objects/entries to pop
539 * WalkState - Current Walk state
543 * DESCRIPTION: Pop this walk's object stack and delete each object that is
546 ******************************************************************************/
549 AcpiDsObjStackPopAndDelete (
551 ACPI_WALK_STATE
*WalkState
)
554 ACPI_OPERAND_OBJECT
*ObjDesc
;
557 ACPI_FUNCTION_NAME (DsObjStackPopAndDelete
);
565 for (i
= (INT32
) PopCount
- 1; i
>= 0; i
--)
567 if (WalkState
->NumOperands
== 0)
572 /* Pop the stack and delete an object if present in this stack entry */
574 WalkState
->NumOperands
--;
575 ObjDesc
= WalkState
->Operands
[i
];
578 AcpiUtRemoveReference (WalkState
->Operands
[i
]);
579 WalkState
->Operands
[i
] = NULL
;
583 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%X\n",
584 PopCount
, WalkState
, WalkState
->NumOperands
));
588 /*******************************************************************************
590 * FUNCTION: AcpiDsGetCurrentWalkState
592 * PARAMETERS: Thread - Get current active state for this Thread
594 * RETURN: Pointer to the current walk state
596 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
599 ******************************************************************************/
602 AcpiDsGetCurrentWalkState (
603 ACPI_THREAD_STATE
*Thread
)
605 ACPI_FUNCTION_NAME (DsGetCurrentWalkState
);
613 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE
, "Current WalkState %p\n",
614 Thread
->WalkStateList
));
616 return (Thread
->WalkStateList
);
620 /*******************************************************************************
622 * FUNCTION: AcpiDsPushWalkState
624 * PARAMETERS: WalkState - State to push
625 * Thread - Thread state object
629 * DESCRIPTION: Place the Thread state at the head of the state list
631 ******************************************************************************/
634 AcpiDsPushWalkState (
635 ACPI_WALK_STATE
*WalkState
,
636 ACPI_THREAD_STATE
*Thread
)
638 ACPI_FUNCTION_TRACE (DsPushWalkState
);
641 WalkState
->Next
= Thread
->WalkStateList
;
642 Thread
->WalkStateList
= WalkState
;
648 /*******************************************************************************
650 * FUNCTION: AcpiDsPopWalkState
652 * PARAMETERS: Thread - Current thread state
654 * RETURN: A WalkState object popped from the thread's stack
656 * DESCRIPTION: Remove and return the walkstate object that is at the head of
657 * the walk stack for the given walk list. NULL indicates that
660 ******************************************************************************/
664 ACPI_THREAD_STATE
*Thread
)
666 ACPI_WALK_STATE
*WalkState
;
669 ACPI_FUNCTION_TRACE (DsPopWalkState
);
672 WalkState
= Thread
->WalkStateList
;
676 /* Next walk state becomes the current walk state */
678 Thread
->WalkStateList
= WalkState
->Next
;
681 * Don't clear the NEXT field, this serves as an indicator
682 * that there is a parent WALK STATE
683 * Do Not: WalkState->Next = NULL;
687 return_PTR (WalkState
);
691 /*******************************************************************************
693 * FUNCTION: AcpiDsCreateWalkState
695 * PARAMETERS: OwnerId - ID for object creation
696 * Origin - Starting point for this walk
697 * MethodDesc - Method object
698 * Thread - Current thread state
700 * RETURN: Pointer to the new walk state.
702 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
703 * state is set to this new state.
705 ******************************************************************************/
708 AcpiDsCreateWalkState (
709 ACPI_OWNER_ID OwnerId
,
710 ACPI_PARSE_OBJECT
*Origin
,
711 ACPI_OPERAND_OBJECT
*MethodDesc
,
712 ACPI_THREAD_STATE
*Thread
)
714 ACPI_WALK_STATE
*WalkState
;
717 ACPI_FUNCTION_TRACE (DsCreateWalkState
);
720 WalkState
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE
));
726 WalkState
->DescriptorType
= ACPI_DESC_TYPE_WALK
;
727 WalkState
->MethodDesc
= MethodDesc
;
728 WalkState
->OwnerId
= OwnerId
;
729 WalkState
->Origin
= Origin
;
730 WalkState
->Thread
= Thread
;
732 WalkState
->ParserState
.StartOp
= Origin
;
734 /* Init the method args/local */
736 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
737 AcpiDsMethodDataInit (WalkState
);
740 /* Put the new state at the head of the walk list */
744 AcpiDsPushWalkState (WalkState
, Thread
);
747 return_PTR (WalkState
);
751 /*******************************************************************************
753 * FUNCTION: AcpiDsInitAmlWalk
755 * PARAMETERS: WalkState - New state to be initialized
756 * Op - Current parse op
757 * MethodNode - Control method NS node, if any
758 * AmlStart - Start of AML
759 * AmlLength - Length of AML
760 * Info - Method info block (params, etc.)
761 * PassNumber - 1, 2, or 3
765 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
767 ******************************************************************************/
771 ACPI_WALK_STATE
*WalkState
,
772 ACPI_PARSE_OBJECT
*Op
,
773 ACPI_NAMESPACE_NODE
*MethodNode
,
776 ACPI_EVALUATE_INFO
*Info
,
780 ACPI_PARSE_STATE
*ParserState
= &WalkState
->ParserState
;
781 ACPI_PARSE_OBJECT
*ExtraOp
;
784 ACPI_FUNCTION_TRACE (DsInitAmlWalk
);
787 WalkState
->ParserState
.Aml
=
788 WalkState
->ParserState
.AmlStart
= AmlStart
;
789 WalkState
->ParserState
.AmlEnd
=
790 WalkState
->ParserState
.PkgEnd
= AmlStart
+ AmlLength
;
792 /* The NextOp of the NextWalk will be the beginning of the method */
794 WalkState
->NextOp
= NULL
;
795 WalkState
->PassNumber
= PassNumber
;
799 WalkState
->Params
= Info
->Parameters
;
800 WalkState
->CallerReturnDesc
= &Info
->ReturnObject
;
803 Status
= AcpiPsInitScope (&WalkState
->ParserState
, Op
);
804 if (ACPI_FAILURE (Status
))
806 return_ACPI_STATUS (Status
);
811 WalkState
->ParserState
.StartNode
= MethodNode
;
812 WalkState
->WalkType
= ACPI_WALK_METHOD
;
813 WalkState
->MethodNode
= MethodNode
;
814 WalkState
->MethodDesc
= AcpiNsGetAttachedObject (MethodNode
);
816 /* Push start scope on scope stack and make it current */
818 Status
= AcpiDsScopeStackPush (
819 MethodNode
, ACPI_TYPE_METHOD
, WalkState
);
820 if (ACPI_FAILURE (Status
))
822 return_ACPI_STATUS (Status
);
825 /* Init the method arguments */
827 Status
= AcpiDsMethodDataInitArgs (WalkState
->Params
,
828 ACPI_METHOD_NUM_ARGS
, WalkState
);
829 if (ACPI_FAILURE (Status
))
831 return_ACPI_STATUS (Status
);
837 * Setup the current scope.
838 * Find a Named Op that has a namespace node associated with it.
839 * search upwards from this Op. Current scope is the first
840 * Op with a namespace node.
842 ExtraOp
= ParserState
->StartOp
;
843 while (ExtraOp
&& !ExtraOp
->Common
.Node
)
845 ExtraOp
= ExtraOp
->Common
.Parent
;
850 ParserState
->StartNode
= NULL
;
854 ParserState
->StartNode
= ExtraOp
->Common
.Node
;
857 if (ParserState
->StartNode
)
859 /* Push start scope on scope stack and make it current */
861 Status
= AcpiDsScopeStackPush (ParserState
->StartNode
,
862 ParserState
->StartNode
->Type
, WalkState
);
863 if (ACPI_FAILURE (Status
))
865 return_ACPI_STATUS (Status
);
870 Status
= AcpiDsInitCallbacks (WalkState
, PassNumber
);
871 return_ACPI_STATUS (Status
);
875 /*******************************************************************************
877 * FUNCTION: AcpiDsDeleteWalkState
879 * PARAMETERS: WalkState - State to delete
883 * DESCRIPTION: Delete a walk state including all internal data structures
885 ******************************************************************************/
888 AcpiDsDeleteWalkState (
889 ACPI_WALK_STATE
*WalkState
)
891 ACPI_GENERIC_STATE
*State
;
894 ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState
, WalkState
);
902 if (WalkState
->DescriptorType
!= ACPI_DESC_TYPE_WALK
)
904 ACPI_ERROR ((AE_INFO
, "%p is not a valid walk state",
909 /* There should not be any open scopes */
911 if (WalkState
->ParserState
.Scope
)
913 ACPI_ERROR ((AE_INFO
, "%p walk still has a scope list",
915 AcpiPsCleanupScope (&WalkState
->ParserState
);
918 /* Always must free any linked control states */
920 while (WalkState
->ControlState
)
922 State
= WalkState
->ControlState
;
923 WalkState
->ControlState
= State
->Common
.Next
;
925 AcpiUtDeleteGenericState (State
);
928 /* Always must free any linked parse states */
930 while (WalkState
->ScopeInfo
)
932 State
= WalkState
->ScopeInfo
;
933 WalkState
->ScopeInfo
= State
->Common
.Next
;
935 AcpiUtDeleteGenericState (State
);
938 /* Always must free any stacked result states */
940 while (WalkState
->Results
)
942 State
= WalkState
->Results
;
943 WalkState
->Results
= State
->Common
.Next
;
945 AcpiUtDeleteGenericState (State
);
948 ACPI_FREE (WalkState
);