]>
Commit | Line | Data |
---|---|---|
73459f73 RM |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: psloop - Main AML parse loop | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
7735ca0e | 8 | * Copyright (C) 2000 - 2017, Intel Corp. |
73459f73 RM |
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 | ||
73459f73 | 44 | /* |
4d0b4af9 MK |
45 | * Parse the AML and build an operation tree as most interpreters, (such as |
46 | * Perl) do. Parsing is done by hand rather than with a YACC generated parser | |
47 | * to tightly constrain stack and dynamic memory usage. Parsing is kept | |
48 | * flexible and the code fairly compact by parsing based on a list of AML | |
49 | * opcode templates in aml_op_info[]. | |
73459f73 RM |
50 | */ |
51 | ||
52 | #include <acpi/acpi.h> | |
e2f7a777 | 53 | #include "accommon.h" |
ab6c5733 | 54 | #include "acinterp.h" |
e2f7a777 LB |
55 | #include "acparser.h" |
56 | #include "acdispat.h" | |
57 | #include "amlcode.h" | |
9cf7adec | 58 | #include "acconvert.h" |
73459f73 RM |
59 | |
60 | #define _COMPONENT ACPI_PARSER | |
4be44fcd | 61 | ACPI_MODULE_NAME("psloop") |
73459f73 | 62 | |
4d0b4af9 | 63 | /* Local prototypes */ |
4d0b4af9 MK |
64 | static acpi_status |
65 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | |
66 | u8 * aml_op_start, union acpi_parse_object *op); | |
67 | ||
7f0c826a | 68 | static void |
9a884ab6 LM |
69 | acpi_ps_link_module_code(union acpi_parse_object *parent_op, |
70 | u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); | |
7f0c826a | 71 | |
4d0b4af9 MK |
72 | /******************************************************************************* |
73 | * | |
74 | * FUNCTION: acpi_ps_get_arguments | |
75 | * | |
76 | * PARAMETERS: walk_state - Current state | |
77 | * aml_op_start - Op start in AML | |
ba494bee | 78 | * op - Current Op |
4d0b4af9 MK |
79 | * |
80 | * RETURN: Status | |
81 | * | |
82 | * DESCRIPTION: Get arguments for passed Op. | |
83 | * | |
84 | ******************************************************************************/ | |
85 | ||
86 | static acpi_status | |
87 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | |
88 | u8 * aml_op_start, union acpi_parse_object *op) | |
89 | { | |
90 | acpi_status status = AE_OK; | |
91 | union acpi_parse_object *arg = NULL; | |
7f0c826a | 92 | const struct acpi_opcode_info *op_info; |
4d0b4af9 MK |
93 | |
94 | ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state); | |
95 | ||
ce87e09d BM |
96 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
97 | "Get arguments for opcode [%s]\n", | |
98 | op->common.aml_op_name)); | |
99 | ||
4d0b4af9 MK |
100 | switch (op->common.aml_opcode) { |
101 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ | |
102 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ | |
103 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ | |
104 | case AML_QWORD_OP: /* AML_QWORDATA_ARG */ | |
105 | case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ | |
106 | ||
107 | /* Fill in constant or string argument directly */ | |
108 | ||
109 | acpi_ps_get_next_simple_arg(&(walk_state->parser_state), | |
110 | GET_CURRENT_ARG_TYPE(walk_state-> | |
111 | arg_types), | |
112 | op); | |
113 | break; | |
114 | ||
115 | case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ | |
116 | ||
89438f96 BM |
117 | status = acpi_ps_get_next_namepath(walk_state, |
118 | &(walk_state->parser_state), | |
119 | op, | |
120 | ACPI_POSSIBLE_METHOD_CALL); | |
4d0b4af9 MK |
121 | if (ACPI_FAILURE(status)) { |
122 | return_ACPI_STATUS(status); | |
123 | } | |
124 | ||
125 | walk_state->arg_types = 0; | |
126 | break; | |
127 | ||
128 | default: | |
129 | /* | |
130 | * Op is not a constant or string, append each argument to the Op | |
131 | */ | |
1fad8738 BM |
132 | while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) && |
133 | !walk_state->arg_count) { | |
83482f75 | 134 | walk_state->aml = walk_state->parser_state.aml; |
4d0b4af9 | 135 | |
9cf7adec BM |
136 | switch (op->common.aml_opcode) { |
137 | case AML_METHOD_OP: | |
138 | case AML_BUFFER_OP: | |
139 | case AML_PACKAGE_OP: | |
140 | case AML_VARIABLE_PACKAGE_OP: | |
141 | case AML_WHILE_OP: | |
142 | ||
143 | break; | |
144 | ||
145 | default: | |
146 | ||
147 | ASL_CV_CAPTURE_COMMENTS(walk_state); | |
148 | break; | |
149 | } | |
150 | ||
4d0b4af9 MK |
151 | status = |
152 | acpi_ps_get_next_arg(walk_state, | |
153 | &(walk_state->parser_state), | |
154 | GET_CURRENT_ARG_TYPE | |
155 | (walk_state->arg_types), &arg); | |
156 | if (ACPI_FAILURE(status)) { | |
157 | return_ACPI_STATUS(status); | |
158 | } | |
159 | ||
160 | if (arg) { | |
4d0b4af9 MK |
161 | acpi_ps_append_arg(op, arg); |
162 | } | |
163 | ||
164 | INCREMENT_ARG_LIST(walk_state->arg_types); | |
165 | } | |
166 | ||
7f0c826a LM |
167 | /* |
168 | * Handle executable code at "module-level". This refers to | |
169 | * executable opcodes that appear outside of any control method. | |
170 | */ | |
171 | if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) && | |
4d0b4af9 MK |
172 | ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { |
173 | /* | |
174 | * We want to skip If/Else/While constructs during Pass1 because we | |
175 | * want to actually conditionally execute the code during Pass2. | |
176 | * | |
177 | * Except for disassembly, where we always want to walk the | |
178 | * If/Else/While packages | |
179 | */ | |
180 | switch (op->common.aml_opcode) { | |
181 | case AML_IF_OP: | |
182 | case AML_ELSE_OP: | |
183 | case AML_WHILE_OP: | |
7f0c826a LM |
184 | /* |
185 | * Currently supported module-level opcodes are: | |
186 | * IF/ELSE/WHILE. These appear to be the most common, | |
187 | * and easiest to support since they open an AML | |
188 | * package. | |
189 | */ | |
190 | if (walk_state->pass_number == | |
191 | ACPI_IMODE_LOAD_PASS1) { | |
9a884ab6 LM |
192 | acpi_ps_link_module_code(op->common. |
193 | parent, | |
194 | aml_op_start, | |
195 | (u32) | |
196 | (walk_state-> | |
7f0c826a LM |
197 | parser_state. |
198 | pkg_end - | |
9a884ab6 | 199 | aml_op_start), |
7f0c826a LM |
200 | walk_state-> |
201 | owner_id); | |
202 | } | |
203 | ||
4d0b4af9 MK |
204 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
205 | "Pass1: Skipping an If/Else/While body\n")); | |
206 | ||
207 | /* Skip body of if/else/while in pass 1 */ | |
208 | ||
209 | walk_state->parser_state.aml = | |
210 | walk_state->parser_state.pkg_end; | |
211 | walk_state->arg_count = 0; | |
212 | break; | |
213 | ||
214 | default: | |
7f0c826a LM |
215 | /* |
216 | * Check for an unsupported executable opcode at module | |
217 | * level. We must be in PASS1, the parent must be a SCOPE, | |
218 | * The opcode class must be EXECUTE, and the opcode must | |
219 | * not be an argument to another opcode. | |
220 | */ | |
221 | if ((walk_state->pass_number == | |
222 | ACPI_IMODE_LOAD_PASS1) | |
223 | && (op->common.parent->common.aml_opcode == | |
224 | AML_SCOPE_OP)) { | |
225 | op_info = | |
226 | acpi_ps_get_opcode_info(op->common. | |
227 | aml_opcode); | |
228 | if ((op_info->class == | |
229 | AML_CLASS_EXECUTE) && (!arg)) { | |
230 | ACPI_WARNING((AE_INFO, | |
00eb3255 BM |
231 | "Unsupported module-level executable opcode " |
232 | "0x%.2X at table offset 0x%.4X", | |
233 | op->common. | |
234 | aml_opcode, | |
235 | (u32) | |
236 | (ACPI_PTR_DIFF | |
237 | (aml_op_start, | |
238 | walk_state-> | |
239 | parser_state. | |
240 | aml_start) + | |
241 | sizeof(struct | |
242 | acpi_table_header)))); | |
7f0c826a LM |
243 | } |
244 | } | |
4d0b4af9 MK |
245 | break; |
246 | } | |
247 | } | |
7f0c826a LM |
248 | |
249 | /* Special processing for certain opcodes */ | |
4d0b4af9 MK |
250 | |
251 | switch (op->common.aml_opcode) { | |
252 | case AML_METHOD_OP: | |
253 | /* | |
254 | * Skip parsing of control method because we don't have enough | |
255 | * info in the first pass to parse it correctly. | |
256 | * | |
257 | * Save the length and address of the body | |
258 | */ | |
259 | op->named.data = walk_state->parser_state.aml; | |
260 | op->named.length = (u32) | |
261 | (walk_state->parser_state.pkg_end - | |
262 | walk_state->parser_state.aml); | |
263 | ||
264 | /* Skip body of method */ | |
265 | ||
266 | walk_state->parser_state.aml = | |
267 | walk_state->parser_state.pkg_end; | |
268 | walk_state->arg_count = 0; | |
269 | break; | |
270 | ||
271 | case AML_BUFFER_OP: | |
272 | case AML_PACKAGE_OP: | |
9ff5a21a | 273 | case AML_VARIABLE_PACKAGE_OP: |
4d0b4af9 MK |
274 | |
275 | if ((op->common.parent) && | |
276 | (op->common.parent->common.aml_opcode == | |
277 | AML_NAME_OP) | |
278 | && (walk_state->pass_number <= | |
279 | ACPI_IMODE_LOAD_PASS2)) { | |
280 | /* | |
281 | * Skip parsing of Buffers and Packages because we don't have | |
282 | * enough info in the first pass to parse them correctly. | |
283 | */ | |
284 | op->named.data = aml_op_start; | |
285 | op->named.length = (u32) | |
286 | (walk_state->parser_state.pkg_end - | |
287 | aml_op_start); | |
288 | ||
289 | /* Skip body */ | |
290 | ||
291 | walk_state->parser_state.aml = | |
292 | walk_state->parser_state.pkg_end; | |
293 | walk_state->arg_count = 0; | |
294 | } | |
295 | break; | |
296 | ||
297 | case AML_WHILE_OP: | |
298 | ||
299 | if (walk_state->control_state) { | |
300 | walk_state->control_state->control.package_end = | |
301 | walk_state->parser_state.pkg_end; | |
302 | } | |
303 | break; | |
304 | ||
305 | default: | |
306 | ||
307 | /* No action for all other opcodes */ | |
1d1ea1b7 | 308 | |
4d0b4af9 MK |
309 | break; |
310 | } | |
311 | ||
312 | break; | |
313 | } | |
314 | ||
315 | return_ACPI_STATUS(AE_OK); | |
316 | } | |
317 | ||
7f0c826a LM |
318 | /******************************************************************************* |
319 | * | |
320 | * FUNCTION: acpi_ps_link_module_code | |
321 | * | |
9a884ab6 LM |
322 | * PARAMETERS: parent_op - Parent parser op |
323 | * aml_start - Pointer to the AML | |
7f0c826a LM |
324 | * aml_length - Length of executable AML |
325 | * owner_id - owner_id of module level code | |
326 | * | |
327 | * RETURN: None. | |
328 | * | |
329 | * DESCRIPTION: Wrap the module-level code with a method object and link the | |
330 | * object to the global list. Note, the mutex field of the method | |
331 | * object is used to link multiple module-level code objects. | |
332 | * | |
333 | ******************************************************************************/ | |
334 | ||
335 | static void | |
9a884ab6 LM |
336 | acpi_ps_link_module_code(union acpi_parse_object *parent_op, |
337 | u8 *aml_start, u32 aml_length, acpi_owner_id owner_id) | |
7f0c826a LM |
338 | { |
339 | union acpi_operand_object *prev; | |
340 | union acpi_operand_object *next; | |
341 | union acpi_operand_object *method_obj; | |
9a884ab6 | 342 | struct acpi_namespace_node *parent_node; |
7f0c826a | 343 | |
25823e78 BM |
344 | ACPI_FUNCTION_TRACE(ps_link_module_code); |
345 | ||
7f0c826a LM |
346 | /* Get the tail of the list */ |
347 | ||
348 | prev = next = acpi_gbl_module_code_list; | |
349 | while (next) { | |
350 | prev = next; | |
351 | next = next->method.mutex; | |
352 | } | |
353 | ||
354 | /* | |
355 | * Insert the module level code into the list. Merge it if it is | |
356 | * adjacent to the previous element. | |
357 | */ | |
358 | if (!prev || | |
359 | ((prev->method.aml_start + prev->method.aml_length) != aml_start)) { | |
360 | ||
361 | /* Create, initialize, and link a new temporary method object */ | |
362 | ||
363 | method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD); | |
364 | if (!method_obj) { | |
25823e78 | 365 | return_VOID; |
7f0c826a LM |
366 | } |
367 | ||
25823e78 BM |
368 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
369 | "Create/Link new code block: %p\n", | |
370 | method_obj)); | |
371 | ||
9a884ab6 LM |
372 | if (parent_op->common.node) { |
373 | parent_node = parent_op->common.node; | |
374 | } else { | |
375 | parent_node = acpi_gbl_root_node; | |
376 | } | |
377 | ||
7f0c826a LM |
378 | method_obj->method.aml_start = aml_start; |
379 | method_obj->method.aml_length = aml_length; | |
380 | method_obj->method.owner_id = owner_id; | |
26294842 | 381 | method_obj->method.info_flags |= ACPI_METHOD_MODULE_LEVEL; |
7f0c826a | 382 | |
9a884ab6 LM |
383 | /* |
384 | * Save the parent node in next_object. This is cheating, but we | |
385 | * don't want to expand the method object. | |
386 | */ | |
387 | method_obj->method.next_object = | |
388 | ACPI_CAST_PTR(union acpi_operand_object, parent_node); | |
389 | ||
7f0c826a LM |
390 | if (!prev) { |
391 | acpi_gbl_module_code_list = method_obj; | |
392 | } else { | |
393 | prev->method.mutex = method_obj; | |
394 | } | |
395 | } else { | |
25823e78 BM |
396 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
397 | "Appending to existing code block: %p\n", | |
398 | prev)); | |
399 | ||
7f0c826a LM |
400 | prev->method.aml_length += aml_length; |
401 | } | |
25823e78 BM |
402 | |
403 | return_VOID; | |
7f0c826a LM |
404 | } |
405 | ||
73459f73 RM |
406 | /******************************************************************************* |
407 | * | |
408 | * FUNCTION: acpi_ps_parse_loop | |
409 | * | |
410 | * PARAMETERS: walk_state - Current state | |
411 | * | |
412 | * RETURN: Status | |
413 | * | |
414 | * DESCRIPTION: Parse AML (pointed to by the current parser state) and return | |
415 | * a tree of ops. | |
416 | * | |
417 | ******************************************************************************/ | |
418 | ||
4be44fcd | 419 | acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) |
73459f73 | 420 | { |
4be44fcd | 421 | acpi_status status = AE_OK; |
4be44fcd | 422 | union acpi_parse_object *op = NULL; /* current op */ |
4be44fcd LB |
423 | struct acpi_parse_state *parser_state; |
424 | u8 *aml_op_start = NULL; | |
73459f73 | 425 | |
b229cf92 | 426 | ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state); |
73459f73 RM |
427 | |
428 | if (walk_state->descending_callback == NULL) { | |
4be44fcd | 429 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
73459f73 RM |
430 | } |
431 | ||
432 | parser_state = &walk_state->parser_state; | |
433 | walk_state->arg_types = 0; | |
434 | ||
435 | #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) | |
436 | ||
437 | if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { | |
52fc0b02 | 438 | |
73459f73 RM |
439 | /* We are restarting a preempted control method */ |
440 | ||
4be44fcd | 441 | if (acpi_ps_has_completed_scope(parser_state)) { |
73459f73 RM |
442 | /* |
443 | * We must check if a predicate to an IF or WHILE statement | |
444 | * was just completed | |
445 | */ | |
446 | if ((parser_state->scope->parse_scope.op) && | |
4be44fcd LB |
447 | ((parser_state->scope->parse_scope.op->common. |
448 | aml_opcode == AML_IF_OP) | |
449 | || (parser_state->scope->parse_scope.op->common. | |
450 | aml_opcode == AML_WHILE_OP)) | |
451 | && (walk_state->control_state) | |
452 | && (walk_state->control_state->common.state == | |
453 | ACPI_CONTROL_PREDICATE_EXECUTING)) { | |
73459f73 RM |
454 | /* |
455 | * A predicate was just completed, get the value of the | |
456 | * predicate and branch based on that value | |
457 | */ | |
458 | walk_state->op = NULL; | |
4be44fcd LB |
459 | status = |
460 | acpi_ds_get_predicate_value(walk_state, | |
461 | ACPI_TO_POINTER | |
462 | (TRUE)); | |
463 | if (ACPI_FAILURE(status) | |
464 | && ((status & AE_CODE_MASK) != | |
465 | AE_CODE_CONTROL)) { | |
73459f73 | 466 | if (status == AE_AML_NO_RETURN_VALUE) { |
b8e4d893 BM |
467 | ACPI_EXCEPTION((AE_INFO, status, |
468 | "Invoked method did not return a value")); | |
73459f73 | 469 | } |
4d0b4af9 | 470 | |
b8e4d893 | 471 | ACPI_EXCEPTION((AE_INFO, status, |
b229cf92 | 472 | "GetPredicate Failed")); |
4be44fcd | 473 | return_ACPI_STATUS(status); |
73459f73 RM |
474 | } |
475 | ||
4be44fcd LB |
476 | status = |
477 | acpi_ps_next_parse_state(walk_state, op, | |
478 | status); | |
73459f73 RM |
479 | } |
480 | ||
4be44fcd LB |
481 | acpi_ps_pop_scope(parser_state, &op, |
482 | &walk_state->arg_types, | |
483 | &walk_state->arg_count); | |
484 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | |
485 | "Popped scope, Op=%p\n", op)); | |
486 | } else if (walk_state->prev_op) { | |
52fc0b02 | 487 | |
73459f73 RM |
488 | /* We were in the middle of an op */ |
489 | ||
4d0b4af9 MK |
490 | op = walk_state->prev_op; |
491 | walk_state->arg_types = walk_state->prev_arg_types; | |
492 | } | |
493 | } | |
494 | #endif | |
73459f73 | 495 | |
4d0b4af9 | 496 | /* Iterative parsing loop, while there is more AML to process: */ |
73459f73 | 497 | |
4d0b4af9 | 498 | while ((parser_state->aml < parser_state->aml_end) || (op)) { |
9cf7adec BM |
499 | ASL_CV_CAPTURE_COMMENTS(walk_state); |
500 | ||
4d0b4af9 MK |
501 | aml_op_start = parser_state->aml; |
502 | if (!op) { | |
503 | status = | |
504 | acpi_ps_create_op(walk_state, aml_op_start, &op); | |
505 | if (ACPI_FAILURE(status)) { | |
506 | if (status == AE_CTRL_PARSE_CONTINUE) { | |
73459f73 RM |
507 | continue; |
508 | } | |
509 | ||
4d0b4af9 | 510 | if (status == AE_CTRL_PARSE_PENDING) { |
73459f73 | 511 | status = AE_OK; |
73459f73 RM |
512 | } |
513 | ||
22b5afce BM |
514 | if (status == AE_CTRL_TERMINATE) { |
515 | return_ACPI_STATUS(status); | |
516 | } | |
517 | ||
4d0b4af9 MK |
518 | status = |
519 | acpi_ps_complete_op(walk_state, &op, | |
520 | status); | |
4be44fcd | 521 | if (ACPI_FAILURE(status)) { |
4d0b4af9 | 522 | return_ACPI_STATUS(status); |
73459f73 RM |
523 | } |
524 | ||
4d0b4af9 | 525 | continue; |
73459f73 RM |
526 | } |
527 | ||
ab6c5733 | 528 | acpi_ex_start_trace_opcode(op, walk_state); |
73459f73 RM |
529 | } |
530 | ||
73459f73 RM |
531 | /* |
532 | * Start arg_count at zero because we don't know if there are | |
533 | * any args yet | |
534 | */ | |
535 | walk_state->arg_count = 0; | |
536 | ||
9cf7adec BM |
537 | switch (op->common.aml_opcode) { |
538 | case AML_BYTE_OP: | |
539 | case AML_WORD_OP: | |
540 | case AML_DWORD_OP: | |
541 | case AML_QWORD_OP: | |
542 | ||
543 | break; | |
544 | ||
545 | default: | |
546 | ||
547 | ASL_CV_CAPTURE_COMMENTS(walk_state); | |
548 | break; | |
549 | } | |
550 | ||
73459f73 RM |
551 | /* Are there any arguments that must be processed? */ |
552 | ||
553 | if (walk_state->arg_types) { | |
52fc0b02 | 554 | |
73459f73 RM |
555 | /* Get arguments */ |
556 | ||
4d0b4af9 MK |
557 | status = |
558 | acpi_ps_get_arguments(walk_state, aml_op_start, op); | |
559 | if (ACPI_FAILURE(status)) { | |
4be44fcd | 560 | status = |
4d0b4af9 MK |
561 | acpi_ps_complete_op(walk_state, &op, |
562 | status); | |
4be44fcd | 563 | if (ACPI_FAILURE(status)) { |
4d0b4af9 | 564 | return_ACPI_STATUS(status); |
73459f73 | 565 | } |
73459f73 | 566 | |
4d0b4af9 | 567 | continue; |
73459f73 RM |
568 | } |
569 | } | |
570 | ||
571 | /* Check for arguments that need to be processed */ | |
572 | ||
573 | if (walk_state->arg_count) { | |
574 | /* | |
575 | * There are arguments (complex ones), push Op and | |
576 | * prepare for argument | |
577 | */ | |
4be44fcd LB |
578 | status = acpi_ps_push_scope(parser_state, op, |
579 | walk_state->arg_types, | |
580 | walk_state->arg_count); | |
581 | if (ACPI_FAILURE(status)) { | |
4d0b4af9 MK |
582 | status = |
583 | acpi_ps_complete_op(walk_state, &op, | |
584 | status); | |
585 | if (ACPI_FAILURE(status)) { | |
586 | return_ACPI_STATUS(status); | |
587 | } | |
588 | ||
589 | continue; | |
73459f73 | 590 | } |
4d0b4af9 | 591 | |
73459f73 RM |
592 | op = NULL; |
593 | continue; | |
594 | } | |
595 | ||
596 | /* | |
597 | * All arguments have been processed -- Op is complete, | |
598 | * prepare for next | |
599 | */ | |
4be44fcd LB |
600 | walk_state->op_info = |
601 | acpi_ps_get_opcode_info(op->common.aml_opcode); | |
73459f73 | 602 | if (walk_state->op_info->flags & AML_NAMED) { |
941f48bb LM |
603 | if (op->common.aml_opcode == AML_REGION_OP || |
604 | op->common.aml_opcode == AML_DATA_REGION_OP) { | |
73459f73 RM |
605 | /* |
606 | * Skip parsing of control method or opregion body, | |
607 | * because we don't have enough info in the first pass | |
608 | * to parse them correctly. | |
609 | * | |
610 | * Completed parsing an op_region declaration, we now | |
611 | * know the length. | |
612 | */ | |
4be44fcd LB |
613 | op->named.length = |
614 | (u32) (parser_state->aml - op->named.data); | |
73459f73 RM |
615 | } |
616 | } | |
617 | ||
618 | if (walk_state->op_info->flags & AML_CREATE) { | |
619 | /* | |
ba494bee | 620 | * Backup to beginning of create_XXXfield declaration (1 for |
73459f73 RM |
621 | * Opcode) |
622 | * | |
623 | * body_length is unknown until we parse the body | |
624 | */ | |
4be44fcd LB |
625 | op->named.length = |
626 | (u32) (parser_state->aml - op->named.data); | |
73459f73 RM |
627 | } |
628 | ||
ef805d95 LM |
629 | if (op->common.aml_opcode == AML_BANK_FIELD_OP) { |
630 | /* | |
631 | * Backup to beginning of bank_field declaration | |
632 | * | |
633 | * body_length is unknown until we parse the body | |
634 | */ | |
635 | op->named.length = | |
636 | (u32) (parser_state->aml - op->named.data); | |
637 | } | |
638 | ||
73459f73 RM |
639 | /* This op complete, notify the dispatcher */ |
640 | ||
641 | if (walk_state->ascending_callback != NULL) { | |
4be44fcd | 642 | walk_state->op = op; |
73459f73 RM |
643 | walk_state->opcode = op->common.aml_opcode; |
644 | ||
4be44fcd LB |
645 | status = walk_state->ascending_callback(walk_state); |
646 | status = | |
647 | acpi_ps_next_parse_state(walk_state, op, status); | |
73459f73 RM |
648 | if (status == AE_CTRL_PENDING) { |
649 | status = AE_OK; | |
73459f73 RM |
650 | } |
651 | } | |
652 | ||
4d0b4af9 MK |
653 | status = acpi_ps_complete_op(walk_state, &op, status); |
654 | if (ACPI_FAILURE(status)) { | |
4be44fcd | 655 | return_ACPI_STATUS(status); |
73459f73 RM |
656 | } |
657 | ||
4be44fcd | 658 | } /* while parser_state->Aml */ |
73459f73 | 659 | |
4d0b4af9 | 660 | status = acpi_ps_complete_final_op(walk_state, op, status); |
4be44fcd | 661 | return_ACPI_STATUS(status); |
73459f73 | 662 | } |