1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include <acpi/acpi.h>
46 #include <acpi/acparser.h>
47 #include <acpi/acdispat.h>
48 #include <acpi/acnamesp.h>
50 #define _COMPONENT ACPI_DISPATCHER
51 ACPI_MODULE_NAME ("dswstate")
54 #ifdef ACPI_FUTURE_USAGE
56 /*******************************************************************************
58 * FUNCTION: acpi_ds_result_insert
60 * PARAMETERS: Object - Object to push
61 * Index - Where to insert the object
62 * walk_state - Current Walk state
66 * DESCRIPTION: Insert an object onto this walk's result stack
68 ******************************************************************************/
71 acpi_ds_result_insert (
74 struct acpi_walk_state
*walk_state
)
76 union acpi_generic_state
*state
;
79 ACPI_FUNCTION_NAME ("ds_result_insert");
82 state
= walk_state
->results
;
84 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "No result object pushed! State=%p\n",
86 return (AE_NOT_EXIST
);
89 if (index
>= ACPI_OBJ_NUM_OPERANDS
) {
90 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
91 "Index out of range: %X Obj=%p State=%p Num=%X\n",
92 index
, object
, walk_state
, state
->results
.num_results
));
93 return (AE_BAD_PARAMETER
);
97 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
98 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
99 index
, object
, walk_state
, state
->results
.num_results
));
100 return (AE_BAD_PARAMETER
);
103 state
->results
.obj_desc
[index
] = object
;
104 state
->results
.num_results
++;
106 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
107 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
108 object
, object
? acpi_ut_get_object_type_name ((union acpi_operand_object
*) object
) : "NULL",
109 walk_state
, state
->results
.num_results
, walk_state
->current_result
));
115 /*******************************************************************************
117 * FUNCTION: acpi_ds_result_remove
119 * PARAMETERS: Object - Where to return the popped object
120 * Index - Where to extract the object
121 * walk_state - Current Walk state
125 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
126 * other words, this is a FIFO.
128 ******************************************************************************/
131 acpi_ds_result_remove (
132 union acpi_operand_object
**object
,
134 struct acpi_walk_state
*walk_state
)
136 union acpi_generic_state
*state
;
139 ACPI_FUNCTION_NAME ("ds_result_remove");
142 state
= walk_state
->results
;
144 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "No result object pushed! State=%p\n",
146 return (AE_NOT_EXIST
);
149 if (index
>= ACPI_OBJ_MAX_OPERAND
) {
150 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
151 "Index out of range: %X State=%p Num=%X\n",
152 index
, walk_state
, state
->results
.num_results
));
155 /* Check for a valid result object */
157 if (!state
->results
.obj_desc
[index
]) {
158 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
159 "Null operand! State=%p #Ops=%X, Index=%X\n",
160 walk_state
, state
->results
.num_results
, index
));
161 return (AE_AML_NO_RETURN_VALUE
);
164 /* Remove the object */
166 state
->results
.num_results
--;
168 *object
= state
->results
.obj_desc
[index
];
169 state
->results
.obj_desc
[index
] = NULL
;
171 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
172 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
173 *object
, (*object
) ? acpi_ut_get_object_type_name (*object
) : "NULL",
174 index
, walk_state
, state
->results
.num_results
));
179 #endif /* ACPI_FUTURE_USAGE */
182 /*******************************************************************************
184 * FUNCTION: acpi_ds_result_pop
186 * PARAMETERS: Object - Where to return the popped object
187 * walk_state - Current Walk state
191 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
192 * other words, this is a FIFO.
194 ******************************************************************************/
198 union acpi_operand_object
**object
,
199 struct acpi_walk_state
*walk_state
)
201 acpi_native_uint index
;
202 union acpi_generic_state
*state
;
205 ACPI_FUNCTION_NAME ("ds_result_pop");
208 state
= walk_state
->results
;
213 if (!state
->results
.num_results
) {
214 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "Result stack is empty! State=%p\n",
216 return (AE_AML_NO_RETURN_VALUE
);
219 /* Remove top element */
221 state
->results
.num_results
--;
223 for (index
= ACPI_OBJ_NUM_OPERANDS
; index
; index
--) {
224 /* Check for a valid result object */
226 if (state
->results
.obj_desc
[index
-1]) {
227 *object
= state
->results
.obj_desc
[index
-1];
228 state
->results
.obj_desc
[index
-1] = NULL
;
230 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
231 *object
, (*object
) ? acpi_ut_get_object_type_name (*object
) : "NULL",
232 (u32
) index
-1, walk_state
, state
->results
.num_results
));
238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "No result objects! State=%p\n", walk_state
));
239 return (AE_AML_NO_RETURN_VALUE
);
243 /*******************************************************************************
245 * FUNCTION: acpi_ds_result_pop_from_bottom
247 * PARAMETERS: Object - Where to return the popped object
248 * walk_state - Current Walk state
252 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
253 * other words, this is a FIFO.
255 ******************************************************************************/
258 acpi_ds_result_pop_from_bottom (
259 union acpi_operand_object
**object
,
260 struct acpi_walk_state
*walk_state
)
262 acpi_native_uint index
;
263 union acpi_generic_state
*state
;
266 ACPI_FUNCTION_NAME ("ds_result_pop_from_bottom");
269 state
= walk_state
->results
;
271 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
272 "Warning: No result object pushed! State=%p\n", walk_state
));
273 return (AE_NOT_EXIST
);
276 if (!state
->results
.num_results
) {
277 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "No result objects! State=%p\n", walk_state
));
278 return (AE_AML_NO_RETURN_VALUE
);
281 /* Remove Bottom element */
283 *object
= state
->results
.obj_desc
[0];
285 /* Push entire stack down one element */
287 for (index
= 0; index
< state
->results
.num_results
; index
++) {
288 state
->results
.obj_desc
[index
] = state
->results
.obj_desc
[index
+ 1];
291 state
->results
.num_results
--;
293 /* Check for a valid result object */
296 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "Null operand! State=%p #Ops=%X, Index=%X\n",
297 walk_state
, state
->results
.num_results
, (u32
) index
));
298 return (AE_AML_NO_RETURN_VALUE
);
301 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s], Results=%p State=%p\n",
302 *object
, (*object
) ? acpi_ut_get_object_type_name (*object
) : "NULL",
309 /*******************************************************************************
311 * FUNCTION: acpi_ds_result_push
313 * PARAMETERS: Object - Where to return the popped object
314 * walk_state - Current Walk state
318 * DESCRIPTION: Push an object onto the current result stack
320 ******************************************************************************/
323 acpi_ds_result_push (
324 union acpi_operand_object
*object
,
325 struct acpi_walk_state
*walk_state
)
327 union acpi_generic_state
*state
;
330 ACPI_FUNCTION_NAME ("ds_result_push");
333 state
= walk_state
->results
;
335 ACPI_REPORT_ERROR (("No result stack frame during push\n"));
336 return (AE_AML_INTERNAL
);
339 if (state
->results
.num_results
== ACPI_OBJ_NUM_OPERANDS
) {
340 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
341 "Result stack overflow: Obj=%p State=%p Num=%X\n",
342 object
, walk_state
, state
->results
.num_results
));
343 return (AE_STACK_OVERFLOW
);
347 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "Null Object! Obj=%p State=%p Num=%X\n",
348 object
, walk_state
, state
->results
.num_results
));
349 return (AE_BAD_PARAMETER
);
352 state
->results
.obj_desc
[state
->results
.num_results
] = object
;
353 state
->results
.num_results
++;
355 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
356 object
, object
? acpi_ut_get_object_type_name ((union acpi_operand_object
*) object
) : "NULL",
357 walk_state
, state
->results
.num_results
, walk_state
->current_result
));
363 /*******************************************************************************
365 * FUNCTION: acpi_ds_result_stack_push
367 * PARAMETERS: walk_state - Current Walk state
371 * DESCRIPTION: Push an object onto the walk_state result stack.
373 ******************************************************************************/
376 acpi_ds_result_stack_push (
377 struct acpi_walk_state
*walk_state
)
379 union acpi_generic_state
*state
;
381 ACPI_FUNCTION_NAME ("ds_result_stack_push");
384 state
= acpi_ut_create_generic_state ();
386 return (AE_NO_MEMORY
);
389 state
->common
.data_type
= ACPI_DESC_TYPE_STATE_RESULT
;
390 acpi_ut_push_generic_state (&walk_state
->results
, state
);
392 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Results=%p State=%p\n",
399 /*******************************************************************************
401 * FUNCTION: acpi_ds_result_stack_pop
403 * PARAMETERS: walk_state - Current Walk state
407 * DESCRIPTION: Pop an object off of the walk_state result stack.
409 ******************************************************************************/
412 acpi_ds_result_stack_pop (
413 struct acpi_walk_state
*walk_state
)
415 union acpi_generic_state
*state
;
417 ACPI_FUNCTION_NAME ("ds_result_stack_pop");
420 /* Check for stack underflow */
422 if (walk_state
->results
== NULL
) {
423 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Underflow - State=%p\n",
425 return (AE_AML_NO_OPERAND
);
428 state
= acpi_ut_pop_generic_state (&walk_state
->results
);
430 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
431 "Result=%p remaining_results=%X State=%p\n",
432 state
, state
->results
.num_results
, walk_state
));
434 acpi_ut_delete_generic_state (state
);
440 /*******************************************************************************
442 * FUNCTION: acpi_ds_obj_stack_delete_all
444 * PARAMETERS: walk_state - Current Walk state
448 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
449 * Should be used with great care, if at all!
451 ******************************************************************************/
452 #ifdef ACPI_FUTURE_USAGE
454 acpi_ds_obj_stack_delete_all (
455 struct acpi_walk_state
*walk_state
)
460 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state
);
463 /* The stack size is configurable, but fixed */
465 for (i
= 0; i
< ACPI_OBJ_NUM_OPERANDS
; i
++) {
466 if (walk_state
->operands
[i
]) {
467 acpi_ut_remove_reference (walk_state
->operands
[i
]);
468 walk_state
->operands
[i
] = NULL
;
472 return_ACPI_STATUS (AE_OK
);
474 #endif /* ACPI_FUTURE_USAGE */
477 /*******************************************************************************
479 * FUNCTION: acpi_ds_obj_stack_push
481 * PARAMETERS: Object - Object to push
482 * walk_state - Current Walk state
486 * DESCRIPTION: Push an object onto this walk's object/operand stack
488 ******************************************************************************/
491 acpi_ds_obj_stack_push (
493 struct acpi_walk_state
*walk_state
)
495 ACPI_FUNCTION_NAME ("ds_obj_stack_push");
498 /* Check for stack overflow */
500 if (walk_state
->num_operands
>= ACPI_OBJ_NUM_OPERANDS
) {
501 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
502 "overflow! Obj=%p State=%p #Ops=%X\n",
503 object
, walk_state
, walk_state
->num_operands
));
504 return (AE_STACK_OVERFLOW
);
507 /* Put the object onto the stack */
509 walk_state
->operands
[walk_state
->num_operands
] = object
;
510 walk_state
->num_operands
++;
512 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p #Ops=%X\n",
513 object
, acpi_ut_get_object_type_name ((union acpi_operand_object
*) object
),
514 walk_state
, walk_state
->num_operands
));
521 /*******************************************************************************
523 * FUNCTION: acpi_ds_obj_stack_pop_object
525 * PARAMETERS: pop_count - Number of objects/entries to pop
526 * walk_state - Current Walk state
530 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
531 * deleted by this routine.
533 ******************************************************************************/
536 acpi_ds_obj_stack_pop_object (
537 union acpi_operand_object
**object
,
538 struct acpi_walk_state
*walk_state
)
540 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
543 /* Check for stack underflow */
545 if (walk_state
->num_operands
== 0) {
546 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
547 "Missing operand/stack empty! State=%p #Ops=%X\n",
548 walk_state
, walk_state
->num_operands
));
550 return (AE_AML_NO_OPERAND
);
555 walk_state
->num_operands
--;
557 /* Check for a valid operand */
559 if (!walk_state
->operands
[walk_state
->num_operands
]) {
560 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
561 "Null operand! State=%p #Ops=%X\n",
562 walk_state
, walk_state
->num_operands
));
564 return (AE_AML_NO_OPERAND
);
567 /* Get operand and set stack entry to null */
569 *object
= walk_state
->operands
[walk_state
->num_operands
];
570 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
572 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p #Ops=%X\n",
573 *object
, acpi_ut_get_object_type_name (*object
),
574 walk_state
, walk_state
->num_operands
));
581 /*******************************************************************************
583 * FUNCTION: acpi_ds_obj_stack_pop
585 * PARAMETERS: pop_count - Number of objects/entries to pop
586 * walk_state - Current Walk state
590 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
591 * deleted by this routine.
593 ******************************************************************************/
596 acpi_ds_obj_stack_pop (
598 struct acpi_walk_state
*walk_state
)
602 ACPI_FUNCTION_NAME ("ds_obj_stack_pop");
605 for (i
= 0; i
< pop_count
; i
++) {
606 /* Check for stack underflow */
608 if (walk_state
->num_operands
== 0) {
609 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
610 "Underflow! Count=%X State=%p #Ops=%X\n",
611 pop_count
, walk_state
, walk_state
->num_operands
));
612 return (AE_STACK_UNDERFLOW
);
615 /* Just set the stack entry to null */
617 walk_state
->num_operands
--;
618 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
621 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%X\n",
622 pop_count
, walk_state
, walk_state
->num_operands
));
628 /*******************************************************************************
630 * FUNCTION: acpi_ds_obj_stack_pop_and_delete
632 * PARAMETERS: pop_count - Number of objects/entries to pop
633 * walk_state - Current Walk state
637 * DESCRIPTION: Pop this walk's object stack and delete each object that is
640 ******************************************************************************/
643 acpi_ds_obj_stack_pop_and_delete (
645 struct acpi_walk_state
*walk_state
)
648 union acpi_operand_object
*obj_desc
;
651 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete");
654 for (i
= 0; i
< pop_count
; i
++) {
655 /* Check for stack underflow */
657 if (walk_state
->num_operands
== 0) {
658 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
659 "Underflow! Count=%X State=%p #Ops=%X\n",
660 pop_count
, walk_state
, walk_state
->num_operands
));
661 return (AE_STACK_UNDERFLOW
);
664 /* Pop the stack and delete an object if present in this stack entry */
666 walk_state
->num_operands
--;
667 obj_desc
= walk_state
->operands
[walk_state
->num_operands
];
669 acpi_ut_remove_reference (walk_state
->operands
[walk_state
->num_operands
]);
670 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
674 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%X\n",
675 pop_count
, walk_state
, walk_state
->num_operands
));
681 /*******************************************************************************
683 * FUNCTION: acpi_ds_obj_stack_get_value
685 * PARAMETERS: Index - Stack index whose value is desired. Based
686 * on the top of the stack (index=0 == top)
687 * walk_state - Current Walk state
691 * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
692 * be within the range of the current stack pointer.
694 ******************************************************************************/
695 #ifdef ACPI_FUTURE_USAGE
697 acpi_ds_obj_stack_get_value (
699 struct acpi_walk_state
*walk_state
)
702 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state
);
705 /* Can't do it if the stack is empty */
707 if (walk_state
->num_operands
== 0) {
711 /* or if the index is past the top of the stack */
713 if (index
> (walk_state
->num_operands
- (u32
) 1)) {
717 return_PTR (walk_state
->operands
[(acpi_native_uint
)(walk_state
->num_operands
- 1) -
720 #endif /* ACPI_FUTURE_USAGE */
723 /*******************************************************************************
725 * FUNCTION: acpi_ds_get_current_walk_state
727 * PARAMETERS: Thread - Get current active state for this Thread
729 * RETURN: Pointer to the current walk state
731 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
734 ******************************************************************************/
736 struct acpi_walk_state
*
737 acpi_ds_get_current_walk_state (
738 struct acpi_thread_state
*thread
)
741 ACPI_FUNCTION_NAME ("ds_get_current_walk_state");
748 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE
, "Current walk_state %p\n",
749 thread
->walk_state_list
));
751 return (thread
->walk_state_list
);
755 /*******************************************************************************
757 * FUNCTION: acpi_ds_push_walk_state
759 * PARAMETERS: walk_state - State to push
760 * walk_list - The list that owns the walk stack
764 * DESCRIPTION: Place the walk_state at the head of the state list.
766 ******************************************************************************/
769 acpi_ds_push_walk_state (
770 struct acpi_walk_state
*walk_state
,
771 struct acpi_thread_state
*thread
)
773 ACPI_FUNCTION_TRACE ("ds_push_walk_state");
776 walk_state
->next
= thread
->walk_state_list
;
777 thread
->walk_state_list
= walk_state
;
783 /*******************************************************************************
785 * FUNCTION: acpi_ds_pop_walk_state
787 * PARAMETERS: walk_list - The list that owns the walk stack
789 * RETURN: A walk_state object popped from the stack
791 * DESCRIPTION: Remove and return the walkstate object that is at the head of
792 * the walk stack for the given walk list. NULL indicates that
795 ******************************************************************************/
797 struct acpi_walk_state
*
798 acpi_ds_pop_walk_state (
799 struct acpi_thread_state
*thread
)
801 struct acpi_walk_state
*walk_state
;
804 ACPI_FUNCTION_TRACE ("ds_pop_walk_state");
807 walk_state
= thread
->walk_state_list
;
810 /* Next walk state becomes the current walk state */
812 thread
->walk_state_list
= walk_state
->next
;
815 * Don't clear the NEXT field, this serves as an indicator
816 * that there is a parent WALK STATE
817 * NO: walk_state->Next = NULL;
821 return_PTR (walk_state
);
825 /*******************************************************************************
827 * FUNCTION: acpi_ds_create_walk_state
829 * PARAMETERS: Origin - Starting point for this walk
830 * Thread - Current thread state
832 * RETURN: Pointer to the new walk state.
834 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
835 * state is set to this new state.
837 ******************************************************************************/
839 struct acpi_walk_state
*
840 acpi_ds_create_walk_state (
841 acpi_owner_id owner_id
,
842 union acpi_parse_object
*origin
,
843 union acpi_operand_object
*mth_desc
,
844 struct acpi_thread_state
*thread
)
846 struct acpi_walk_state
*walk_state
;
850 ACPI_FUNCTION_TRACE ("ds_create_walk_state");
853 walk_state
= acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK
);
858 walk_state
->data_type
= ACPI_DESC_TYPE_WALK
;
859 walk_state
->owner_id
= owner_id
;
860 walk_state
->origin
= origin
;
861 walk_state
->method_desc
= mth_desc
;
862 walk_state
->thread
= thread
;
864 walk_state
->parser_state
.start_op
= origin
;
866 /* Init the method args/local */
868 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
869 acpi_ds_method_data_init (walk_state
);
872 /* Create an initial result stack entry */
874 status
= acpi_ds_result_stack_push (walk_state
);
875 if (ACPI_FAILURE (status
)) {
876 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK
, walk_state
);
880 /* Put the new state at the head of the walk list */
883 acpi_ds_push_walk_state (walk_state
, thread
);
886 return_PTR (walk_state
);
890 /*******************************************************************************
892 * FUNCTION: acpi_ds_init_aml_walk
894 * PARAMETERS: walk_state - New state to be initialized
895 * Op - Current parse op
896 * method_node - Control method NS node, if any
897 * aml_start - Start of AML
898 * aml_length - Length of AML
899 * Params - Method args, if any
900 * return_obj_desc - Where to store a return object, if any
901 * pass_number - 1, 2, or 3
905 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
907 ******************************************************************************/
910 acpi_ds_init_aml_walk (
911 struct acpi_walk_state
*walk_state
,
912 union acpi_parse_object
*op
,
913 struct acpi_namespace_node
*method_node
,
916 struct acpi_parameter_info
*info
,
920 struct acpi_parse_state
*parser_state
= &walk_state
->parser_state
;
921 union acpi_parse_object
*extra_op
;
924 ACPI_FUNCTION_TRACE ("ds_init_aml_walk");
927 walk_state
->parser_state
.aml
=
928 walk_state
->parser_state
.aml_start
= aml_start
;
929 walk_state
->parser_state
.aml_end
=
930 walk_state
->parser_state
.pkg_end
= aml_start
+ aml_length
;
932 /* The next_op of the next_walk will be the beginning of the method */
934 walk_state
->next_op
= NULL
;
937 if (info
->parameter_type
== ACPI_PARAM_GPE
) {
938 walk_state
->gpe_event_info
= ACPI_CAST_PTR (struct acpi_gpe_event_info
,
942 walk_state
->params
= info
->parameters
;
943 walk_state
->caller_return_desc
= &info
->return_object
;
947 status
= acpi_ps_init_scope (&walk_state
->parser_state
, op
);
948 if (ACPI_FAILURE (status
)) {
949 return_ACPI_STATUS (status
);
953 walk_state
->parser_state
.start_node
= method_node
;
954 walk_state
->walk_type
= ACPI_WALK_METHOD
;
955 walk_state
->method_node
= method_node
;
956 walk_state
->method_desc
= acpi_ns_get_attached_object (method_node
);
958 /* Push start scope on scope stack and make it current */
960 status
= acpi_ds_scope_stack_push (method_node
, ACPI_TYPE_METHOD
, walk_state
);
961 if (ACPI_FAILURE (status
)) {
962 return_ACPI_STATUS (status
);
965 /* Init the method arguments */
967 status
= acpi_ds_method_data_init_args (walk_state
->params
, ACPI_METHOD_NUM_ARGS
, walk_state
);
968 if (ACPI_FAILURE (status
)) {
969 return_ACPI_STATUS (status
);
974 * Setup the current scope.
975 * Find a Named Op that has a namespace node associated with it.
976 * search upwards from this Op. Current scope is the first
977 * Op with a namespace node.
979 extra_op
= parser_state
->start_op
;
980 while (extra_op
&& !extra_op
->common
.node
) {
981 extra_op
= extra_op
->common
.parent
;
985 parser_state
->start_node
= NULL
;
988 parser_state
->start_node
= extra_op
->common
.node
;
991 if (parser_state
->start_node
) {
992 /* Push start scope on scope stack and make it current */
994 status
= acpi_ds_scope_stack_push (parser_state
->start_node
,
995 parser_state
->start_node
->type
, walk_state
);
996 if (ACPI_FAILURE (status
)) {
997 return_ACPI_STATUS (status
);
1002 status
= acpi_ds_init_callbacks (walk_state
, pass_number
);
1003 return_ACPI_STATUS (status
);
1007 /*******************************************************************************
1009 * FUNCTION: acpi_ds_delete_walk_state
1011 * PARAMETERS: walk_state - State to delete
1015 * DESCRIPTION: Delete a walk state including all internal data structures
1017 ******************************************************************************/
1020 acpi_ds_delete_walk_state (
1021 struct acpi_walk_state
*walk_state
)
1023 union acpi_generic_state
*state
;
1026 ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state
);
1033 if (walk_state
->data_type
!= ACPI_DESC_TYPE_WALK
) {
1034 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "%p is not a valid walk state\n", walk_state
));
1038 if (walk_state
->parser_state
.scope
) {
1039 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "%p walk still has a scope list\n", walk_state
));
1042 /* Always must free any linked control states */
1044 while (walk_state
->control_state
) {
1045 state
= walk_state
->control_state
;
1046 walk_state
->control_state
= state
->common
.next
;
1048 acpi_ut_delete_generic_state (state
);
1051 /* Always must free any linked parse states */
1053 while (walk_state
->scope_info
) {
1054 state
= walk_state
->scope_info
;
1055 walk_state
->scope_info
= state
->common
.next
;
1057 acpi_ut_delete_generic_state (state
);
1060 /* Always must free any stacked result states */
1062 while (walk_state
->results
) {
1063 state
= walk_state
->results
;
1064 walk_state
->results
= state
->common
.next
;
1066 acpi_ut_delete_generic_state (state
);
1069 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK
, walk_state
);
1074 #ifdef ACPI_ENABLE_OBJECT_CACHE
1075 /******************************************************************************
1077 * FUNCTION: acpi_ds_delete_walk_state_cache
1083 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1086 ******************************************************************************/
1089 acpi_ds_delete_walk_state_cache (
1092 ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
1095 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK
);