]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/executer/exoparg1.c
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6-omap-h63xx.git] / drivers / acpi / executer / exoparg1.c
index 23d0823bcd5e69df8a8f88c78d639f57e3bfead5..f622f9eac8a1a85bfe0bfb4afbed5854b5435609 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
@@ -89,7 +89,7 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
        acpi_status status = AE_OK;
        union acpi_operand_object *return_desc = NULL;
 
-       ACPI_FUNCTION_TRACE_STR("ex_opcode_0A_0T_1R",
+       ACPI_FUNCTION_TRACE_STR(ex_opcode_0A_0T_1R,
                                acpi_ps_get_opcode_name(walk_state->opcode));
 
        /* Examine the AML opcode */
@@ -104,9 +104,7 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
                        status = AE_NO_MEMORY;
                        goto cleanup;
                }
-#if ACPI_MACHINE_WIDTH != 16
                return_desc->integer.value = acpi_os_get_timer();
-#endif
                break;
 
        default:                /*  Unknown opcode  */
@@ -123,6 +121,7 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
 
        if ((ACPI_FAILURE(status)) || walk_state->result_obj) {
                acpi_ut_remove_reference(return_desc);
+               walk_state->result_obj = NULL;
        } else {
                /* Save the return value */
 
@@ -150,7 +149,7 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
        union acpi_operand_object **operand = &walk_state->operands[0];
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_0R",
+       ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_0R,
                                acpi_ps_get_opcode_name(walk_state->opcode));
 
        /* Examine the AML opcode */
@@ -216,7 +215,7 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
        acpi_status status = AE_OK;
        union acpi_operand_object **operand = &walk_state->operands[0];
 
-       ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_0R",
+       ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_0R,
                                acpi_ps_get_opcode_name(walk_state->opcode));
 
        /* Examine the AML opcode */
@@ -264,7 +263,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
        acpi_integer power_of_ten;
        acpi_integer digit;
 
-       ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_1R",
+       ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R,
                                acpi_ps_get_opcode_name(walk_state->opcode));
 
        /* Examine the AML opcode */
@@ -322,8 +321,9 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
 
                        /* Since the bit position is one-based, subtract from 33 (65) */
 
-                       return_desc->integer.value = temp32 == 0 ? 0 :
-                           (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
+                       return_desc->integer.value =
+                           temp32 ==
+                           0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
                        break;
 
                case AML_FROM_BCD_OP:   /* from_bcd (BCDValue, Result) */
@@ -342,6 +342,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                        for (i = 0;
                             (i < acpi_gbl_integer_nybble_width) && (digit > 0);
                             i++) {
+
                                /* Get the least significant 4-bit BCD digit */
 
                                temp32 = ((u32) digit) & 0xF;
@@ -487,6 +488,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                status = acpi_ex_convert_to_string(operand[0], &return_desc,
                                                   ACPI_EXPLICIT_CONVERT_DECIMAL);
                if (return_desc == operand[0]) {
+
                        /* No conversion performed, add ref to handle return value */
                        acpi_ut_add_reference(return_desc);
                }
@@ -497,6 +499,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                status = acpi_ex_convert_to_string(operand[0], &return_desc,
                                                   ACPI_EXPLICIT_CONVERT_HEX);
                if (return_desc == operand[0]) {
+
                        /* No conversion performed, add ref to handle return value */
                        acpi_ut_add_reference(return_desc);
                }
@@ -506,6 +509,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
 
                status = acpi_ex_convert_to_buffer(operand[0], &return_desc);
                if (return_desc == operand[0]) {
+
                        /* No conversion performed, add ref to handle return value */
                        acpi_ut_add_reference(return_desc);
                }
@@ -516,6 +520,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                status = acpi_ex_convert_to_integer(operand[0], &return_desc,
                                                    ACPI_ANY_BASE);
                if (return_desc == operand[0]) {
+
                        /* No conversion performed, add ref to handle return value */
                        acpi_ut_add_reference(return_desc);
                }
@@ -541,6 +546,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
        }
 
        if (ACPI_SUCCESS(status)) {
+
                /* Store the return value computed above into the target object */
 
                status = acpi_ex_store(return_desc, operand[1], walk_state);
@@ -548,16 +554,18 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
 
       cleanup:
 
-       if (!walk_state->result_obj) {
-               walk_state->result_obj = return_desc;
-       }
-
        /* Delete return object on error */
 
        if (ACPI_FAILURE(status)) {
                acpi_ut_remove_reference(return_desc);
        }
 
+       /* Save return object on success */
+
+       else if (!walk_state->result_obj) {
+               walk_state->result_obj = return_desc;
+       }
+
        return_ACPI_STATUS(status);
 }
 
@@ -582,7 +590,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
        u32 type;
        acpi_integer value;
 
-       ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_1R",
+       ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R,
                                acpi_ps_get_opcode_name(walk_state->opcode));
 
        /* Examine the AML opcode */
