diff options
Diffstat (limited to 'drivers/acpi/dispatcher/dswexec.c')
-rw-r--r-- | drivers/acpi/dispatcher/dswexec.c | 751 |
1 files changed, 751 insertions, 0 deletions
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c new file mode 100644 index 000000000000..2071a0d2bbbb --- /dev/null +++ b/drivers/acpi/dispatcher/dswexec.c | |||
@@ -0,0 +1,751 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: dswexec - Dispatcher method execution callbacks; | ||
4 | * dispatch to interpreter. | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2005, R. Byron Moore | ||
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 | |||
46 | #include <acpi/acpi.h> | ||
47 | #include <acpi/acparser.h> | ||
48 | #include <acpi/amlcode.h> | ||
49 | #include <acpi/acdispat.h> | ||
50 | #include <acpi/acinterp.h> | ||
51 | #include <acpi/acnamesp.h> | ||
52 | #include <acpi/acdebug.h> | ||
53 | #include <acpi/acdisasm.h> | ||
54 | |||
55 | |||
56 | #define _COMPONENT ACPI_DISPATCHER | ||
57 | ACPI_MODULE_NAME ("dswexec") | ||
58 | |||
59 | /* | ||
60 | * Dispatch table for opcode classes | ||
61 | */ | ||
62 | static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = { | ||
63 | acpi_ex_opcode_0A_0T_1R, | ||
64 | acpi_ex_opcode_1A_0T_0R, | ||
65 | acpi_ex_opcode_1A_0T_1R, | ||
66 | acpi_ex_opcode_1A_1T_0R, | ||
67 | acpi_ex_opcode_1A_1T_1R, | ||
68 | acpi_ex_opcode_2A_0T_0R, | ||
69 | acpi_ex_opcode_2A_0T_1R, | ||
70 | acpi_ex_opcode_2A_1T_1R, | ||
71 | acpi_ex_opcode_2A_2T_1R, | ||
72 | acpi_ex_opcode_3A_0T_0R, | ||
73 | acpi_ex_opcode_3A_1T_1R, | ||
74 | acpi_ex_opcode_6A_0T_1R}; | ||
75 | |||
76 | /***************************************************************************** | ||
77 | * | ||
78 | * FUNCTION: acpi_ds_get_predicate_value | ||
79 | * | ||
80 | * PARAMETERS: walk_state - Current state of the parse tree walk | ||
81 | * | ||
82 | * RETURN: Status | ||
83 | * | ||
84 | * DESCRIPTION: Get the result of a predicate evaluation | ||
85 | * | ||
86 | ****************************************************************************/ | ||
87 | |||
88 | acpi_status | ||
89 | acpi_ds_get_predicate_value ( | ||
90 | struct acpi_walk_state *walk_state, | ||
91 | union acpi_operand_object *result_obj) { | ||
92 | acpi_status status = AE_OK; | ||
93 | union acpi_operand_object *obj_desc; | ||
94 | union acpi_operand_object *local_obj_desc = NULL; | ||
95 | |||
96 | |||
97 | ACPI_FUNCTION_TRACE_PTR ("ds_get_predicate_value", walk_state); | ||
98 | |||
99 | |||
100 | walk_state->control_state->common.state = 0; | ||
101 | |||
102 | if (result_obj) { | ||
103 | status = acpi_ds_result_pop (&obj_desc, walk_state); | ||
104 | if (ACPI_FAILURE (status)) { | ||
105 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
106 | "Could not get result from predicate evaluation, %s\n", | ||
107 | acpi_format_exception (status))); | ||
108 | |||
109 | return_ACPI_STATUS (status); | ||
110 | } | ||
111 | } | ||
112 | else { | ||
113 | status = acpi_ds_create_operand (walk_state, walk_state->op, 0); | ||
114 | if (ACPI_FAILURE (status)) { | ||
115 | return_ACPI_STATUS (status); | ||
116 | } | ||
117 | |||
118 | status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); | ||
119 | if (ACPI_FAILURE (status)) { | ||
120 | return_ACPI_STATUS (status); | ||
121 | } | ||
122 | |||
123 | obj_desc = walk_state->operands [0]; | ||
124 | } | ||
125 | |||
126 | if (!obj_desc) { | ||
127 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate obj_desc=%p State=%p\n", | ||
128 | obj_desc, walk_state)); | ||
129 | |||
130 | return_ACPI_STATUS (AE_AML_NO_OPERAND); | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * Result of predicate evaluation must be an Integer | ||
135 | * object. Implicitly convert the argument if necessary. | ||
136 | */ | ||
137 | status = acpi_ex_convert_to_integer (obj_desc, &local_obj_desc, 16); | ||
138 | if (ACPI_FAILURE (status)) { | ||
139 | goto cleanup; | ||
140 | } | ||
141 | |||
142 | if (ACPI_GET_OBJECT_TYPE (local_obj_desc) != ACPI_TYPE_INTEGER) { | ||
143 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
144 | "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", | ||
145 | obj_desc, walk_state, ACPI_GET_OBJECT_TYPE (obj_desc))); | ||
146 | |||
147 | status = AE_AML_OPERAND_TYPE; | ||
148 | goto cleanup; | ||
149 | } | ||
150 | |||
151 | /* Truncate the predicate to 32-bits if necessary */ | ||
152 | |||
153 | acpi_ex_truncate_for32bit_table (local_obj_desc); | ||
154 | |||
155 | /* | ||
156 | * Save the result of the predicate evaluation on | ||
157 | * the control stack | ||
158 | */ | ||
159 | if (local_obj_desc->integer.value) { | ||
160 | walk_state->control_state->common.value = TRUE; | ||
161 | } | ||
162 | else { | ||
163 | /* | ||
164 | * Predicate is FALSE, we will just toss the | ||
165 | * rest of the package | ||
166 | */ | ||
167 | walk_state->control_state->common.value = FALSE; | ||
168 | status = AE_CTRL_FALSE; | ||
169 | } | ||
170 | |||
171 | |||
172 | cleanup: | ||
173 | |||
174 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", | ||
175 | walk_state->control_state->common.value, walk_state->op)); | ||
176 | |||
177 | /* Break to debugger to display result */ | ||
178 | |||
179 | ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (local_obj_desc, walk_state)); | ||
180 | |||
181 | /* | ||
182 | * Delete the predicate result object (we know that | ||
183 | * we don't need it anymore) | ||
184 | */ | ||
185 | if (local_obj_desc != obj_desc) { | ||
186 | acpi_ut_remove_reference (local_obj_desc); | ||
187 | } | ||
188 | acpi_ut_remove_reference (obj_desc); | ||
189 | |||
190 | walk_state->control_state->common.state = ACPI_CONTROL_NORMAL; | ||
191 | return_ACPI_STATUS (status); | ||
192 | } | ||
193 | |||
194 | |||
195 | /***************************************************************************** | ||
196 | * | ||
197 | * FUNCTION: acpi_ds_exec_begin_op | ||
198 | * | ||
199 | * PARAMETERS: walk_state - Current state of the parse tree walk | ||
200 | * out_op - Return op if a new one is created | ||
201 | * | ||
202 | * RETURN: Status | ||
203 | * | ||
204 | * DESCRIPTION: Descending callback used during the execution of control | ||
205 | * methods. This is where most operators and operands are | ||
206 | * dispatched to the interpreter. | ||
207 | * | ||
208 | ****************************************************************************/ | ||
209 | |||
210 | acpi_status | ||
211 | acpi_ds_exec_begin_op ( | ||
212 | struct acpi_walk_state *walk_state, | ||
213 | union acpi_parse_object **out_op) | ||
214 | { | ||
215 | union acpi_parse_object *op; | ||
216 | acpi_status status = AE_OK; | ||
217 | u32 opcode_class; | ||
218 | |||
219 | |||
220 | ACPI_FUNCTION_TRACE_PTR ("ds_exec_begin_op", walk_state); | ||
221 | |||
222 | |||
223 | op = walk_state->op; | ||
224 | if (!op) { | ||
225 | status = acpi_ds_load2_begin_op (walk_state, out_op); | ||
226 | if (ACPI_FAILURE (status)) { | ||
227 | return_ACPI_STATUS (status); | ||
228 | } | ||
229 | |||
230 | op = *out_op; | ||
231 | walk_state->op = op; | ||
232 | walk_state->opcode = op->common.aml_opcode; | ||
233 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
234 | |||
235 | if (acpi_ns_opens_scope (walk_state->op_info->object_type)) { | ||
236 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", | ||
237 | acpi_ut_get_type_name (walk_state->op_info->object_type), op)); | ||
238 | |||
239 | status = acpi_ds_scope_stack_pop (walk_state); | ||
240 | if (ACPI_FAILURE (status)) { | ||
241 | return_ACPI_STATUS (status); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
246 | if (op == walk_state->origin) { | ||
247 | if (out_op) { | ||
248 | *out_op = op; | ||
249 | } | ||
250 | |||
251 | return_ACPI_STATUS (AE_OK); | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * If the previous opcode was a conditional, this opcode | ||
256 | * must be the beginning of the associated predicate. | ||
257 | * Save this knowledge in the current scope descriptor | ||
258 | */ | ||
259 | if ((walk_state->control_state) && | ||
260 | (walk_state->control_state->common.state == | ||
261 | ACPI_CONTROL_CONDITIONAL_EXECUTING)) { | ||
262 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", | ||
263 | op, walk_state)); | ||
264 | |||
265 | walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING; | ||
266 | |||
267 | /* Save start of predicate */ | ||
268 | |||
269 | walk_state->control_state->control.predicate_op = op; | ||
270 | } | ||
271 | |||
272 | |||
273 | opcode_class = walk_state->op_info->class; | ||
274 | |||
275 | /* We want to send namepaths to the load code */ | ||
276 | |||
277 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | ||
278 | opcode_class = AML_CLASS_NAMED_OBJECT; | ||
279 | } | ||
280 | |||
281 | /* | ||
282 | * Handle the opcode based upon the opcode type | ||
283 | */ | ||
284 | switch (opcode_class) { | ||
285 | case AML_CLASS_CONTROL: | ||
286 | |||
287 | status = acpi_ds_result_stack_push (walk_state); | ||
288 | if (ACPI_FAILURE (status)) { | ||
289 | return_ACPI_STATUS (status); | ||
290 | } | ||
291 | |||
292 | status = acpi_ds_exec_begin_control_op (walk_state, op); | ||
293 | break; | ||
294 | |||
295 | |||
296 | case AML_CLASS_NAMED_OBJECT: | ||
297 | |||
298 | if (walk_state->walk_type == ACPI_WALK_METHOD) { | ||
299 | /* | ||
300 | * Found a named object declaration during method | ||
301 | * execution; we must enter this object into the | ||
302 | * namespace. The created object is temporary and | ||
303 | * will be deleted upon completion of the execution | ||
304 | * of this method. | ||
305 | */ | ||
306 | status = acpi_ds_load2_begin_op (walk_state, NULL); | ||
307 | } | ||
308 | |||
309 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
310 | status = acpi_ds_result_stack_push (walk_state); | ||
311 | } | ||
312 | break; | ||
313 | |||
314 | |||
315 | case AML_CLASS_EXECUTE: | ||
316 | case AML_CLASS_CREATE: | ||
317 | |||
318 | /* | ||
319 | * Most operators with arguments. | ||
320 | * Start a new result/operand state | ||
321 | */ | ||
322 | status = acpi_ds_result_stack_push (walk_state); | ||
323 | break; | ||
324 | |||
325 | |||
326 | default: | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | /* Nothing to do here during method execution */ | ||
331 | |||
332 | return_ACPI_STATUS (status); | ||
333 | } | ||
334 | |||
335 | |||
336 | /***************************************************************************** | ||
337 | * | ||
338 | * FUNCTION: acpi_ds_exec_end_op | ||
339 | * | ||
340 | * PARAMETERS: walk_state - Current state of the parse tree walk | ||
341 | * Op - Op that has been just been completed in the | ||
342 | * walk; Arguments have now been evaluated. | ||
343 | * | ||
344 | * RETURN: Status | ||
345 | * | ||
346 | * DESCRIPTION: Ascending callback used during the execution of control | ||
347 | * methods. The only thing we really need to do here is to | ||
348 | * notice the beginning of IF, ELSE, and WHILE blocks. | ||
349 | * | ||
350 | ****************************************************************************/ | ||
351 | |||
352 | acpi_status | ||
353 | acpi_ds_exec_end_op ( | ||
354 | struct acpi_walk_state *walk_state) | ||
355 | { | ||
356 | union acpi_parse_object *op; | ||
357 | acpi_status status = AE_OK; | ||
358 | u32 op_type; | ||
359 | u32 op_class; | ||
360 | union acpi_parse_object *next_op; | ||
361 | union acpi_parse_object *first_arg; | ||
362 | |||
363 | |||
364 | ACPI_FUNCTION_TRACE_PTR ("ds_exec_end_op", walk_state); | ||
365 | |||
366 | |||
367 | op = walk_state->op; | ||
368 | op_type = walk_state->op_info->type; | ||
369 | op_class = walk_state->op_info->class; | ||
370 | |||
371 | if (op_class == AML_CLASS_UNKNOWN) { | ||
372 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->common.aml_opcode)); | ||
373 | return_ACPI_STATUS (AE_NOT_IMPLEMENTED); | ||
374 | } | ||
375 | |||
376 | first_arg = op->common.value.arg; | ||
377 | |||
378 | /* Init the walk state */ | ||
379 | |||
380 | walk_state->num_operands = 0; | ||
381 | walk_state->return_desc = NULL; | ||
382 | walk_state->result_obj = NULL; | ||
383 | |||
384 | /* Call debugger for single step support (DEBUG build only) */ | ||
385 | |||
386 | ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class)); | ||
387 | ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);}); | ||
388 | |||
389 | /* Decode the Opcode Class */ | ||
390 | |||
391 | switch (op_class) { | ||
392 | case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */ | ||
393 | break; | ||
394 | |||
395 | |||
396 | case AML_CLASS_EXECUTE: /* most operators with arguments */ | ||
397 | |||
398 | /* Build resolved operand stack */ | ||
399 | |||
400 | status = acpi_ds_create_operands (walk_state, first_arg); | ||
401 | if (ACPI_FAILURE (status)) { | ||
402 | goto cleanup; | ||
403 | } | ||
404 | |||
405 | /* Done with this result state (Now that operand stack is built) */ | ||
406 | |||
407 | status = acpi_ds_result_stack_pop (walk_state); | ||
408 | if (ACPI_FAILURE (status)) { | ||
409 | goto cleanup; | ||
410 | } | ||
411 | |||
412 | /* | ||
413 | * All opcodes require operand resolution, with the only exceptions | ||
414 | * being the object_type and size_of operators. | ||
415 | */ | ||
416 | if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) { | ||
417 | /* Resolve all operands */ | ||
418 | |||
419 | status = acpi_ex_resolve_operands (walk_state->opcode, | ||
420 | &(walk_state->operands [walk_state->num_operands -1]), | ||
421 | walk_state); | ||
422 | if (ACPI_SUCCESS (status)) { | ||
423 | ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, | ||
424 | acpi_ps_get_opcode_name (walk_state->opcode), | ||
425 | walk_state->num_operands, "after ex_resolve_operands"); | ||
426 | } | ||
427 | } | ||
428 | |||
429 | if (ACPI_SUCCESS (status)) { | ||
430 | /* | ||
431 | * Dispatch the request to the appropriate interpreter handler | ||
432 | * routine. There is one routine per opcode "type" based upon the | ||
433 | * number of opcode arguments and return type. | ||
434 | */ | ||
435 | status = acpi_gbl_op_type_dispatch[op_type] (walk_state); | ||
436 | } | ||
437 | else { | ||
438 | /* | ||
439 | * Treat constructs of the form "Store(local_x,local_x)" as noops when the | ||
440 | * Local is uninitialized. | ||
441 | */ | ||
442 | if ((status == AE_AML_UNINITIALIZED_LOCAL) && | ||
443 | (walk_state->opcode == AML_STORE_OP) && | ||
444 | (walk_state->operands[0]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && | ||
445 | (walk_state->operands[1]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && | ||
446 | (walk_state->operands[0]->reference.opcode == | ||
447 | walk_state->operands[1]->reference.opcode) && | ||
448 | (walk_state->operands[0]->reference.offset == | ||
449 | walk_state->operands[1]->reference.offset)) { | ||
450 | status = AE_OK; | ||
451 | } | ||
452 | else { | ||
453 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
454 | "[%s]: Could not resolve operands, %s\n", | ||
455 | acpi_ps_get_opcode_name (walk_state->opcode), | ||
456 | acpi_format_exception (status))); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | /* Always delete the argument objects and clear the operand stack */ | ||
461 | |||
462 | acpi_ds_clear_operands (walk_state); | ||
463 | |||
464 | /* | ||
465 | * If a result object was returned from above, push it on the | ||
466 | * current result stack | ||
467 | */ | ||
468 | if (ACPI_SUCCESS (status) && | ||
469 | walk_state->result_obj) { | ||
470 | status = acpi_ds_result_push (walk_state->result_obj, walk_state); | ||
471 | } | ||
472 | |||
473 | break; | ||
474 | |||
475 | |||
476 | default: | ||
477 | |||
478 | switch (op_type) { | ||
479 | case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ | ||
480 | |||
481 | /* 1 Operand, 0 external_result, 0 internal_result */ | ||
482 | |||
483 | status = acpi_ds_exec_end_control_op (walk_state, op); | ||
484 | |||
485 | /* Make sure to properly pop the result stack */ | ||
486 | |||
487 | if (ACPI_SUCCESS (status)) { | ||
488 | status = acpi_ds_result_stack_pop (walk_state); | ||
489 | } | ||
490 | else if (status == AE_CTRL_PENDING) { | ||
491 | status = acpi_ds_result_stack_pop (walk_state); | ||
492 | if (ACPI_SUCCESS (status)) { | ||
493 | status = AE_CTRL_PENDING; | ||
494 | } | ||
495 | } | ||
496 | break; | ||
497 | |||
498 | |||
499 | case AML_TYPE_METHOD_CALL: | ||
500 | |||
501 | /* | ||
502 | * If the method is referenced from within a package | ||
503 | * declaration, it is not a invocation of the method, just | ||
504 | * a reference to it. | ||
505 | */ | ||
506 | if ((op->asl.parent) && | ||
507 | ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) || | ||
508 | (op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) { | ||
509 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", op)); | ||
510 | op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object; | ||
511 | acpi_ut_add_reference (op->asl.value.arg->asl.node->object); | ||
512 | return_ACPI_STATUS (AE_OK); | ||
513 | } | ||
514 | |||
515 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", op)); | ||
516 | |||
517 | /* | ||
518 | * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains | ||
519 | * the method Node pointer | ||
520 | */ | ||
521 | /* next_op points to the op that holds the method name */ | ||
522 | |||
523 | next_op = first_arg; | ||
524 | |||
525 | /* next_op points to first argument op */ | ||
526 | |||
527 | next_op = next_op->common.next; | ||
528 | |||
529 | /* | ||
530 | * Get the method's arguments and put them on the operand stack | ||
531 | */ | ||
532 | status = acpi_ds_create_operands (walk_state, next_op); | ||
533 | if (ACPI_FAILURE (status)) { | ||
534 | break; | ||
535 | } | ||
536 | |||
537 | /* | ||
538 | * Since the operands will be passed to another control method, | ||
539 | * we must resolve all local references here (Local variables, | ||
540 | * arguments to *this* method, etc.) | ||
541 | */ | ||
542 | status = acpi_ds_resolve_operands (walk_state); | ||
543 | if (ACPI_FAILURE (status)) { | ||
544 | /* On error, clear all resolved operands */ | ||
545 | |||
546 | acpi_ds_clear_operands (walk_state); | ||
547 | break; | ||
548 | } | ||
549 | |||
550 | /* | ||
551 | * Tell the walk loop to preempt this running method and | ||
552 | * execute the new method | ||
553 | */ | ||
554 | status = AE_CTRL_TRANSFER; | ||
555 | |||
556 | /* | ||
557 | * Return now; we don't want to disturb anything, | ||
558 | * especially the operand count! | ||
559 | */ | ||
560 | return_ACPI_STATUS (status); | ||
561 | |||
562 | |||
563 | case AML_TYPE_CREATE_FIELD: | ||
564 | |||
565 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | ||
566 | "Executing create_field Buffer/Index Op=%p\n", op)); | ||
567 | |||
568 | status = acpi_ds_load2_end_op (walk_state); | ||
569 | if (ACPI_FAILURE (status)) { | ||
570 | break; | ||
571 | } | ||
572 | |||
573 | status = acpi_ds_eval_buffer_field_operands (walk_state, op); | ||
574 | break; | ||
575 | |||
576 | |||
577 | case AML_TYPE_CREATE_OBJECT: | ||
578 | |||
579 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | ||
580 | "Executing create_object (Buffer/Package) Op=%p\n", op)); | ||
581 | |||
582 | switch (op->common.parent->common.aml_opcode) { | ||
583 | case AML_NAME_OP: | ||
584 | |||
585 | /* | ||
586 | * Put the Node on the object stack (Contains the ACPI Name of | ||
587 | * this object) | ||
588 | */ | ||
589 | walk_state->operands[0] = (void *) op->common.parent->common.node; | ||
590 | walk_state->num_operands = 1; | ||
591 | |||
592 | status = acpi_ds_create_node (walk_state, op->common.parent->common.node, op->common.parent); | ||
593 | if (ACPI_FAILURE (status)) { | ||
594 | break; | ||
595 | } | ||
596 | |||
597 | /* Fall through */ | ||
598 | /*lint -fallthrough */ | ||
599 | |||
600 | case AML_INT_EVAL_SUBTREE_OP: | ||
601 | |||
602 | status = acpi_ds_eval_data_object_operands (walk_state, op, | ||
603 | acpi_ns_get_attached_object (op->common.parent->common.node)); | ||
604 | break; | ||
605 | |||
606 | default: | ||
607 | |||
608 | status = acpi_ds_eval_data_object_operands (walk_state, op, NULL); | ||
609 | break; | ||
610 | } | ||
611 | |||
612 | /* Done with this result state (Now that operand stack is built) */ | ||
613 | |||
614 | status = acpi_ds_result_stack_pop (walk_state); | ||
615 | if (ACPI_FAILURE (status)) { | ||
616 | goto cleanup; | ||
617 | } | ||
618 | |||
619 | /* | ||
620 | * If a result object was returned from above, push it on the | ||
621 | * current result stack | ||
622 | */ | ||
623 | if (ACPI_SUCCESS (status) && | ||
624 | walk_state->result_obj) { | ||
625 | status = acpi_ds_result_push (walk_state->result_obj, walk_state); | ||
626 | } | ||
627 | break; | ||
628 | |||
629 | |||
630 | case AML_TYPE_NAMED_FIELD: | ||
631 | case AML_TYPE_NAMED_COMPLEX: | ||
632 | case AML_TYPE_NAMED_SIMPLE: | ||
633 | case AML_TYPE_NAMED_NO_OBJ: | ||
634 | |||
635 | status = acpi_ds_load2_end_op (walk_state); | ||
636 | if (ACPI_FAILURE (status)) { | ||
637 | break; | ||
638 | } | ||
639 | |||
640 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
641 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | ||
642 | "Executing op_region Address/Length Op=%p\n", op)); | ||
643 | |||
644 | status = acpi_ds_eval_region_operands (walk_state, op); | ||
645 | if (ACPI_FAILURE (status)) { | ||
646 | break; | ||
647 | } | ||
648 | |||
649 | status = acpi_ds_result_stack_pop (walk_state); | ||
650 | } | ||
651 | |||
652 | break; | ||
653 | |||
654 | |||
655 | case AML_TYPE_UNDEFINED: | ||
656 | |||
657 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", op)); | ||
658 | return_ACPI_STATUS (AE_NOT_IMPLEMENTED); | ||
659 | |||
660 | |||
661 | case AML_TYPE_BOGUS: | ||
662 | |||
663 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, | ||
664 | "Internal opcode=%X type Op=%p\n", | ||
665 | walk_state->opcode, op)); | ||
666 | break; | ||
667 | |||
668 | |||
669 | default: | ||
670 | |||
671 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
672 | "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", | ||
673 | op_class, op_type, op->common.aml_opcode, op)); | ||
674 | |||
675 | status = AE_NOT_IMPLEMENTED; | ||
676 | break; | ||
677 | } | ||
678 | } | ||
679 | |||
680 | /* | ||
681 | * ACPI 2.0 support for 64-bit integers: Truncate numeric | ||
682 | * result value if we are executing from a 32-bit ACPI table | ||
683 | */ | ||
684 | acpi_ex_truncate_for32bit_table (walk_state->result_obj); | ||
685 | |||
686 | /* | ||
687 | * Check if we just completed the evaluation of a | ||
688 | * conditional predicate | ||
689 | */ | ||
690 | |||
691 | if ((ACPI_SUCCESS (status)) && | ||
692 | (walk_state->control_state) && | ||
693 | (walk_state->control_state->common.state == | ||
694 | ACPI_CONTROL_PREDICATE_EXECUTING) && | ||
695 | (walk_state->control_state->control.predicate_op == op)) { | ||
696 | status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj); | ||
697 | walk_state->result_obj = NULL; | ||
698 | } | ||
699 | |||
700 | |||
701 | cleanup: | ||
702 | |||
703 | /* Invoke exception handler on error */ | ||
704 | |||
705 | if (ACPI_FAILURE (status) && | ||
706 | acpi_gbl_exception_handler && | ||
707 | !(status & AE_CODE_CONTROL)) { | ||
708 | acpi_ex_exit_interpreter (); | ||
709 | status = acpi_gbl_exception_handler (status, | ||
710 | walk_state->method_node->name.integer, walk_state->opcode, | ||
711 | walk_state->aml_offset, NULL); | ||
712 | acpi_ex_enter_interpreter (); | ||
713 | } | ||
714 | |||
715 | if (walk_state->result_obj) { | ||
716 | /* Break to debugger to display result */ | ||
717 | |||
718 | ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state)); | ||
719 | |||
720 | /* | ||
721 | * Delete the result op if and only if: | ||
722 | * Parent will not use the result -- such as any | ||
723 | * non-nested type2 op in a method (parent will be method) | ||
724 | */ | ||
725 | acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state); | ||
726 | } | ||
727 | |||
728 | #ifdef _UNDER_DEVELOPMENT | ||
729 | |||
730 | if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) { | ||
731 | acpi_db_method_end (walk_state); | ||
732 | } | ||
733 | #endif | ||
734 | |||
735 | /* Always clear the object stack */ | ||
736 | |||
737 | walk_state->num_operands = 0; | ||
738 | |||
739 | #ifdef ACPI_DISASSEMBLER | ||
740 | |||
741 | /* On error, display method locals/args */ | ||
742 | |||
743 | if (ACPI_FAILURE (status)) { | ||
744 | acpi_dm_dump_method_info (status, walk_state, op); | ||
745 | } | ||
746 | #endif | ||
747 | |||
748 | return_ACPI_STATUS (status); | ||
749 | } | ||
750 | |||
751 | |||