ACPI: ACPICA 20060421
[sfrench/cifs-2.6.git] / drivers / acpi / executer / exoparg1.c
index 97e34542f5e44746bea68b73f9f01e2e353f9841..05b89c5878ebb0e2ce6de51f6e653804938ed049 100644 (file)
@@ -6,7 +6,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
@@ -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 */
@@ -111,7 +111,8 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
 
        default:                /*  Unknown opcode  */
 
-               ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
+                           walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                break;
        }
@@ -149,7 +150,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 */
@@ -188,7 +189,8 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
 
        default:                /*  Unknown opcode  */
 
-               ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
+                           walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                break;
        }
@@ -214,7 +216,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 */
@@ -227,7 +229,8 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
 
        default:                /* Unknown opcode */
 
-               ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
+                           walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
        }
@@ -261,7 +264,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 */
@@ -339,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;
@@ -346,9 +350,9 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                                /* Check the range of the digit */
 
                                if (temp32 > 9) {
-                                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                         "BCD digit too large (not decimal): 0x%X\n",
-                                                         temp32));
+                                       ACPI_ERROR((AE_INFO,
+                                                   "BCD digit too large (not decimal): 0x%X",
+                                                   temp32));
 
                                        status = AE_AML_NUMERIC_OVERFLOW;
                                        goto cleanup;
@@ -393,12 +397,10 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
                        /* Overflow if there is any data left in Digit */
 
                        if (digit > 0) {
-                               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                 "Integer too large to convert to BCD: %8.8X%8.8X\n",
-                                                 ACPI_FORMAT_UINT64(operand
-                                                                    [0]->
-                                                                    integer.
-                                                                    value)));
+                               ACPI_ERROR((AE_INFO,
+                                           "Integer too large to convert to BCD: %8.8X%8.8X",
+                                           ACPI_FORMAT_UINT64(operand[0]->
+                                                              integer.value)));
                                status = AE_AML_NUMERIC_OVERFLOW;
                                goto cleanup;
                        }
@@ -486,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);
                }
@@ -496,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);
                }
@@ -505,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);
                }
@@ -515,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);
                }
@@ -525,20 +531,22 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
 
                /* These are two obsolete opcodes */
 
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "%s is obsolete and not implemented\n",
-                                 acpi_ps_get_opcode_name(walk_state->opcode)));
+               ACPI_ERROR((AE_INFO,
+                           "%s is obsolete and not implemented",
+                           acpi_ps_get_opcode_name(walk_state->opcode)));
                status = AE_SUPPORT;
                goto cleanup;
 
        default:                /* Unknown opcode */
 
-               ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
+                           walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
        }
 
        if (ACPI_SUCCESS(status)) {
+
                /* Store the return value computed above into the target object */
 
                status = acpi_ex_store(return_desc, operand[1], walk_state);
@@ -546,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);
 }
 
@@ -580,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 */
@@ -623,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);
@@ -639,11 +650,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                    acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc,
                                             walk_state);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "%s: bad operand(s) %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)));
 
                        goto cleanup;
                }
@@ -742,9 +752,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                        break;
 
                default:
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
-                                         acpi_ut_get_type_name(type)));
+                       ACPI_ERROR((AE_INFO,
+                                   "Operand is not Buf/Int/Str/Pkg - found type %s",
+                                   acpi_ut_get_type_name(type)));
                        status = AE_AML_OPERAND_TYPE;
                        goto cleanup;
                }
@@ -776,8 +786,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:
                                /*
@@ -826,13 +853,24 @@ 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 =
@@ -856,11 +894,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;
                        }
                }
 
@@ -941,11 +974,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
 
                                default:
 
-                                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                         "Unknown Index target_type %X in obj %p\n",
-                                                         operand[0]->reference.
-                                                         target_type,
-                                                         operand[0]));
+                                       ACPI_ERROR((AE_INFO,
+                                                   "Unknown Index TargetType %X in obj %p",
+                                                   operand[0]->reference.
+                                                   target_type, operand[0]));
                                        status = AE_AML_OPERAND_TYPE;
                                        goto cleanup;
                                }
@@ -971,11 +1003,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
                                break;
 
                        default:
-                               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                 "Unknown opcode in ref(%p) - %X\n",
-                                                 operand[0],
-                                                 operand[0]->reference.
-                                                 opcode));
+                               ACPI_ERROR((AE_INFO,
+                                           "Unknown opcode in ref(%p) - %X",
+                                           operand[0],
+                                           operand[0]->reference.opcode));
 
                                status = AE_TYPE;
                                goto cleanup;
@@ -985,7 +1016,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
 
        default:
 
-               ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
+                           walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
        }
@@ -998,6 +1030,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);
 }