aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2011-02-14 03:09:40 -0500
committerLen Brown <len.brown@intel.com>2011-03-02 19:38:05 -0500
commit9ad19ac456a5f097f7cbbfef820b95297d6a934f (patch)
tree6404bfae32d506a66fa6611f4fa131773a309095 /drivers/acpi/acpica
parentd59a3c6b35995615fa9e4f21d63fdf21328c5b6b (diff)
ACPICA: Split large dsopcode and dsload.c files.
Split dsopcode.c into dsargs.c and dscontrol.c. Split dsload.c into dsload2.c. Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/Makefile2
-rw-r--r--drivers/acpi/acpica/acdispat.h38
-rw-r--r--drivers/acpi/acpica/dsargs.c391
-rw-r--r--drivers/acpi/acpica/dscontrol.c410
-rw-r--r--drivers/acpi/acpica/dsopcode.c725
-rw-r--r--drivers/acpi/acpica/dswload.c670
-rw-r--r--drivers/acpi/acpica/dswload2.c720
7 files changed, 1549 insertions, 1407 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index b1706aacbe98..a1224712fd0c 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -10,7 +10,7 @@ obj-y += acpi.o
10 10
11acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \ 11acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \ 12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
13 dsinit.o 13 dsinit.o dsargs.o dscontrol.o dswload2.o
14 14
15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ 15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \
16 evmisc.o evrgnini.o evxface.o evxfregn.o \ 16 evmisc.o evrgnini.o evxface.o evxfregn.o \
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 666271b65418..2d1b7ffa377a 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -48,7 +48,7 @@
48#define NAMEOF_ARG_NTE "__A0" 48#define NAMEOF_ARG_NTE "__A0"
49 49
50/* 50/*
51 * dsopcode - support for late evaluation 51 * dsargs - execution of dynamic arguments for static objects
52 */ 52 */
53acpi_status 53acpi_status
54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc); 54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
@@ -62,6 +62,20 @@ acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
62 62
63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc); 63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
64 64
65/*
66 * dscontrol - support for execution control opcodes
67 */
68acpi_status
69acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
70 union acpi_parse_object *op);
71
72acpi_status
73acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
74 union acpi_parse_object *op);
75
76/*
77 * dsopcode - support for late operand evaluation
78 */
65acpi_status 79acpi_status
66acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, 80acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
67 union acpi_parse_object *op); 81 union acpi_parse_object *op);
@@ -86,17 +100,6 @@ acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
86acpi_status acpi_ds_initialize_region(acpi_handle obj_handle); 100acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
87 101
88/* 102/*
89 * dsctrl - Parser/Interpreter interface, control stack routines
90 */
91acpi_status
92acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
93 union acpi_parse_object *op);
94
95acpi_status
96acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
97 union acpi_parse_object *op);
98
99/*
100 * dsexec - Parser/Interpreter interface, method execution callbacks 103 * dsexec - Parser/Interpreter interface, method execution callbacks
101 */ 104 */
102acpi_status 105acpi_status
@@ -136,23 +139,26 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
136 struct acpi_walk_state *walk_state); 139 struct acpi_walk_state *walk_state);
137 140
138/* 141/*
139 * dsload - Parser/Interpreter interface, namespace load callbacks 142 * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks
140 */ 143 */
141acpi_status 144acpi_status
145acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
146
147acpi_status
142acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state, 148acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
143 union acpi_parse_object **out_op); 149 union acpi_parse_object **out_op);
144 150
145acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state); 151acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
146 152
153/*
154 * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks
155 */
147acpi_status 156acpi_status
148acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, 157acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
149 union acpi_parse_object **out_op); 158 union acpi_parse_object **out_op);
150 159
151acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state); 160acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state);
152 161
153acpi_status
154acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
155
156/* 162/*
157 * dsmthdat - method data (locals/args) 163 * dsmthdat - method data (locals/args)
158 */ 164 */
diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
new file mode 100644
index 000000000000..8c7b99728aa2
--- /dev/null
+++ b/drivers/acpi/acpica/dsargs.c
@@ -0,0 +1,391 @@
1/******************************************************************************
2 *
3 * Module Name: dsargs - Support for execution of dynamic arguments for static
4 * objects (regions, fields, buffer fields, etc.)
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acparser.h"
48#include "amlcode.h"
49#include "acdispat.h"
50#include "acnamesp.h"
51
52#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsargs")
54
55/* Local prototypes */
56static acpi_status
57acpi_ds_execute_arguments(struct acpi_namespace_node *node,
58 struct acpi_namespace_node *scope_node,
59 u32 aml_length, u8 *aml_start);
60
61/*******************************************************************************
62 *
63 * FUNCTION: acpi_ds_execute_arguments
64 *
65 * PARAMETERS: Node - Object NS node
66 * scope_node - Parent NS node
67 * aml_length - Length of executable AML
68 * aml_start - Pointer to the AML
69 *
70 * RETURN: Status.
71 *
72 * DESCRIPTION: Late (deferred) execution of region or field arguments
73 *
74 ******************************************************************************/
75
76static acpi_status
77acpi_ds_execute_arguments(struct acpi_namespace_node *node,
78 struct acpi_namespace_node *scope_node,
79 u32 aml_length, u8 *aml_start)
80{
81 acpi_status status;
82 union acpi_parse_object *op;
83 struct acpi_walk_state *walk_state;
84
85 ACPI_FUNCTION_TRACE(ds_execute_arguments);
86
87 /* Allocate a new parser op to be the root of the parsed tree */
88
89 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
90 if (!op) {
91 return_ACPI_STATUS(AE_NO_MEMORY);
92 }
93
94 /* Save the Node for use in acpi_ps_parse_aml */
95
96 op->common.node = scope_node;
97
98 /* Create and initialize a new parser state */
99
100 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
101 if (!walk_state) {
102 status = AE_NO_MEMORY;
103 goto cleanup;
104 }
105
106 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
107 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
108 if (ACPI_FAILURE(status)) {
109 acpi_ds_delete_walk_state(walk_state);
110 goto cleanup;
111 }
112
113 /* Mark this parse as a deferred opcode */
114
115 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
116 walk_state->deferred_node = node;
117
118 /* Pass1: Parse the entire declaration */
119
120 status = acpi_ps_parse_aml(walk_state);
121 if (ACPI_FAILURE(status)) {
122 goto cleanup;
123 }
124
125 /* Get and init the Op created above */
126
127 op->common.node = node;
128 acpi_ps_delete_parse_tree(op);
129
130 /* Evaluate the deferred arguments */
131
132 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
133 if (!op) {
134 return_ACPI_STATUS(AE_NO_MEMORY);
135 }
136
137 op->common.node = scope_node;
138
139 /* Create and initialize a new parser state */
140
141 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
142 if (!walk_state) {
143 status = AE_NO_MEMORY;
144 goto cleanup;
145 }
146
147 /* Execute the opcode and arguments */
148
149 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
150 aml_length, NULL, ACPI_IMODE_EXECUTE);
151 if (ACPI_FAILURE(status)) {
152 acpi_ds_delete_walk_state(walk_state);
153 goto cleanup;
154 }
155
156 /* Mark this execution as a deferred opcode */
157
158 walk_state->deferred_node = node;
159 status = acpi_ps_parse_aml(walk_state);
160
161 cleanup:
162 acpi_ps_delete_parse_tree(op);
163 return_ACPI_STATUS(status);
164}
165
166/*******************************************************************************
167 *
168 * FUNCTION: acpi_ds_get_buffer_field_arguments
169 *
170 * PARAMETERS: obj_desc - A valid buffer_field object
171 *
172 * RETURN: Status.
173 *
174 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
175 * evaluation of these field attributes.
176 *
177 ******************************************************************************/
178
179acpi_status
180acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
181{
182 union acpi_operand_object *extra_desc;
183 struct acpi_namespace_node *node;
184 acpi_status status;
185
186 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
187
188 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
189 return_ACPI_STATUS(AE_OK);
190 }
191
192 /* Get the AML pointer (method object) and buffer_field node */
193
194 extra_desc = acpi_ns_get_secondary_object(obj_desc);
195 node = obj_desc->buffer_field.node;
196
197 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_BUFFER_FIELD,
198 node, NULL));
199
200 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
201 acpi_ut_get_node_name(node)));
202
203 /* Execute the AML code for the term_arg arguments */
204
205 status = acpi_ds_execute_arguments(node, node->parent,
206 extra_desc->extra.aml_length,
207 extra_desc->extra.aml_start);
208 return_ACPI_STATUS(status);
209}
210
211/*******************************************************************************
212 *
213 * FUNCTION: acpi_ds_get_bank_field_arguments
214 *
215 * PARAMETERS: obj_desc - A valid bank_field object
216 *
217 * RETURN: Status.
218 *
219 * DESCRIPTION: Get bank_field bank_value. This implements the late
220 * evaluation of these field attributes.
221 *
222 ******************************************************************************/
223
224acpi_status
225acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
226{
227 union acpi_operand_object *extra_desc;
228 struct acpi_namespace_node *node;
229 acpi_status status;
230
231 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
232
233 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
234 return_ACPI_STATUS(AE_OK);
235 }
236
237 /* Get the AML pointer (method object) and bank_field node */
238
239 extra_desc = acpi_ns_get_secondary_object(obj_desc);
240 node = obj_desc->bank_field.node;
241
242 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
243 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
244
245 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
246 acpi_ut_get_node_name(node)));
247
248 /* Execute the AML code for the term_arg arguments */
249
250 status = acpi_ds_execute_arguments(node, node->parent,
251 extra_desc->extra.aml_length,
252 extra_desc->extra.aml_start);
253 return_ACPI_STATUS(status);
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_ds_get_buffer_arguments
259 *
260 * PARAMETERS: obj_desc - A valid Buffer object
261 *
262 * RETURN: Status.
263 *
264 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
265 * the late evaluation of these attributes.
266 *
267 ******************************************************************************/
268
269acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
270{
271 struct acpi_namespace_node *node;
272 acpi_status status;
273
274 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
275
276 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
277 return_ACPI_STATUS(AE_OK);
278 }
279
280 /* Get the Buffer node */
281
282 node = obj_desc->buffer.node;
283 if (!node) {
284 ACPI_ERROR((AE_INFO,
285 "No pointer back to namespace node in buffer object %p",
286 obj_desc));
287 return_ACPI_STATUS(AE_AML_INTERNAL);
288 }
289
290 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
291
292 /* Execute the AML code for the term_arg arguments */
293
294 status = acpi_ds_execute_arguments(node, node,
295 obj_desc->buffer.aml_length,
296 obj_desc->buffer.aml_start);
297 return_ACPI_STATUS(status);
298}
299
300/*******************************************************************************
301 *
302 * FUNCTION: acpi_ds_get_package_arguments
303 *
304 * PARAMETERS: obj_desc - A valid Package object
305 *
306 * RETURN: Status.
307 *
308 * DESCRIPTION: Get Package length and initializer byte list. This implements
309 * the late evaluation of these attributes.
310 *
311 ******************************************************************************/
312
313acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
314{
315 struct acpi_namespace_node *node;
316 acpi_status status;
317
318 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
319
320 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
321 return_ACPI_STATUS(AE_OK);
322 }
323
324 /* Get the Package node */
325
326 node = obj_desc->package.node;
327 if (!node) {
328 ACPI_ERROR((AE_INFO,
329 "No pointer back to namespace node in package %p",
330 obj_desc));
331 return_ACPI_STATUS(AE_AML_INTERNAL);
332 }
333
334 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
335
336 /* Execute the AML code for the term_arg arguments */
337
338 status = acpi_ds_execute_arguments(node, node,
339 obj_desc->package.aml_length,
340 obj_desc->package.aml_start);
341 return_ACPI_STATUS(status);
342}
343
344/*******************************************************************************
345 *
346 * FUNCTION: acpi_ds_get_region_arguments
347 *
348 * PARAMETERS: obj_desc - A valid region object
349 *
350 * RETURN: Status.
351 *
352 * DESCRIPTION: Get region address and length. This implements the late
353 * evaluation of these region attributes.
354 *
355 ******************************************************************************/
356
357acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
358{
359 struct acpi_namespace_node *node;
360 acpi_status status;
361 union acpi_operand_object *extra_desc;
362
363 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
364
365 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
366 return_ACPI_STATUS(AE_OK);
367 }
368
369 extra_desc = acpi_ns_get_secondary_object(obj_desc);
370 if (!extra_desc) {
371 return_ACPI_STATUS(AE_NOT_EXIST);
372 }
373
374 /* Get the Region node */
375
376 node = obj_desc->region.node;
377
378 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
379 (ACPI_TYPE_REGION, node, NULL));
380
381 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
382 acpi_ut_get_node_name(node),
383 extra_desc->extra.aml_start));
384
385 /* Execute the argument AML */
386
387 status = acpi_ds_execute_arguments(node, node->parent,
388 extra_desc->extra.aml_length,
389 extra_desc->extra.aml_start);
390 return_ACPI_STATUS(status);
391}
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
new file mode 100644
index 000000000000..26c49fff58da
--- /dev/null
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -0,0 +1,410 @@
1/******************************************************************************
2 *
3 * Module Name: dscontrol - Support for execution control opcodes -
4 * if/else/while/return
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "amlcode.h"
48#include "acdispat.h"
49#include "acinterp.h"
50
51#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dscontrol")
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ds_exec_begin_control_op
57 *
58 * PARAMETERS: walk_list - The list that owns the walk stack
59 * Op - The control Op
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Handles all control ops encountered during control method
64 * execution.
65 *
66 ******************************************************************************/
67acpi_status
68acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
69 union acpi_parse_object *op)
70{
71 acpi_status status = AE_OK;
72 union acpi_generic_state *control_state;
73
74 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
75
76 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
77 op, op->common.aml_opcode, walk_state));
78
79 switch (op->common.aml_opcode) {
80 case AML_WHILE_OP:
81
82 /*
83 * If this is an additional iteration of a while loop, continue.
84 * There is no need to allocate a new control state.
85 */
86 if (walk_state->control_state) {
87 if (walk_state->control_state->control.
88 aml_predicate_start ==
89 (walk_state->parser_state.aml - 1)) {
90
91 /* Reset the state to start-of-loop */
92
93 walk_state->control_state->common.state =
94 ACPI_CONTROL_CONDITIONAL_EXECUTING;
95 break;
96 }
97 }
98
99 /*lint -fallthrough */
100
101 case AML_IF_OP:
102
103 /*
104 * IF/WHILE: Create a new control state to manage these
105 * constructs. We need to manage these as a stack, in order
106 * to handle nesting.
107 */
108 control_state = acpi_ut_create_control_state();
109 if (!control_state) {
110 status = AE_NO_MEMORY;
111 break;
112 }
113 /*
114 * Save a pointer to the predicate for multiple executions
115 * of a loop
116 */
117 control_state->control.aml_predicate_start =
118 walk_state->parser_state.aml - 1;
119 control_state->control.package_end =
120 walk_state->parser_state.pkg_end;
121 control_state->control.opcode = op->common.aml_opcode;
122
123 /* Push the control state on this walk's control stack */
124
125 acpi_ut_push_generic_state(&walk_state->control_state,
126 control_state);
127 break;
128
129 case AML_ELSE_OP:
130
131 /* Predicate is in the state object */
132 /* If predicate is true, the IF was executed, ignore ELSE part */
133
134 if (walk_state->last_predicate) {
135 status = AE_CTRL_TRUE;
136 }
137
138 break;
139
140 case AML_RETURN_OP:
141
142 break;
143
144 default:
145 break;
146 }
147
148 return (status);
149}
150
151/*******************************************************************************
152 *
153 * FUNCTION: acpi_ds_exec_end_control_op
154 *
155 * PARAMETERS: walk_list - The list that owns the walk stack
156 * Op - The control Op
157 *
158 * RETURN: Status
159 *
160 * DESCRIPTION: Handles all control ops encountered during control method
161 * execution.
162 *
163 ******************************************************************************/
164
165acpi_status
166acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
167 union acpi_parse_object * op)
168{
169 acpi_status status = AE_OK;
170 union acpi_generic_state *control_state;
171
172 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
173
174 switch (op->common.aml_opcode) {
175 case AML_IF_OP:
176
177 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
178
179 /*
180 * Save the result of the predicate in case there is an
181 * ELSE to come
182 */
183 walk_state->last_predicate =
184 (u8)walk_state->control_state->common.value;
185
186 /*
187 * Pop the control state that was created at the start
188 * of the IF and free it
189 */
190 control_state =
191 acpi_ut_pop_generic_state(&walk_state->control_state);
192 acpi_ut_delete_generic_state(control_state);
193 break;
194
195 case AML_ELSE_OP:
196
197 break;
198
199 case AML_WHILE_OP:
200
201 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
202
203 control_state = walk_state->control_state;
204 if (control_state->common.value) {
205
206 /* Predicate was true, the body of the loop was just executed */
207
208 /*
209 * This loop counter mechanism allows the interpreter to escape
210 * possibly infinite loops. This can occur in poorly written AML
211 * when the hardware does not respond within a while loop and the
212 * loop does not implement a timeout.
213 */
214 control_state->control.loop_count++;
215 if (control_state->control.loop_count >
216 ACPI_MAX_LOOP_ITERATIONS) {
217 status = AE_AML_INFINITE_LOOP;
218 break;
219 }
220
221 /*
222 * Go back and evaluate the predicate and maybe execute the loop
223 * another time
224 */
225 status = AE_CTRL_PENDING;
226 walk_state->aml_last_while =
227 control_state->control.aml_predicate_start;
228 break;
229 }
230
231 /* Predicate was false, terminate this while loop */
232
233 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
234 "[WHILE_OP] termination! Op=%p\n", op));
235
236 /* Pop this control state and free it */
237
238 control_state =
239 acpi_ut_pop_generic_state(&walk_state->control_state);
240 acpi_ut_delete_generic_state(control_state);
241 break;
242
243 case AML_RETURN_OP:
244
245 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
246 "[RETURN_OP] Op=%p Arg=%p\n", op,
247 op->common.value.arg));
248
249 /*
250 * One optional operand -- the return value
251 * It can be either an immediate operand or a result that
252 * has been bubbled up the tree
253 */
254 if (op->common.value.arg) {
255
256 /* Since we have a real Return(), delete any implicit return */
257
258 acpi_ds_clear_implicit_return(walk_state);
259
260 /* Return statement has an immediate operand */
261
262 status =
263 acpi_ds_create_operands(walk_state,
264 op->common.value.arg);
265 if (ACPI_FAILURE(status)) {
266 return (status);
267 }
268
269 /*
270 * If value being returned is a Reference (such as
271 * an arg or local), resolve it now because it may
272 * cease to exist at the end of the method.
273 */
274 status =
275 acpi_ex_resolve_to_value(&walk_state->operands[0],
276 walk_state);
277 if (ACPI_FAILURE(status)) {
278 return (status);
279 }
280
281 /*
282 * Get the return value and save as the last result
283 * value. This is the only place where walk_state->return_desc
284 * is set to anything other than zero!
285 */
286 walk_state->return_desc = walk_state->operands[0];
287 } else if (walk_state->result_count) {
288
289 /* Since we have a real Return(), delete any implicit return */
290
291 acpi_ds_clear_implicit_return(walk_state);
292
293 /*
294 * The return value has come from a previous calculation.
295 *
296 * If value being returned is a Reference (such as
297 * an arg or local), resolve it now because it may
298 * cease to exist at the end of the method.
299 *
300 * Allow references created by the Index operator to return
301 * unchanged.
302 */
303 if ((ACPI_GET_DESCRIPTOR_TYPE
304 (walk_state->results->results.obj_desc[0]) ==
305 ACPI_DESC_TYPE_OPERAND)
306 && ((walk_state->results->results.obj_desc[0])->
307 common.type == ACPI_TYPE_LOCAL_REFERENCE)
308 && ((walk_state->results->results.obj_desc[0])->
309 reference.class != ACPI_REFCLASS_INDEX)) {
310 status =
311 acpi_ex_resolve_to_value(&walk_state->
312 results->results.
313 obj_desc[0],
314 walk_state);
315 if (ACPI_FAILURE(status)) {
316 return (status);
317 }
318 }
319
320 walk_state->return_desc =
321 walk_state->results->results.obj_desc[0];
322 } else {
323 /* No return operand */
324
325 if (walk_state->num_operands) {
326 acpi_ut_remove_reference(walk_state->
327 operands[0]);
328 }
329
330 walk_state->operands[0] = NULL;
331 walk_state->num_operands = 0;
332 walk_state->return_desc = NULL;
333 }
334
335 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
336 "Completed RETURN_OP State=%p, RetVal=%p\n",
337 walk_state, walk_state->return_desc));
338
339 /* End the control method execution right now */
340
341 status = AE_CTRL_TERMINATE;
342 break;
343
344 case AML_NOOP_OP:
345
346 /* Just do nothing! */
347 break;
348
349 case AML_BREAK_POINT_OP:
350
351 /*
352 * Set the single-step flag. This will cause the debugger (if present)
353 * to break to the console within the AML debugger at the start of the
354 * next AML instruction.
355 */
356 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
357 ACPI_DEBUGGER_EXEC(acpi_os_printf
358 ("**break** Executed AML BreakPoint opcode\n"));
359
360 /* Call to the OSL in case OS wants a piece of the action */
361
362 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
363 "Executed AML Breakpoint opcode");
364 break;
365
366 case AML_BREAK_OP:
367 case AML_CONTINUE_OP: /* ACPI 2.0 */
368
369 /* Pop and delete control states until we find a while */
370
371 while (walk_state->control_state &&
372 (walk_state->control_state->control.opcode !=
373 AML_WHILE_OP)) {
374 control_state =
375 acpi_ut_pop_generic_state(&walk_state->
376 control_state);
377 acpi_ut_delete_generic_state(control_state);
378 }
379
380 /* No while found? */
381
382 if (!walk_state->control_state) {
383 return (AE_AML_NO_WHILE);
384 }
385
386 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
387
388 walk_state->aml_last_while =
389 walk_state->control_state->control.package_end;
390
391 /* Return status depending on opcode */
392
393 if (op->common.aml_opcode == AML_BREAK_OP) {
394 status = AE_CTRL_BREAK;
395 } else {
396 status = AE_CTRL_CONTINUE;
397 }
398 break;
399
400 default:
401
402 ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p",
403 op->common.aml_opcode, op));
404
405 status = AE_AML_BAD_OPCODE;
406 break;
407 }
408
409 return (status);
410}
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index bbecf293aeeb..c627a288e027 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -1,7 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of 3 * Module Name: dsopcode - Dispatcher suport for regions and fields
4 * "control" opcodes
5 * 4 *
6 *****************************************************************************/ 5 *****************************************************************************/
7 6
@@ -57,11 +56,6 @@ ACPI_MODULE_NAME("dsopcode")
57 56
58/* Local prototypes */ 57/* Local prototypes */
59static acpi_status 58static acpi_status
60acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *scope_node,
62 u32 aml_length, u8 * aml_start);
63
64static acpi_status
65acpi_ds_init_buffer_field(u16 aml_opcode, 59acpi_ds_init_buffer_field(u16 aml_opcode,
66 union acpi_operand_object *obj_desc, 60 union acpi_operand_object *obj_desc,
67 union acpi_operand_object *buffer_desc, 61 union acpi_operand_object *buffer_desc,
@@ -71,361 +65,6 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
71 65
72/******************************************************************************* 66/*******************************************************************************
73 * 67 *
74 * FUNCTION: acpi_ds_execute_arguments
75 *
76 * PARAMETERS: Node - Object NS node
77 * scope_node - Parent NS node
78 * aml_length - Length of executable AML
79 * aml_start - Pointer to the AML
80 *
81 * RETURN: Status.
82 *
83 * DESCRIPTION: Late (deferred) execution of region or field arguments
84 *
85 ******************************************************************************/
86
87static acpi_status
88acpi_ds_execute_arguments(struct acpi_namespace_node *node,
89 struct acpi_namespace_node *scope_node,
90 u32 aml_length, u8 * aml_start)
91{
92 acpi_status status;
93 union acpi_parse_object *op;
94 struct acpi_walk_state *walk_state;
95
96 ACPI_FUNCTION_TRACE(ds_execute_arguments);
97
98 /*
99 * Allocate a new parser op to be the root of the parsed tree
100 */
101 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
102 if (!op) {
103 return_ACPI_STATUS(AE_NO_MEMORY);
104 }
105
106 /* Save the Node for use in acpi_ps_parse_aml */
107
108 op->common.node = scope_node;
109
110 /* Create and initialize a new parser state */
111
112 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
113 if (!walk_state) {
114 status = AE_NO_MEMORY;
115 goto cleanup;
116 }
117
118 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
119 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
120 if (ACPI_FAILURE(status)) {
121 acpi_ds_delete_walk_state(walk_state);
122 goto cleanup;
123 }
124
125 /* Mark this parse as a deferred opcode */
126
127 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
128 walk_state->deferred_node = node;
129
130 /* Pass1: Parse the entire declaration */
131
132 status = acpi_ps_parse_aml(walk_state);
133 if (ACPI_FAILURE(status)) {
134 goto cleanup;
135 }
136
137 /* Get and init the Op created above */
138
139 op->common.node = node;
140 acpi_ps_delete_parse_tree(op);
141
142 /* Evaluate the deferred arguments */
143
144 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
145 if (!op) {
146 return_ACPI_STATUS(AE_NO_MEMORY);
147 }
148
149 op->common.node = scope_node;
150
151 /* Create and initialize a new parser state */
152
153 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
154 if (!walk_state) {
155 status = AE_NO_MEMORY;
156 goto cleanup;
157 }
158
159 /* Execute the opcode and arguments */
160
161 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
162 aml_length, NULL, ACPI_IMODE_EXECUTE);
163 if (ACPI_FAILURE(status)) {
164 acpi_ds_delete_walk_state(walk_state);
165 goto cleanup;
166 }
167
168 /* Mark this execution as a deferred opcode */
169
170 walk_state->deferred_node = node;
171 status = acpi_ps_parse_aml(walk_state);
172
173 cleanup:
174 acpi_ps_delete_parse_tree(op);
175 return_ACPI_STATUS(status);
176}
177
178/*******************************************************************************
179 *
180 * FUNCTION: acpi_ds_get_buffer_field_arguments
181 *
182 * PARAMETERS: obj_desc - A valid buffer_field object
183 *
184 * RETURN: Status.
185 *
186 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
187 * evaluation of these field attributes.
188 *
189 ******************************************************************************/
190
191acpi_status
192acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
193{
194 union acpi_operand_object *extra_desc;
195 struct acpi_namespace_node *node;
196 acpi_status status;
197
198 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
199
200 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
201 return_ACPI_STATUS(AE_OK);
202 }
203
204 /* Get the AML pointer (method object) and buffer_field node */
205
206 extra_desc = acpi_ns_get_secondary_object(obj_desc);
207 node = obj_desc->buffer_field.node;
208
209 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
210 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
211 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
212 acpi_ut_get_node_name(node)));
213
214 /* Execute the AML code for the term_arg arguments */
215
216 status = acpi_ds_execute_arguments(node, node->parent,
217 extra_desc->extra.aml_length,
218 extra_desc->extra.aml_start);
219 return_ACPI_STATUS(status);
220}
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_ds_get_bank_field_arguments
225 *
226 * PARAMETERS: obj_desc - A valid bank_field object
227 *
228 * RETURN: Status.
229 *
230 * DESCRIPTION: Get bank_field bank_value. This implements the late
231 * evaluation of these field attributes.
232 *
233 ******************************************************************************/
234
235acpi_status
236acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
237{
238 union acpi_operand_object *extra_desc;
239 struct acpi_namespace_node *node;
240 acpi_status status;
241
242 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
243
244 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
245 return_ACPI_STATUS(AE_OK);
246 }
247
248 /* Get the AML pointer (method object) and bank_field node */
249
250 extra_desc = acpi_ns_get_secondary_object(obj_desc);
251 node = obj_desc->bank_field.node;
252
253 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
254 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
255 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
256 acpi_ut_get_node_name(node)));
257
258 /* Execute the AML code for the term_arg arguments */
259
260 status = acpi_ds_execute_arguments(node, node->parent,
261 extra_desc->extra.aml_length,
262 extra_desc->extra.aml_start);
263 return_ACPI_STATUS(status);
264}
265
266/*******************************************************************************
267 *
268 * FUNCTION: acpi_ds_get_buffer_arguments
269 *
270 * PARAMETERS: obj_desc - A valid Buffer object
271 *
272 * RETURN: Status.
273 *
274 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
275 * the late evaluation of these attributes.
276 *
277 ******************************************************************************/
278
279acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
280{
281 struct acpi_namespace_node *node;
282 acpi_status status;
283
284 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
285
286 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
287 return_ACPI_STATUS(AE_OK);
288 }
289
290 /* Get the Buffer node */
291
292 node = obj_desc->buffer.node;
293 if (!node) {
294 ACPI_ERROR((AE_INFO,
295 "No pointer back to namespace node in buffer object %p",
296 obj_desc));
297 return_ACPI_STATUS(AE_AML_INTERNAL);
298 }
299
300 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
301
302 /* Execute the AML code for the term_arg arguments */
303
304 status = acpi_ds_execute_arguments(node, node,
305 obj_desc->buffer.aml_length,
306 obj_desc->buffer.aml_start);
307 return_ACPI_STATUS(status);
308}
309
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_ds_get_package_arguments
313 *
314 * PARAMETERS: obj_desc - A valid Package object
315 *
316 * RETURN: Status.
317 *
318 * DESCRIPTION: Get Package length and initializer byte list. This implements
319 * the late evaluation of these attributes.
320 *
321 ******************************************************************************/
322
323acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
324{
325 struct acpi_namespace_node *node;
326 acpi_status status;
327
328 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
329
330 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
331 return_ACPI_STATUS(AE_OK);
332 }
333
334 /* Get the Package node */
335
336 node = obj_desc->package.node;
337 if (!node) {
338 ACPI_ERROR((AE_INFO,
339 "No pointer back to namespace node in package %p",
340 obj_desc));
341 return_ACPI_STATUS(AE_AML_INTERNAL);
342 }
343
344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
345
346 /* Execute the AML code for the term_arg arguments */
347
348 status = acpi_ds_execute_arguments(node, node,
349 obj_desc->package.aml_length,
350 obj_desc->package.aml_start);
351 return_ACPI_STATUS(status);
352}
353
354/*****************************************************************************
355 *
356 * FUNCTION: acpi_ds_get_region_arguments
357 *
358 * PARAMETERS: obj_desc - A valid region object
359 *
360 * RETURN: Status.
361 *
362 * DESCRIPTION: Get region address and length. This implements the late
363 * evaluation of these region attributes.
364 *
365 ****************************************************************************/
366
367acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
368{
369 struct acpi_namespace_node *node;
370 acpi_status status;
371 union acpi_operand_object *extra_desc;
372
373 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
374
375 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
376 return_ACPI_STATUS(AE_OK);
377 }
378
379 extra_desc = acpi_ns_get_secondary_object(obj_desc);
380 if (!extra_desc) {
381 return_ACPI_STATUS(AE_NOT_EXIST);
382 }
383
384 /* Get the Region node */
385
386 node = obj_desc->region.node;
387
388 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
389 (ACPI_TYPE_REGION, node, NULL));
390
391 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
392 acpi_ut_get_node_name(node),
393 extra_desc->extra.aml_start));
394
395 /* Execute the argument AML */
396
397 status = acpi_ds_execute_arguments(node, node->parent,
398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404 /* Validate the region address/length via the host OS */
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412 /*
413 * Invalid address/length. We will emit an error message and mark
414 * the region as invalid, so that it will cause an additional error if
415 * it is ever used. Then return AE_OK.
416 */
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
424 return_ACPI_STATUS(status);
425}
426
427/*******************************************************************************
428 *
429 * FUNCTION: acpi_ds_initialize_region 68 * FUNCTION: acpi_ds_initialize_region
430 * 69 *
431 * PARAMETERS: obj_handle - Region namespace node 70 * PARAMETERS: obj_handle - Region namespace node
@@ -826,8 +465,9 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
826 * 465 *
827 * RETURN: Status 466 * RETURN: Status
828 * 467 *
829 * DESCRIPTION: Get region address and length 468 * DESCRIPTION: Get region address and length.
830 * Called from acpi_ds_exec_end_op during data_table_region parse tree walk 469 * Called from acpi_ds_exec_end_op during data_table_region parse
470 * tree walk.
831 * 471 *
832 ******************************************************************************/ 472 ******************************************************************************/
833 473
@@ -1114,360 +754,3 @@ acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
1114 acpi_ut_remove_reference(operand_desc); 754 acpi_ut_remove_reference(operand_desc);
1115 return_ACPI_STATUS(status); 755 return_ACPI_STATUS(status);
1116} 756}
1117
1118/*******************************************************************************
1119 *
1120 * FUNCTION: acpi_ds_exec_begin_control_op
1121 *
1122 * PARAMETERS: walk_list - The list that owns the walk stack
1123 * Op - The control Op
1124 *
1125 * RETURN: Status
1126 *
1127 * DESCRIPTION: Handles all control ops encountered during control method
1128 * execution.
1129 *
1130 ******************************************************************************/
1131
1132acpi_status
1133acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1134 union acpi_parse_object *op)
1135{
1136 acpi_status status = AE_OK;
1137 union acpi_generic_state *control_state;
1138
1139 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
1140
1141 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
1142 op->common.aml_opcode, walk_state));
1143
1144 switch (op->common.aml_opcode) {
1145 case AML_WHILE_OP:
1146
1147 /*
1148 * If this is an additional iteration of a while loop, continue.
1149 * There is no need to allocate a new control state.
1150 */
1151 if (walk_state->control_state) {
1152 if (walk_state->control_state->control.aml_predicate_start
1153 == (walk_state->parser_state.aml - 1)) {
1154
1155 /* Reset the state to start-of-loop */
1156
1157 walk_state->control_state->common.state =
1158 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1159 break;
1160 }
1161 }
1162
1163 /*lint -fallthrough */
1164
1165 case AML_IF_OP:
1166
1167 /*
1168 * IF/WHILE: Create a new control state to manage these
1169 * constructs. We need to manage these as a stack, in order
1170 * to handle nesting.
1171 */
1172 control_state = acpi_ut_create_control_state();
1173 if (!control_state) {
1174 status = AE_NO_MEMORY;
1175 break;
1176 }
1177 /*
1178 * Save a pointer to the predicate for multiple executions
1179 * of a loop
1180 */
1181 control_state->control.aml_predicate_start =
1182 walk_state->parser_state.aml - 1;
1183 control_state->control.package_end =
1184 walk_state->parser_state.pkg_end;
1185 control_state->control.opcode = op->common.aml_opcode;
1186
1187 /* Push the control state on this walk's control stack */
1188
1189 acpi_ut_push_generic_state(&walk_state->control_state,
1190 control_state);
1191 break;
1192
1193 case AML_ELSE_OP:
1194
1195 /* Predicate is in the state object */
1196 /* If predicate is true, the IF was executed, ignore ELSE part */
1197
1198 if (walk_state->last_predicate) {
1199 status = AE_CTRL_TRUE;
1200 }
1201
1202 break;
1203
1204 case AML_RETURN_OP:
1205
1206 break;
1207
1208 default:
1209 break;
1210 }
1211
1212 return (status);
1213}
1214
1215/*******************************************************************************
1216 *
1217 * FUNCTION: acpi_ds_exec_end_control_op
1218 *
1219 * PARAMETERS: walk_list - The list that owns the walk stack
1220 * Op - The control Op
1221 *
1222 * RETURN: Status
1223 *
1224 * DESCRIPTION: Handles all control ops encountered during control method
1225 * execution.
1226 *
1227 ******************************************************************************/
1228
1229acpi_status
1230acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1231 union acpi_parse_object * op)
1232{
1233 acpi_status status = AE_OK;
1234 union acpi_generic_state *control_state;
1235
1236 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
1237
1238 switch (op->common.aml_opcode) {
1239 case AML_IF_OP:
1240
1241 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
1242
1243 /*
1244 * Save the result of the predicate in case there is an
1245 * ELSE to come
1246 */
1247 walk_state->last_predicate =
1248 (u8) walk_state->control_state->common.value;
1249
1250 /*
1251 * Pop the control state that was created at the start
1252 * of the IF and free it
1253 */
1254 control_state =
1255 acpi_ut_pop_generic_state(&walk_state->control_state);
1256 acpi_ut_delete_generic_state(control_state);
1257 break;
1258
1259 case AML_ELSE_OP:
1260
1261 break;
1262
1263 case AML_WHILE_OP:
1264
1265 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1266
1267 control_state = walk_state->control_state;
1268 if (control_state->common.value) {
1269
1270 /* Predicate was true, the body of the loop was just executed */
1271
1272 /*
1273 * This loop counter mechanism allows the interpreter to escape
1274 * possibly infinite loops. This can occur in poorly written AML
1275 * when the hardware does not respond within a while loop and the
1276 * loop does not implement a timeout.
1277 */
1278 control_state->control.loop_count++;
1279 if (control_state->control.loop_count >
1280 ACPI_MAX_LOOP_ITERATIONS) {
1281 status = AE_AML_INFINITE_LOOP;
1282 break;
1283 }
1284
1285 /*
1286 * Go back and evaluate the predicate and maybe execute the loop
1287 * another time
1288 */
1289 status = AE_CTRL_PENDING;
1290 walk_state->aml_last_while =
1291 control_state->control.aml_predicate_start;
1292 break;
1293 }
1294
1295 /* Predicate was false, terminate this while loop */
1296
1297 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1298 "[WHILE_OP] termination! Op=%p\n", op));
1299
1300 /* Pop this control state and free it */
1301
1302 control_state =
1303 acpi_ut_pop_generic_state(&walk_state->control_state);
1304 acpi_ut_delete_generic_state(control_state);
1305 break;
1306
1307 case AML_RETURN_OP:
1308
1309 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1310 "[RETURN_OP] Op=%p Arg=%p\n", op,
1311 op->common.value.arg));
1312
1313 /*
1314 * One optional operand -- the return value
1315 * It can be either an immediate operand or a result that
1316 * has been bubbled up the tree
1317 */
1318 if (op->common.value.arg) {
1319
1320 /* Since we have a real Return(), delete any implicit return */
1321
1322 acpi_ds_clear_implicit_return(walk_state);
1323
1324 /* Return statement has an immediate operand */
1325
1326 status =
1327 acpi_ds_create_operands(walk_state,
1328 op->common.value.arg);
1329 if (ACPI_FAILURE(status)) {
1330 return (status);
1331 }
1332
1333 /*
1334 * If value being returned is a Reference (such as
1335 * an arg or local), resolve it now because it may
1336 * cease to exist at the end of the method.
1337 */
1338 status =
1339 acpi_ex_resolve_to_value(&walk_state->operands[0],
1340 walk_state);
1341 if (ACPI_FAILURE(status)) {
1342 return (status);
1343 }
1344
1345 /*
1346 * Get the return value and save as the last result
1347 * value. This is the only place where walk_state->return_desc
1348 * is set to anything other than zero!
1349 */
1350 walk_state->return_desc = walk_state->operands[0];
1351 } else if (walk_state->result_count) {
1352
1353 /* Since we have a real Return(), delete any implicit return */
1354
1355 acpi_ds_clear_implicit_return(walk_state);
1356
1357 /*
1358 * The return value has come from a previous calculation.
1359 *
1360 * If value being returned is a Reference (such as
1361 * an arg or local), resolve it now because it may
1362 * cease to exist at the end of the method.
1363 *
1364 * Allow references created by the Index operator to return unchanged.
1365 */
1366 if ((ACPI_GET_DESCRIPTOR_TYPE
1367 (walk_state->results->results.obj_desc[0]) ==
1368 ACPI_DESC_TYPE_OPERAND)
1369 && ((walk_state->results->results.obj_desc[0])->
1370 common.type == ACPI_TYPE_LOCAL_REFERENCE)
1371 && ((walk_state->results->results.obj_desc[0])->
1372 reference.class != ACPI_REFCLASS_INDEX)) {
1373 status =
1374 acpi_ex_resolve_to_value(&walk_state->
1375 results->results.
1376 obj_desc[0],
1377 walk_state);
1378 if (ACPI_FAILURE(status)) {
1379 return (status);
1380 }
1381 }
1382
1383 walk_state->return_desc =
1384 walk_state->results->results.obj_desc[0];
1385 } else {
1386 /* No return operand */
1387
1388 if (walk_state->num_operands) {
1389 acpi_ut_remove_reference(walk_state->
1390 operands[0]);
1391 }
1392
1393 walk_state->operands[0] = NULL;
1394 walk_state->num_operands = 0;
1395 walk_state->return_desc = NULL;
1396 }
1397
1398 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1399 "Completed RETURN_OP State=%p, RetVal=%p\n",
1400 walk_state, walk_state->return_desc));
1401
1402 /* End the control method execution right now */
1403
1404 status = AE_CTRL_TERMINATE;
1405 break;
1406
1407 case AML_NOOP_OP:
1408
1409 /* Just do nothing! */
1410 break;
1411
1412 case AML_BREAK_POINT_OP:
1413
1414 /*
1415 * Set the single-step flag. This will cause the debugger (if present)
1416 * to break to the console within the AML debugger at the start of the
1417 * next AML instruction.
1418 */
1419 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
1420 ACPI_DEBUGGER_EXEC(acpi_os_printf
1421 ("**break** Executed AML BreakPoint opcode\n"));
1422
1423 /* Call to the OSL in case OS wants a piece of the action */
1424
1425 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1426 "Executed AML Breakpoint opcode");
1427 break;
1428
1429 case AML_BREAK_OP:
1430 case AML_CONTINUE_OP: /* ACPI 2.0 */
1431
1432 /* Pop and delete control states until we find a while */
1433
1434 while (walk_state->control_state &&
1435 (walk_state->control_state->control.opcode !=
1436 AML_WHILE_OP)) {
1437 control_state =
1438 acpi_ut_pop_generic_state(&walk_state->
1439 control_state);
1440 acpi_ut_delete_generic_state(control_state);
1441 }
1442
1443 /* No while found? */
1444
1445 if (!walk_state->control_state) {
1446 return (AE_AML_NO_WHILE);
1447 }
1448
1449 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1450
1451 walk_state->aml_last_while =
1452 walk_state->control_state->control.package_end;
1453
1454 /* Return status depending on opcode */
1455
1456 if (op->common.aml_opcode == AML_BREAK_OP) {
1457 status = AE_CTRL_BREAK;
1458 } else {
1459 status = AE_CTRL_CONTINUE;
1460 }
1461 break;
1462
1463 default:
1464
1465 ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p",
1466 op->common.aml_opcode, op));
1467
1468 status = AE_AML_BAD_OPCODE;
1469 break;
1470 }
1471
1472 return (status);
1473}
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 52566ff5e903..23a3b1ab20c1 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: dswload - Dispatcher namespace load callbacks 3 * Module Name: dswload - Dispatcher first pass namespace load callbacks
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -48,7 +48,6 @@
48#include "acdispat.h" 48#include "acdispat.h"
49#include "acinterp.h" 49#include "acinterp.h"
50#include "acnamesp.h" 50#include "acnamesp.h"
51#include "acevents.h"
52 51
53#ifdef ACPI_ASL_COMPILER 52#ifdef ACPI_ASL_COMPILER
54#include <acpi/acdisasm.h> 53#include <acpi/acdisasm.h>
@@ -537,670 +536,3 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
537 536
538 return_ACPI_STATUS(status); 537 return_ACPI_STATUS(status);
539} 538}
540
541/*******************************************************************************
542 *
543 * FUNCTION: acpi_ds_load2_begin_op
544 *
545 * PARAMETERS: walk_state - Current state of the parse tree walk
546 * out_op - Wher to return op if a new one is created
547 *
548 * RETURN: Status
549 *
550 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
551 *
552 ******************************************************************************/
553
554acpi_status
555acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
556 union acpi_parse_object **out_op)
557{
558 union acpi_parse_object *op;
559 struct acpi_namespace_node *node;
560 acpi_status status;
561 acpi_object_type object_type;
562 char *buffer_ptr;
563 u32 flags;
564
565 ACPI_FUNCTION_TRACE(ds_load2_begin_op);
566
567 op = walk_state->op;
568 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
569 walk_state));
570
571 if (op) {
572 if ((walk_state->control_state) &&
573 (walk_state->control_state->common.state ==
574 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
575
576 /* We are executing a while loop outside of a method */
577
578 status = acpi_ds_exec_begin_op(walk_state, out_op);
579 return_ACPI_STATUS(status);
580 }
581
582 /* We only care about Namespace opcodes here */
583
584 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
585 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
586 (!(walk_state->op_info->flags & AML_NAMED))) {
587 return_ACPI_STATUS(AE_OK);
588 }
589
590 /* Get the name we are going to enter or lookup in the namespace */
591
592 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
593
594 /* For Namepath op, get the path string */
595
596 buffer_ptr = op->common.value.string;
597 if (!buffer_ptr) {
598
599 /* No name, just exit */
600
601 return_ACPI_STATUS(AE_OK);
602 }
603 } else {
604 /* Get name from the op */
605
606 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
607 }
608 } else {
609 /* Get the namestring from the raw AML */
610
611 buffer_ptr =
612 acpi_ps_get_next_namestring(&walk_state->parser_state);
613 }
614
615 /* Map the opcode into an internal object type */
616
617 object_type = walk_state->op_info->object_type;
618
619 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
620 "State=%p Op=%p Type=%X\n", walk_state, op,
621 object_type));
622
623 switch (walk_state->opcode) {
624 case AML_FIELD_OP:
625 case AML_BANK_FIELD_OP:
626 case AML_INDEX_FIELD_OP:
627
628 node = NULL;
629 status = AE_OK;
630 break;
631
632 case AML_INT_NAMEPATH_OP:
633 /*
634 * The name_path is an object reference to an existing object.
635 * Don't enter the name into the namespace, but look it up
636 * for use later.
637 */
638 status =
639 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
640 object_type, ACPI_IMODE_EXECUTE,
641 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
642 break;
643
644 case AML_SCOPE_OP:
645
646 /* Special case for Scope(\) -> refers to the Root node */
647
648 if (op && (op->named.node == acpi_gbl_root_node)) {
649 node = op->named.node;
650
651 status =
652 acpi_ds_scope_stack_push(node, object_type,
653 walk_state);
654 if (ACPI_FAILURE(status)) {
655 return_ACPI_STATUS(status);
656 }
657 } else {
658 /*
659 * The Path is an object reference to an existing object.
660 * Don't enter the name into the namespace, but look it up
661 * for use later.
662 */
663 status =
664 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
665 object_type, ACPI_IMODE_EXECUTE,
666 ACPI_NS_SEARCH_PARENT, walk_state,
667 &(node));
668 if (ACPI_FAILURE(status)) {
669#ifdef ACPI_ASL_COMPILER
670 if (status == AE_NOT_FOUND) {
671 status = AE_OK;
672 } else {
673 ACPI_ERROR_NAMESPACE(buffer_ptr,
674 status);
675 }
676#else
677 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
678#endif
679 return_ACPI_STATUS(status);
680 }
681 }
682
683 /*
684 * We must check to make sure that the target is
685 * one of the opcodes that actually opens a scope
686 */
687 switch (node->type) {
688 case ACPI_TYPE_ANY:
689 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
690 case ACPI_TYPE_DEVICE:
691 case ACPI_TYPE_POWER:
692 case ACPI_TYPE_PROCESSOR:
693 case ACPI_TYPE_THERMAL:
694
695 /* These are acceptable types */
696 break;
697
698 case ACPI_TYPE_INTEGER:
699 case ACPI_TYPE_STRING:
700 case ACPI_TYPE_BUFFER:
701
702 /*
703 * These types we will allow, but we will change the type.
704 * This enables some existing code of the form:
705 *
706 * Name (DEB, 0)
707 * Scope (DEB) { ... }
708 */
709 ACPI_WARNING((AE_INFO,
710 "Type override - [%4.4s] had invalid type (%s) "
711 "for Scope operator, changed to type ANY\n",
712 acpi_ut_get_node_name(node),
713 acpi_ut_get_type_name(node->type)));
714
715 node->type = ACPI_TYPE_ANY;
716 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
717 break;
718
719 default:
720
721 /* All other types are an error */
722
723 ACPI_ERROR((AE_INFO,
724 "Invalid type (%s) for target of "
725 "Scope operator [%4.4s] (Cannot override)",
726 acpi_ut_get_type_name(node->type),
727 acpi_ut_get_node_name(node)));
728
729 return (AE_AML_OPERAND_TYPE);
730 }
731 break;
732
733 default:
734
735 /* All other opcodes */
736
737 if (op && op->common.node) {
738
739 /* This op/node was previously entered into the namespace */
740
741 node = op->common.node;
742
743 if (acpi_ns_opens_scope(object_type)) {
744 status =
745 acpi_ds_scope_stack_push(node, object_type,
746 walk_state);
747 if (ACPI_FAILURE(status)) {
748 return_ACPI_STATUS(status);
749 }
750 }
751
752 return_ACPI_STATUS(AE_OK);
753 }
754
755 /*
756 * Enter the named type into the internal namespace. We enter the name
757 * as we go downward in the parse tree. Any necessary subobjects that
758 * involve arguments to the opcode must be created as we go back up the
759 * parse tree later.
760 *
761 * Note: Name may already exist if we are executing a deferred opcode.
762 */
763 if (walk_state->deferred_node) {
764
765 /* This name is already in the namespace, get the node */
766
767 node = walk_state->deferred_node;
768 status = AE_OK;
769 break;
770 }
771
772 flags = ACPI_NS_NO_UPSEARCH;
773 if (walk_state->pass_number == ACPI_IMODE_EXECUTE) {
774
775 /* Execution mode, node cannot already exist, node is temporary */
776
777 flags |= ACPI_NS_ERROR_IF_FOUND;
778
779 if (!
780 (walk_state->
781 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
782 flags |= ACPI_NS_TEMPORARY;
783 }
784 }
785
786 /* Add new entry or lookup existing entry */
787
788 status =
789 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
790 object_type, ACPI_IMODE_LOAD_PASS2, flags,
791 walk_state, &node);
792
793 if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) {
794 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
795 "***New Node [%4.4s] %p is temporary\n",
796 acpi_ut_get_node_name(node), node));
797 }
798 break;
799 }
800
801 if (ACPI_FAILURE(status)) {
802 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
803 return_ACPI_STATUS(status);
804 }
805
806 if (!op) {
807
808 /* Create a new op */
809
810 op = acpi_ps_alloc_op(walk_state->opcode);
811 if (!op) {
812 return_ACPI_STATUS(AE_NO_MEMORY);
813 }
814
815 /* Initialize the new op */
816
817 if (node) {
818 op->named.name = node->name.integer;
819 }
820 *out_op = op;
821 }
822
823 /*
824 * Put the Node in the "op" object that the parser uses, so we
825 * can get it again quickly when this scope is closed
826 */
827 op->common.node = node;
828 return_ACPI_STATUS(status);
829}
830
831/*******************************************************************************
832 *
833 * FUNCTION: acpi_ds_load2_end_op
834 *
835 * PARAMETERS: walk_state - Current state of the parse tree walk
836 *
837 * RETURN: Status
838 *
839 * DESCRIPTION: Ascending callback used during the loading of the namespace,
840 * both control methods and everything else.
841 *
842 ******************************************************************************/
843
844acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
845{
846 union acpi_parse_object *op;
847 acpi_status status = AE_OK;
848 acpi_object_type object_type;
849 struct acpi_namespace_node *node;
850 union acpi_parse_object *arg;
851 struct acpi_namespace_node *new_node;
852#ifndef ACPI_NO_METHOD_EXECUTION
853 u32 i;
854 u8 region_space;
855#endif
856
857 ACPI_FUNCTION_TRACE(ds_load2_end_op);
858
859 op = walk_state->op;
860 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
861 walk_state->op_info->name, op, walk_state));
862
863 /* Check if opcode had an associated namespace object */
864
865 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
866 return_ACPI_STATUS(AE_OK);
867 }
868
869 if (op->common.aml_opcode == AML_SCOPE_OP) {
870 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
871 "Ending scope Op=%p State=%p\n", op,
872 walk_state));
873 }
874
875 object_type = walk_state->op_info->object_type;
876
877 /*
878 * Get the Node/name from the earlier lookup
879 * (It was saved in the *op structure)
880 */
881 node = op->common.node;
882
883 /*
884 * Put the Node on the object stack (Contains the ACPI Name of
885 * this object)
886 */
887 walk_state->operands[0] = (void *)node;
888 walk_state->num_operands = 1;
889
890 /* Pop the scope stack */
891
892 if (acpi_ns_opens_scope(object_type) &&
893 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
894 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
895 "(%s) Popping scope for Op %p\n",
896 acpi_ut_get_type_name(object_type), op));
897
898 status = acpi_ds_scope_stack_pop(walk_state);
899 if (ACPI_FAILURE(status)) {
900 goto cleanup;
901 }
902 }
903
904 /*
905 * Named operations are as follows:
906 *
907 * AML_ALIAS
908 * AML_BANKFIELD
909 * AML_CREATEBITFIELD
910 * AML_CREATEBYTEFIELD
911 * AML_CREATEDWORDFIELD
912 * AML_CREATEFIELD
913 * AML_CREATEQWORDFIELD
914 * AML_CREATEWORDFIELD
915 * AML_DATA_REGION
916 * AML_DEVICE
917 * AML_EVENT
918 * AML_FIELD
919 * AML_INDEXFIELD
920 * AML_METHOD
921 * AML_METHODCALL
922 * AML_MUTEX
923 * AML_NAME
924 * AML_NAMEDFIELD
925 * AML_OPREGION
926 * AML_POWERRES
927 * AML_PROCESSOR
928 * AML_SCOPE
929 * AML_THERMALZONE
930 */
931
932 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
933 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
934 acpi_ps_get_opcode_name(op->common.aml_opcode),
935 walk_state, op, node));
936
937 /* Decode the opcode */
938
939 arg = op->common.value.arg;
940
941 switch (walk_state->op_info->type) {
942#ifndef ACPI_NO_METHOD_EXECUTION
943
944 case AML_TYPE_CREATE_FIELD:
945 /*
946 * Create the field object, but the field buffer and index must
947 * be evaluated later during the execution phase
948 */
949 status = acpi_ds_create_buffer_field(op, walk_state);
950 break;
951
952 case AML_TYPE_NAMED_FIELD:
953 /*
954 * If we are executing a method, initialize the field
955 */
956 if (walk_state->method_node) {
957 status = acpi_ds_init_field_objects(op, walk_state);
958 }
959
960 switch (op->common.aml_opcode) {
961 case AML_INDEX_FIELD_OP:
962
963 status =
964 acpi_ds_create_index_field(op,
965 (acpi_handle) arg->
966 common.node, walk_state);
967 break;
968
969 case AML_BANK_FIELD_OP:
970
971 status =
972 acpi_ds_create_bank_field(op, arg->common.node,
973 walk_state);
974 break;
975
976 case AML_FIELD_OP:
977
978 status =
979 acpi_ds_create_field(op, arg->common.node,
980 walk_state);
981 break;
982
983 default:
984 /* All NAMED_FIELD opcodes must be handled above */
985 break;
986 }
987 break;
988
989 case AML_TYPE_NAMED_SIMPLE:
990
991 status = acpi_ds_create_operands(walk_state, arg);
992 if (ACPI_FAILURE(status)) {
993 goto cleanup;
994 }
995
996 switch (op->common.aml_opcode) {
997 case AML_PROCESSOR_OP:
998
999 status = acpi_ex_create_processor(walk_state);
1000 break;
1001
1002 case AML_POWER_RES_OP:
1003
1004 status = acpi_ex_create_power_resource(walk_state);
1005 break;
1006
1007 case AML_MUTEX_OP:
1008
1009 status = acpi_ex_create_mutex(walk_state);
1010 break;
1011
1012 case AML_EVENT_OP:
1013
1014 status = acpi_ex_create_event(walk_state);
1015 break;
1016
1017 case AML_ALIAS_OP:
1018
1019 status = acpi_ex_create_alias(walk_state);
1020 break;
1021
1022 default:
1023 /* Unknown opcode */
1024
1025 status = AE_OK;
1026 goto cleanup;
1027 }
1028
1029 /* Delete operands */
1030
1031 for (i = 1; i < walk_state->num_operands; i++) {
1032 acpi_ut_remove_reference(walk_state->operands[i]);
1033 walk_state->operands[i] = NULL;
1034 }
1035
1036 break;
1037#endif /* ACPI_NO_METHOD_EXECUTION */
1038
1039 case AML_TYPE_NAMED_COMPLEX:
1040
1041 switch (op->common.aml_opcode) {
1042#ifndef ACPI_NO_METHOD_EXECUTION
1043 case AML_REGION_OP:
1044 case AML_DATA_REGION_OP:
1045
1046 if (op->common.aml_opcode == AML_REGION_OP) {
1047 region_space = (acpi_adr_space_type)
1048 ((op->common.value.arg)->common.value.
1049 integer);
1050 } else {
1051 region_space = REGION_DATA_TABLE;
1052 }
1053
1054 /*
1055 * The op_region is not fully parsed at this time. The only valid
1056 * argument is the space_id. (We must save the address of the
1057 * AML of the address and length operands)
1058 *
1059 * If we have a valid region, initialize it. The namespace is
1060 * unlocked at this point.
1061 *
1062 * Need to unlock interpreter if it is locked (if we are running
1063 * a control method), in order to allow _REG methods to be run
1064 * during acpi_ev_initialize_region.
1065 */
1066 if (walk_state->method_node) {
1067 /*
1068 * Executing a method: initialize the region and unlock
1069 * the interpreter
1070 */
1071 status =
1072 acpi_ex_create_region(op->named.data,
1073 op->named.length,
1074 region_space,
1075 walk_state);
1076 if (ACPI_FAILURE(status)) {
1077 return (status);
1078 }
1079
1080 acpi_ex_exit_interpreter();
1081 }
1082
1083 status =
1084 acpi_ev_initialize_region
1085 (acpi_ns_get_attached_object(node), FALSE);
1086 if (walk_state->method_node) {
1087 acpi_ex_enter_interpreter();
1088 }
1089
1090 if (ACPI_FAILURE(status)) {
1091 /*
1092 * If AE_NOT_EXIST is returned, it is not fatal
1093 * because many regions get created before a handler
1094 * is installed for said region.
1095 */
1096 if (AE_NOT_EXIST == status) {
1097 status = AE_OK;
1098 }
1099 }
1100 break;
1101
1102 case AML_NAME_OP:
1103
1104 status = acpi_ds_create_node(walk_state, node, op);
1105 break;
1106
1107 case AML_METHOD_OP:
1108 /*
1109 * method_op pkg_length name_string method_flags term_list
1110 *
1111 * Note: We must create the method node/object pair as soon as we
1112 * see the method declaration. This allows later pass1 parsing
1113 * of invocations of the method (need to know the number of
1114 * arguments.)
1115 */
1116 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1117 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
1118 walk_state, op, op->named.node));
1119
1120 if (!acpi_ns_get_attached_object(op->named.node)) {
1121 walk_state->operands[0] =
1122 ACPI_CAST_PTR(void, op->named.node);
1123 walk_state->num_operands = 1;
1124
1125 status =
1126 acpi_ds_create_operands(walk_state,
1127 op->common.value.
1128 arg);
1129 if (ACPI_SUCCESS(status)) {
1130 status =
1131 acpi_ex_create_method(op->named.
1132 data,
1133 op->named.
1134 length,
1135 walk_state);
1136 }
1137 walk_state->operands[0] = NULL;
1138 walk_state->num_operands = 0;
1139
1140 if (ACPI_FAILURE(status)) {
1141 return_ACPI_STATUS(status);
1142 }
1143 }
1144 break;
1145
1146#endif /* ACPI_NO_METHOD_EXECUTION */
1147
1148 default:
1149 /* All NAMED_COMPLEX opcodes must be handled above */
1150 break;
1151 }
1152 break;
1153
1154 case AML_CLASS_INTERNAL:
1155
1156 /* case AML_INT_NAMEPATH_OP: */
1157 break;
1158
1159 case AML_CLASS_METHOD_CALL:
1160
1161 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1162 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
1163 walk_state, op, node));
1164
1165 /*
1166 * Lookup the method name and save the Node
1167 */
1168 status =
1169 acpi_ns_lookup(walk_state->scope_info,
1170 arg->common.value.string, ACPI_TYPE_ANY,
1171 ACPI_IMODE_LOAD_PASS2,
1172 ACPI_NS_SEARCH_PARENT |
1173 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
1174 &(new_node));
1175 if (ACPI_SUCCESS(status)) {
1176 /*
1177 * Make sure that what we found is indeed a method
1178 * We didn't search for a method on purpose, to see if the name
1179 * would resolve
1180 */
1181 if (new_node->type != ACPI_TYPE_METHOD) {
1182 status = AE_AML_OPERAND_TYPE;
1183 }
1184
1185 /* We could put the returned object (Node) on the object stack for
1186 * later, but for now, we will put it in the "op" object that the
1187 * parser uses, so we can get it again at the end of this scope
1188 */
1189 op->common.node = new_node;
1190 } else {
1191 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
1192 }
1193 break;
1194
1195 default:
1196 break;
1197 }
1198
1199 cleanup:
1200
1201 /* Remove the Node pushed at the very beginning */
1202
1203 walk_state->operands[0] = NULL;
1204 walk_state->num_operands = 0;
1205 return_ACPI_STATUS(status);
1206}
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
new file mode 100644
index 000000000000..4be4e921dfe1
--- /dev/null
+++ b/drivers/acpi/acpica/dswload2.c
@@ -0,0 +1,720 @@
1/******************************************************************************
2 *
3 * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
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.
25 *
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.
29 *
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.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acparser.h"
47#include "amlcode.h"
48#include "acdispat.h"
49#include "acinterp.h"
50#include "acnamesp.h"
51#include "acevents.h"
52
53#define _COMPONENT ACPI_DISPATCHER
54ACPI_MODULE_NAME("dswload2")
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ds_load2_begin_op
59 *
60 * PARAMETERS: walk_state - Current state of the parse tree walk
61 * out_op - Wher to return op if a new one is created
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
66 *
67 ******************************************************************************/
68acpi_status
69acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
70 union acpi_parse_object **out_op)
71{
72 union acpi_parse_object *op;
73 struct acpi_namespace_node *node;
74 acpi_status status;
75 acpi_object_type object_type;
76 char *buffer_ptr;
77 u32 flags;
78
79 ACPI_FUNCTION_TRACE(ds_load2_begin_op);
80
81 op = walk_state->op;
82 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
83 walk_state));
84
85 if (op) {
86 if ((walk_state->control_state) &&
87 (walk_state->control_state->common.state ==
88 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
89
90 /* We are executing a while loop outside of a method */
91
92 status = acpi_ds_exec_begin_op(walk_state, out_op);
93 return_ACPI_STATUS(status);
94 }
95
96 /* We only care about Namespace opcodes here */
97
98 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
99 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
100 (!(walk_state->op_info->flags & AML_NAMED))) {
101 return_ACPI_STATUS(AE_OK);
102 }
103
104 /* Get the name we are going to enter or lookup in the namespace */
105
106 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
107
108 /* For Namepath op, get the path string */
109
110 buffer_ptr = op->common.value.string;
111 if (!buffer_ptr) {
112
113 /* No name, just exit */
114
115 return_ACPI_STATUS(AE_OK);
116 }
117 } else {
118 /* Get name from the op */
119
120 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
121 }
122 } else {
123 /* Get the namestring from the raw AML */
124
125 buffer_ptr =
126 acpi_ps_get_next_namestring(&walk_state->parser_state);
127 }
128
129 /* Map the opcode into an internal object type */
130
131 object_type = walk_state->op_info->object_type;
132
133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
134 "State=%p Op=%p Type=%X\n", walk_state, op,
135 object_type));
136
137 switch (walk_state->opcode) {
138 case AML_FIELD_OP:
139 case AML_BANK_FIELD_OP:
140 case AML_INDEX_FIELD_OP:
141
142 node = NULL;
143 status = AE_OK;
144 break;
145
146 case AML_INT_NAMEPATH_OP:
147 /*
148 * The name_path is an object reference to an existing object.
149 * Don't enter the name into the namespace, but look it up
150 * for use later.
151 */
152 status =
153 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
154 object_type, ACPI_IMODE_EXECUTE,
155 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
156 break;
157
158 case AML_SCOPE_OP:
159
160 /* Special case for Scope(\) -> refers to the Root node */
161
162 if (op && (op->named.node == acpi_gbl_root_node)) {
163 node = op->named.node;
164
165 status =
166 acpi_ds_scope_stack_push(node, object_type,
167 walk_state);
168 if (ACPI_FAILURE(status)) {
169 return_ACPI_STATUS(status);
170 }
171 } else {
172 /*
173 * The Path is an object reference to an existing object.
174 * Don't enter the name into the namespace, but look it up
175 * for use later.
176 */
177 status =
178 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
179 object_type, ACPI_IMODE_EXECUTE,
180 ACPI_NS_SEARCH_PARENT, walk_state,
181 &(node));
182 if (ACPI_FAILURE(status)) {
183#ifdef ACPI_ASL_COMPILER
184 if (status == AE_NOT_FOUND) {
185 status = AE_OK;
186 } else {
187 ACPI_ERROR_NAMESPACE(buffer_ptr,
188 status);
189 }
190#else
191 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
192#endif
193 return_ACPI_STATUS(status);
194 }
195 }
196
197 /*
198 * We must check to make sure that the target is
199 * one of the opcodes that actually opens a scope
200 */
201 switch (node->type) {
202 case ACPI_TYPE_ANY:
203 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
204 case ACPI_TYPE_DEVICE:
205 case ACPI_TYPE_POWER:
206 case ACPI_TYPE_PROCESSOR:
207 case ACPI_TYPE_THERMAL:
208
209 /* These are acceptable types */
210 break;
211
212 case ACPI_TYPE_INTEGER:
213 case ACPI_TYPE_STRING:
214 case ACPI_TYPE_BUFFER:
215
216 /*
217 * These types we will allow, but we will change the type.
218 * This enables some existing code of the form:
219 *
220 * Name (DEB, 0)
221 * Scope (DEB) { ... }
222 */
223 ACPI_WARNING((AE_INFO,
224 "Type override - [%4.4s] had invalid type (%s) "
225 "for Scope operator, changed to type ANY\n",
226 acpi_ut_get_node_name(node),
227 acpi_ut_get_type_name(node->type)));
228
229 node->type = ACPI_TYPE_ANY;
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break;
232
233 default:
234
235 /* All other types are an error */
236
237 ACPI_ERROR((AE_INFO,
238 "Invalid type (%s) for target of "
239 "Scope operator [%4.4s] (Cannot override)",
240 acpi_ut_get_type_name(node->type),
241 acpi_ut_get_node_name(node)));
242
243 return (AE_AML_OPERAND_TYPE);
244 }
245 break;
246
247 default:
248
249 /* All other opcodes */
250
251 if (op && op->common.node) {
252
253 /* This op/node was previously entered into the namespace */
254
255 node = op->common.node;
256
257 if (acpi_ns_opens_scope(object_type)) {
258 status =
259 acpi_ds_scope_stack_push(node, object_type,
260 walk_state);
261 if (ACPI_FAILURE(status)) {
262 return_ACPI_STATUS(status);
263 }
264 }
265
266 return_ACPI_STATUS(AE_OK);
267 }
268
269 /*
270 * Enter the named type into the internal namespace. We enter the name
271 * as we go downward in the parse tree. Any necessary subobjects that
272 * involve arguments to the opcode must be created as we go back up the
273 * parse tree later.
274 *
275 * Note: Name may already exist if we are executing a deferred opcode.
276 */
277 if (walk_state->deferred_node) {
278
279 /* This name is already in the namespace, get the node */
280
281 node = walk_state->deferred_node;
282 status = AE_OK;
283 break;
284 }
285
286 flags = ACPI_NS_NO_UPSEARCH;
287 if (walk_state->pass_number == ACPI_IMODE_EXECUTE) {
288
289 /* Execution mode, node cannot already exist, node is temporary */
290
291 flags |= ACPI_NS_ERROR_IF_FOUND;
292
293 if (!
294 (walk_state->
295 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
296 flags |= ACPI_NS_TEMPORARY;
297 }
298 }
299
300 /* Add new entry or lookup existing entry */
301
302 status =
303 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
304 object_type, ACPI_IMODE_LOAD_PASS2, flags,
305 walk_state, &node);
306
307 if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) {
308 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
309 "***New Node [%4.4s] %p is temporary\n",
310 acpi_ut_get_node_name(node), node));
311 }
312 break;
313 }
314
315 if (ACPI_FAILURE(status)) {
316 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
317 return_ACPI_STATUS(status);
318 }
319
320 if (!op) {
321
322 /* Create a new op */
323
324 op = acpi_ps_alloc_op(walk_state->opcode);
325 if (!op) {
326 return_ACPI_STATUS(AE_NO_MEMORY);
327 }
328
329 /* Initialize the new op */
330
331 if (node) {
332 op->named.name = node->name.integer;
333 }
334 *out_op = op;
335 }
336
337 /*
338 * Put the Node in the "op" object that the parser uses, so we
339 * can get it again quickly when this scope is closed
340 */
341 op->common.node = node;
342 return_ACPI_STATUS(status);
343}
344
345/*******************************************************************************
346 *
347 * FUNCTION: acpi_ds_load2_end_op
348 *
349 * PARAMETERS: walk_state - Current state of the parse tree walk
350 *
351 * RETURN: Status
352 *
353 * DESCRIPTION: Ascending callback used during the loading of the namespace,
354 * both control methods and everything else.
355 *
356 ******************************************************************************/
357
358acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
359{
360 union acpi_parse_object *op;
361 acpi_status status = AE_OK;
362 acpi_object_type object_type;
363 struct acpi_namespace_node *node;
364 union acpi_parse_object *arg;
365 struct acpi_namespace_node *new_node;
366#ifndef ACPI_NO_METHOD_EXECUTION
367 u32 i;
368 u8 region_space;
369#endif
370
371 ACPI_FUNCTION_TRACE(ds_load2_end_op);
372
373 op = walk_state->op;
374 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
375 walk_state->op_info->name, op, walk_state));
376
377 /* Check if opcode had an associated namespace object */
378
379 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
380 return_ACPI_STATUS(AE_OK);
381 }
382
383 if (op->common.aml_opcode == AML_SCOPE_OP) {
384 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
385 "Ending scope Op=%p State=%p\n", op,
386 walk_state));
387 }
388
389 object_type = walk_state->op_info->object_type;
390
391 /*
392 * Get the Node/name from the earlier lookup
393 * (It was saved in the *op structure)
394 */
395 node = op->common.node;
396
397 /*
398 * Put the Node on the object stack (Contains the ACPI Name of
399 * this object)
400 */
401 walk_state->operands[0] = (void *)node;
402 walk_state->num_operands = 1;
403
404 /* Pop the scope stack */
405
406 if (acpi_ns_opens_scope(object_type) &&
407 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
408 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
409 "(%s) Popping scope for Op %p\n",
410 acpi_ut_get_type_name(object_type), op));
411
412 status = acpi_ds_scope_stack_pop(walk_state);
413 if (ACPI_FAILURE(status)) {
414 goto cleanup;
415 }
416 }
417
418 /*
419 * Named operations are as follows:
420 *
421 * AML_ALIAS
422 * AML_BANKFIELD
423 * AML_CREATEBITFIELD
424 * AML_CREATEBYTEFIELD
425 * AML_CREATEDWORDFIELD
426 * AML_CREATEFIELD
427 * AML_CREATEQWORDFIELD
428 * AML_CREATEWORDFIELD
429 * AML_DATA_REGION
430 * AML_DEVICE
431 * AML_EVENT
432 * AML_FIELD
433 * AML_INDEXFIELD
434 * AML_METHOD
435 * AML_METHODCALL
436 * AML_MUTEX
437 * AML_NAME
438 * AML_NAMEDFIELD
439 * AML_OPREGION
440 * AML_POWERRES
441 * AML_PROCESSOR
442 * AML_SCOPE
443 * AML_THERMALZONE
444 */
445
446 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
447 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
448 acpi_ps_get_opcode_name(op->common.aml_opcode),
449 walk_state, op, node));
450
451 /* Decode the opcode */
452
453 arg = op->common.value.arg;
454
455 switch (walk_state->op_info->type) {
456#ifndef ACPI_NO_METHOD_EXECUTION
457
458 case AML_TYPE_CREATE_FIELD:
459 /*
460 * Create the field object, but the field buffer and index must
461 * be evaluated later during the execution phase
462 */
463 status = acpi_ds_create_buffer_field(op, walk_state);
464 break;
465
466 case AML_TYPE_NAMED_FIELD:
467 /*
468 * If we are executing a method, initialize the field
469 */
470 if (walk_state->method_node) {
471 status = acpi_ds_init_field_objects(op, walk_state);
472 }
473
474 switch (op->common.aml_opcode) {
475 case AML_INDEX_FIELD_OP:
476
477 status =
478 acpi_ds_create_index_field(op,
479 (acpi_handle) arg->
480 common.node, walk_state);
481 break;
482
483 case AML_BANK_FIELD_OP:
484
485 status =
486 acpi_ds_create_bank_field(op, arg->common.node,
487 walk_state);
488 break;
489
490 case AML_FIELD_OP:
491
492 status =
493 acpi_ds_create_field(op, arg->common.node,
494 walk_state);
495 break;
496
497 default:
498 /* All NAMED_FIELD opcodes must be handled above */
499 break;
500 }
501 break;
502
503 case AML_TYPE_NAMED_SIMPLE:
504
505 status = acpi_ds_create_operands(walk_state, arg);
506 if (ACPI_FAILURE(status)) {
507 goto cleanup;
508 }
509
510 switch (op->common.aml_opcode) {
511 case AML_PROCESSOR_OP:
512
513 status = acpi_ex_create_processor(walk_state);
514 break;
515
516 case AML_POWER_RES_OP:
517
518 status = acpi_ex_create_power_resource(walk_state);
519 break;
520
521 case AML_MUTEX_OP:
522
523 status = acpi_ex_create_mutex(walk_state);
524 break;
525
526 case AML_EVENT_OP:
527
528 status = acpi_ex_create_event(walk_state);
529 break;
530
531 case AML_ALIAS_OP:
532
533 status = acpi_ex_create_alias(walk_state);
534 break;
535
536 default:
537 /* Unknown opcode */
538
539 status = AE_OK;
540 goto cleanup;
541 }
542
543 /* Delete operands */
544
545 for (i = 1; i < walk_state->num_operands; i++) {
546 acpi_ut_remove_reference(walk_state->operands[i]);
547 walk_state->operands[i] = NULL;
548 }
549
550 break;
551#endif /* ACPI_NO_METHOD_EXECUTION */
552
553 case AML_TYPE_NAMED_COMPLEX:
554
555 switch (op->common.aml_opcode) {
556#ifndef ACPI_NO_METHOD_EXECUTION
557 case AML_REGION_OP:
558 case AML_DATA_REGION_OP:
559
560 if (op->common.aml_opcode == AML_REGION_OP) {
561 region_space = (acpi_adr_space_type)
562 ((op->common.value.arg)->common.value.
563 integer);
564 } else {
565 region_space = REGION_DATA_TABLE;
566 }
567
568 /*
569 * The op_region is not fully parsed at this time. The only valid
570 * argument is the space_id. (We must save the address of the
571 * AML of the address and length operands)
572 *
573 * If we have a valid region, initialize it. The namespace is
574 * unlocked at this point.
575 *
576 * Need to unlock interpreter if it is locked (if we are running
577 * a control method), in order to allow _REG methods to be run
578 * during acpi_ev_initialize_region.
579 */
580 if (walk_state->method_node) {
581 /*
582 * Executing a method: initialize the region and unlock
583 * the interpreter
584 */
585 status =
586 acpi_ex_create_region(op->named.data,
587 op->named.length,
588 region_space,
589 walk_state);
590 if (ACPI_FAILURE(status)) {
591 return (status);
592 }
593
594 acpi_ex_exit_interpreter();
595 }
596
597 status =
598 acpi_ev_initialize_region
599 (acpi_ns_get_attached_object(node), FALSE);
600 if (walk_state->method_node) {
601 acpi_ex_enter_interpreter();
602 }
603
604 if (ACPI_FAILURE(status)) {
605 /*
606 * If AE_NOT_EXIST is returned, it is not fatal
607 * because many regions get created before a handler
608 * is installed for said region.
609 */
610 if (AE_NOT_EXIST == status) {
611 status = AE_OK;
612 }
613 }
614 break;
615
616 case AML_NAME_OP:
617
618 status = acpi_ds_create_node(walk_state, node, op);
619 break;
620
621 case AML_METHOD_OP:
622 /*
623 * method_op pkg_length name_string method_flags term_list
624 *
625 * Note: We must create the method node/object pair as soon as we
626 * see the method declaration. This allows later pass1 parsing
627 * of invocations of the method (need to know the number of
628 * arguments.)
629 */
630 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
631 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
632 walk_state, op, op->named.node));
633
634 if (!acpi_ns_get_attached_object(op->named.node)) {
635 walk_state->operands[0] =
636 ACPI_CAST_PTR(void, op->named.node);
637 walk_state->num_operands = 1;
638
639 status =
640 acpi_ds_create_operands(walk_state,
641 op->common.value.
642 arg);
643 if (ACPI_SUCCESS(status)) {
644 status =
645 acpi_ex_create_method(op->named.
646 data,
647 op->named.
648 length,
649 walk_state);
650 }
651 walk_state->operands[0] = NULL;
652 walk_state->num_operands = 0;
653
654 if (ACPI_FAILURE(status)) {
655 return_ACPI_STATUS(status);
656 }
657 }
658 break;
659
660#endif /* ACPI_NO_METHOD_EXECUTION */
661
662 default:
663 /* All NAMED_COMPLEX opcodes must be handled above */
664 break;
665 }
666 break;
667
668 case AML_CLASS_INTERNAL:
669
670 /* case AML_INT_NAMEPATH_OP: */
671 break;
672
673 case AML_CLASS_METHOD_CALL:
674
675 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
676 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
677 walk_state, op, node));
678
679 /*
680 * Lookup the method name and save the Node
681 */
682 status =
683 acpi_ns_lookup(walk_state->scope_info,
684 arg->common.value.string, ACPI_TYPE_ANY,
685 ACPI_IMODE_LOAD_PASS2,
686 ACPI_NS_SEARCH_PARENT |
687 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
688 &(new_node));
689 if (ACPI_SUCCESS(status)) {
690 /*
691 * Make sure that what we found is indeed a method
692 * We didn't search for a method on purpose, to see if the name
693 * would resolve
694 */
695 if (new_node->type != ACPI_TYPE_METHOD) {
696 status = AE_AML_OPERAND_TYPE;
697 }
698
699 /* We could put the returned object (Node) on the object stack for
700 * later, but for now, we will put it in the "op" object that the
701 * parser uses, so we can get it again at the end of this scope
702 */
703 op->common.node = new_node;
704 } else {
705 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
706 }
707 break;
708
709 default:
710 break;
711 }
712
713 cleanup:
714
715 /* Remove the Node pushed at the very beginning */
716
717 walk_state->operands[0] = NULL;
718 walk_state->num_operands = 0;
719 return_ACPI_STATUS(status);
720}