1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acdispat.h"
47
48#define _COMPONENT ACPI_DISPATCHER
49ACPI_MODULE_NAME("dswscope")
50
51
52
53
54
55
56
57
58
59
60
61
62
63void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state)
64{
65 union acpi_generic_state *scope_info;
66
67 ACPI_FUNCTION_NAME(ds_scope_stack_clear);
68
69 while (walk_state->scope_info) {
70
71
72
73 scope_info = walk_state->scope_info;
74 walk_state->scope_info = scope_info->scope.next;
75
76 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
77 "Popped object type (%s)\n",
78 acpi_ut_get_type_name(scope_info->common.
79 value)));
80 acpi_ut_delete_generic_state(scope_info);
81 }
82}
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99acpi_status
100acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
101 acpi_object_type type,
102 struct acpi_walk_state *walk_state)
103{
104 union acpi_generic_state *scope_info;
105 union acpi_generic_state *old_scope_info;
106
107 ACPI_FUNCTION_TRACE(ds_scope_stack_push);
108
109 if (!node) {
110
111
112
113 ACPI_ERROR((AE_INFO, "Null scope parameter"));
114 return_ACPI_STATUS(AE_BAD_PARAMETER);
115 }
116
117
118
119 if (!acpi_ut_valid_object_type(type)) {
120 ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type));
121 }
122
123
124
125 scope_info = acpi_ut_create_generic_state();
126 if (!scope_info) {
127 return_ACPI_STATUS(AE_NO_MEMORY);
128 }
129
130
131
132 scope_info->common.descriptor_type = ACPI_DESC_TYPE_STATE_WSCOPE;
133 scope_info->scope.node = node;
134 scope_info->common.value = (u16) type;
135
136 walk_state->scope_depth++;
137
138 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
139 "[%.2d] Pushed scope ",
140 (u32) walk_state->scope_depth));
141
142 old_scope_info = walk_state->scope_info;
143 if (old_scope_info) {
144 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
145 "[%4.4s] (%s)",
146 acpi_ut_get_node_name(old_scope_info->
147 scope.node),
148 acpi_ut_get_type_name(old_scope_info->
149 common.value)));
150 } else {
151 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT"));
152 }
153
154 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
155 ", New scope -> [%4.4s] (%s)\n",
156 acpi_ut_get_node_name(scope_info->scope.node),
157 acpi_ut_get_type_name(scope_info->common.value)));
158
159
160
161 acpi_ut_push_generic_state(&walk_state->scope_info, scope_info);
162 return_ACPI_STATUS(AE_OK);
163}
164
165
166
167
168
169
170
171
172
173
174
175
176
177acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state)
178{
179 union acpi_generic_state *scope_info;
180 union acpi_generic_state *new_scope_info;
181
182 ACPI_FUNCTION_TRACE(ds_scope_stack_pop);
183
184
185
186
187 scope_info = acpi_ut_pop_generic_state(&walk_state->scope_info);
188 if (!scope_info) {
189 return_ACPI_STATUS(AE_STACK_UNDERFLOW);
190 }
191
192 walk_state->scope_depth--;
193
194 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
195 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
196 (u32) walk_state->scope_depth,
197 acpi_ut_get_node_name(scope_info->scope.node),
198 acpi_ut_get_type_name(scope_info->common.value)));
199
200 new_scope_info = walk_state->scope_info;
201 if (new_scope_info) {
202 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
203 "[%4.4s] (%s)\n",
204 acpi_ut_get_node_name(new_scope_info->
205 scope.node),
206 acpi_ut_get_type_name(new_scope_info->
207 common.value)));
208 } else {
209 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (ROOT)\n"));
210 }
211
212 acpi_ut_delete_generic_state(scope_info);
213 return_ACPI_STATUS(AE_OK);
214}
215