@@ -625,6 +633,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                temp_desc = operand[0];
                if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) ==
                    ACPI_DESC_TYPE_OPERAND) {
+
                        /* Internal reference object - prevent deletion */
 
                        acpi_ut_add_reference(temp_desc);
@@ -689,6 +698,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                if (ACPI_FAILURE(status)) {
                        goto cleanup;
                }
+
                /* Allocate a descriptor to hold the type. */
 
                return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
@@ -730,26 +740,38 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                        value = acpi_gbl_integer_byte_width;
                        break;
 
-               case ACPI_TYPE_BUFFER:
-                       value = temp_desc->buffer.length;
-                       break;
-
                case ACPI_TYPE_STRING:
                        value = temp_desc->string.length;
                        break;
 
+               case ACPI_TYPE_BUFFER:
+
+                       /* Buffer arguments may not be evaluated at this point */
+
+                       status = acpi_ds_get_buffer_arguments(temp_desc);
+                       value = temp_desc->buffer.length;
+                       break;
+
                case ACPI_TYPE_PACKAGE:
+
+                       /* Package arguments may not be evaluated at this point */
+
+                       status = acpi_ds_get_package_arguments(temp_desc);
                        value = temp_desc->package.count;
                        break;
 
                default:
                        ACPI_ERROR((AE_INFO,
-                                   "Operand is not Buf/Int/Str/Pkg - found type %s",
+                                   "Operand must be Buffer/Integer/String/Package - found type %s",
                                    acpi_ut_get_type_name(type)));
                        status = AE_AML_OPERAND_TYPE;
                        goto cleanup;
                }
 
+               if (ACPI_FAILURE(status)) {
+                       goto cleanup;
+               }
+
                /*
                 * Now that we have the size of the object, create a result
                 * object to hold the value
@@ -777,8 +799,25 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
 
                /* Check for a method local or argument, or standalone String */
 
