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