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--) {
174 /* Check for a valid result object */
176 if (state->results.obj_desc[index - 1]) {
177 *object = state->results.obj_desc[index - 1];
178 state->results.obj_desc[index - 1] = NULL;
180 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
181 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
184 acpi_ut_get_object_type_name(*object)
185 : "NULL", (u32) index - 1, walk_state,
186 state->results.num_results));
192 ACPI_ERROR((AE_INFO, "No result objects! State=%p", walk_state));
193 return (AE_AML_NO_RETURN_VALUE);
196 /*******************************************************************************
198 * FUNCTION: acpi_ds_result_pop_from_bottom
200 * PARAMETERS: Object - Where to return the popped object
201 * walk_state - Current Walk state
205 * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
206 * other words, this is a FIFO.
208 ******************************************************************************/
211 acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
212 struct acpi_walk_state * walk_state)
214 acpi_native_uint index;
215 union acpi_generic_state *state;
217 ACPI_FUNCTION_NAME("ds_result_pop_from_bottom");
219 state = walk_state->results;
222 "No result object pushed! State=%p", walk_state));
223 return (AE_NOT_EXIST);
226 if (!state->results.num_results) {
227 ACPI_ERROR((AE_INFO, "No result objects! State=%p",
229 return (AE_AML_NO_RETURN_VALUE);
232 /* Remove Bottom element */
234 *object = state->results.obj_desc[0];
236 /* Push entire stack down one element */
238 for (index = 0; index < state->results.num_results; index++) {
239 state->results.obj_desc[index] =
240 state->results.obj_desc[index + 1];
243 state->results.num_results--;
245 /* Check for a valid result object */
249 "Null operand! State=%p #Ops=%X Index=%X",
250 walk_state, state->results.num_results,
252 return (AE_AML_NO_RETURN_VALUE);
255 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n",
257 (*object) ? acpi_ut_get_object_type_name(*object) :
258 "NULL", state, walk_state));
263 /*******************************************************************************
265 * FUNCTION: acpi_ds_result_push
267 * PARAMETERS: Object - Where to return the popped object
268 * walk_state - Current Walk state
272 * DESCRIPTION: Push an object onto the current result stack
274 ******************************************************************************/
277 acpi_ds_result_push(union acpi_operand_object * object,
278 struct acpi_walk_state * walk_state)
280 union acpi_generic_state *state;
282 ACPI_FUNCTION_NAME("ds_result_push");
284 state = walk_state->results;
286 ACPI_ERROR((AE_INFO, "No result stack frame during push"));
287 return (AE_AML_INTERNAL);
290 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
292 "Result stack overflow: Obj=%p State=%p Num=%X",
293 object, walk_state, state->results.num_results));
294 return (AE_STACK_OVERFLOW);
299 "Null Object! Obj=%p State=%p Num=%X",
300 object, walk_state, state->results.num_results));
301 return (AE_BAD_PARAMETER);
304 state->results.obj_desc[state->results.num_results] = object;
305 state->results.num_results++;
307 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
310 acpi_ut_get_object_type_name((union
311 acpi_operand_object *)
313 walk_state, state->results.num_results,
314 walk_state->current_result));
319 /*******************************************************************************
321 * FUNCTION: acpi_ds_result_stack_push
323 * PARAMETERS: walk_state - Current Walk state
327 * DESCRIPTION: Push an object onto the walk_state result stack.
329 ******************************************************************************/
331 acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
333 union acpi_generic_state *state;
335 ACPI_FUNCTION_NAME("ds_result_stack_push");
337 state = acpi_ut_create_generic_state();
339 return (AE_NO_MEMORY);
342 state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT;
343 acpi_ut_push_generic_state(&walk_state->results, state);
345 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
351 /*******************************************************************************
353 * FUNCTION: acpi_ds_result_stack_pop
355 * PARAMETERS: walk_state - Current Walk state
359 * DESCRIPTION: Pop an object off of the walk_state result stack.
361 ******************************************************************************/
363 acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
365 union acpi_generic_state *state;
367 ACPI_FUNCTION_NAME("ds_result_stack_pop");
369 /* Check for stack underflow */
371 if (walk_state->results == NULL) {
372 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Underflow - State=%p\n",
374 return (AE_AML_NO_OPERAND);
377 state = acpi_ut_pop_generic_state(&walk_state->results);
379 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
380 "Result=%p remaining_results=%X State=%p\n",
381 state, state->results.num_results, walk_state));
383 acpi_ut_delete_generic_state(state);
388 /*******************************************************************************
390 * FUNCTION: acpi_ds_obj_stack_push
392 * PARAMETERS: Object - Object to push
393 * walk_state - Current Walk state
397 * DESCRIPTION: Push an object onto this walk's object/operand stack
399 ******************************************************************************/
402 acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
404 ACPI_FUNCTION_NAME("ds_obj_stack_push");
406 /* Check for stack overflow */
408 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
410 "Object stack overflow! Obj=%p State=%p #Ops=%X",
411 object, walk_state, walk_state->num_operands));
412 return (AE_STACK_OVERFLOW);
415 /* Put the object onto the stack */
417 walk_state->operands[walk_state->num_operands] = object;
418 walk_state->num_operands++;
420 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
422 acpi_ut_get_object_type_name((union
423 acpi_operand_object *)
425 walk_state->num_operands));
430 /*******************************************************************************
432 * FUNCTION: acpi_ds_obj_stack_pop
434 * PARAMETERS: pop_count - Number of objects/entries to pop
435 * walk_state - Current Walk state
439 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
440 * deleted by this routine.
442 ******************************************************************************/
445 acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
449 ACPI_FUNCTION_NAME("ds_obj_stack_pop");
451 for (i = 0; i < pop_count; i++) {
453 /* Check for stack underflow */
455 if (walk_state->num_operands == 0) {
457 "Object stack underflow! Count=%X State=%p #Ops=%X",
458 pop_count, walk_state,
459 walk_state->num_operands));
460 return (AE_STACK_UNDERFLOW);
463 /* Just set the stack entry to null */
465 walk_state->num_operands--;
466 walk_state->operands[walk_state->num_operands] = NULL;
469 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
470 pop_count, walk_state, walk_state->num_operands));
475 /*******************************************************************************
477 * FUNCTION: acpi_ds_obj_stack_pop_and_delete
479 * PARAMETERS: pop_count - Number of objects/entries to pop
480 * walk_state - Current Walk state
484 * DESCRIPTION: Pop this walk's object stack and delete each object that is
487 ******************************************************************************/
490 acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
491 struct acpi_walk_state * walk_state)
494 union acpi_operand_object *obj_desc;
496 ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete");
498 for (i = 0; i < pop_count; i++) {
500 /* Check for stack underflow */
502 if (walk_state->num_operands == 0) {
504 "Object stack underflow! Count=%X State=%p #Ops=%X",
505 pop_count, walk_state,
506 walk_state->num_operands));
507 return (AE_STACK_UNDERFLOW);
510 /* Pop the stack and delete an object if present in this stack entry */
512 walk_state->num_operands--;
513 obj_desc = walk_state->operands[walk_state->num_operands];
515 acpi_ut_remove_reference(walk_state->
516 operands[walk_state->
518 walk_state->operands[walk_state->num_operands] = NULL;
522 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
523 pop_count, walk_state, walk_state->num_operands));
528 /*******************************************************************************
530 * FUNCTION: acpi_ds_get_current_walk_state
532 * PARAMETERS: Thread - Get current active state for this Thread
534 * RETURN: Pointer to the current walk state
536 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
539 ******************************************************************************/
541 struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
544 ACPI_FUNCTION_NAME("ds_get_current_walk_state");
550 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n",
551 thread->walk_state_list));
553 return (thread->walk_state_list);
556 /*******************************************************************************
558 * FUNCTION: acpi_ds_push_walk_state
560 * PARAMETERS: walk_state - State to push
561 * Thread - Thread state object
565 * DESCRIPTION: Place the Thread state at the head of the state list.
567 ******************************************************************************/
570 acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
571 struct acpi_thread_state *thread)
573 ACPI_FUNCTION_TRACE("ds_push_walk_state");
575 walk_state->next = thread->walk_state_list;
576 thread->walk_state_list = walk_state;
581 /*******************************************************************************
583 * FUNCTION: acpi_ds_pop_walk_state
585 * PARAMETERS: Thread - Current thread state
587 * RETURN: A walk_state object popped from the thread's stack
589 * DESCRIPTION: Remove and return the walkstate object that is at the head of
590 * the walk stack for the given walk list. NULL indicates that
593 ******************************************************************************/
595 struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
597 struct acpi_walk_state *walk_state;
599 ACPI_FUNCTION_TRACE("ds_pop_walk_state");
601 walk_state = thread->walk_state_list;
605 /* Next walk state becomes the current walk state */
607 thread->walk_state_list = walk_state->next;
610 * Don't clear the NEXT field, this serves as an indicator
611 * that there is a parent WALK STATE
612 * Do Not: walk_state->Next = NULL;
616 return_PTR(walk_state);
619 /*******************************************************************************
621 * FUNCTION: acpi_ds_create_walk_state
623 * PARAMETERS: owner_id - ID for object creation
624 * Origin - Starting point for this walk
625 * mth_desc - Method object
626 * Thread - Current thread state
628 * RETURN: Pointer to the new walk state.
630 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
631 * state is set to this new state.
633 ******************************************************************************/
635 struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
636 union acpi_parse_object
638 union acpi_operand_object
640 struct acpi_thread_state
643 struct acpi_walk_state *walk_state;
646 ACPI_FUNCTION_TRACE("ds_create_walk_state");
648 walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state));
653 walk_state->data_type = ACPI_DESC_TYPE_WALK;
654 walk_state->owner_id = owner_id;
655 walk_state->origin = origin;
656 walk_state->method_desc = mth_desc;
657 walk_state->thread = thread;
659 walk_state->parser_state.start_op = origin;
661 /* Init the method args/local */
663 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
664 acpi_ds_method_data_init(walk_state);
667 /* Create an initial result stack entry */
669 status = acpi_ds_result_stack_push(walk_state);
670 if (ACPI_FAILURE(status)) {
671 ACPI_MEM_FREE(walk_state);
675 /* Put the new state at the head of the walk list */
678 acpi_ds_push_walk_state(walk_state, thread);
681 return_PTR(walk_state);
684 /*******************************************************************************
686 * FUNCTION: acpi_ds_init_aml_walk
688 * PARAMETERS: walk_state - New state to be initialized
689 * Op - Current parse op
690 * method_node - Control method NS node, if any
691 * aml_start - Start of AML
692 * aml_length - Length of AML
693 * Info - Method info block (params, etc.)
694 * pass_number - 1, 2, or 3
698 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
700 ******************************************************************************/
703 acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
704 union acpi_parse_object *op,
705 struct acpi_namespace_node *method_node,
708 struct acpi_parameter_info *info, u8 pass_number)
711 struct acpi_parse_state *parser_state = &walk_state->parser_state;
712 union acpi_parse_object *extra_op;
714 ACPI_FUNCTION_TRACE("ds_init_aml_walk");
716 walk_state->parser_state.aml =
717 walk_state->parser_state.aml_start = aml_start;
718 walk_state->parser_state.aml_end =
719 walk_state->parser_state.pkg_end = aml_start + aml_length;
721 /* The next_op of the next_walk will be the beginning of the method */
723 walk_state->next_op = NULL;
724 walk_state->pass_number = pass_number;
727 if (info->parameter_type == ACPI_PARAM_GPE) {
728 walk_state->gpe_event_info =
729 ACPI_CAST_PTR(struct acpi_gpe_event_info,
732 walk_state->params = info->parameters;
733 walk_state->caller_return_desc = &info->return_object;
737 status = acpi_ps_init_scope(&walk_state->parser_state, op);
738 if (ACPI_FAILURE(status)) {
739 return_ACPI_STATUS(status);
743 walk_state->parser_state.start_node = method_node;
744 walk_state->walk_type = ACPI_WALK_METHOD;
745 walk_state->method_node = method_node;
746 walk_state->method_desc =
747 acpi_ns_get_attached_object(method_node);
749 /* Push start scope on scope stack and make it current */
752 acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD,
754 if (ACPI_FAILURE(status)) {
755 return_ACPI_STATUS(status);
758 /* Init the method arguments */
760 status = acpi_ds_method_data_init_args(walk_state->params,
761 ACPI_METHOD_NUM_ARGS,
763 if (ACPI_FAILURE(status)) {
764 return_ACPI_STATUS(status);
768 * Setup the current scope.
769 * Find a Named Op that has a namespace node associated with it.
770 * search upwards from this Op. Current scope is the first
771 * Op with a namespace node.
773 extra_op = parser_state->start_op;
774 while (extra_op && !extra_op->common.node) {
775 extra_op = extra_op->common.parent;
779 parser_state->start_node = NULL;
781 parser_state->start_node = extra_op->common.node;
784 if (parser_state->start_node) {
786 /* Push start scope on scope stack and make it current */
789 acpi_ds_scope_stack_push(parser_state->start_node,
790 parser_state->start_node->
792 if (ACPI_FAILURE(status)) {
793 return_ACPI_STATUS(status);
798 status = acpi_ds_init_callbacks(walk_state, pass_number);
799 return_ACPI_STATUS(status);
802 /*******************************************************************************
804 * FUNCTION: acpi_ds_delete_walk_state
806 * PARAMETERS: walk_state - State to delete
810 * DESCRIPTION: Delete a walk state including all internal data structures
812 ******************************************************************************/
814 void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
816 union acpi_generic_state *state;
818 ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state);
824 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
825 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
830 if (walk_state->parser_state.scope) {
831 ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
835 /* Always must free any linked control states */
837 while (walk_state->control_state) {
838 state = walk_state->control_state;
839 walk_state->control_state = state->common.next;
841 acpi_ut_delete_generic_state(state);
844 /* Always must free any linked parse states */
846 while (walk_state->scope_info) {
847 state = walk_state->scope_info;
848 walk_state->scope_info = state->common.next;
850 acpi_ut_delete_generic_state(state);
853 /* Always must free any stacked result states */
855 while (walk_state->results) {
856 state = walk_state->results;
857 walk_state->results = state->common.next;
859 acpi_ut_delete_generic_state(state);
862 ACPI_MEM_FREE(walk_state);
866 #ifdef ACPI_OBSOLETE_FUNCTIONS
867 /*******************************************************************************
869 * FUNCTION: acpi_ds_result_insert
871 * PARAMETERS: Object - Object to push
872 * Index - Where to insert the object
873 * walk_state - Current Walk state
877 * DESCRIPTION: Insert an object onto this walk's result stack
879 ******************************************************************************/
882 acpi_ds_result_insert(void *object,
883 u32 index, struct acpi_walk_state *walk_state)
885 union acpi_generic_state *state;
887 ACPI_FUNCTION_NAME("ds_result_insert");
889 state = walk_state->results;
891 ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
893 return (AE_NOT_EXIST);
896 if (index >= ACPI_OBJ_NUM_OPERANDS) {
898 "Index out of range: %X Obj=%p State=%p Num=%X",
899 index, object, walk_state,
900 state->results.num_results));
901 return (AE_BAD_PARAMETER);
906 "Null Object! Index=%X Obj=%p State=%p Num=%X",
907 index, object, walk_state,
908 state->results.num_results));
909 return (AE_BAD_PARAMETER);
912 state->results.obj_desc[index] = object;
913 state->results.num_results++;
915 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
916 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
919 acpi_ut_get_object_type_name((union
920 acpi_operand_object *)
922 walk_state, state->results.num_results,
923 walk_state->current_result));
928 /*******************************************************************************
930 * FUNCTION: acpi_ds_obj_stack_delete_all
932 * PARAMETERS: walk_state - Current Walk state
936 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
937 * Should be used with great care, if at all!
939 ******************************************************************************/
941 acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state)
945 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state);
947 /* The stack size is configurable, but fixed */
949 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
950 if (walk_state->operands[i]) {
951 acpi_ut_remove_reference(walk_state->operands[i]);
952 walk_state->operands[i] = NULL;
956 return_ACPI_STATUS(AE_OK);
959 /*******************************************************************************
961 * FUNCTION: acpi_ds_obj_stack_pop_object
963 * PARAMETERS: Object - Where to return the popped object
964 * walk_state - Current Walk state
968 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
969 * deleted by this routine.
971 ******************************************************************************/
974 acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
975 struct acpi_walk_state *walk_state)
977 ACPI_FUNCTION_NAME("ds_obj_stack_pop_object");
979 /* Check for stack underflow */
981 if (walk_state->num_operands == 0) {
983 "Missing operand/stack empty! State=%p #Ops=%X",
984 walk_state, walk_state->num_operands));
986 return (AE_AML_NO_OPERAND);
991 walk_state->num_operands--;
993 /* Check for a valid operand */
995 if (!walk_state->operands[walk_state->num_operands]) {
997 "Null operand! State=%p #Ops=%X",
998 walk_state, walk_state->num_operands));
1000 return (AE_AML_NO_OPERAND);
1003 /* Get operand and set stack entry to null */
1005 *object = walk_state->operands[walk_state->num_operands];
1006 walk_state->operands[walk_state->num_operands] = NULL;
1008 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
1009 *object, acpi_ut_get_object_type_name(*object),
1010 walk_state, walk_state->num_operands));
1015 /*******************************************************************************
1017 * FUNCTION: acpi_ds_obj_stack_get_value
1019 * PARAMETERS: Index - Stack index whose value is desired. Based
1020 * on the top of the stack (index=0 == top)
1021 * walk_state - Current Walk state
1023 * RETURN: Pointer to the requested operand
1025 * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must
1026 * be within the range of the current stack pointer.
1028 ******************************************************************************/
1030 void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state)
1033 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state);
1035 /* Can't do it if the stack is empty */
1037 if (walk_state->num_operands == 0) {
1041 /* or if the index is past the top of the stack */
1043 if (index > (walk_state->num_operands - (u32) 1)) {
1047 return_PTR(walk_state->
1048 operands[(acpi_native_uint) (walk_state->num_operands - 1) -