Commit c86eccb1 authored by Len Brown's avatar Len Brown Committed by Len Brown

[ACPI] ACPICA 20040211 udpate from Bob Moore

Completed investigation and implementation of the
call-by-reference mechanism for control method arguments.

Fixed a problem where a store of an object into an indexed
package could fail if the store occurs within a different
method than the method that created the package.

Fixed a problem where the ToDecimal operator could return
incorrect results.

Fixed a problem where the CopyObject operator could fail
on some of the more obscure objects (e.g., Reference objects.)

Improved the output of the Debug object to display buffer,
package, and index objects.

Fixed a problem where constructs of the form "RefOf (ArgX)"
did not return the expected result.

Added permanent ACPI_REPORT_ERROR macros for all instances of the
ACPI_AML_INTERNAL exception.
parent 6981e211
......@@ -203,10 +203,10 @@ acpi_ds_method_data_init_args (
while ((index < ACPI_METHOD_NUM_ARGS) && (index < max_param_count) && params[index]) {
/*
* A valid parameter.
* Store the argument in the method/walk descriptor
* Store the argument in the method/walk descriptor.
* Do not copy the arg in order to implement call by reference
*/
status = acpi_ds_store_object_to_local (AML_ARG_OP, index, params[index],
walk_state);
status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
......@@ -464,6 +464,7 @@ acpi_ds_method_data_get_value (
return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
default:
ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
}
......@@ -596,7 +597,10 @@ acpi_ds_store_object_to_local (
/*
* If the reference count on the object is more than one, we must
* take a copy of the object before we store.
* take a copy of the object before we store. A reference count
* of exactly 1 means that the object was just created during the
* evaluation of an expression, and we can safely use it since it
* is not used anywhere else.
*/
new_obj_desc = obj_desc;
if (obj_desc->common.reference_count > 1) {
......
......@@ -582,6 +582,11 @@ acpi_ds_init_object_from_op (
obj_desc->reference.opcode = AML_ARG_OP;
obj_desc->reference.offset = opcode - AML_ARG_OP;
#ifndef ACPI_NO_METHOD_EXECUTION
status = acpi_ds_method_data_get_node (AML_ARG_OP, obj_desc->reference.offset,
walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object);
#endif
break;
default: /* Other literals, etc.. */
......
......@@ -243,8 +243,8 @@ acpi_ds_get_buffer_arguments (
node = obj_desc->buffer.node;
if (!node) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"No pointer back to NS node in buffer %p\n", obj_desc));
ACPI_REPORT_ERROR ((
"No pointer back to NS node in buffer obj %p\n", obj_desc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......@@ -290,7 +290,7 @@ acpi_ds_get_package_arguments (
node = obj_desc->package.node;
if (!node) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
ACPI_REPORT_ERROR ((
"No pointer back to NS node in package %p\n", obj_desc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......
......@@ -280,7 +280,8 @@ acpi_ds_resolve_operands (
/*
* Attempt to resolve each of the valid operands
* Method arguments are passed by value, not by reference
* Method arguments are passed by reference, not by value. This means
* that the actual objects are passed, not copies of the objects.
*/
for (i = 0; i < walk_state->num_operands; i++) {
status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
......
......@@ -328,7 +328,7 @@ acpi_ds_result_push (
state = walk_state->results;
if (!state) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n"));
ACPI_REPORT_ERROR (("No result stack frame during push\n"));
return (AE_AML_INTERNAL);
}
......
......@@ -55,8 +55,9 @@
*
* FUNCTION: acpi_ex_convert_to_integer
*
* PARAMETERS: *obj_desc - Object to be converted. Must be an
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new Integer object is returned
* walk_state - Current method state
*
* RETURN: Status
......@@ -189,8 +190,9 @@ acpi_ex_convert_to_integer (
*
* FUNCTION: acpi_ex_convert_to_buffer
*
* PARAMETERS: *obj_desc - Object to be converted. Must be an
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new buffer object is returned
* walk_state - Current method state
*
* RETURN: Status
......@@ -319,6 +321,7 @@ acpi_ex_convert_to_ascii (
ACPI_FUNCTION_ENTRY ();
if (data_width < sizeof (acpi_integer)) {
leading_zero = FALSE;
length = data_width;
......@@ -328,22 +331,21 @@ acpi_ex_convert_to_ascii (
length = sizeof (acpi_integer);
}
switch (base) {
case 10:
remainder = 0;
for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--) {
for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0; i--) {
/* Divide by nth factor of 10 */
digit = integer;
for (j = 1; j < i; j++) {
for (j = 0; j < i; j++) {
(void) acpi_ut_short_divide (&digit, 10, &digit, &remainder);
}
/* Create the decimal digit */
if (digit != 0) {
if (remainder != 0) {
leading_zero = FALSE;
}
......@@ -354,6 +356,7 @@ acpi_ex_convert_to_ascii (
}
break;
case 16:
/* Copy the integer to the buffer */
......@@ -372,13 +375,14 @@ acpi_ex_convert_to_ascii (
}
break;
default:
break;
}
/*
* Since leading zeros are supressed, we must check for the case where
* the integer equals 0.
* the integer equals 0
*
* Finally, null terminate the string and return the length
*/
......@@ -396,8 +400,11 @@ acpi_ex_convert_to_ascii (
*
* FUNCTION: acpi_ex_convert_to_string
*
* PARAMETERS: *obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the string object is returned
* Base - 10 or 16
* max_length - Max length of the returned string
* walk_state - Current method state
*
* RETURN: Status
......@@ -415,10 +422,10 @@ acpi_ex_convert_to_string (
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *ret_desc;
u32 i;
u32 string_length;
u8 *new_buf;
u8 *pointer;
u32 string_length;
u32 i;
ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc);
......@@ -539,7 +546,6 @@ acpi_ex_convert_to_string (
return_ACPI_STATUS (AE_TYPE);
}
/*
* If we are about to overwrite the original object on the operand stack,
* we must remove a reference on the original object because we are
......@@ -562,6 +568,7 @@ acpi_ex_convert_to_string (
*
* PARAMETERS: destination_type - Current type of the destination
* source_desc - Source object to be converted.
* result_desc - Where the converted object is returned
* walk_state - Current method state
*
* RETURN: Status
......@@ -653,6 +660,8 @@ acpi_ex_convert_to_target_type (
default:
ACPI_REPORT_ERROR (("Bad destination type during conversion: %X\n",
destination_type));
status = AE_AML_INTERNAL;
break;
}
......@@ -672,6 +681,8 @@ acpi_ex_convert_to_target_type (
GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args),
walk_state->op_info->name, acpi_ut_get_type_name (destination_type)));
ACPI_REPORT_ERROR (("Bad Target Type (ARGI): %X\n",
GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)))
status = AE_AML_INTERNAL;
}
......
......@@ -507,8 +507,8 @@ acpi_ex_field_datum_io (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n",
obj_desc, acpi_ut_get_object_type_name (obj_desc)));
ACPI_REPORT_ERROR (("Wrong object type in field I/O %X\n",
ACPI_GET_OBJECT_TYPE (obj_desc)));
status = AE_AML_INTERNAL;
break;
}
......
......@@ -103,7 +103,7 @@ acpi_ex_get_object_reference (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %X\n",
ACPI_REPORT_ERROR (("Unknown Reference subtype in get ref %X\n",
obj_desc->reference.opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......@@ -121,8 +121,8 @@ acpi_ex_get_object_reference (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p has invalid descriptor [%s]\n",
obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
ACPI_REPORT_ERROR (("Invalid descriptor type in get ref: %X\n",
ACPI_GET_DESCRIPTOR_TYPE (obj_desc)));
return_ACPI_STATUS (AE_TYPE);
}
......@@ -349,6 +349,8 @@ acpi_ex_do_concatenate (
/* Invalid object type, should not happen here */
ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
ACPI_GET_OBJECT_TYPE (obj_desc1)));
status = AE_AML_INTERNAL;
return_desc = NULL;
}
......
......@@ -329,6 +329,8 @@ acpi_ex_opcode_2A_1T_1R (
break;
default:
ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
ACPI_GET_OBJECT_TYPE (operand[0])));
status = AE_AML_INTERNAL;
}
......@@ -433,7 +435,7 @@ acpi_ex_opcode_2A_1T_1R (
}
return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
return_desc->reference.object = operand[0]->package.elements [index];
return_desc->reference.object = operand[0];
return_desc->reference.where = &operand[0]->package.elements [index];
}
else {
......
......@@ -507,7 +507,7 @@ acpi_ex_prep_field_value (
(info->field_bit_position / ACPI_MUL_8 (obj_desc->field.access_byte_width));
if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Index Object\n"));
ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......
......@@ -238,8 +238,8 @@ acpi_ex_resolve_object_to_value (
/* Invalid reference object */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown target_type %X in Index/Reference obj %p\n",
ACPI_REPORT_ERROR ((
"During resolve, Unknown target_type %X in Index/Reference obj %p\n",
stack_desc->reference.target_type, stack_desc));
status = AE_AML_INTERNAL;
break;
......@@ -258,7 +258,7 @@ acpi_ex_resolve_object_to_value (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X (%s) in %p\n",
ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n",
opcode, acpi_ps_get_opcode_name (opcode), stack_desc));
status = AE_AML_INTERNAL;
break;
......
......@@ -154,7 +154,7 @@ acpi_ex_resolve_operands (
arg_types = op_info->runtime_args;
if (arg_types == ARGI_INVALID_OPCODE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
ACPI_REPORT_ERROR (("resolve_operands: %X is not a valid AML opcode\n",
opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
......@@ -172,7 +172,7 @@ acpi_ex_resolve_operands (
*/
while (GET_CURRENT_ARG_TYPE (arg_types)) {
if (!stack_ptr || !*stack_ptr) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %p\n",
ACPI_REPORT_ERROR (("resolve_operands: Null stack entry at %p\n",
stack_ptr));
return_ACPI_STATUS (AE_AML_INTERNAL);
......
......@@ -125,7 +125,7 @@ acpi_ex_store (
default:
/* Destination is not an Reference */
/* Destination is not a Reference object */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Destination is not a Reference or Constant object [%p]\n", dest_desc));
......@@ -189,35 +189,38 @@ acpi_ex_store (
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
case ACPI_TYPE_INTEGER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n",
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (source_desc->integer.value)));
break;
case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n",
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X",
(u32) source_desc->buffer.length));
ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
(source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
break;
case ACPI_TYPE_STRING:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", source_desc->string.pointer));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n",
source_desc->string.length, source_desc->string.pointer));
break;
case ACPI_TYPE_PACKAGE:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n",
source_desc->package.elements));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Size 0x%.2X Elements Ptr - %p\n",
source_desc->package.count, source_desc->package.elements));
break;
default:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n",
acpi_ut_get_object_type_name (source_desc), source_desc));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n",
source_desc));
break;
}
......@@ -227,7 +230,7 @@ acpi_ex_store (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n",
ACPI_REPORT_ERROR (("ex_store: Unknown Reference opcode %X\n",
ref_desc->reference.opcode));
ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR);
......@@ -263,6 +266,7 @@ acpi_ex_store_object_to_index (
union acpi_operand_object *obj_desc;
union acpi_operand_object *new_desc;
u8 value = 0;
u32 i;
ACPI_FUNCTION_TRACE ("ex_store_object_to_index");
......@@ -283,6 +287,7 @@ acpi_ex_store_object_to_index (
/*
* The object at *(index_desc->Reference.Where) is the
* element within the package that is to be modified.
* The parent package object is at index_desc->Reference.Object
*/
obj_desc = *(index_desc->reference.where);
......@@ -309,6 +314,12 @@ acpi_ex_store_object_to_index (
if (new_desc == source_desc) {
acpi_ut_add_reference (new_desc);
}
/* Increment reference count by the ref count of the parent package -1 */
for (i = 1; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) {
acpi_ut_add_reference (new_desc);
}
}
break;
......
......@@ -112,6 +112,12 @@ acpi_ex_resolve_object (
}
}
/* For copy_object, no further validation necessary */
if (walk_state->opcode == AML_COPY_OP) {
break;
}
/*
* Must have a Integer, Buffer, or String
*/
......@@ -136,7 +142,7 @@ acpi_ex_resolve_object (
/*
* Aliases are resolved by acpi_ex_prep_operands
*/
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n"));
ACPI_REPORT_ERROR (("Store into Alias - should never happen\n"));
status = AE_AML_INTERNAL;
break;
......
......@@ -314,7 +314,7 @@ acpi_ns_lookup (
else {
prefix_node = scope_info->scope.node;
if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p Not a namespace node [%s]\n",
ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n",
prefix_node, acpi_ut_get_descriptor_name (prefix_node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......
......@@ -315,8 +315,8 @@ acpi_ps_get_next_namepath (
acpi_ps_append_arg (arg, name_op);
if (!method_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Control Method - %p has no attached object\n",
ACPI_REPORT_ERROR ((
"ps_get_next_namepath: Control Method %p has no attached object\n",
node));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
......
......@@ -64,7 +64,7 @@
/* Version string */
#define ACPI_CA_VERSION 0x20040116
#define ACPI_CA_VERSION 0x20040211
/* Maximum objects in the various object caches */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment