]> err.no Git - linux-2.6/blobdiff - drivers/acpi/dispatcher/dswexec.c
Merge branch 'upstream' into upstream-jgarzik
[linux-2.6] / drivers / acpi / dispatcher / dswexec.c
index e522763bb692aeacdb568a51a3e1a2fe7b73a213..69693fa07224b8514e5c6c05b3bb7e81a12ce7ed 100644 (file)
@@ -6,7 +6,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2005, R. Byron Moore
+ * Copyright (C) 2000 - 2007, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,6 @@
 #include <acpi/acinterp.h>
 #include <acpi/acnamesp.h>
 #include <acpi/acdebug.h>
-#include <acpi/acdisasm.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
 ACPI_MODULE_NAME("dswexec")
@@ -93,16 +92,15 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
        union acpi_operand_object *obj_desc;
        union acpi_operand_object *local_obj_desc = NULL;
 
-       ACPI_FUNCTION_TRACE_PTR("ds_get_predicate_value", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ds_get_predicate_value, walk_state);
 
        walk_state->control_state->common.state = 0;
 
        if (result_obj) {
                status = acpi_ds_result_pop(&obj_desc, walk_state);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Could not get result from predicate evaluation, %s\n",
-                                         acpi_format_exception(status)));
+                       ACPI_EXCEPTION((AE_INFO, status,
+                                       "Could not get result from predicate evaluation"));
 
                        return_ACPI_STATUS(status);
                }
@@ -123,9 +121,9 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
        }
 
        if (!obj_desc) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "No predicate obj_desc=%p State=%p\n",
-                                 obj_desc, walk_state));
+               ACPI_ERROR((AE_INFO,
+                           "No predicate ObjDesc=%p State=%p",
+                           obj_desc, walk_state));
 
                return_ACPI_STATUS(AE_AML_NO_OPERAND);
        }
@@ -140,10 +138,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
        }
 
        if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n",
-                                 obj_desc, walk_state,
-                                 ACPI_GET_OBJECT_TYPE(obj_desc)));
+               ACPI_ERROR((AE_INFO,
+                           "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X",
+                           obj_desc, walk_state,
+                           ACPI_GET_OBJECT_TYPE(obj_desc)));
 
                status = AE_AML_OPERAND_TYPE;
                goto cleanup;
@@ -215,13 +213,13 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
        acpi_status status = AE_OK;
        u32 opcode_class;
 
-       ACPI_FUNCTION_TRACE_PTR("ds_exec_begin_op", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ds_exec_begin_op, walk_state);
 
        op = walk_state->op;
        if (!op) {
                status = acpi_ds_load2_begin_op(walk_state, out_op);
                if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
+                       goto error_exit;
                }
 
                op = *out_op;
@@ -240,7 +238,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
 
                        status = acpi_ds_scope_stack_pop(walk_state);
                        if (ACPI_FAILURE(status)) {
-                               return_ACPI_STATUS(status);
+                               goto error_exit;
                        }
                }
        }
@@ -289,7 +287,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
 
                status = acpi_ds_result_stack_push(walk_state);
                if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
+                       goto error_exit;
                }
 
                status = acpi_ds_exec_begin_control_op(walk_state, op);
@@ -297,7 +295,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
 
        case AML_CLASS_NAMED_OBJECT:
 
-               if (walk_state->walk_type == ACPI_WALK_METHOD) {
+               if (walk_state->walk_type & ACPI_WALK_METHOD) {
                        /*
                         * Found a named object declaration during method execution;
                         * we must enter this object into the namespace.  The created
@@ -314,12 +312,13 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
 
        case AML_CLASS_EXECUTE:
        case AML_CLASS_CREATE:
-
                /*
-                * Most operators with arguments.
+                * Most operators with arguments (except create_xxx_field operators)
                 * Start a new result/operand state
                 */
-               status = acpi_ds_result_stack_push(walk_state);
+               if (walk_state->op_info->object_type != ACPI_TYPE_BUFFER_FIELD) {
+                       status = acpi_ds_result_stack_push(walk_state);
+               }
                break;
 
        default:
@@ -329,6 +328,10 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
        /* Nothing to do here during method execution */
 
        return_ACPI_STATUS(status);
+
+      error_exit:
+       status = acpi_ds_method_error(status, walk_state);
+       return_ACPI_STATUS(status);
 }
 
 /*****************************************************************************
@@ -354,15 +357,15 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
        union acpi_parse_object *next_op;
        union acpi_parse_object *first_arg;
 
-       ACPI_FUNCTION_TRACE_PTR("ds_exec_end_op", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ds_exec_end_op, walk_state);
 
        op = walk_state->op;
        op_type = walk_state->op_info->type;
        op_class = walk_state->op_info->class;
 
        if (op_class == AML_CLASS_UNKNOWN) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n",
-                                 op->common.aml_opcode));
+               ACPI_ERROR((AE_INFO, "Unknown opcode %X",
+                           op->common.aml_opcode));
                return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
        }
 
@@ -409,6 +412,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                 * being the object_type and size_of operators.
                 */
                if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) {
+
                        /* Resolve all operands */
 
                        status = acpi_ex_resolve_operands(walk_state->opcode,
@@ -423,7 +427,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                                   acpi_ps_get_opcode_name
                                                   (walk_state->opcode),
                                                   walk_state->num_operands,
-                                                  "after ex_resolve_operands");
+                                                  "after ExResolveOperands");
                        }
                }
 
