RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / drivers / acpi / dispatcher / dswscope.c
blob3927c495e4bfef7a12374f80e3aa0f672f2477ad
1 /******************************************************************************
3 * Module Name: dswscope - Scope stack manipulation
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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/acdispat.h>
47 #define _COMPONENT ACPI_DISPATCHER
48 ACPI_MODULE_NAME("dswscope")
50 /****************************************************************************
52 * FUNCTION: acpi_ds_scope_stack_clear
54 * PARAMETERS: walk_state - Current state
56 * RETURN: None
58 * DESCRIPTION: Pop (and free) everything on the scope stack except the
59 * root scope object (which remains at the stack top.)
61 ***************************************************************************/
62 void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state)
64 union acpi_generic_state *scope_info;
66 ACPI_FUNCTION_NAME(ds_scope_stack_clear);
68 while (walk_state->scope_info) {
70 /* Pop a scope off the stack */
72 scope_info = walk_state->scope_info;
73 walk_state->scope_info = scope_info->scope.next;
75 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
76 "Popped object type (%s)\n",
77 acpi_ut_get_type_name(scope_info->common.
78 value)));
79 acpi_ut_delete_generic_state(scope_info);
83 /****************************************************************************
85 * FUNCTION: acpi_ds_scope_stack_push
87 * PARAMETERS: Node - Name to be made current
88 * Type - Type of frame being pushed
89 * walk_state - Current state
91 * RETURN: Status
93 * DESCRIPTION: Push the current scope on the scope stack, and make the
94 * passed Node current.
96 ***************************************************************************/
98 acpi_status
99 acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
100 acpi_object_type type,
101 struct acpi_walk_state *walk_state)
103 union acpi_generic_state *scope_info;
104 union acpi_generic_state *old_scope_info;
106 ACPI_FUNCTION_TRACE(ds_scope_stack_push);
108 if (!node) {
110 /* Invalid scope */
112 ACPI_ERROR((AE_INFO, "Null scope parameter"));
113 return_ACPI_STATUS(AE_BAD_PARAMETER);
116 /* Make sure object type is valid */
118 if (!acpi_ut_valid_object_type(type)) {
119 ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type));
122 /* Allocate a new scope object */
124 scope_info = acpi_ut_create_generic_state();
125 if (!scope_info) {
126 return_ACPI_STATUS(AE_NO_MEMORY);
129 /* Init new scope object */
131 scope_info->common.descriptor_type = ACPI_DESC_TYPE_STATE_WSCOPE;
132 scope_info->scope.node = node;
133 scope_info->common.value = (u16) type;
135 walk_state->scope_depth++;
137 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
138 "[%.2d] Pushed scope ",
139 (u32) walk_state->scope_depth));
141 old_scope_info = walk_state->scope_info;
142 if (old_scope_info) {
143 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
144 "[%4.4s] (%s)",
145 acpi_ut_get_node_name(old_scope_info->
146 scope.node),
147 acpi_ut_get_type_name(old_scope_info->
148 common.value)));
149 } else {
150 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT"));
153 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
154 ", New scope -> [%4.4s] (%s)\n",
155 acpi_ut_get_node_name(scope_info->scope.node),
156 acpi_ut_get_type_name(scope_info->common.value)));
158 /* Push new scope object onto stack */
160 acpi_ut_push_generic_state(&walk_state->scope_info, scope_info);
161 return_ACPI_STATUS(AE_OK);
164 /****************************************************************************
166 * FUNCTION: acpi_ds_scope_stack_pop
168 * PARAMETERS: walk_state - Current state
170 * RETURN: Status
172 * DESCRIPTION: Pop the scope stack once.
174 ***************************************************************************/
176 acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state)
178 union acpi_generic_state *scope_info;
179 union acpi_generic_state *new_scope_info;
181 ACPI_FUNCTION_TRACE(ds_scope_stack_pop);
184 * Pop scope info object off the stack.
186 scope_info = acpi_ut_pop_generic_state(&walk_state->scope_info);
187 if (!scope_info) {
188 return_ACPI_STATUS(AE_STACK_UNDERFLOW);
191 walk_state->scope_depth--;
193 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
194 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
195 (u32) walk_state->scope_depth,
196 acpi_ut_get_node_name(scope_info->scope.node),
197 acpi_ut_get_type_name(scope_info->common.value)));
199 new_scope_info = walk_state->scope_info;
200 if (new_scope_info) {
201 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
202 "[%4.4s] (%s)\n",
203 acpi_ut_get_node_name(new_scope_info->
204 scope.node),
205 acpi_ut_get_type_name(new_scope_info->
206 common.value)));
207 } else {
208 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (ROOT)\n"));
211 acpi_ut_delete_generic_state(scope_info);
212 return_ACPI_STATUS(AE_OK);