-               if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
+               if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) ==
                    ACPI_DESC_TYPE_NAMED) {
+                       temp_desc =
+                           acpi_ns_get_attached_object((struct
+                                                        acpi_namespace_node *)
+                                                       operand[0]);
+                       if (temp_desc
+                           &&
+                           ((ACPI_GET_OBJECT_TYPE(temp_desc) ==
+                             ACPI_TYPE_STRING)
+                            || (ACPI_GET_OBJECT_TYPE(temp_desc) ==
+                                ACPI_TYPE_LOCAL_REFERENCE))) {
+                               operand[0] = temp_desc;
+                               acpi_ut_add_reference(temp_desc);
+                       } else {
+                               status = AE_AML_OPERAND_TYPE;
+                               goto cleanup;
+                       }
+               } else {
                        switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
                        case ACPI_TYPE_LOCAL_REFERENCE:
                                /*
@@ -786,16 +825,16 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                 *
                                 * Must resolve/dereference the local/arg reference first
                                 */
-                               switch (operand[0]->reference.opcode) {
-                               case AML_LOCAL_OP:
-                               case AML_ARG_OP:
+                               switch (operand[0]->reference.class) {
+                               case ACPI_REFCLASS_LOCAL:
+                               case ACPI_REFCLASS_ARG:
 
                                        /* Set Operand[0] to the value of the local/arg */
 
                                        status =
                                            acpi_ds_method_data_get_value
-                                           (operand[0]->reference.opcode,
-                                            operand[0]->reference.offset,
+                                           (operand[0]->reference.class,
+                                            operand[0]->reference.value,
                                             walk_state, &temp_desc);
                                        if (ACPI_FAILURE(status)) {
                                                goto cleanup;
@@ -809,7 +848,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                        operand[0] = temp_desc;
                                        break;
 
-                               case AML_REF_OF_OP:
+                               case ACPI_REFCLASS_REFOF:
 
                                        /* Get the object to which the reference refers */
 
@@ -827,26 +866,35 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                break;
 
                        case ACPI_TYPE_STRING:
+                               break;
 
+                       default:
+                               status = AE_AML_OPERAND_TYPE;
+                               goto cleanup;
+                       }
+               }
+
+               if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
+                   ACPI_DESC_TYPE_NAMED) {
+                       if (ACPI_GET_OBJECT_TYPE(operand[0]) ==
+                           ACPI_TYPE_STRING) {
                                /*
                                 * This is a deref_of (String). The string is a reference
                                 * to a named ACPI object.
                                 *
                                 * 1) Find the owning Node
-                                * 2) Dereference the node to an actual object.  Could be a
+                                * 2) Dereference the node to an actual object. Could be a
                                 *    Field, so we need to resolve the node to a value.
                                 */
                                status =
-                                   acpi_ns_get_node_by_path(operand[0]->string.
-                                                            pointer,
-                                                            walk_state->
-                                                            scope_info->scope.
-                                                            node,
-                                                            ACPI_NS_SEARCH_PARENT,
-                                                            ACPI_CAST_INDIRECT_PTR
-                                                            (struct
-                                                             acpi_namespace_node,
-                                                             &return_desc));
+                                   acpi_ns_get_node(walk_state->scope_info->
+                                                    scope.node,
+                                                    operand[0]->string.pointer,
+                                                    ACPI_NS_SEARCH_PARENT,
+                                                    ACPI_CAST_INDIRECT_PTR
+                                                    (struct
+                                                     acpi_namespace_node,
+                                                     &return_desc));
                                if (ACPI_FAILURE(status)) {
                                        goto cleanup;
                                }
@@ -857,11 +905,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                     (struct acpi_namespace_node, &return_desc),
                                     walk_state);
                                goto cleanup;
-
-                       default:
-
-                               status = AE_AML_OPERAND_TYPE;
-                               goto cleanup;
                        }
                }
 
@@ -885,8 +928,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                         * This must be a reference object produced by either the
                         * Index() or ref_of() operator
                         */
-                       switch (operand[0]->reference.opcode) {
-                       case AML_INDEX_OP:
+                       switch (operand[0]->reference.class) {
+                       case ACPI_REFCLASS_INDEX:
 
                                /*
                                 * The target type for the Index operator must be
@@ -922,7 +965,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                        return_desc->integer.value =
                                            temp_desc->buffer.
                                            pointer[operand[0]->reference.
-                                                   offset];
+                                                   value];
                                        break;
 
                                case ACPI_TYPE_PACKAGE:
@@ -937,13 +980,12 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                                acpi_ut_add_reference
                                                    (return_desc);
                                        }
-
                                        break;
 
                                default:
 
                                        ACPI_ERROR((AE_INFO,
-                                                   "Unknown Index target_type %X in obj %p",
+                                                   "Unknown Index TargetType %X in reference object %p",
                                                    operand[0]->reference.
                                                    target_type, operand[0]));
                                        status = AE_AML_OPERAND_TYPE;
@@ -951,13 +993,12 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                }
                                break;
 
-                       case AML_REF_OF_OP:
+                       case ACPI_REFCLASS_REFOF:
 
                                return_desc = operand[0]->reference.object;
 
                                if (ACPI_GET_DESCRIPTOR_TYPE(return_desc) ==
                                    ACPI_DESC_TYPE_NAMED) {
-
                                        return_desc =
                                            acpi_ns_get_attached_object((struct
                                                                         acpi_namespace_node
@@ -972,9 +1013,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
 
                        default:
                                ACPI_ERROR((AE_INFO,
-                                           "Unknown opcode in ref(%p) - %X",
+                                           "Unknown class in reference(%p) - %2.2X",
                                            operand[0],
-                                           operand[0]->reference.opcode));
+                                           operand[0]->reference.class));
 
                                status = AE_TYPE;
                                goto cleanup;
@@ -998,6 +1039,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                acpi_ut_remove_reference(return_desc);
        }
 
-       walk_state->result_obj = return_desc;
+       /* Save return object on success */
+
+       else {
+               walk_state->result_obj = return_desc;
+       }
+
        return_ACPI_STATUS(status);
 }