@@ -437,7 +441,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                            acpi_gbl_op_type_dispatch[op_type] (walk_state);
                } else {
                        /*
-                        * Treat constructs of the form "Store(local_x,local_x)" as noops when the
+                        * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
                         * Local is uninitialized.
                         */
                        if ((status == AE_AML_UNINITIALIZED_LOCAL) &&
@@ -452,12 +456,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                walk_state->operands[1]->reference.offset)) {
                                status = AE_OK;
                        } else {
-                               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                 "[%s]: Could not resolve operands, %s\n",
-                                                 acpi_ps_get_opcode_name
-                                                 (walk_state->opcode),
-                                                 acpi_format_exception
-                                                 (status)));
+                               ACPI_EXCEPTION((AE_INFO, status,
+                                               "While resolving operands for [%s]",
+                                               acpi_ps_get_opcode_name
+                                               (walk_state->opcode)));
                        }
                }
 
@@ -474,7 +476,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                            acpi_ds_result_push(walk_state->result_obj,
                                                walk_state);
                }
-
                break;
 
        default:
@@ -512,6 +513,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
                                                  "Method Reference in a Package, Op=%p\n",
                                                  op));
+
                                op->common.node =
                                    (struct acpi_namespace_node *)op->asl.value.
                                    arg->asl.node->object;
@@ -550,6 +552,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                         */
                        status = acpi_ds_resolve_operands(walk_state);
                        if (ACPI_FAILURE(status)) {
+
                                /* On error, clear all resolved operands */
 
                                acpi_ds_clear_operands(walk_state);
@@ -571,7 +574,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                case AML_TYPE_CREATE_FIELD:
 
                        ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                                         "Executing create_field Buffer/Index Op=%p\n",
+                                         "Executing CreateField Buffer/Index Op=%p\n",
                                          op));
 
                        status = acpi_ds_load2_end_op(walk_state);
@@ -586,7 +589,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                case AML_TYPE_CREATE_OBJECT:
 
                        ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                                         "Executing create_object (Buffer/Package) Op=%p\n",
+                                         "Executing CreateObject (Buffer/Package) Op=%p\n",
                                          op));
 
                        switch (op->common.parent->common.aml_opcode) {
@@ -659,7 +662,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                        if (op->common.aml_opcode == AML_REGION_OP) {
                                ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                                                 "Executing op_region Address/Length Op=%p\n",
+                                                 "Executing OpRegion Address/Length Op=%p\n",
                                                  op));
 
                                status =
@@ -671,13 +674,12 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                                status = acpi_ds_result_stack_pop(walk_state);
                        }
-
                        break;
 
                case AML_TYPE_UNDEFINED:
 
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Undefined opcode type Op=%p\n", op));
+                       ACPI_ERROR((AE_INFO,
+                                   "Undefined opcode type Op=%p", op));
                        return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
 
                case AML_TYPE_BOGUS:
@@ -689,10 +691,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                default:
 
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
-                                         op_class, op_type,
-                                         op->common.aml_opcode, op));
+                       ACPI_ERROR((AE_INFO,
+                                   "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p",
+                                   op_class, op_type, op->common.aml_opcode,
+                                   op));
 
                        status = AE_NOT_IMPLEMENTED;
                        break;
@@ -709,7 +711,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
         * Check if we just completed the evaluation of a
         * conditional predicate
         */
-
        if ((ACPI_SUCCESS(status)) &&
            (walk_state->control_state) &&
            (walk_state->control_state->common.state ==
@@ -723,21 +724,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
       cleanup:
 
-       /* Invoke exception handler on error */
-
-       if (ACPI_FAILURE(status) &&
-           acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) {
-               acpi_ex_exit_interpreter();
-               status = acpi_gbl_exception_handler(status,
-                                                   walk_state->method_node->
-                                                   name.integer,
-                                                   walk_state->opcode,
-                                                   walk_state->aml_offset,
-                                                   NULL);
-               (void)acpi_ex_enter_interpreter();
-       }
-
        if (walk_state->result_obj) {
+
                /* Break to debugger to display result */
 
                ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
@@ -758,18 +746,14 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
        }
 #endif
 
-       /* Always clear the object stack */
-
-       walk_state->num_operands = 0;
-
-#ifdef ACPI_DISASSEMBLER
-
-       /* On error, display method locals/args */
+       /* Invoke exception handler on error */
 
        if (ACPI_FAILURE(status)) {
-               acpi_dm_dump_method_info(status, walk_state, op);
+               status = acpi_ds_method_error(status, walk_state);
        }
-#endif
 
+       /* Always clear the object stack */
+
+       walk_state->num_operands = 0;
        return_ACPI_STATUS(status);
 }