]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/dispatcher/dsobject.c
Merge branch 'bugzilla-10503' into test
[linux-2.6-omap-h63xx.git] / drivers / acpi / dispatcher / dsobject.c
index 58d4d91c8e97d5dba3fc2266a54ce6f10529fb7b..4f08e599d07e2a62eb257fefa2b6ba812b132578 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
@@ -373,7 +373,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
        union acpi_parse_object *parent;
        union acpi_operand_object *obj_desc = NULL;
        acpi_status status = AE_OK;
-       acpi_native_uint i;
+       unsigned i;
        u16 index;
        u16 reference_count;
 
@@ -476,10 +476,37 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
                arg = arg->common.next;
        }
 
-       if (!arg) {
+       /* Check for match between num_elements and actual length of package_list */
+
+       if (arg) {
+               /*
+                * num_elements was exhausted, but there are remaining elements in the
+                * package_list.
+                *
+                * Note: technically, this is an error, from ACPI spec: "It is an error
+                * for NumElements to be less than the number of elements in the
+                * PackageList". However, for now, we just print an error message and
+                * no exception is returned.
+                */
+               while (arg) {
+
+                       /* Find out how many elements there really are */
+
+                       i++;
+                       arg = arg->common.next;
+               }
+
+               ACPI_WARNING((AE_INFO,
+                           "Package List length (%X) larger than NumElements count (%X), truncated\n",
+                           i, element_count));
+       } else if (i < element_count) {
+               /*
+                * Arg list (elements) was exhausted, but we did not reach num_elements count.
+                * Note: this is not an error, the package is padded out with NULLs.
+                */
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                                 "Package List length larger than NumElements count (%X), truncated\n",
-                                 element_count));
+                                 "Package List length (%X) smaller than NumElements count (%X), padded with null elements\n",
+                                 i, element_count));
        }
 
        obj_desc->package.flags |= AOPOBJ_DATA_VALID;
@@ -704,54 +731,70 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
                switch (op_info->type) {
                case AML_TYPE_LOCAL_VARIABLE:
 
-                       /* Split the opcode into a base opcode + offset */
+                       /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
 
-                       obj_desc->reference.opcode = AML_LOCAL_OP;
-                       obj_desc->reference.offset = opcode - AML_LOCAL_OP;
+                       obj_desc->reference.value = opcode - AML_LOCAL_OP;
+                       obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
 
 #ifndef ACPI_NO_METHOD_EXECUTION
-                       status = acpi_ds_method_data_get_node(AML_LOCAL_OP,
-                                                             obj_desc->
-                                                             reference.offset,
-                                                             walk_state,
-                                                             (struct
-                                                              acpi_namespace_node
-                                                              **)&obj_desc->
-                                                             reference.object);
+                       status =
+                           acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
+                                                        obj_desc->reference.
+                                                        value, walk_state,
+                                                        ACPI_CAST_INDIRECT_PTR
+                                                        (struct
+                                                         acpi_namespace_node,
+                                                         &obj_desc->reference.
+                                                         object));
 #endif
                        break;
 
                case AML_TYPE_METHOD_ARGUMENT:
 
-                       /* Split the opcode into a base opcode + offset */
+                       /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
 
-                       obj_desc->reference.opcode = AML_ARG_OP;
-                       obj_desc->reference.offset = opcode - AML_ARG_OP;
+                       obj_desc->reference.value = opcode - AML_ARG_OP;
+                       obj_desc->reference.class = ACPI_REFCLASS_ARG;
 
 #ifndef ACPI_NO_METHOD_EXECUTION
-                       status = acpi_ds_method_data_get_node(AML_ARG_OP,
+                       status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
                                                              obj_desc->
-                                                             reference.offset,
+                                                             reference.value,
                                                              walk_state,
+                                                             ACPI_CAST_INDIRECT_PTR
                                                              (struct
-                                                              acpi_namespace_node
-                                                              **)&obj_desc->
-                                                             reference.object);
+                                                              acpi_namespace_node,
+                                                              &obj_desc->
+                                                              reference.
+                                                              object));
 #endif
                        break;
 
-               default:        /* Other literals, etc.. */
+               default:        /* Object name or Debug object */
 
-                       if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
+                       switch (op->common.aml_opcode) {
+                       case AML_INT_NAMEPATH_OP:
 
                                /* Node was saved in Op */
 
                                obj_desc->reference.node = op->common.node;
                                obj_desc->reference.object =
                                    op->common.node->object;
-                       }
+                               obj_desc->reference.class = ACPI_REFCLASS_NAME;
+                               break;
+
+                       case AML_DEBUG_OP:
+
+                               obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
+                               break;
+
+                       default:
 
-                       obj_desc->reference.opcode = opcode;
+                               ACPI_ERROR((AE_INFO,
+                                           "Unimplemented reference type for AML opcode: %4.4X",
+                                           opcode));
+                               return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
+                       }
                        break;
                }
                break;