aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/parser/psloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/parser/psloop.c')
-rw-r--r--drivers/acpi/parser/psloop.c511
1 files changed, 302 insertions, 209 deletions
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
index 551d54bdbec3..088d33999d90 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/parser/psloop.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45/* 44/*
46 * Parse the AML and build an operation tree as most interpreters, 45 * Parse the AML and build an operation tree as most interpreters,
47 * like Perl, do. Parsing is done by hand rather than with a YACC 46 * like Perl, do. Parsing is done by hand rather than with a YACC
@@ -57,10 +56,9 @@
57#include <acpi/amlcode.h> 56#include <acpi/amlcode.h>
58 57
59#define _COMPONENT ACPI_PARSER 58#define _COMPONENT ACPI_PARSER
60 ACPI_MODULE_NAME ("psloop") 59ACPI_MODULE_NAME("psloop")
61
62static u32 acpi_gbl_depth = 0;
63 60
61static u32 acpi_gbl_depth = 0;
64 62
65/******************************************************************************* 63/*******************************************************************************
66 * 64 *
@@ -75,23 +73,20 @@ static u32 acpi_gbl_depth = 0;
75 * 73 *
76 ******************************************************************************/ 74 ******************************************************************************/
77 75
78acpi_status 76acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
79acpi_ps_parse_loop (
80 struct acpi_walk_state *walk_state)
81{ 77{
82 acpi_status status = AE_OK; 78 acpi_status status = AE_OK;
83 acpi_status status2; 79 acpi_status status2;
84 union acpi_parse_object *op = NULL; /* current op */ 80 union acpi_parse_object *op = NULL; /* current op */
85 union acpi_parse_object *arg = NULL; 81 union acpi_parse_object *arg = NULL;
86 union acpi_parse_object *pre_op = NULL; 82 union acpi_parse_object *pre_op = NULL;
87 struct acpi_parse_state *parser_state; 83 struct acpi_parse_state *parser_state;
88 u8 *aml_op_start = NULL; 84 u8 *aml_op_start = NULL;
89
90 85
91 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); 86 ACPI_FUNCTION_TRACE_PTR("ps_parse_loop", walk_state);
92 87
93 if (walk_state->descending_callback == NULL) { 88 if (walk_state->descending_callback == NULL) {
94 return_ACPI_STATUS (AE_BAD_PARAMETER); 89 return_ACPI_STATUS(AE_BAD_PARAMETER);
95 } 90 }
96 91
97 parser_state = &walk_state->parser_state; 92 parser_state = &walk_state->parser_state;
@@ -102,45 +97,56 @@ acpi_ps_parse_loop (
102 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { 97 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
103 /* We are restarting a preempted control method */ 98 /* We are restarting a preempted control method */
104 99
105 if (acpi_ps_has_completed_scope (parser_state)) { 100 if (acpi_ps_has_completed_scope(parser_state)) {
106 /* 101 /*
107 * We must check if a predicate to an IF or WHILE statement 102 * We must check if a predicate to an IF or WHILE statement
108 * was just completed 103 * was just completed
109 */ 104 */
110 if ((parser_state->scope->parse_scope.op) && 105 if ((parser_state->scope->parse_scope.op) &&
111 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || 106 ((parser_state->scope->parse_scope.op->common.
112 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && 107 aml_opcode == AML_IF_OP)
113 (walk_state->control_state) && 108 || (parser_state->scope->parse_scope.op->common.
114 (walk_state->control_state->common.state == 109 aml_opcode == AML_WHILE_OP))
115 ACPI_CONTROL_PREDICATE_EXECUTING)) { 110 && (walk_state->control_state)
111 && (walk_state->control_state->common.state ==
112 ACPI_CONTROL_PREDICATE_EXECUTING)) {
116 /* 113 /*
117 * A predicate was just completed, get the value of the 114 * A predicate was just completed, get the value of the
118 * predicate and branch based on that value 115 * predicate and branch based on that value
119 */ 116 */
120 walk_state->op = NULL; 117 walk_state->op = NULL;
121 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); 118 status =
122 if (ACPI_FAILURE (status) && 119 acpi_ds_get_predicate_value(walk_state,
123 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { 120 ACPI_TO_POINTER
121 (TRUE));
122 if (ACPI_FAILURE(status)
123 && ((status & AE_CODE_MASK) !=
124 AE_CODE_CONTROL)) {
124 if (status == AE_AML_NO_RETURN_VALUE) { 125 if (status == AE_AML_NO_RETURN_VALUE) {
125 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
126 "Invoked method did not return a value, %s\n", 127 "Invoked method did not return a value, %s\n",
127 acpi_format_exception (status))); 128 acpi_format_exception
129 (status)));
128 130
129 } 131 }
130 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
131 "get_predicate Failed, %s\n", 133 "get_predicate Failed, %s\n",
132 acpi_format_exception (status))); 134 acpi_format_exception
133 return_ACPI_STATUS (status); 135 (status)));
136 return_ACPI_STATUS(status);
134 } 137 }
135 138
136 status = acpi_ps_next_parse_state (walk_state, op, status); 139 status =
140 acpi_ps_next_parse_state(walk_state, op,
141 status);
137 } 142 }
138 143
139 acpi_ps_pop_scope (parser_state, &op, 144 acpi_ps_pop_scope(parser_state, &op,
140 &walk_state->arg_types, &walk_state->arg_count); 145 &walk_state->arg_types,
141 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); 146 &walk_state->arg_count);
142 } 147 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
143 else if (walk_state->prev_op) { 148 "Popped scope, Op=%p\n", op));
149 } else if (walk_state->prev_op) {
144 /* We were in the middle of an op */ 150 /* We were in the middle of an op */
145 151
146 op = walk_state->prev_op; 152 op = walk_state->prev_op;
@@ -156,9 +162,10 @@ acpi_ps_parse_loop (
156 if (!op) { 162 if (!op) {
157 /* Get the next opcode from the AML stream */ 163 /* Get the next opcode from the AML stream */
158 164
159 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, 165 walk_state->aml_offset =
160 parser_state->aml_start); 166 (u32) ACPI_PTR_DIFF(parser_state->aml,
161 walk_state->opcode = acpi_ps_peek_opcode (parser_state); 167 parser_state->aml_start);
168 walk_state->opcode = acpi_ps_peek_opcode(parser_state);
162 169
163 /* 170 /*
164 * First cut to determine what we have found: 171 * First cut to determine what we have found:
@@ -166,7 +173,8 @@ acpi_ps_parse_loop (
166 * 2) A name string 173 * 2) A name string
167 * 3) An unknown/invalid opcode 174 * 3) An unknown/invalid opcode
168 */ 175 */
169 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); 176 walk_state->op_info =
177 acpi_ps_get_opcode_info(walk_state->opcode);
170 switch (walk_state->op_info->class) { 178 switch (walk_state->op_info->class) {
171 case AML_CLASS_ASCII: 179 case AML_CLASS_ASCII:
172 case AML_CLASS_PREFIX: 180 case AML_CLASS_PREFIX:
@@ -182,11 +190,13 @@ acpi_ps_parse_loop (
182 190
183 /* The opcode is unrecognized. Just skip unknown opcodes */ 191 /* The opcode is unrecognized. Just skip unknown opcodes */
184 192
185 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 193 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
186 "Found unknown opcode %X at AML address %p offset %X, ignoring\n", 194 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
187 walk_state->opcode, parser_state->aml, walk_state->aml_offset)); 195 walk_state->opcode,
196 parser_state->aml,
197 walk_state->aml_offset));
188 198
189 ACPI_DUMP_BUFFER (parser_state->aml, 128); 199 ACPI_DUMP_BUFFER(parser_state->aml, 128);
190 200
191 /* Assume one-byte bad opcode */ 201 /* Assume one-byte bad opcode */
192 202
@@ -197,8 +207,10 @@ acpi_ps_parse_loop (
197 207
198 /* Found opcode info, this is a normal opcode */ 208 /* Found opcode info, this is a normal opcode */
199 209
200 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); 210 parser_state->aml +=
201 walk_state->arg_types = walk_state->op_info->parse_args; 211 acpi_ps_get_opcode_size(walk_state->opcode);
212 walk_state->arg_types =
213 walk_state->op_info->parse_args;
202 break; 214 break;
203 } 215 }
204 216
@@ -208,7 +220,9 @@ acpi_ps_parse_loop (
208 /* Allocate a new pre_op if necessary */ 220 /* Allocate a new pre_op if necessary */
209 221
210 if (!pre_op) { 222 if (!pre_op) {
211 pre_op = acpi_ps_alloc_op (walk_state->opcode); 223 pre_op =
224 acpi_ps_alloc_op(walk_state->
225 opcode);
212 if (!pre_op) { 226 if (!pre_op) {
213 status = AE_NO_MEMORY; 227 status = AE_NO_MEMORY;
214 goto close_this_op; 228 goto close_this_op;
@@ -222,30 +236,40 @@ acpi_ps_parse_loop (
222 * Get and append arguments until we find the node that contains 236 * Get and append arguments until we find the node that contains
223 * the name (the type ARGP_NAME). 237 * the name (the type ARGP_NAME).
224 */ 238 */
225 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && 239 while (GET_CURRENT_ARG_TYPE
226 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { 240 (walk_state->arg_types)
227 status = acpi_ps_get_next_arg (walk_state, parser_state, 241 &&
228 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); 242 (GET_CURRENT_ARG_TYPE
229 if (ACPI_FAILURE (status)) { 243 (walk_state->arg_types) != ARGP_NAME)) {
244 status =
245 acpi_ps_get_next_arg(walk_state,
246 parser_state,
247 GET_CURRENT_ARG_TYPE
248 (walk_state->
249 arg_types),
250 &arg);
251 if (ACPI_FAILURE(status)) {
230 goto close_this_op; 252 goto close_this_op;
231 } 253 }
232 254
233 acpi_ps_append_arg (pre_op, arg); 255 acpi_ps_append_arg(pre_op, arg);
234 INCREMENT_ARG_LIST (walk_state->arg_types); 256 INCREMENT_ARG_LIST(walk_state->
257 arg_types);
235 } 258 }
236 259
237 /* 260 /*
238 * Make sure that we found a NAME and didn't run out of 261 * Make sure that we found a NAME and didn't run out of
239 * arguments 262 * arguments
240 */ 263 */
241 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { 264 if (!GET_CURRENT_ARG_TYPE
265 (walk_state->arg_types)) {
242 status = AE_AML_NO_OPERAND; 266 status = AE_AML_NO_OPERAND;
243 goto close_this_op; 267 goto close_this_op;
244 } 268 }
245 269
246 /* We know that this arg is a name, move to next arg */ 270 /* We know that this arg is a name, move to next arg */
247 271
248 INCREMENT_ARG_LIST (walk_state->arg_types); 272 INCREMENT_ARG_LIST(walk_state->arg_types);
249 273
250 /* 274 /*
251 * Find the object. This will either insert the object into 275 * Find the object. This will either insert the object into
@@ -253,11 +277,14 @@ acpi_ps_parse_loop (
253 */ 277 */
254 walk_state->op = NULL; 278 walk_state->op = NULL;
255 279
256 status = walk_state->descending_callback (walk_state, &op); 280 status =
257 if (ACPI_FAILURE (status)) { 281 walk_state->descending_callback(walk_state,
258 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 282 &op);
259 "During name lookup/catalog, %s\n", 283 if (ACPI_FAILURE(status)) {
260 acpi_format_exception (status))); 284 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
285 "During name lookup/catalog, %s\n",
286 acpi_format_exception
287 (status)));
261 goto close_this_op; 288 goto close_this_op;
262 } 289 }
263 290
@@ -265,17 +292,20 @@ acpi_ps_parse_loop (
265 continue; 292 continue;
266 } 293 }
267 294
268 status = acpi_ps_next_parse_state (walk_state, op, status); 295 status =
296 acpi_ps_next_parse_state(walk_state, op,
297 status);
269 if (status == AE_CTRL_PENDING) { 298 if (status == AE_CTRL_PENDING) {
270 status = AE_OK; 299 status = AE_OK;
271 goto close_this_op; 300 goto close_this_op;
272 } 301 }
273 302
274 if (ACPI_FAILURE (status)) { 303 if (ACPI_FAILURE(status)) {
275 goto close_this_op; 304 goto close_this_op;
276 } 305 }
277 306
278 acpi_ps_append_arg (op, pre_op->common.value.arg); 307 acpi_ps_append_arg(op,
308 pre_op->common.value.arg);
279 acpi_gbl_depth++; 309 acpi_gbl_depth++;
280 310
281 if (op->common.aml_opcode == AML_REGION_OP) { 311 if (op->common.aml_opcode == AML_REGION_OP) {
@@ -291,15 +321,15 @@ acpi_ps_parse_loop (
291 * 321 *
292 * (Length is unknown until parse of the body complete) 322 * (Length is unknown until parse of the body complete)
293 */ 323 */
294 op->named.data = aml_op_start; 324 op->named.data = aml_op_start;
295 op->named.length = 0; 325 op->named.length = 0;
296 } 326 }
297 } 327 } else {
298 else {
299 /* Not a named opcode, just allocate Op and append to parent */ 328 /* Not a named opcode, just allocate Op and append to parent */
300 329
301 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); 330 walk_state->op_info =
302 op = acpi_ps_alloc_op (walk_state->opcode); 331 acpi_ps_get_opcode_info(walk_state->opcode);
332 op = acpi_ps_alloc_op(walk_state->opcode);
303 if (!op) { 333 if (!op) {
304 status = AE_NO_MEMORY; 334 status = AE_NO_MEMORY;
305 goto close_this_op; 335 goto close_this_op;
@@ -310,11 +340,12 @@ acpi_ps_parse_loop (
310 * Backup to beginning of create_xXXfield declaration 340 * Backup to beginning of create_xXXfield declaration
311 * body_length is unknown until we parse the body 341 * body_length is unknown until we parse the body
312 */ 342 */
313 op->named.data = aml_op_start; 343 op->named.data = aml_op_start;
314 op->named.length = 0; 344 op->named.length = 0;
315 } 345 }
316 346
317 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); 347 acpi_ps_append_arg(acpi_ps_get_parent_scope
348 (parser_state), op);
318 349
319 if ((walk_state->descending_callback != NULL)) { 350 if ((walk_state->descending_callback != NULL)) {
320 /* 351 /*
@@ -323,14 +354,20 @@ acpi_ps_parse_loop (
323 */ 354 */
324 walk_state->op = op; 355 walk_state->op = op;
325 356
326 status = walk_state->descending_callback (walk_state, &op); 357 status =
327 status = acpi_ps_next_parse_state (walk_state, op, status); 358 walk_state->
359 descending_callback(walk_state,
360 &op);
361 status =
362 acpi_ps_next_parse_state(walk_state,
363 op,
364 status);
328 if (status == AE_CTRL_PENDING) { 365 if (status == AE_CTRL_PENDING) {
329 status = AE_OK; 366 status = AE_OK;
330 goto close_this_op; 367 goto close_this_op;
331 } 368 }
332 369
333 if (ACPI_FAILURE (status)) { 370 if (ACPI_FAILURE(status)) {
334 goto close_this_op; 371 goto close_this_op;
335 } 372 }
336 } 373 }
@@ -339,14 +376,15 @@ acpi_ps_parse_loop (
339 op->common.aml_offset = walk_state->aml_offset; 376 op->common.aml_offset = walk_state->aml_offset;
340 377
341 if (walk_state->op_info) { 378 if (walk_state->op_info) {
342 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 379 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
343 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", 380 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
344 (u32) op->common.aml_opcode, walk_state->op_info->name, 381 (u32) op->common.aml_opcode,
345 op, parser_state->aml, op->common.aml_offset)); 382 walk_state->op_info->name, op,
383 parser_state->aml,
384 op->common.aml_offset));
346 } 385 }
347 } 386 }
348 387
349
350 /* 388 /*
351 * Start arg_count at zero because we don't know if there are 389 * Start arg_count at zero because we don't know if there are
352 * any args yet 390 * any args yet
@@ -359,22 +397,27 @@ acpi_ps_parse_loop (
359 /* Get arguments */ 397 /* Get arguments */
360 398
361 switch (op->common.aml_opcode) { 399 switch (op->common.aml_opcode) {
362 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ 400 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
363 case AML_WORD_OP: /* AML_WORDDATA_ARG */ 401 case AML_WORD_OP: /* AML_WORDDATA_ARG */
364 case AML_DWORD_OP: /* AML_DWORDATA_ARG */ 402 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
365 case AML_QWORD_OP: /* AML_QWORDATA_ARG */ 403 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
366 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ 404 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
367 405
368 /* Fill in constant or string argument directly */ 406 /* Fill in constant or string argument directly */
369 407
370 acpi_ps_get_next_simple_arg (parser_state, 408 acpi_ps_get_next_simple_arg(parser_state,
371 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); 409 GET_CURRENT_ARG_TYPE
410 (walk_state->
411 arg_types), op);
372 break; 412 break;
373 413
374 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ 414 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
375 415
376 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); 416 status =
377 if (ACPI_FAILURE (status)) { 417 acpi_ps_get_next_namepath(walk_state,
418 parser_state, op,
419 1);
420 if (ACPI_FAILURE(status)) {
378 goto close_this_op; 421 goto close_this_op;
379 } 422 }
380 423
@@ -386,34 +429,46 @@ acpi_ps_parse_loop (
386 * Op is not a constant or string, append each argument 429 * Op is not a constant or string, append each argument
387 * to the Op 430 * to the Op
388 */ 431 */
389 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && 432 while (GET_CURRENT_ARG_TYPE
390 !walk_state->arg_count) { 433 (walk_state->arg_types)
434 && !walk_state->arg_count) {
391 walk_state->aml_offset = (u32) 435 walk_state->aml_offset = (u32)
392 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); 436 ACPI_PTR_DIFF(parser_state->aml,
393 437 parser_state->
394 status = acpi_ps_get_next_arg (walk_state, parser_state, 438 aml_start);
395 GET_CURRENT_ARG_TYPE (walk_state->arg_types), 439
396 &arg); 440 status =
397 if (ACPI_FAILURE (status)) { 441 acpi_ps_get_next_arg(walk_state,
442 parser_state,
443 GET_CURRENT_ARG_TYPE
444 (walk_state->
445 arg_types),
446 &arg);
447 if (ACPI_FAILURE(status)) {
398 goto close_this_op; 448 goto close_this_op;
399 } 449 }
400 450
401 if (arg) { 451 if (arg) {
402 arg->common.aml_offset = walk_state->aml_offset; 452 arg->common.aml_offset =
403 acpi_ps_append_arg (op, arg); 453 walk_state->aml_offset;
454 acpi_ps_append_arg(op, arg);
404 } 455 }
405 INCREMENT_ARG_LIST (walk_state->arg_types); 456 INCREMENT_ARG_LIST(walk_state->
457 arg_types);
406 } 458 }
407 459
408
409 /* Special processing for certain opcodes */ 460 /* Special processing for certain opcodes */
410 461
411 /* TBD (remove): Temporary mechanism to disable this code if needed */ 462 /* TBD (remove): Temporary mechanism to disable this code if needed */
412 463
413#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE 464#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
414 465
415 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && 466 if ((walk_state->pass_number <=
416 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { 467 ACPI_IMODE_LOAD_PASS1)
468 &&
469 ((walk_state->
470 parse_flags & ACPI_PARSE_DISASSEMBLE) ==
471 0)) {
417 /* 472 /*
418 * We want to skip If/Else/While constructs during Pass1 473 * We want to skip If/Else/While constructs during Pass1
419 * because we want to actually conditionally execute the 474 * because we want to actually conditionally execute the
@@ -427,12 +482,13 @@ acpi_ps_parse_loop (
427 case AML_ELSE_OP: 482 case AML_ELSE_OP:
428 case AML_WHILE_OP: 483 case AML_WHILE_OP:
429 484
430 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 485 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
431 "Pass1: Skipping an If/Else/While body\n")); 486 "Pass1: Skipping an If/Else/While body\n"));
432 487
433 /* Skip body of if/else/while in pass 1 */ 488 /* Skip body of if/else/while in pass 1 */
434 489
435 parser_state->aml = parser_state->pkg_end; 490 parser_state->aml =
491 parser_state->pkg_end;
436 walk_state->arg_count = 0; 492 walk_state->arg_count = 0;
437 break; 493 break;
438 494
@@ -451,13 +507,15 @@ acpi_ps_parse_loop (
451 * 507 *
452 * Save the length and address of the body 508 * Save the length and address of the body
453 */ 509 */
454 op->named.data = parser_state->aml; 510 op->named.data = parser_state->aml;
455 op->named.length = (u32) (parser_state->pkg_end - 511 op->named.length =
456 parser_state->aml); 512 (u32) (parser_state->pkg_end -
513 parser_state->aml);
457 514
458 /* Skip body of method */ 515 /* Skip body of method */
459 516
460 parser_state->aml = parser_state->pkg_end; 517 parser_state->aml =
518 parser_state->pkg_end;
461 walk_state->arg_count = 0; 519 walk_state->arg_count = 0;
462 break; 520 break;
463 521
@@ -466,20 +524,25 @@ acpi_ps_parse_loop (
466 case AML_VAR_PACKAGE_OP: 524 case AML_VAR_PACKAGE_OP:
467 525
468 if ((op->common.parent) && 526 if ((op->common.parent) &&
469 (op->common.parent->common.aml_opcode == AML_NAME_OP) && 527 (op->common.parent->common.
470 (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { 528 aml_opcode == AML_NAME_OP)
529 && (walk_state->pass_number <=
530 ACPI_IMODE_LOAD_PASS2)) {
471 /* 531 /*
472 * Skip parsing of Buffers and Packages 532 * Skip parsing of Buffers and Packages
473 * because we don't have enough info in the first pass 533 * because we don't have enough info in the first pass
474 * to parse them correctly. 534 * to parse them correctly.
475 */ 535 */
476 op->named.data = aml_op_start; 536 op->named.data = aml_op_start;
477 op->named.length = (u32) (parser_state->pkg_end - 537 op->named.length =
478 aml_op_start); 538 (u32) (parser_state->
539 pkg_end -
540 aml_op_start);
479 541
480 /* Skip body */ 542 /* Skip body */
481 543
482 parser_state->aml = parser_state->pkg_end; 544 parser_state->aml =
545 parser_state->pkg_end;
483 walk_state->arg_count = 0; 546 walk_state->arg_count = 0;
484 } 547 }
485 break; 548 break;
@@ -487,8 +550,9 @@ acpi_ps_parse_loop (
487 case AML_WHILE_OP: 550 case AML_WHILE_OP:
488 551
489 if (walk_state->control_state) { 552 if (walk_state->control_state) {
490 walk_state->control_state->control.package_end = 553 walk_state->control_state->
491 parser_state->pkg_end; 554 control.package_end =
555 parser_state->pkg_end;
492 } 556 }
493 break; 557 break;
494 558
@@ -508,9 +572,10 @@ acpi_ps_parse_loop (
508 * There are arguments (complex ones), push Op and 572 * There are arguments (complex ones), push Op and
509 * prepare for argument 573 * prepare for argument
510 */ 574 */
511 status = acpi_ps_push_scope (parser_state, op, 575 status = acpi_ps_push_scope(parser_state, op,
512 walk_state->arg_types, walk_state->arg_count); 576 walk_state->arg_types,
513 if (ACPI_FAILURE (status)) { 577 walk_state->arg_count);
578 if (ACPI_FAILURE(status)) {
514 goto close_this_op; 579 goto close_this_op;
515 } 580 }
516 op = NULL; 581 op = NULL;
@@ -521,7 +586,8 @@ acpi_ps_parse_loop (
521 * All arguments have been processed -- Op is complete, 586 * All arguments have been processed -- Op is complete,
522 * prepare for next 587 * prepare for next
523 */ 588 */
524 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 589 walk_state->op_info =
590 acpi_ps_get_opcode_info(op->common.aml_opcode);
525 if (walk_state->op_info->flags & AML_NAMED) { 591 if (walk_state->op_info->flags & AML_NAMED) {
526 if (acpi_gbl_depth) { 592 if (acpi_gbl_depth) {
527 acpi_gbl_depth--; 593 acpi_gbl_depth--;
@@ -536,7 +602,8 @@ acpi_ps_parse_loop (
536 * Completed parsing an op_region declaration, we now 602 * Completed parsing an op_region declaration, we now
537 * know the length. 603 * know the length.
538 */ 604 */
539 op->named.length = (u32) (parser_state->aml - op->named.data); 605 op->named.length =
606 (u32) (parser_state->aml - op->named.data);
540 } 607 }
541 } 608 }
542 609
@@ -547,25 +614,26 @@ acpi_ps_parse_loop (
547 * 614 *
548 * body_length is unknown until we parse the body 615 * body_length is unknown until we parse the body
549 */ 616 */
550 op->named.length = (u32) (parser_state->aml - op->named.data); 617 op->named.length =
618 (u32) (parser_state->aml - op->named.data);
551 } 619 }
552 620
553 /* This op complete, notify the dispatcher */ 621 /* This op complete, notify the dispatcher */
554 622
555 if (walk_state->ascending_callback != NULL) { 623 if (walk_state->ascending_callback != NULL) {
556 walk_state->op = op; 624 walk_state->op = op;
557 walk_state->opcode = op->common.aml_opcode; 625 walk_state->opcode = op->common.aml_opcode;
558 626
559 status = walk_state->ascending_callback (walk_state); 627 status = walk_state->ascending_callback(walk_state);
560 status = acpi_ps_next_parse_state (walk_state, op, status); 628 status =
629 acpi_ps_next_parse_state(walk_state, op, status);
561 if (status == AE_CTRL_PENDING) { 630 if (status == AE_CTRL_PENDING) {
562 status = AE_OK; 631 status = AE_OK;
563 goto close_this_op; 632 goto close_this_op;
564 } 633 }
565 } 634 }
566 635
567 636 close_this_op:
568close_this_op:
569 /* 637 /*
570 * Finished one argument of the containing scope 638 * Finished one argument of the containing scope
571 */ 639 */
@@ -574,15 +642,15 @@ close_this_op:
574 /* Finished with pre_op */ 642 /* Finished with pre_op */
575 643
576 if (pre_op) { 644 if (pre_op) {
577 acpi_ps_free_op (pre_op); 645 acpi_ps_free_op(pre_op);
578 pre_op = NULL; 646 pre_op = NULL;
579 } 647 }
580 648
581 /* Close this Op (will result in parse subtree deletion) */ 649 /* Close this Op (will result in parse subtree deletion) */
582 650
583 status2 = acpi_ps_complete_this_op (walk_state, op); 651 status2 = acpi_ps_complete_this_op(walk_state, op);
584 if (ACPI_FAILURE (status2)) { 652 if (ACPI_FAILURE(status2)) {
585 return_ACPI_STATUS (status2); 653 return_ACPI_STATUS(status2);
586 } 654 }
587 op = NULL; 655 op = NULL;
588 656
@@ -590,68 +658,74 @@ close_this_op:
590 case AE_OK: 658 case AE_OK:
591 break; 659 break;
592 660
593
594 case AE_CTRL_TRANSFER: 661 case AE_CTRL_TRANSFER:
595 662
596 /* We are about to transfer to a called method. */ 663 /* We are about to transfer to a called method. */
597 664
598 walk_state->prev_op = op; 665 walk_state->prev_op = op;
599 walk_state->prev_arg_types = walk_state->arg_types; 666 walk_state->prev_arg_types = walk_state->arg_types;
600 return_ACPI_STATUS (status); 667 return_ACPI_STATUS(status);
601
602 668
603 case AE_CTRL_END: 669 case AE_CTRL_END:
604 670
605 acpi_ps_pop_scope (parser_state, &op, 671 acpi_ps_pop_scope(parser_state, &op,
606 &walk_state->arg_types, &walk_state->arg_count); 672 &walk_state->arg_types,
673 &walk_state->arg_count);
607 674
608 if (op) { 675 if (op) {
609 walk_state->op = op; 676 walk_state->op = op;
610 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 677 walk_state->op_info =
678 acpi_ps_get_opcode_info(op->common.
679 aml_opcode);
611 walk_state->opcode = op->common.aml_opcode; 680 walk_state->opcode = op->common.aml_opcode;
612 681
613 status = walk_state->ascending_callback (walk_state); 682 status =
614 status = acpi_ps_next_parse_state (walk_state, op, status); 683 walk_state->ascending_callback(walk_state);
684 status =
685 acpi_ps_next_parse_state(walk_state, op,
686 status);
615 687
616 status2 = acpi_ps_complete_this_op (walk_state, op); 688 status2 =
617 if (ACPI_FAILURE (status2)) { 689 acpi_ps_complete_this_op(walk_state, op);
618 return_ACPI_STATUS (status2); 690 if (ACPI_FAILURE(status2)) {
691 return_ACPI_STATUS(status2);
619 } 692 }
620 op = NULL; 693 op = NULL;
621 } 694 }
622 status = AE_OK; 695 status = AE_OK;
623 break; 696 break;
624 697
625
626 case AE_CTRL_BREAK: 698 case AE_CTRL_BREAK:
627 case AE_CTRL_CONTINUE: 699 case AE_CTRL_CONTINUE:
628 700
629 /* Pop off scopes until we find the While */ 701 /* Pop off scopes until we find the While */
630 702
631 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { 703 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
632 acpi_ps_pop_scope (parser_state, &op, 704 acpi_ps_pop_scope(parser_state, &op,
633 &walk_state->arg_types, &walk_state->arg_count); 705 &walk_state->arg_types,
706 &walk_state->arg_count);
634 } 707 }
635 708
636 /* Close this iteration of the While loop */ 709 /* Close this iteration of the While loop */
637 710
638 walk_state->op = op; 711 walk_state->op = op;
639 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 712 walk_state->op_info =
713 acpi_ps_get_opcode_info(op->common.aml_opcode);
640 walk_state->opcode = op->common.aml_opcode; 714 walk_state->opcode = op->common.aml_opcode;
641 715
642 status = walk_state->ascending_callback (walk_state); 716 status = walk_state->ascending_callback(walk_state);
643 status = acpi_ps_next_parse_state (walk_state, op, status); 717 status =
718 acpi_ps_next_parse_state(walk_state, op, status);
644 719
645 status2 = acpi_ps_complete_this_op (walk_state, op); 720 status2 = acpi_ps_complete_this_op(walk_state, op);
646 if (ACPI_FAILURE (status2)) { 721 if (ACPI_FAILURE(status2)) {
647 return_ACPI_STATUS (status2); 722 return_ACPI_STATUS(status2);
648 } 723 }
649 op = NULL; 724 op = NULL;
650 725
651 status = AE_OK; 726 status = AE_OK;
652 break; 727 break;
653 728
654
655 case AE_CTRL_TERMINATE: 729 case AE_CTRL_TERMINATE:
656 730
657 status = AE_OK; 731 status = AE_OK;
@@ -659,61 +733,66 @@ close_this_op:
659 /* Clean up */ 733 /* Clean up */
660 do { 734 do {
661 if (op) { 735 if (op) {
662 status2 = acpi_ps_complete_this_op (walk_state, op); 736 status2 =
663 if (ACPI_FAILURE (status2)) { 737 acpi_ps_complete_this_op(walk_state,
664 return_ACPI_STATUS (status2); 738 op);
739 if (ACPI_FAILURE(status2)) {
740 return_ACPI_STATUS(status2);
665 } 741 }
666 } 742 }
667 acpi_ps_pop_scope (parser_state, &op, 743 acpi_ps_pop_scope(parser_state, &op,
668 &walk_state->arg_types, &walk_state->arg_count); 744 &walk_state->arg_types,
745 &walk_state->arg_count);
669 746
670 } while (op); 747 } while (op);
671 748
672 return_ACPI_STATUS (status); 749 return_ACPI_STATUS(status);
673 750
674 751 default: /* All other non-AE_OK status */
675 default: /* All other non-AE_OK status */
676 752
677 do { 753 do {
678 if (op) { 754 if (op) {
679 status2 = acpi_ps_complete_this_op (walk_state, op); 755 status2 =
680 if (ACPI_FAILURE (status2)) { 756 acpi_ps_complete_this_op(walk_state,
681 return_ACPI_STATUS (status2); 757 op);
758 if (ACPI_FAILURE(status2)) {
759 return_ACPI_STATUS(status2);
682 } 760 }
683 } 761 }
684 acpi_ps_pop_scope (parser_state, &op, 762 acpi_ps_pop_scope(parser_state, &op,
685 &walk_state->arg_types, &walk_state->arg_count); 763 &walk_state->arg_types,
764 &walk_state->arg_count);
686 765
687 } while (op); 766 } while (op);
688 767
689
690 /* 768 /*
691 * TBD: Cleanup parse ops on error 769 * TBD: Cleanup parse ops on error
692 */ 770 */
693#if 0 771#if 0
694 if (op == NULL) { 772 if (op == NULL) {
695 acpi_ps_pop_scope (parser_state, &op, 773 acpi_ps_pop_scope(parser_state, &op,
696 &walk_state->arg_types, &walk_state->arg_count); 774 &walk_state->arg_types,
775 &walk_state->arg_count);
697 } 776 }
698#endif 777#endif
699 walk_state->prev_op = op; 778 walk_state->prev_op = op;
700 walk_state->prev_arg_types = walk_state->arg_types; 779 walk_state->prev_arg_types = walk_state->arg_types;
701 return_ACPI_STATUS (status); 780 return_ACPI_STATUS(status);
702 } 781 }
703 782
704 /* This scope complete? */ 783 /* This scope complete? */
705 784
706 if (acpi_ps_has_completed_scope (parser_state)) { 785 if (acpi_ps_has_completed_scope(parser_state)) {
707 acpi_ps_pop_scope (parser_state, &op, 786 acpi_ps_pop_scope(parser_state, &op,
708 &walk_state->arg_types, &walk_state->arg_count); 787 &walk_state->arg_types,
709 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); 788 &walk_state->arg_count);
710 } 789 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
711 else { 790 "Popped scope, Op=%p\n", op));
791 } else {
712 op = NULL; 792 op = NULL;
713 } 793 }
714 794
715 } /* while parser_state->Aml */ 795 } /* while parser_state->Aml */
716
717 796
718 /* 797 /*
719 * Complete the last Op (if not completed), and clear the scope stack. 798 * Complete the last Op (if not completed), and clear the scope stack.
@@ -721,16 +800,22 @@ close_this_op:
721 * of open scopes (such as when several ASL blocks are closed with 800 * of open scopes (such as when several ASL blocks are closed with
722 * sequential closing braces). We want to terminate each one cleanly. 801 * sequential closing braces). We want to terminate each one cleanly.
723 */ 802 */
724 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); 803 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
804 op));
725 do { 805 do {
726 if (op) { 806 if (op) {
727 if (walk_state->ascending_callback != NULL) { 807 if (walk_state->ascending_callback != NULL) {
728 walk_state->op = op; 808 walk_state->op = op;
729 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 809 walk_state->op_info =
810 acpi_ps_get_opcode_info(op->common.
811 aml_opcode);
730 walk_state->opcode = op->common.aml_opcode; 812 walk_state->opcode = op->common.aml_opcode;
731 813
732 status = walk_state->ascending_callback (walk_state); 814 status =
733 status = acpi_ps_next_parse_state (walk_state, op, status); 815 walk_state->ascending_callback(walk_state);
816 status =
817 acpi_ps_next_parse_state(walk_state, op,
818 status);
734 if (status == AE_CTRL_PENDING) { 819 if (status == AE_CTRL_PENDING) {
735 status = AE_OK; 820 status = AE_OK;
736 goto close_this_op; 821 goto close_this_op;
@@ -742,40 +827,48 @@ close_this_op:
742 /* Clean up */ 827 /* Clean up */
743 do { 828 do {
744 if (op) { 829 if (op) {
745 status2 = acpi_ps_complete_this_op (walk_state, op); 830 status2 =
746 if (ACPI_FAILURE (status2)) { 831 acpi_ps_complete_this_op
747 return_ACPI_STATUS (status2); 832 (walk_state, op);
833 if (ACPI_FAILURE
834 (status2)) {
835 return_ACPI_STATUS
836 (status2);
748 } 837 }
749 } 838 }
750 839
751 acpi_ps_pop_scope (parser_state, &op, 840 acpi_ps_pop_scope(parser_state,
752 &walk_state->arg_types, &walk_state->arg_count); 841 &op,
842 &walk_state->
843 arg_types,
844 &walk_state->
845 arg_count);
753 846
754 } while (op); 847 } while (op);
755 848
756 return_ACPI_STATUS (status); 849 return_ACPI_STATUS(status);
757 } 850 }
758 851
759 else if (ACPI_FAILURE (status)) { 852 else if (ACPI_FAILURE(status)) {
760 /* First error is most important */ 853 /* First error is most important */
761 854
762 (void) acpi_ps_complete_this_op (walk_state, op); 855 (void)
763 return_ACPI_STATUS (status); 856 acpi_ps_complete_this_op(walk_state,
857 op);
858 return_ACPI_STATUS(status);
764 } 859 }
765 } 860 }
766 861
767 status2 = acpi_ps_complete_this_op (walk_state, op); 862 status2 = acpi_ps_complete_this_op(walk_state, op);
768 if (ACPI_FAILURE (status2)) { 863 if (ACPI_FAILURE(status2)) {
769 return_ACPI_STATUS (status2); 864 return_ACPI_STATUS(status2);
770 } 865 }
771 } 866 }
772 867
773 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, 868 acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types,
774 &walk_state->arg_count); 869 &walk_state->arg_count);
775 870
776 } while (op); 871 } while (op);
777 872
778 return_ACPI_STATUS (status); 873 return_ACPI_STATUS(status);
779} 874}
780
781