# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1222344400 -3600
# Node ID 3057b932abea648469f5bfc28676d62322599f2c
# Parent 28419b05401ca2cb00908f9d527f76644523e032
ACPI cpufreq fix (2/2)
commit 8f9337c88335846b01801b1047a4caf10527a320
Author: Bob Moore <robert.moore@xxxxxxxxx>
Date: Fri Feb 2 19:48:18 2007 +0300
ACPICA: Handle case NumElements > Package length
Additional update for NumElements fix. Must handle
case where NumElements > Package list length, pad package
with null elements.
Signed-off-by: Alexey Starikovskiy
<alexey.y.starikovskiy@xxxxxxxxx>
Signed-off-by: Len Brown <len.brown@xxxxxxxxx>
---
drivers/acpi/dispatcher/dsobject.c | 85 +++++++++++++++++--------------------
1 files changed, 40 insertions(+), 45 deletions(-)
diff -r 28419b05401c -r 3057b932abea drivers/acpi/dispatcher/dsobject.c
--- a/drivers/acpi/dispatcher/dsobject.c Thu Sep 25 13:06:12 2008 +0100
+++ b/drivers/acpi/dispatcher/dsobject.c Thu Sep 25 13:06:40 2008 +0100
@@ -326,7 +326,7 @@ acpi_ds_build_internal_buffer_obj(struct
}
obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
- op->common.node = (struct acpi_namespace_node *)obj_desc;
+ op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
return_ACPI_STATUS(AE_OK);
}
@@ -336,26 +336,38 @@ acpi_ds_build_internal_buffer_obj(struct
*
* PARAMETERS: walk_state - Current walk state
* Op - Parser object to be translated
- * package_length - Number of elements in the package
+ * element_count - Number of elements in the package - this is
+ * the num_elements argument to Package()
* obj_desc_ptr - Where the ACPI internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: Translate a parser Op package object to the equivalent
* namespace object
+ *
+ * NOTE: The number of elements in the package will be always be the
num_elements
+ * count, regardless of the number of elements in the package list. If
+ * num_elements is smaller, only that many package list elements are used.
+ * if num_elements is larger, the Package object is padded out with
+ * objects of type Uninitialized (as per ACPI spec.)
+ *
+ * Even though the ASL compilers do not allow num_elements to be smaller
+ * than the Package list length (for the fixed length package opcode), some
+ * BIOS code modifies the AML on the fly to adjust the num_elements, and
+ * this code compensates for that. This also provides compatibility with
+ * other AML interpreters.
*
******************************************************************************/
acpi_status
acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
- u32 package_length,
+ u32 element_count,
union acpi_operand_object **obj_desc_ptr)
{
union acpi_parse_object *arg;
union acpi_parse_object *parent;
union acpi_operand_object *obj_desc = NULL;
- u32 package_list_length;
acpi_status status = AE_OK;
acpi_native_uint i;
@@ -384,43 +396,13 @@ acpi_ds_build_internal_package_obj(struc
obj_desc->package.node = parent->common.node;
}
- /* Count the *actual* number of items in the package list */
-
- arg = op->common.value.arg;
- arg = arg->common.next;
- for (package_list_length = 0; arg; package_list_length++) {
- arg = arg->common.next;
- }
-
/*
- * The number of elements in the package will be the lesser of the
- * specified element count and the length of the initializer list.
- *
- * Even though the ASL compilers do not allow this to happen (for the
- * fixed length package opcode), some BIOS code modifies the AML on the
- * fly to adjust the package length, and this code compensates for that.
- * This also provides compatibility with other AML interpreters.
- */
- obj_desc->package.count = package_length;
-
- if (package_list_length != package_length) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Package length mismatch, using lesser of
%X(Length Arg) and %X(AML Length)\n",
- package_length, package_list_length));
-
- if (package_list_length < package_length) {
- obj_desc->package.count = package_list_length;
- }
- }
-
- /*
- * Allocate the pointer array (array of pointers to the
- * individual objects). Add an extra pointer slot so
- * that the list is always null terminated.
+ * Allocate the element array (array of pointers to the individual
+ * objects) based on the num_elements parameter. Add an extra pointer
slot
+ * so that the list is always null terminated.
*/
obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
- obj_desc->package.
- count +
+ element_count +
1) * sizeof(void *));
if (!obj_desc->package.elements) {
@@ -428,12 +410,17 @@ acpi_ds_build_internal_package_obj(struc
return_ACPI_STATUS(AE_NO_MEMORY);
}
+ obj_desc->package.count = element_count;
+
/*
- * Initialize all elements of the package
+ * Initialize the elements of the package, up to the num_elements count.
+ * Package is automatically padded with uninitialized (NULL) elements
+ * if num_elements is greater than the package list length. Likewise,
+ * Package is truncated if num_elements is less than the list length.
*/
arg = op->common.value.arg;
arg = arg->common.next;
- for (i = 0; i < obj_desc->package.count; i++) {
+ for (i = 0; arg && (i < element_count); i++) {
if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
if (arg->common.node->type == ACPI_TYPE_METHOD) {
/*
@@ -463,8 +450,14 @@ acpi_ds_build_internal_package_obj(struc
arg = arg->common.next;
}
+ if (!arg) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "Package List length larger than NumElements
count (%X), truncated\n",
+ element_count));
+ }
+
obj_desc->package.flags |= AOPOBJ_DATA_VALID;
- op->common.node = (struct acpi_namespace_node *)obj_desc;
+ op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
return_ACPI_STATUS(status);
}
@@ -578,8 +571,9 @@ acpi_ds_init_object_from_op(struct acpi_
/*
* Defer evaluation of Buffer term_arg operand
*/
- obj_desc->buffer.node = (struct acpi_namespace_node *)
- walk_state->operands[0];
+ obj_desc->buffer.node =
+ ACPI_CAST_PTR(struct acpi_namespace_node,
+ walk_state->operands[0]);
obj_desc->buffer.aml_start = op->named.data;
obj_desc->buffer.aml_length = op->named.length;
break;
@@ -589,8 +583,9 @@ acpi_ds_init_object_from_op(struct acpi_
/*
* Defer evaluation of Package term_arg operand
*/
- obj_desc->package.node = (struct acpi_namespace_node *)
- walk_state->operands[0];
+ obj_desc->package.node =
+ ACPI_CAST_PTR(struct acpi_namespace_node,
+ walk_state->operands[0]);
obj_desc->package.aml_start = op->named.data;
obj_desc->package.aml_length = op->named.length;
break;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|