X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Facpi%2Fparser%2Fpsparse.c;h=796f6b719929f16503b2e5dbe7f5eaf8eb0c4e9c;hb=b229cf92eee616c7cb5ad8cdb35a19b119f00bc8;hp=76d4d640d83cdebaa7362742258b2daac841e2d9;hpb=4e0c1159d83a658d1ffba5bc3442f4ec4cadb436;p=powerpc.git diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 76d4d640d8..796f6b7199 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -106,6 +106,7 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state) opcode = (u16) ACPI_GET8(aml); if (opcode == AML_EXTENDED_OP_PREFIX) { + /* Extended opcode, get the second opcode byte */ aml++; @@ -137,7 +138,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, const struct acpi_opcode_info *parent_info; union acpi_parse_object *replacement_op = NULL; - ACPI_FUNCTION_TRACE_PTR("ps_complete_this_op", op); + ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op); /* Check for null Op, can happen if AML code is corrupt */ @@ -158,6 +159,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, if (op->common.parent) { prev = op->common.parent->common.value.arg; if (!prev) { + /* Nothing more to do */ goto cleanup; @@ -245,6 +247,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, /* We must unlink this op from the parent tree */ if (prev == op) { + /* This op is the first in the list */ if (replacement_op) { @@ -265,6 +268,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, else while (prev) { + /* Traverse all siblings in the parent's argument list */ next = prev->common.next; @@ -329,11 +333,10 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, struct acpi_parse_state *parser_state = &walk_state->parser_state; acpi_status status = AE_CTRL_PENDING; - ACPI_FUNCTION_TRACE_PTR("ps_next_parse_state", op); + ACPI_FUNCTION_TRACE_PTR(ps_next_parse_state, op); switch (callback_status) { case AE_CTRL_TERMINATE: - /* * A control method was terminated via a RETURN statement. * The walk of this method is complete. @@ -346,13 +349,19 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, parser_state->aml = walk_state->aml_last_while; walk_state->control_state->common.value = FALSE; - status = AE_CTRL_BREAK; + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_BREAK; + } break; case AE_CTRL_CONTINUE: parser_state->aml = walk_state->aml_last_while; - status = AE_CTRL_CONTINUE; + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_CONTINUE; + } break; case AE_CTRL_PENDING: @@ -369,16 +378,18 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, #endif case AE_CTRL_TRUE: - /* * Predicate of an IF was true, and we are at the matching ELSE. * Just close out this package */ parser_state->aml = acpi_ps_get_next_package_end(parser_state); + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_PENDING; + } break; case AE_CTRL_FALSE: - /* * Either an IF/WHILE Predicate was false or we encountered a BREAK * opcode. In both cases, we do not execute the rest of the @@ -442,10 +453,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; struct acpi_walk_state *previous_walk_state; - ACPI_FUNCTION_TRACE("ps_parse_aml"); + ACPI_FUNCTION_TRACE(ps_parse_aml); ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "Entered with walk_state=%p Aml=%p size=%X\n", + "Entered with WalkState=%p Aml=%p size=%X\n", walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size)); @@ -503,22 +514,24 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } else if (status == AE_CTRL_TERMINATE) { status = AE_OK; } else if ((status != AE_OK) && (walk_state->method_desc)) { - ACPI_REPORT_METHOD_ERROR("Method execution failed", - walk_state->method_node, NULL, - status); - /* Ensure proper cleanup */ + /* Either the method parse or actual execution failed */ - walk_state->parse_flags |= ACPI_PARSE_EXECUTE; + ACPI_ERROR_METHOD("Method parse/execution failed", + walk_state->method_node, NULL, + status); /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && (!walk_state->method_desc->method.semaphore)) { /* - * This method is marked not_serialized, but it tried to create + * Method tried to create an object twice. The probable cause is + * that the method cannot handle reentrancy. + * + * The method is marked not_serialized, but it tried to create * a named object, causing the second thread entrance to fail. - * We will workaround this by marking the method permanently + * Workaround this problem by marking the method permanently * as Serialized. */ walk_state->method_desc->method.method_flags |= @@ -536,28 +549,24 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) acpi_ds_scope_stack_clear(walk_state); /* - * If we just returned from the execution of a control method, - * there's lots of cleanup to do + * If we just returned from the execution of a control method or if we + * encountered an error during the method parse phase, there's lots of + * cleanup to do */ - if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == - ACPI_PARSE_EXECUTE) { - if (walk_state->method_desc) { - /* Decrement the thread count on the method parse tree */ - - walk_state->method_desc->method.thread_count--; - } - - acpi_ds_terminate_control_method(walk_state); + if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) { + acpi_ds_terminate_control_method(walk_state-> + method_desc, + walk_state); } /* Delete this walk state and all linked control states */ acpi_ps_cleanup_scope(&walk_state->parser_state); - previous_walk_state = walk_state; ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "return_value=%p, implicit_value=%p State=%p\n", + "ReturnValue=%p, ImplicitValue=%p State=%p\n", walk_state->return_desc, walk_state->implicit_return_obj, walk_state)); @@ -618,12 +627,14 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } } else { if (previous_walk_state->return_desc) { + /* Caller doesn't want it, must delete it */ acpi_ut_remove_reference(previous_walk_state-> return_desc); } if (previous_walk_state->implicit_return_obj) { + /* Caller doesn't want it, must delete it */ acpi_ut_remove_reference(previous_walk_state->