]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/utilities/utcopy.c
Merge branch 'ec' into test
[linux-2.6-omap-h63xx.git] / drivers / acpi / utilities / utcopy.c
index 879eaa10d3ae77cf92777f4198dc60eb1b4c7058..5b2f7c27b705f2714c9fce18f997837ff8bdf6f3 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2007, R. Byron Moore
+ * Copyright (C) 2000 - 2008, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,8 @@
  */
 
 #include <acpi/acpi.h>
-#include <acpi/amlcode.h>
+#include <acpi/acnamesp.h>
+
 
 #define _COMPONENT          ACPI_UTILITIES
 ACPI_MODULE_NAME("utcopy")
@@ -172,23 +173,26 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
 
        case ACPI_TYPE_LOCAL_REFERENCE:
 
-               /*
-                * This is an object reference.  Attempt to dereference it.
-                */
-               switch (internal_object->reference.opcode) {
-               case AML_INT_NAMEPATH_OP:
+               /* This is an object reference. */
 
-                       /* For namepath, return the object handle ("reference") */
+               switch (internal_object->reference.class) {
+               case ACPI_REFCLASS_NAME:
 
-               default:
                        /*
-                        * Use the object type of "Any" to indicate a reference
-                        * to object containing a handle to an ACPI named object.
+                        * For namepath, return the object handle ("reference")
+                        * We are referring to the namespace node
                         */
-                       external_object->type = ACPI_TYPE_ANY;
                        external_object->reference.handle =
                            internal_object->reference.node;
+                       external_object->reference.actual_type =
+                           acpi_ns_get_type(internal_object->reference.node);
                        break;
+
+               default:
+
+                       /* All other reference types are unsupported */
+
+                       return_ACPI_STATUS(AE_TYPE);
                }
                break;
 
@@ -215,6 +219,11 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
                /*
                 * There is no corresponding external object type
                 */
+               ACPI_ERROR((AE_INFO,
+                           "Unsupported object type, cannot convert to external object: %s",
+                           acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
+                                                 (internal_object))));
+
                return_ACPI_STATUS(AE_SUPPORT);
        }
 
@@ -455,6 +464,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
        case ACPI_TYPE_STRING:
        case ACPI_TYPE_BUFFER:
        case ACPI_TYPE_INTEGER:
+       case ACPI_TYPE_LOCAL_REFERENCE:
 
                internal_object = acpi_ut_create_internal_object((u8)
                                                                 external_object->
@@ -464,9 +474,18 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
                }
                break;
 
+       case ACPI_TYPE_ANY:     /* This is the case for a NULL object */
+
+               *ret_internal_object = NULL;
+               return_ACPI_STATUS(AE_OK);
+
        default:
                /* All other types are not supported */
 
+               ACPI_ERROR((AE_INFO,
+                           "Unsupported object type, cannot convert to internal object: %s",
+                           acpi_ut_get_type_name(external_object->type)));
+
                return_ACPI_STATUS(AE_SUPPORT);
        }
 
@@ -502,6 +521,10 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
                            external_object->buffer.length);
 
                internal_object->buffer.length = external_object->buffer.length;
+
+               /* Mark buffer data valid */
+
+               internal_object->buffer.flags |= AOPOBJ_DATA_VALID;
                break;
 
        case ACPI_TYPE_INTEGER:
@@ -509,6 +532,15 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
                internal_object->integer.value = external_object->integer.value;
                break;
 
+       case ACPI_TYPE_LOCAL_REFERENCE:
+
+               /* TBD: should validate incoming handle */
+
+               internal_object->reference.class = ACPI_REFCLASS_NAME;
+               internal_object->reference.node =
+                   external_object->reference.handle;
+               break;
+
        default:
                /* Other types can't get here */
                break;
@@ -543,7 +575,7 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
        acpi_status status = AE_OK;
        union acpi_operand_object *package_object;
        union acpi_operand_object **package_elements;
-       acpi_native_uint i;
+       u32 i;
 
        ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
 
@@ -577,6 +609,10 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
                }
        }
 
+       /* Mark package data valid */
+
+       package_object->package.flags |= AOPOBJ_DATA_VALID;
+
        *internal_object = package_object;
        return_ACPI_STATUS(status);
 }
@@ -709,7 +745,15 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
                /*
                 * We copied the reference object, so we now must add a reference
                 * to the object pointed to by the reference
+                *
+                * DDBHandle reference (from Load/load_table) is a special reference,
+                * it does not have a Reference.Object, so does not need to
+                * increase the reference count
                 */
+               if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
+                       break;
+               }
+
                acpi_ut_add_reference(source_desc->reference.object);
                break;