1 /******************************************************************************
3 * Module Name: dswstate - Dispatcher parse tree walk management routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2006, 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.
44 #include <acpi/acpi.h>
45 #include <acpi/acparser.h>
46 #include <acpi/acdispat.h>
47 #include <acpi/acnamesp.h>
49 #define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME("dswstate")
52 /* Local prototypes */
53 #ifdef ACPI_OBSOLETE_FUNCTIONS
55 acpi_ds_result_insert(void *object
,
56 u32 index
, struct acpi_walk_state
*walk_state
);
58 acpi_status
acpi_ds_obj_stack_delete_all(struct acpi_walk_state
*walk_state
);
61 acpi_ds_obj_stack_pop_object(union acpi_operand_object
**object
,
62 struct acpi_walk_state
*walk_state
);
64 void *acpi_ds_obj_stack_get_value(u32 index
,
65 struct acpi_walk_state
*walk_state
);
68 #ifdef ACPI_FUTURE_USAGE
70 /*******************************************************************************
72 * FUNCTION: acpi_ds_result_remove
74 * PARAMETERS: Object - Where to return the popped object
75 * Index - Where to extract the object
76 * walk_state - Current Walk state
80 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
81 * other words, this is a FIFO.
83 ******************************************************************************/
86 acpi_ds_result_remove(union acpi_operand_object
**object
,
87 u32 index
, struct acpi_walk_state
*walk_state
)
89 union acpi_generic_state
*state
;
91 ACPI_FUNCTION_NAME("ds_result_remove");
93 state
= walk_state
->results
;
95 ACPI_ERROR((AE_INFO
, "No result object pushed! State=%p",
97 return (AE_NOT_EXIST
);
100 if (index
>= ACPI_OBJ_MAX_OPERAND
) {
102 "Index out of range: %X State=%p Num=%X",
103 index
, walk_state
, state
->results
.num_results
));
106 /* Check for a valid result object */
108 if (!state
->results
.obj_desc
[index
]) {
110 "Null operand! State=%p #Ops=%X, Index=%X",
111 walk_state
, state
->results
.num_results
, index
));
112 return (AE_AML_NO_RETURN_VALUE
);
115 /* Remove the object */
117 state
->results
.num_results
--;
119 *object
= state
->results
.obj_desc
[index
];
120 state
->results
.obj_desc
[index
] = NULL
;
122 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
123 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
125 (*object
) ? acpi_ut_get_object_type_name(*object
) :
126 "NULL", index
, walk_state
,
127 state
->results
.num_results
));
132 #endif /* ACPI_FUTURE_USAGE */
134 /*******************************************************************************
136 * FUNCTION: acpi_ds_result_pop
138 * PARAMETERS: Object - Where to return the popped object
139 * walk_state - Current Walk state
143 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
144 * other words, this is a FIFO.
146 ******************************************************************************/
149 acpi_ds_result_pop(union acpi_operand_object
** object
,
150 struct acpi_walk_state
* walk_state
)
152 acpi_native_uint index
;
153 union acpi_generic_state
*state
;
155 ACPI_FUNCTION_NAME("ds_result_pop");
157 state
= walk_state
->results
;
162 if (!state
->results
.num_results
) {
163 ACPI_ERROR((AE_INFO
, "Result stack is empty! State=%p",
165 return (AE_AML_NO_RETURN_VALUE
);
168 /* Remove top element */
170 state
->results
.num_results
--;
172 for (index
= ACPI_OBJ_NUM_OPERANDS
; index
; index
--) {
173 /* Check for a valid result object */
175 if (state
->results
.obj_desc
[index
- 1]) {
176 *object
= state
->results
.obj_desc
[index
- 1];
177 state
->results
.obj_desc
[index
- 1] = NULL
;
179 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
180 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
183 acpi_ut_get_object_type_name(*object
)
184 : "NULL", (u32
) index
- 1, walk_state
,
185 state
->results
.num_results
));
191 ACPI_ERROR((AE_INFO
, "No result objects! State=%p", walk_state
));
192 return (AE_AML_NO_RETURN_VALUE
);
195 /*******************************************************************************
197 * FUNCTION: acpi_ds_result_pop_from_bottom
199 * PARAMETERS: Object - Where to return the popped object
200 * walk_state - Current Walk state
204 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
205 * other words, this is a FIFO.
207 ******************************************************************************/
210 acpi_ds_result_pop_from_bottom(union acpi_operand_object
** object
,
211 struct acpi_walk_state
* walk_state
)
213 acpi_native_uint index
;
214 union acpi_generic_state
*state
;
216 ACPI_FUNCTION_NAME("ds_result_pop_from_bottom");
218 state
= walk_state
->results
;
221 "No result object pushed! State=%p", walk_state
));
222 return (AE_NOT_EXIST
);
225 if (!state
->results
.num_results
) {
226 ACPI_ERROR((AE_INFO
, "No result objects! State=%p",
228 return (AE_AML_NO_RETURN_VALUE
);
231 /* Remove Bottom element */
233 *object
= state
->results
.obj_desc
[0];
235 /* Push entire stack down one element */
237 for (index
= 0; index
< state
->results
.num_results
; index
++) {
238 state
->results
.obj_desc
[index
] =
239 state
->results
.obj_desc
[index
+ 1];
242 state
->results
.num_results
--;
244 /* Check for a valid result object */
248 "Null operand! State=%p #Ops=%X Index=%X",
249 walk_state
, state
->results
.num_results
,
251 return (AE_AML_NO_RETURN_VALUE
);
254 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Obj=%p [%s] Results=%p State=%p\n",
256 (*object
) ? acpi_ut_get_object_type_name(*object
) :
257 "NULL", state
, walk_state
));
262 /*******************************************************************************
264 * FUNCTION: acpi_ds_result_push
266 * PARAMETERS: Object - Where to return the popped object
267 * walk_state - Current Walk state
271 * DESCRIPTION: Push an object onto the current result stack
273 ******************************************************************************/
276 acpi_ds_result_push(union acpi_operand_object
* object
,
277 struct acpi_walk_state
* walk_state
)
279 union acpi_generic_state
*state
;
281 ACPI_FUNCTION_NAME("ds_result_push");
283 state
= walk_state
->results
;
285 ACPI_ERROR((AE_INFO
, "No result stack frame during push"));
286 return (AE_AML_INTERNAL
);
289 if (state
->results
.num_results
== ACPI_OBJ_NUM_OPERANDS
) {
291 "Result stack overflow: Obj=%p State=%p Num=%X",
292 object
, walk_state
, state
->results
.num_results
));
293 return (AE_STACK_OVERFLOW
);
298 "Null Object! Obj=%p State=%p Num=%X",
299 object
, walk_state
, state
->results
.num_results
));
300 return (AE_BAD_PARAMETER
);
303 state
->results
.obj_desc
[state
->results
.num_results
] = object
;
304 state
->results
.num_results
++;
306 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
309 acpi_ut_get_object_type_name((union
310 acpi_operand_object
*)
312 walk_state
, state
->results
.num_results
,
313 walk_state
->current_result
));
318 /*******************************************************************************
320 * FUNCTION: acpi_ds_result_stack_push
322 * PARAMETERS: walk_state - Current Walk state
326 * DESCRIPTION: Push an object onto the walk_state result stack.
328 ******************************************************************************/
330 acpi_status
acpi_ds_result_stack_push(struct acpi_walk_state
* walk_state
)
332 union acpi_generic_state
*state
;
334 ACPI_FUNCTION_NAME("ds_result_stack_push");
336 state
= acpi_ut_create_generic_state();
338 return (AE_NO_MEMORY
);
341 state
->common
.data_type
= ACPI_DESC_TYPE_STATE_RESULT
;
342 acpi_ut_push_generic_state(&walk_state
->results
, state
);
344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Results=%p State=%p\n",
350 /*******************************************************************************
352 * FUNCTION: acpi_ds_result_stack_pop
354 * PARAMETERS: walk_state - Current Walk state
358 * DESCRIPTION: Pop an object off of the walk_state result stack.
360 ******************************************************************************/
362 acpi_status
acpi_ds_result_stack_pop(struct acpi_walk_state
* walk_state
)
364 union acpi_generic_state
*state
;
366 ACPI_FUNCTION_NAME("ds_result_stack_pop");
368 /* Check for stack underflow */
370 if (walk_state
->results
== NULL
) {
371 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Underflow - State=%p\n",
373 return (AE_AML_NO_OPERAND
);
376 state
= acpi_ut_pop_generic_state(&walk_state
->results
);
378 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
379 "Result=%p remaining_results=%X State=%p\n",
380 state
, state
->results
.num_results
, walk_state
));
382 acpi_ut_delete_generic_state(state
);
387 /*******************************************************************************
389 * FUNCTION: acpi_ds_obj_stack_push
391 * PARAMETERS: Object - Object to push
392 * walk_state - Current Walk state
396 * DESCRIPTION: Push an object onto this walk's object/operand stack
398 ******************************************************************************/
401 acpi_ds_obj_stack_push(void *object
, struct acpi_walk_state
* walk_state
)
403 ACPI_FUNCTION_NAME("ds_obj_stack_push");
405 /* Check for stack overflow */
407 if (walk_state
->num_operands
>= ACPI_OBJ_NUM_OPERANDS
) {
409 "Object stack overflow! Obj=%p State=%p #Ops=%X",
410 object
, walk_state
, walk_state
->num_operands
));
411 return (AE_STACK_OVERFLOW
);
414 /* Put the object onto the stack */
416 walk_state
->operands
[walk_state
->num_operands
] = object
;
417 walk_state
->num_operands
++;
419 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p #Ops=%X\n",
421 acpi_ut_get_object_type_name((union
422 acpi_operand_object
*)
424 walk_state
->num_operands
));
429 /*******************************************************************************
431 * FUNCTION: acpi_ds_obj_stack_pop
433 * PARAMETERS: pop_count - Number of objects/entries to pop
434 * walk_state - Current Walk state
438 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
439 * deleted by this routine.
441 ******************************************************************************/
444 acpi_ds_obj_stack_pop(u32 pop_count
, struct acpi_walk_state
* walk_state
)
448 ACPI_FUNCTION_NAME("ds_obj_stack_pop");
450 for (i
= 0; i
< pop_count
; i
++) {
451 /* Check for stack underflow */
453 if (walk_state
->num_operands
== 0) {
455 "Object stack underflow! Count=%X State=%p #Ops=%X",
456 pop_count
, walk_state
,
457 walk_state
->num_operands
));
458 return (AE_STACK_UNDERFLOW
);
461 /* Just set the stack entry to null */
463 walk_state
->num_operands
--;
464 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
467 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%X\n",
468 pop_count
, walk_state
, walk_state
->num_operands
));
473 /*******************************************************************************
475 * FUNCTION: acpi_ds_obj_stack_pop_and_delete
477 * PARAMETERS: pop_count - Number of objects/entries to pop
478 * walk_state - Current Walk state
482 * DESCRIPTION: Pop this walk's object stack and delete each object that is
485 ******************************************************************************/
488 acpi_ds_obj_stack_pop_and_delete(u32 pop_count
,
489 struct acpi_walk_state
* walk_state
)
492 union acpi_operand_object
*obj_desc
;
494 ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete");
496 for (i
= 0; i
< pop_count
; i
++) {
497 /* Check for stack underflow */
499 if (walk_state
->num_operands
== 0) {
501 "Object stack underflow! Count=%X State=%p #Ops=%X",
502 pop_count
, walk_state
,
503 walk_state
->num_operands
));
504 return (AE_STACK_UNDERFLOW
);
507 /* Pop the stack and delete an object if present in this stack entry */
509 walk_state
->num_operands
--;
510 obj_desc
= walk_state
->operands
[walk_state
->num_operands
];
512 acpi_ut_remove_reference(walk_state
->
513 operands
[walk_state
->
515 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
519 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Count=%X State=%p #Ops=%X\n",
520 pop_count
, walk_state
, walk_state
->num_operands
));
525 /*******************************************************************************
527 * FUNCTION: acpi_ds_get_current_walk_state
529 * PARAMETERS: Thread - Get current active state for this Thread
531 * RETURN: Pointer to the current walk state
533 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
536 ******************************************************************************/
538 struct acpi_walk_state
*acpi_ds_get_current_walk_state(struct acpi_thread_state
541 ACPI_FUNCTION_NAME("ds_get_current_walk_state");
547 ACPI_DEBUG_PRINT((ACPI_DB_PARSE
, "Current walk_state %p\n",
548 thread
->walk_state_list
));
550 return (thread
->walk_state_list
);
553 /*******************************************************************************
555 * FUNCTION: acpi_ds_push_walk_state
557 * PARAMETERS: walk_state - State to push
558 * Thread - Thread state object
562 * DESCRIPTION: Place the Thread state at the head of the state list.
564 ******************************************************************************/
567 acpi_ds_push_walk_state(struct acpi_walk_state
*walk_state
,
568 struct acpi_thread_state
*thread
)
570 ACPI_FUNCTION_TRACE("ds_push_walk_state");
572 walk_state
->next
= thread
->walk_state_list
;
573 thread
->walk_state_list
= walk_state
;
578 /*******************************************************************************
580 * FUNCTION: acpi_ds_pop_walk_state
582 * PARAMETERS: Thread - Current thread state
584 * RETURN: A walk_state object popped from the thread's stack
586 * DESCRIPTION: Remove and return the walkstate object that is at the head of
587 * the walk stack for the given walk list. NULL indicates that
590 ******************************************************************************/
592 struct acpi_walk_state
*acpi_ds_pop_walk_state(struct acpi_thread_state
*thread
)
594 struct acpi_walk_state
*walk_state
;
596 ACPI_FUNCTION_TRACE("ds_pop_walk_state");
598 walk_state
= thread
->walk_state_list
;
601 /* Next walk state becomes the current walk state */
603 thread
->walk_state_list
= walk_state
->next
;
606 * Don't clear the NEXT field, this serves as an indicator
607 * that there is a parent WALK STATE
608 * Do Not: walk_state->Next = NULL;
612 return_PTR(walk_state
);
615 /*******************************************************************************
617 * FUNCTION: acpi_ds_create_walk_state
619 * PARAMETERS: owner_id - ID for object creation
620 * Origin - Starting point for this walk
621 * mth_desc - Method object
622 * Thread - Current thread state
624 * RETURN: Pointer to the new walk state.
626 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
627 * state is set to this new state.
629 ******************************************************************************/
631 struct acpi_walk_state
*acpi_ds_create_walk_state(acpi_owner_id owner_id
,
632 union acpi_parse_object
634 union acpi_operand_object
636 struct acpi_thread_state
639 struct acpi_walk_state
*walk_state
;
642 ACPI_FUNCTION_TRACE("ds_create_walk_state");
644 walk_state
= ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state
));
649 walk_state
->data_type
= ACPI_DESC_TYPE_WALK
;
650 walk_state
->owner_id
= owner_id
;
651 walk_state
->origin
= origin
;
652 walk_state
->method_desc
= mth_desc
;
653 walk_state
->thread
= thread
;
655 walk_state
->parser_state
.start_op
= origin
;
657 /* Init the method args/local */
659 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
660 acpi_ds_method_data_init(walk_state
);
663 /* Create an initial result stack entry */
665 status
= acpi_ds_result_stack_push(walk_state
);
666 if (ACPI_FAILURE(status
)) {
667 ACPI_MEM_FREE(walk_state
);
671 /* Put the new state at the head of the walk list */
674 acpi_ds_push_walk_state(walk_state
, thread
);
677 return_PTR(walk_state
);
680 /*******************************************************************************
682 * FUNCTION: acpi_ds_init_aml_walk
684 * PARAMETERS: walk_state - New state to be initialized
685 * Op - Current parse op
686 * method_node - Control method NS node, if any
687 * aml_start - Start of AML
688 * aml_length - Length of AML
689 * Info - Method info block (params, etc.)
690 * pass_number - 1, 2, or 3
694 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
696 ******************************************************************************/
699 acpi_ds_init_aml_walk(struct acpi_walk_state
*walk_state
,
700 union acpi_parse_object
*op
,
701 struct acpi_namespace_node
*method_node
,
704 struct acpi_parameter_info
*info
, u8 pass_number
)
707 struct acpi_parse_state
*parser_state
= &walk_state
->parser_state
;
708 union acpi_parse_object
*extra_op
;
710 ACPI_FUNCTION_TRACE("ds_init_aml_walk");
712 walk_state
->parser_state
.aml
=
713 walk_state
->parser_state
.aml_start
= aml_start
;
714 walk_state
->parser_state
.aml_end
=
715 walk_state
->parser_state
.pkg_end
= aml_start
+ aml_length
;
717 /* The next_op of the next_walk will be the beginning of the method */
719 walk_state
->next_op
= NULL
;
720 walk_state
->pass_number
= pass_number
;
723 if (info
->parameter_type
== ACPI_PARAM_GPE
) {
724 walk_state
->gpe_event_info
=
725 ACPI_CAST_PTR(struct acpi_gpe_event_info
,
728 walk_state
->params
= info
->parameters
;
729 walk_state
->caller_return_desc
= &info
->return_object
;
733 status
= acpi_ps_init_scope(&walk_state
->parser_state
, op
);
734 if (ACPI_FAILURE(status
)) {
735 return_ACPI_STATUS(status
);
739 walk_state
->parser_state
.start_node
= method_node
;
740 walk_state
->walk_type
= ACPI_WALK_METHOD
;
741 walk_state
->method_node
= method_node
;
742 walk_state
->method_desc
=
743 acpi_ns_get_attached_object(method_node
);
745 /* Push start scope on scope stack and make it current */
748 acpi_ds_scope_stack_push(method_node
, ACPI_TYPE_METHOD
,
750 if (ACPI_FAILURE(status
)) {
751 return_ACPI_STATUS(status
);
754 /* Init the method arguments */
756 status
= acpi_ds_method_data_init_args(walk_state
->params
,
757 ACPI_METHOD_NUM_ARGS
,
759 if (ACPI_FAILURE(status
)) {
760 return_ACPI_STATUS(status
);
764 * Setup the current scope.
765 * Find a Named Op that has a namespace node associated with it.
766 * search upwards from this Op. Current scope is the first
767 * Op with a namespace node.
769 extra_op
= parser_state
->start_op
;
770 while (extra_op
&& !extra_op
->common
.node
) {
771 extra_op
= extra_op
->common
.parent
;
775 parser_state
->start_node
= NULL
;
777 parser_state
->start_node
= extra_op
->common
.node
;
780 if (parser_state
->start_node
) {
781 /* Push start scope on scope stack and make it current */
784 acpi_ds_scope_stack_push(parser_state
->start_node
,
785 parser_state
->start_node
->
787 if (ACPI_FAILURE(status
)) {
788 return_ACPI_STATUS(status
);
793 status
= acpi_ds_init_callbacks(walk_state
, pass_number
);
794 return_ACPI_STATUS(status
);
797 /*******************************************************************************
799 * FUNCTION: acpi_ds_delete_walk_state
801 * PARAMETERS: walk_state - State to delete
805 * DESCRIPTION: Delete a walk state including all internal data structures
807 ******************************************************************************/
809 void acpi_ds_delete_walk_state(struct acpi_walk_state
*walk_state
)
811 union acpi_generic_state
*state
;
813 ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state
);
819 if (walk_state
->data_type
!= ACPI_DESC_TYPE_WALK
) {
820 ACPI_ERROR((AE_INFO
, "%p is not a valid walk state",
825 if (walk_state
->parser_state
.scope
) {
826 ACPI_ERROR((AE_INFO
, "%p walk still has a scope list",
830 /* Always must free any linked control states */
832 while (walk_state
->control_state
) {
833 state
= walk_state
->control_state
;
834 walk_state
->control_state
= state
->common
.next
;
836 acpi_ut_delete_generic_state(state
);
839 /* Always must free any linked parse states */
841 while (walk_state
->scope_info
) {
842 state
= walk_state
->scope_info
;
843 walk_state
->scope_info
= state
->common
.next
;
845 acpi_ut_delete_generic_state(state
);
848 /* Always must free any stacked result states */
850 while (walk_state
->results
) {
851 state
= walk_state
->results
;
852 walk_state
->results
= state
->common
.next
;
854 acpi_ut_delete_generic_state(state
);
857 ACPI_MEM_FREE(walk_state
);
861 #ifdef ACPI_OBSOLETE_FUNCTIONS
862 /*******************************************************************************
864 * FUNCTION: acpi_ds_result_insert
866 * PARAMETERS: Object - Object to push
867 * Index - Where to insert the object
868 * walk_state - Current Walk state
872 * DESCRIPTION: Insert an object onto this walk's result stack
874 ******************************************************************************/
877 acpi_ds_result_insert(void *object
,
878 u32 index
, struct acpi_walk_state
*walk_state
)
880 union acpi_generic_state
*state
;
882 ACPI_FUNCTION_NAME("ds_result_insert");
884 state
= walk_state
->results
;
886 ACPI_ERROR((AE_INFO
, "No result object pushed! State=%p",
888 return (AE_NOT_EXIST
);
891 if (index
>= ACPI_OBJ_NUM_OPERANDS
) {
893 "Index out of range: %X Obj=%p State=%p Num=%X",
894 index
, object
, walk_state
,
895 state
->results
.num_results
));
896 return (AE_BAD_PARAMETER
);
901 "Null Object! Index=%X Obj=%p State=%p Num=%X",
902 index
, object
, walk_state
,
903 state
->results
.num_results
));
904 return (AE_BAD_PARAMETER
);
907 state
->results
.obj_desc
[index
] = object
;
908 state
->results
.num_results
++;
910 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
911 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
914 acpi_ut_get_object_type_name((union
915 acpi_operand_object
*)
917 walk_state
, state
->results
.num_results
,
918 walk_state
->current_result
));
923 /*******************************************************************************
925 * FUNCTION: acpi_ds_obj_stack_delete_all
927 * PARAMETERS: walk_state - Current Walk state
931 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
932 * Should be used with great care, if at all!
934 ******************************************************************************/
936 acpi_status
acpi_ds_obj_stack_delete_all(struct acpi_walk_state
* walk_state
)
940 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state
);
942 /* The stack size is configurable, but fixed */
944 for (i
= 0; i
< ACPI_OBJ_NUM_OPERANDS
; i
++) {
945 if (walk_state
->operands
[i
]) {
946 acpi_ut_remove_reference(walk_state
->operands
[i
]);
947 walk_state
->operands
[i
] = NULL
;
951 return_ACPI_STATUS(AE_OK
);
954 /*******************************************************************************
956 * FUNCTION: acpi_ds_obj_stack_pop_object
958 * PARAMETERS: Object - Where to return the popped object
959 * walk_state - Current Walk state
963 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
964 * deleted by this routine.
966 ******************************************************************************/
969 acpi_ds_obj_stack_pop_object(union acpi_operand_object
**object
,
970 struct acpi_walk_state
*walk_state
)
972 ACPI_FUNCTION_NAME("ds_obj_stack_pop_object");
974 /* Check for stack underflow */
976 if (walk_state
->num_operands
== 0) {
978 "Missing operand/stack empty! State=%p #Ops=%X",
979 walk_state
, walk_state
->num_operands
));
981 return (AE_AML_NO_OPERAND
);
986 walk_state
->num_operands
--;
988 /* Check for a valid operand */
990 if (!walk_state
->operands
[walk_state
->num_operands
]) {
992 "Null operand! State=%p #Ops=%X",
993 walk_state
, walk_state
->num_operands
));
995 return (AE_AML_NO_OPERAND
);
998 /* Get operand and set stack entry to null */
1000 *object
= walk_state
->operands
[walk_state
->num_operands
];
1001 walk_state
->operands
[walk_state
->num_operands
] = NULL
;
1003 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
, "Obj=%p [%s] State=%p #Ops=%X\n",
1004 *object
, acpi_ut_get_object_type_name(*object
),
1005 walk_state
, walk_state
->num_operands
));
1010 /*******************************************************************************
1012 * FUNCTION: acpi_ds_obj_stack_get_value
1014 * PARAMETERS: Index - Stack index whose value is desired. Based
1015 * on the top of the stack (index=0 == top)
1016 * walk_state - Current Walk state
1018 * RETURN: Pointer to the requested operand
1020 * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must
1021 * be within the range of the current stack pointer.
1023 ******************************************************************************/
1025 void *acpi_ds_obj_stack_get_value(u32 index
, struct acpi_walk_state
*walk_state
)
1028 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state
);
1030 /* Can't do it if the stack is empty */
1032 if (walk_state
->num_operands
== 0) {
1036 /* or if the index is past the top of the stack */
1038 if (index
> (walk_state
->num_operands
- (u32
) 1)) {
1042 return_PTR(walk_state
->
1043 operands
[(acpi_native_uint
) (walk_state
->num_operands
- 1) -