]> err.no Git - linux-2.6/blobdiff - drivers/acpi/dispatcher/dswexec.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / drivers / acpi / dispatcher / dswexec.c
index 5a9b91fe93d2623a0b2f5c976c04a7c8b01f0d28..b246b9657eada3b0c2f7e2fd55eb156ce78ed7a9 100644 (file)
@@ -6,7 +6,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2006, R. Byron Moore
+ * Copyright (C) 2000 - 2008, Intel Corp.
  * 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,14 +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_REPORT_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);
                }
@@ -121,8 +121,9 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
        }
 
        if (!obj_desc) {
-               ACPI_REPORT_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);
        }
@@ -137,7 +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_REPORT_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;
@@ -209,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;
@@ -234,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;
                        }
                }
        }
@@ -281,17 +285,12 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
        switch (opcode_class) {
        case AML_CLASS_CONTROL:
 
-               status = acpi_ds_result_stack_push(walk_state);
-               if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
-               }
-
                status = acpi_ds_exec_begin_control_op(walk_state, op);
                break;
 
        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
@@ -301,20 +300,11 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
                        status = acpi_ds_load2_begin_op(walk_state, NULL);
                }
 
-               if (op->common.aml_opcode == AML_REGION_OP) {
-                       status = acpi_ds_result_stack_push(walk_state);
-               }
                break;
 
        case AML_CLASS_EXECUTE:
        case AML_CLASS_CREATE:
-               /*
-                * Most operators with arguments.
-                * Start a new result/operand state
-                */
-               if (walk_state->opcode != AML_CREATE_FIELD_OP) {
-                       status = acpi_ds_result_stack_push(walk_state);
-               }
+
                break;
 
        default:
@@ -324,6 +314,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);
 }
 
 /*****************************************************************************
@@ -349,15 +343,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_REPORT_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);
        }
 
@@ -366,6 +360,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
        /* Init the walk state */
 
        walk_state->num_operands = 0;
+       walk_state->operand_index = 0;
        walk_state->return_desc = NULL;
        walk_state->result_obj = NULL;
 
@@ -380,10 +375,17 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
        /* Decode the Opcode Class */
 
        switch (op_class) {
-       case AML_CLASS_ARGUMENT:        /* constants, literals, etc. - do nothing */
+       case AML_CLASS_ARGUMENT:        /* Constants, literals, etc. */
+
+               if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
+                       status = acpi_ds_evaluate_name_path(walk_state);
+                       if (ACPI_FAILURE(status)) {
+                               goto cleanup;
+                       }
+               }
                break;
 
-       case AML_CLASS_EXECUTE: /* most operators with arguments */
+       case AML_CLASS_EXECUTE: /* Most operators with arguments */
 
                /* Build resolved operand stack */
 
@@ -392,18 +394,12 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                        goto cleanup;
                }
 
-               /* Done with this result state (Now that operand stack is built) */
-
-               status = acpi_ds_result_stack_pop(walk_state);
-               if (ACPI_FAILURE(status)) {
-                       goto cleanup;
-               }
-
                /*
                 * All opcodes require operand resolution, with the only exceptions
                 * 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,
@@ -418,7 +414,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");
                        }
                }
 
@@ -432,7 +428,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) &&
@@ -447,7 +443,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_REPORT_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)));
                        }
                }
 
@@ -464,7 +463,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:
@@ -476,16 +474,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                        status = acpi_ds_exec_end_control_op(walk_state, op);
 
-                       /* Make sure to properly pop the result stack */
-
-                       if (ACPI_SUCCESS(status)) {
-                               status = acpi_ds_result_stack_pop(walk_state);
-                       } else if (status == AE_CTRL_PENDING) {
-                               status = acpi_ds_result_stack_pop(walk_state);
-                               if (ACPI_SUCCESS(status)) {
-                                       status = AE_CTRL_PENDING;
-                               }
-                       }
                        break;
 
                case AML_TYPE_METHOD_CALL:
@@ -502,9 +490,10 @@ 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;
+                                   arg->asl.node;
                                acpi_ut_add_reference(op->asl.value.arg->asl.
                                                      node->object);
                                return_ACPI_STATUS(AE_OK);
@@ -540,6 +529,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);
@@ -561,7 +551,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);
@@ -576,7 +566,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) {
@@ -619,13 +609,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                break;
                        }
 
-                       /* Done with result state (Now that operand stack is built) */
-
-                       status = acpi_ds_result_stack_pop(walk_state);
-                       if (ACPI_FAILURE(status)) {
-                               goto cleanup;
-                       }
-
                        /*
                         * If a result object was returned from above, push it on the
                         * current result stack
@@ -649,7 +632,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 =
@@ -658,16 +641,35 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                if (ACPI_FAILURE(status)) {
                                        break;
                                }
+                       } else if (op->common.aml_opcode == AML_DATA_REGION_OP) {
+                               ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+                                                 "Executing DataTableRegion Strings Op=%p\n",
+                                                 op));
 
-                               status = acpi_ds_result_stack_pop(walk_state);
-                       }
+                               status =
+                                   acpi_ds_eval_table_region_operands
+                                   (walk_state, op);
+                               if (ACPI_FAILURE(status)) {
+                                       break;
+                               }
+                       } else if (op->common.aml_opcode == AML_BANK_FIELD_OP) {
+                               ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+                                                 "Executing BankField Op=%p\n",
+                                                 op));
 
+                               status =
+                                   acpi_ds_eval_bank_field_operands(walk_state,
+                                                                    op);
+                               if (ACPI_FAILURE(status)) {
+                                       break;
+                               }
+                       }
                        break;
 
                case AML_TYPE_UNDEFINED:
 
-                       ACPI_REPORT_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:
@@ -679,7 +681,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                default:
 
-                       ACPI_REPORT_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;
@@ -696,7 +701,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 ==
@@ -711,6 +715,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
       cleanup:
 
        if (walk_state->result_obj) {
+
                /* Break to debugger to display result */
 
                ACPI_DEBUGGER_EXEC(acpi_db_display_result_object