Commit 4b207d82 authored by Andy Grover's avatar Andy Grover

ACPI: Interpreter fixes

  Fixed memory leak in method argument resolution
  Fixed Index() operator to work properly with a target operand
  Fixed attempted double delete in the Index() code
  Code size improvements
  Improved debug/error messages and levels
  Fixed a problem with premature deletion of a buffer object
parent 7fb1589a
/******************************************************************************* /*******************************************************************************
* *
* Module Name: dsutils - Dispatcher utilities * Module Name: dsutils - Dispatcher utilities
* $Revision: 96 $ * $Revision: 97 $
* *
******************************************************************************/ ******************************************************************************/
...@@ -274,6 +274,45 @@ acpi_ds_resolve_operands ( ...@@ -274,6 +274,45 @@ acpi_ds_resolve_operands (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
/*******************************************************************************
*
* FUNCTION: Acpi_ds_clear_operands
*
* PARAMETERS: Walk_state - Current walk state with operands on stack
*
* RETURN: None
*
* DESCRIPTION: Clear all operands on the current walk state operand stack.
*
******************************************************************************/
void
acpi_ds_clear_operands (
acpi_walk_state *walk_state)
{
u32 i;
ACPI_FUNCTION_TRACE_PTR ("Acpi_ds_clear_operands", walk_state);
/*
* Remove a reference on each operand on the stack
*/
for (i = 0; i < walk_state->num_operands; i++) {
/*
* Remove a reference to all operands, including both
* "Arguments" and "Targets".
*/
acpi_ut_remove_reference (walk_state->operands[i]);
walk_state->operands[i] = NULL;
}
walk_state->num_operands = 0;
return_VOID;
}
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Module Name: dswexec - Dispatcher method execution callbacks; * Module Name: dswexec - Dispatcher method execution callbacks;
* dispatch to interpreter. * dispatch to interpreter.
* $Revision: 95 $ * $Revision: 96 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -329,7 +329,6 @@ acpi_ds_exec_end_op ( ...@@ -329,7 +329,6 @@ acpi_ds_exec_end_op (
u32 op_class; u32 op_class;
acpi_parse_object *next_op; acpi_parse_object *next_op;
acpi_parse_object *first_arg; acpi_parse_object *first_arg;
u32 i;
ACPI_FUNCTION_TRACE_PTR ("Ds_exec_end_op", walk_state); ACPI_FUNCTION_TRACE_PTR ("Ds_exec_end_op", walk_state);
...@@ -406,15 +405,7 @@ acpi_ds_exec_end_op ( ...@@ -406,15 +405,7 @@ acpi_ds_exec_end_op (
/* Always delete the argument objects and clear the operand stack */ /* Always delete the argument objects and clear the operand stack */
for (i = 0; i < walk_state->num_operands; i++) { acpi_ds_clear_operands (walk_state);
/*
* Remove a reference to all operands, including both
* "Arguments" and "Targets".
*/
acpi_ut_remove_reference (walk_state->operands[i]);
walk_state->operands[i] = NULL;
}
walk_state->num_operands = 0;
/* /*
* If a result object was returned from above, push it on the * If a result object was returned from above, push it on the
...@@ -475,6 +466,9 @@ acpi_ds_exec_end_op ( ...@@ -475,6 +466,9 @@ acpi_ds_exec_end_op (
*/ */
status = acpi_ds_resolve_operands (walk_state); status = acpi_ds_resolve_operands (walk_state);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
/* On error, clear all resolved operands */
acpi_ds_clear_operands (walk_state);
break; break;
} }
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: evmisc - Miscellaneous event manager support functions * Module Name: evmisc - Miscellaneous event manager support functions
* $Revision: 58 $ * $Revision: 59 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -228,7 +228,8 @@ acpi_ev_queue_notify_request ( ...@@ -228,7 +228,8 @@ acpi_ev_queue_notify_request (
if (!handler_obj) { if (!handler_obj) {
/* There is no per-device notify handler for this device */ /* There is no per-device notify handler for this device */
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for node %p \n", node)); ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"No notify handler for [%4.4s] node %p\n", node->name.ascii, node));
} }
return (status); return (status);
...@@ -466,7 +467,7 @@ acpi_ev_acquire_global_lock ( ...@@ -466,7 +467,7 @@ acpi_ev_acquire_global_lock (
if (acquired) { if (acquired) {
/* We got the lock */ /* We got the lock */
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the HW Global Lock\n")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n"));
acpi_gbl_global_lock_acquired = TRUE; acpi_gbl_global_lock_acquired = TRUE;
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
...@@ -476,7 +477,7 @@ acpi_ev_acquire_global_lock ( ...@@ -476,7 +477,7 @@ acpi_ev_acquire_global_lock (
* Did not get the lock. The pending bit was set above, and we must now * Did not get the lock. The pending bit was set above, and we must now
* wait until we get the global lock released interrupt. * wait until we get the global lock released interrupt.
*/ */
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for the HW Global Lock\n")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
/* /*
* Acquire the global lock semaphore first. * Acquire the global lock semaphore first.
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: exconvrt - Object conversion routines * Module Name: exconvrt - Object conversion routines
* $Revision: 41 $ * $Revision: 44 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -147,10 +147,15 @@ acpi_ex_convert_to_integer ( ...@@ -147,10 +147,15 @@ acpi_ex_convert_to_integer (
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Save the Result, delete original descriptor, store new descriptor */ /* Save the Result */
ret_desc->integer.value = result; ret_desc->integer.value = result;
/*
* 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
* essentially removing it from the stack.
*/
if (*result_desc == obj_desc) { if (*result_desc == obj_desc) {
if (walk_state->opcode != AML_STORE_OP) { if (walk_state->opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc); acpi_ut_remove_reference (obj_desc);
...@@ -191,76 +196,50 @@ acpi_ex_convert_to_buffer ( ...@@ -191,76 +196,50 @@ acpi_ex_convert_to_buffer (
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_BUFFER:
/* No conversion necessary */
*result_desc = obj_desc;
return_ACPI_STATUS (AE_OK);
case ACPI_TYPE_INTEGER: case ACPI_TYPE_INTEGER:
/* /*
* Create a new Buffer object * Create a new Buffer object.
* Need enough space for one integer
*/ */
ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); ret_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width);
if (!ret_desc) { if (!ret_desc) {
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Need enough space for one integer */
new_buf = ACPI_MEM_CALLOCATE (acpi_gbl_integer_byte_width);
if (!new_buf) {
ACPI_REPORT_ERROR
(("Ex_convert_to_buffer: Buffer allocation failure\n"));
acpi_ut_remove_reference (ret_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Copy the integer to the buffer */ /* Copy the integer to the buffer */
new_buf = ret_desc->buffer.pointer;
for (i = 0; i < acpi_gbl_integer_byte_width; i++) { for (i = 0; i < acpi_gbl_integer_byte_width; i++) {
new_buf[i] = (u8) (obj_desc->integer.value >> (i * 8)); new_buf[i] = (u8) (obj_desc->integer.value >> (i * 8));
} }
/* Complete buffer object initialization */
ret_desc->buffer.flags |= AOPOBJ_DATA_VALID;
ret_desc->buffer.pointer = new_buf;
ret_desc->buffer.length = acpi_gbl_integer_byte_width;
/* Return the new buffer descriptor */
*result_desc = ret_desc;
break; break;
case ACPI_TYPE_STRING: case ACPI_TYPE_STRING:
/* /*
* Create a new Buffer object * Create a new Buffer object
* Size will be the string length
*/ */
ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); ret_desc = acpi_ut_create_buffer_object (obj_desc->string.length);
if (!ret_desc) { if (!ret_desc) {
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Need enough space for one integer */ /* Copy the string to the buffer */
new_buf = ACPI_MEM_CALLOCATE (obj_desc->string.length); new_buf = ret_desc->buffer.pointer;
if (!new_buf) { ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer,
ACPI_REPORT_ERROR obj_desc->string.length);
(("Ex_convert_to_buffer: Buffer allocation failure\n"));
acpi_ut_remove_reference (ret_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer, obj_desc->string.length);
ret_desc->buffer.flags |= AOPOBJ_DATA_VALID;
ret_desc->buffer.pointer = new_buf;
ret_desc->buffer.length = obj_desc->string.length;
/* Return the new buffer descriptor */
*result_desc = ret_desc;
break;
case ACPI_TYPE_BUFFER:
*result_desc = obj_desc;
break; break;
...@@ -270,7 +249,20 @@ acpi_ex_convert_to_buffer ( ...@@ -270,7 +249,20 @@ acpi_ex_convert_to_buffer (
/* Mark buffer initialized */ /* Mark buffer initialized */
(*result_desc)->common.flags |= AOPOBJ_DATA_VALID; ret_desc->common.flags |= AOPOBJ_DATA_VALID;
/*
* 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
* essentially removing it from the stack.
*/
if (*result_desc == obj_desc) {
if (walk_state->opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = ret_desc;
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
} }
...@@ -405,6 +397,19 @@ acpi_ex_convert_to_string ( ...@@ -405,6 +397,19 @@ acpi_ex_convert_to_string (
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_STRING:
if (max_length >= obj_desc->string.length) {
*result_desc = obj_desc;
return_ACPI_STATUS (AE_OK);
}
else {
/* Must copy the string first and then truncate it */
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
case ACPI_TYPE_INTEGER: case ACPI_TYPE_INTEGER:
string_length = acpi_gbl_integer_byte_width * 2; string_length = acpi_gbl_integer_byte_width * 2;
...@@ -446,16 +451,6 @@ acpi_ex_convert_to_string ( ...@@ -446,16 +451,6 @@ acpi_ex_convert_to_string (
} }
ret_desc->buffer.pointer = new_buf; ret_desc->buffer.pointer = new_buf;
/* Return the new buffer descriptor */
if (*result_desc == obj_desc) {
if (walk_state->opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = ret_desc;
break; break;
...@@ -511,37 +506,26 @@ acpi_ex_convert_to_string ( ...@@ -511,37 +506,26 @@ acpi_ex_convert_to_string (
new_buf [index-1] = 0; new_buf [index-1] = 0;
ret_desc->buffer.pointer = new_buf; ret_desc->buffer.pointer = new_buf;
ret_desc->string.length = (u32) ACPI_STRLEN ((char *) new_buf); ret_desc->string.length = (u32) ACPI_STRLEN ((char *) new_buf);
/* Return the new buffer descriptor */
if (*result_desc == obj_desc) {
if (walk_state->opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = ret_desc;
break; break;
case ACPI_TYPE_STRING: default:
return_ACPI_STATUS (AE_TYPE);
if (max_length >= obj_desc->string.length) { }
*result_desc = obj_desc;
}
else {
/* Must copy the string first and then truncate it */
return_ACPI_STATUS (AE_NOT_IMPLEMENTED); /*
* 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
* essentially removing it from the stack.
*/
if (*result_desc == obj_desc) {
if (walk_state->opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
} }
break;
default:
return_ACPI_STATUS (AE_TYPE);
} }
*result_desc = ret_desc;
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
} }
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: exfield - ACPI AML (p-code) execution - field manipulation * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
* $Revision: 113 $ * $Revision: 115 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "acpi.h" #include "acpi.h"
#include "acdispat.h" #include "acdispat.h"
#include "acinterp.h" #include "acinterp.h"
#include "acevents.h"
#include "amlcode.h"
#define _COMPONENT ACPI_EXECUTER #define _COMPONENT ACPI_EXECUTER
...@@ -90,25 +88,11 @@ acpi_ex_read_data_from_field ( ...@@ -90,25 +88,11 @@ acpi_ex_read_data_from_field (
* This is an SMBus read. We must create a buffer to hold the data * This is an SMBus read. We must create a buffer to hold the data
* and directly access the region handler. * and directly access the region handler.
*/ */
buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc) { if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Create the actual read buffer */
buffer_desc->buffer.pointer = ACPI_MEM_CALLOCATE (ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc->buffer.pointer) {
acpi_ut_remove_reference (buffer_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Complete the buffer object initialization */
buffer_desc->common.flags = AOPOBJ_DATA_VALID;
buffer_desc->buffer.length = ACPI_SMBUS_BUFFER_SIZE;
buffer = buffer_desc->buffer.pointer;
/* Lock entire transaction if requested */ /* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
...@@ -118,7 +102,7 @@ acpi_ex_read_data_from_field ( ...@@ -118,7 +102,7 @@ acpi_ex_read_data_from_field (
* Note: Smbus protocol value is passed in upper 16-bits of Function * Note: Smbus protocol value is passed in upper 16-bits of Function
*/ */
status = acpi_ex_access_region (obj_desc, 0, status = acpi_ex_access_region (obj_desc, 0,
(acpi_integer *) buffer_desc->buffer.pointer, ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
ACPI_READ | (obj_desc->field.attribute << 16)); ACPI_READ | (obj_desc->field.attribute << 16));
acpi_ex_release_global_lock (locked); acpi_ex_release_global_lock (locked);
goto exit; goto exit;
...@@ -138,23 +122,10 @@ acpi_ex_read_data_from_field ( ...@@ -138,23 +122,10 @@ acpi_ex_read_data_from_field (
if (length > acpi_gbl_integer_byte_width) { if (length > acpi_gbl_integer_byte_width) {
/* Field is too large for an Integer, create a Buffer instead */ /* Field is too large for an Integer, create a Buffer instead */
buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); buffer_desc = acpi_ut_create_buffer_object (length);
if (!buffer_desc) { if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Create the actual read buffer */
buffer_desc->buffer.pointer = ACPI_MEM_CALLOCATE (length);
if (!buffer_desc->buffer.pointer) {
acpi_ut_remove_reference (buffer_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Complete the buffer object initialization */
buffer_desc->common.flags = AOPOBJ_DATA_VALID;
buffer_desc->buffer.length = length;
buffer = buffer_desc->buffer.pointer; buffer = buffer_desc->buffer.pointer;
} }
else { else {
...@@ -270,26 +241,12 @@ acpi_ex_write_data_to_field ( ...@@ -270,26 +241,12 @@ acpi_ex_write_data_to_field (
return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
} }
buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc) { if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY); return_ACPI_STATUS (AE_NO_MEMORY);
} }
/* Create the actual read buffer */
buffer_desc->buffer.pointer = ACPI_MEM_CALLOCATE (ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc->buffer.pointer) {
acpi_ut_remove_reference (buffer_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Complete the buffer object initialization */
buffer_desc->common.flags = AOPOBJ_DATA_VALID;
buffer_desc->buffer.length = ACPI_SMBUS_BUFFER_SIZE;
buffer = buffer_desc->buffer.pointer; buffer = buffer_desc->buffer.pointer;
ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE); ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE);
/* Lock entire transaction if requested */ /* Lock entire transaction if requested */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
* $Revision: 110 $ * $Revision: 112 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -148,9 +148,8 @@ acpi_ex_concat_template ( ...@@ -148,9 +148,8 @@ acpi_ex_concat_template (
acpi_operand_object **actual_return_desc, acpi_operand_object **actual_return_desc,
acpi_walk_state *walk_state) acpi_walk_state *walk_state)
{ {
acpi_status status;
acpi_operand_object *return_desc; acpi_operand_object *return_desc;
NATIVE_CHAR *new_buf; u8 *new_buf;
u8 *end_tag1; u8 *end_tag1;
u8 *end_tag2; u8 *end_tag2;
ACPI_SIZE length1; ACPI_SIZE length1;
...@@ -168,54 +167,35 @@ acpi_ex_concat_template ( ...@@ -168,54 +167,35 @@ acpi_ex_concat_template (
return_ACPI_STATUS (AE_AML_OPERAND_TYPE); return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
} }
/* Create a new buffer object for the result */ /* Compute the length of each part */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Allocate a new buffer for the result */
length1 = ACPI_PTR_DIFF (end_tag1, obj_desc1->buffer.pointer); length1 = ACPI_PTR_DIFF (end_tag1, obj_desc1->buffer.pointer);
length2 = ACPI_PTR_DIFF (end_tag2, obj_desc2->buffer.pointer) + length2 = ACPI_PTR_DIFF (end_tag2, obj_desc2->buffer.pointer) +
2; /* Size of END_TAG */ 2; /* Size of END_TAG */
new_buf = ACPI_MEM_ALLOCATE (length1 + length2); /* Create a new buffer object for the result */
if (!new_buf) {
ACPI_REPORT_ERROR return_desc = acpi_ut_create_buffer_object (length1 + length2);
(("Ex_concat_template: Buffer allocation failure\n")); if (!return_desc) {
status = AE_NO_MEMORY; return_ACPI_STATUS (AE_NO_MEMORY);
goto cleanup;
} }
/* Copy the templates to the new descriptor */ /* Copy the templates to the new descriptor */
new_buf = return_desc->buffer.pointer;
ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer, length1); ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer, length1);
ACPI_MEMCPY (new_buf + length1, obj_desc2->buffer.pointer, length2); ACPI_MEMCPY (new_buf + length1, obj_desc2->buffer.pointer, length2);
/* Complete the buffer object initialization */
return_desc->common.flags = AOPOBJ_DATA_VALID;
return_desc->buffer.pointer = (u8 *) new_buf;
return_desc->buffer.length = (u32) (length1 + length2);
/* Compute the new checksum */ /* Compute the new checksum */
new_buf[return_desc->buffer.length - 1] = (NATIVE_CHAR) new_buf[return_desc->buffer.length - 1] =
acpi_ut_generate_checksum (return_desc->buffer.pointer, acpi_ut_generate_checksum (return_desc->buffer.pointer,
(return_desc->buffer.length - 1)); (return_desc->buffer.length - 1));
/* Return the completed template descriptor */ /* Return the completed template descriptor */
*actual_return_desc = return_desc; *actual_return_desc = return_desc;
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
cleanup:
acpi_ut_remove_reference (return_desc);
return_ACPI_STATUS (status);
} }
...@@ -262,22 +242,14 @@ acpi_ex_do_concatenate ( ...@@ -262,22 +242,14 @@ acpi_ex_do_concatenate (
case ACPI_TYPE_INTEGER: case ACPI_TYPE_INTEGER:
/* Result of two Integers is a Buffer */ /* Result of two Integers is a Buffer */
/* Need enough buffer space for two integers */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width * 2);
if (!return_desc) { if (!return_desc) {
return (AE_NO_MEMORY); return (AE_NO_MEMORY);
} }
/* Need enough buffer space for two integers */ new_buf = (NATIVE_CHAR *) return_desc->buffer.pointer;
return_desc->buffer.length = acpi_gbl_integer_byte_width * 2;
new_buf = ACPI_MEM_CALLOCATE (return_desc->buffer.length);
if (!new_buf) {
ACPI_REPORT_ERROR
(("Ex_do_concatenate: Buffer allocation failure\n"));
status = AE_NO_MEMORY;
goto cleanup;
}
/* Convert the first integer */ /* Convert the first integer */
...@@ -295,10 +267,6 @@ acpi_ex_do_concatenate ( ...@@ -295,10 +267,6 @@ acpi_ex_do_concatenate (
this_integer >>= 8; this_integer >>= 8;
} }
/* Complete the buffer object initialization */
return_desc->common.flags = AOPOBJ_DATA_VALID;
return_desc->buffer.pointer = (u8 *) new_buf;
break; break;
...@@ -340,19 +308,14 @@ acpi_ex_do_concatenate ( ...@@ -340,19 +308,14 @@ acpi_ex_do_concatenate (
/* Result of two Buffers is a Buffer */ /* Result of two Buffers is a Buffer */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); return_desc = acpi_ut_create_buffer_object (
(ACPI_SIZE) obj_desc1->buffer.length +
(ACPI_SIZE) obj_desc2->buffer.length);
if (!return_desc) { if (!return_desc) {
return (AE_NO_MEMORY); return (AE_NO_MEMORY);
} }
new_buf = ACPI_MEM_ALLOCATE ((ACPI_SIZE) obj_desc1->buffer.length + new_buf = (NATIVE_CHAR *) return_desc->buffer.pointer;
(ACPI_SIZE) obj_desc2->buffer.length);
if (!new_buf) {
ACPI_REPORT_ERROR
(("Ex_do_concatenate: Buffer allocation failure\n"));
status = AE_NO_MEMORY;
goto cleanup;
}
/* Concatenate the buffers */ /* Concatenate the buffers */
...@@ -361,12 +324,6 @@ acpi_ex_do_concatenate ( ...@@ -361,12 +324,6 @@ acpi_ex_do_concatenate (
ACPI_MEMCPY (new_buf + obj_desc1->buffer.length, obj_desc2->buffer.pointer, ACPI_MEMCPY (new_buf + obj_desc1->buffer.length, obj_desc2->buffer.pointer,
obj_desc2->buffer.length); obj_desc2->buffer.length);
/* Complete the buffer object initialization */
return_desc->common.flags = AOPOBJ_DATA_VALID;
return_desc->buffer.pointer = (u8 *) new_buf;
return_desc->buffer.length = obj_desc1->buffer.length +
obj_desc2->buffer.length;
break; break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: exoparg1 - AML execution - opcodes with 1 argument * Module Name: exoparg1 - AML execution - opcodes with 1 argument
* $Revision: 145 $ * $Revision: 146 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -345,12 +345,6 @@ acpi_ex_opcode_1A_1T_1R ( ...@@ -345,12 +345,6 @@ acpi_ex_opcode_1A_1T_1R (
* return FALSE * return FALSE
*/ */
return_desc->integer.value = 0; return_desc->integer.value = 0;
/*
* Must delete the result descriptor since there is no reference
* being returned
*/
acpi_ut_remove_reference (operand[1]);
goto cleanup; goto cleanup;
} }
...@@ -389,6 +383,8 @@ acpi_ex_opcode_1A_1T_1R ( ...@@ -389,6 +383,8 @@ acpi_ex_opcode_1A_1T_1R (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
/* It is possible that the Store already produced a return object */
if (!walk_state->result_obj) { if (!walk_state->result_obj) {
/* /*
* Normally, we would remove a reference on the Operand[0] parameter; * Normally, we would remove a reference on the Operand[0] parameter;
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: exoparg2 - AML execution - opcodes with 2 arguments * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
* $Revision: 114 $ * $Revision: 115 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -414,39 +414,10 @@ acpi_ex_opcode_2A_1T_1R ( ...@@ -414,39 +414,10 @@ acpi_ex_opcode_2A_1T_1R (
goto cleanup; goto cleanup;
} }
if ((ACPI_GET_OBJECT_TYPE (operand[2]) == ACPI_TYPE_INTEGER) &&
(operand[2]->common.flags & AOPOBJ_AML_CONSTANT)) {
/*
* There is no actual result descriptor (the Zero_op/Constant Result
* descriptor is a placeholder), so just delete the placeholder and
* return a reference to the package element
*/
acpi_ut_remove_reference (operand[2]);
}
else {
/*
* Each element of the package is an internal object. Get the one
* we are after.
*/
temp_desc = operand[0]->package.elements [index];
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.target_type = ACPI_GET_OBJECT_TYPE (temp_desc);
return_desc->reference.object = temp_desc;
status = acpi_ex_store (return_desc, operand[2], walk_state);
return_desc->reference.object = NULL;
}
/*
* The local return object must always be a reference to the package element,
* not the element itself.
*/
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.target_type = ACPI_TYPE_PACKAGE; return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
return_desc->reference.object = operand[0]->package.elements [index];
return_desc->reference.where = &operand[0]->package.elements [index]; return_desc->reference.where = &operand[0]->package.elements [index];
} }
else { else {
/* Object to be indexed is a Buffer */ /* Object to be indexed is a Buffer */
...@@ -457,14 +428,21 @@ acpi_ex_opcode_2A_1T_1R ( ...@@ -457,14 +428,21 @@ acpi_ex_opcode_2A_1T_1R (
goto cleanup; goto cleanup;
} }
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD; return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD;
return_desc->reference.object = operand[0]; return_desc->reference.object = operand[0];
return_desc->reference.offset = index;
status = acpi_ex_store (return_desc, operand[2], walk_state);
} }
/* Complete the Index reference object */
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.offset = index;
/* Store the reference to the Target */
status = acpi_ex_store (return_desc, operand[2], walk_state);
/* Return the reference */
walk_state->result_obj = return_desc; walk_state->result_obj = return_desc;
goto cleanup; goto cleanup;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: exresnte - AML Interpreter object resolution * Module Name: exresnte - AML Interpreter object resolution
* $Revision: 60 $ * $Revision: 61 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -85,8 +85,8 @@ acpi_ex_resolve_node_to_value ( ...@@ -85,8 +85,8 @@ acpi_ex_resolve_node_to_value (
source_desc = acpi_ns_get_attached_object (node); source_desc = acpi_ns_get_attached_object (node);
entry_type = acpi_ns_get_type ((acpi_handle) node); entry_type = acpi_ns_get_type ((acpi_handle) node);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p Source_desc=%p Type=%X\n", ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p Source_desc=%p [%s]\n",
node, source_desc, entry_type)); node, source_desc, acpi_ut_get_type_name (entry_type)));
if (entry_type == ACPI_TYPE_LOCAL_ALIAS) { if (entry_type == ACPI_TYPE_LOCAL_ALIAS) {
/* There is always exactly one level of indirection */ /* There is always exactly one level of indirection */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: exresop - AML Interpreter operand/object resolution * Module Name: exresop - AML Interpreter operand/object resolution
* $Revision: 59 $ * $Revision: 60 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -390,14 +390,6 @@ acpi_ex_resolve_operands ( ...@@ -390,14 +390,6 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
if (obj_desc != *stack_ptr) {
/*
* We just created a new object, remove a reference
* on the original operand object
*/
acpi_ut_remove_reference (obj_desc);
}
goto next_operand; goto next_operand;
...@@ -420,14 +412,6 @@ acpi_ex_resolve_operands ( ...@@ -420,14 +412,6 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
if (obj_desc != *stack_ptr) {
/*
* We just created a new object, remove a reference
* on the original operand object
*/
acpi_ut_remove_reference (obj_desc);
}
goto next_operand; goto next_operand;
...@@ -450,14 +434,6 @@ acpi_ex_resolve_operands ( ...@@ -450,14 +434,6 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
if (obj_desc != *stack_ptr) {
/*
* We just created a new object, remove a reference
* on the original operand object
*/
acpi_ut_remove_reference (obj_desc);
}
goto next_operand; goto next_operand;
......
/****************************************************************************** /******************************************************************************
* *
* Name: acconfig.h - Global configuration constants * Name: acconfig.h - Global configuration constants
* $Revision: 117 $ * $Revision: 118 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
/* Version string */ /* Version string */
#define ACPI_CA_VERSION 0x20021111 #define ACPI_CA_VERSION 0x20021115
/* Version of ACPI supported */ /* Version of ACPI supported */
......
/****************************************************************************** /******************************************************************************
* *
* Name: acdispat.h - dispatcher (parser to interpreter interface) * Name: acdispat.h - dispatcher (parser to interpreter interface)
* $Revision: 54 $ * $Revision: 55 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -378,6 +378,10 @@ acpi_status ...@@ -378,6 +378,10 @@ acpi_status
acpi_ds_resolve_operands ( acpi_ds_resolve_operands (
acpi_walk_state *walk_state); acpi_walk_state *walk_state);
void
acpi_ds_clear_operands (
acpi_walk_state *walk_state);
/* /*
* dswscope - Scope Stack manipulation * dswscope - Scope Stack manipulation
......
/****************************************************************************** /******************************************************************************
* *
* Name: acutils.h -- prototypes for the common (subsystem-wide) procedures * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
* $Revision: 147 $ * $Revision: 148 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -531,6 +531,10 @@ u8 ...@@ -531,6 +531,10 @@ u8
acpi_ut_valid_internal_object ( acpi_ut_valid_internal_object (
void *object); void *object);
acpi_operand_object *
acpi_ut_create_buffer_object (
ACPI_SIZE buffer_size);
/* /*
* Ut_ref_cnt - Object reference count management * Ut_ref_cnt - Object reference count management
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Module Name: nseval - Object evaluation interfaces -- includes control * Module Name: nseval - Object evaluation interfaces -- includes control
* method lookup and execution. * method lookup and execution.
* $Revision: 118 $ * $Revision: 119 $
* *
******************************************************************************/ ******************************************************************************/
...@@ -383,7 +383,7 @@ acpi_ns_execute_control_method ( ...@@ -383,7 +383,7 @@ acpi_ns_execute_control_method (
return_ACPI_STATUS (AE_NULL_OBJECT); return_ACPI_STATUS (AE_NULL_OBJECT);
} }
ACPI_DUMP_PATHNAME (method_node, "Ns_execute_control_method: Executing", ACPI_DUMP_PATHNAME (method_node, "Execute Method:",
ACPI_LV_INFO, _COMPONENT); ACPI_LV_INFO, _COMPONENT);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: nsinit - namespace initialization * Module Name: nsinit - namespace initialization
* $Revision: 49 $ * $Revision: 50 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -317,7 +317,7 @@ acpi_ns_init_one_device ( ...@@ -317,7 +317,7 @@ acpi_ns_init_one_device (
ACPI_FUNCTION_TRACE ("Ns_init_one_device"); ACPI_FUNCTION_TRACE ("Ns_init_one_device");
if (!(acpi_dbg_level & ACPI_LV_INIT)) { if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && (!(acpi_dbg_level & ACPI_LV_INFO))) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, ".")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
} }
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: psparse - Parser top level AML parse routines * Module Name: psparse - Parser top level AML parse routines
* $Revision: 134 $ * $Revision: 135 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -1078,7 +1078,8 @@ acpi_ps_parse_aml ( ...@@ -1078,7 +1078,8 @@ acpi_ps_parse_aml (
} }
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Completed one call to walk loop, State=%p\n", walk_state)); "Completed one call to walk loop, %s State=%p\n",
acpi_format_exception (status), walk_state));
if (status == AE_CTRL_TRANSFER) { if (status == AE_CTRL_TRANSFER) {
/* /*
...@@ -1094,10 +1095,15 @@ acpi_ps_parse_aml ( ...@@ -1094,10 +1095,15 @@ acpi_ps_parse_aml (
walk_state = acpi_ds_get_current_walk_state (thread); walk_state = acpi_ds_get_current_walk_state (thread);
continue; continue;
} }
else if (status == AE_CTRL_TERMINATE) { else if (status == AE_CTRL_TERMINATE) {
status = AE_OK; status = AE_OK;
} }
else if (status != AE_OK) {
ACPI_REPORT_ERROR (("Method execution failed, %s\n",
acpi_format_exception (status)));
ACPI_DUMP_PATHNAME (walk_state->method_node, "Method pathname: ",
ACPI_LV_ERROR, _COMPONENT);
}
/* We are done with this walk, move on to the parent if any */ /* We are done with this walk, move on to the parent if any */
...@@ -1150,11 +1156,6 @@ acpi_ps_parse_aml ( ...@@ -1150,11 +1156,6 @@ acpi_ps_parse_aml (
/* On error, delete any return object */ /* On error, delete any return object */
acpi_ut_remove_reference (previous_walk_state->return_desc); acpi_ut_remove_reference (previous_walk_state->return_desc);
ACPI_REPORT_ERROR (("Method execution failed, %s\n",
acpi_format_exception (status)));
ACPI_DUMP_PATHNAME (walk_state->method_node, "Method pathname: ",
ACPI_LV_ERROR, _COMPONENT);
} }
} }
...@@ -1165,7 +1166,6 @@ acpi_ps_parse_aml ( ...@@ -1165,7 +1166,6 @@ acpi_ps_parse_aml (
else if (previous_walk_state->caller_return_desc) { else if (previous_walk_state->caller_return_desc) {
*(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc; /* NULL if no return value */ *(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc; /* NULL if no return value */
} }
else if (previous_walk_state->return_desc) { else if (previous_walk_state->return_desc) {
/* Caller doesn't want it, must delete it */ /* Caller doesn't want it, must delete it */
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: utobject - ACPI object create/delete/size/cache routines * Module Name: utobject - ACPI object create/delete/size/cache routines
* $Revision: 77 $ * $Revision: 79 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -114,6 +114,59 @@ acpi_ut_create_internal_object_dbg ( ...@@ -114,6 +114,59 @@ acpi_ut_create_internal_object_dbg (
} }
/*******************************************************************************
*
* FUNCTION: Acpi_ut_create_buffer_object
*
* PARAMETERS: Buffer_size - Size of buffer to be created
*
* RETURN: Pointer to a new Buffer object
*
* DESCRIPTION: Create a fully initialized buffer object
*
******************************************************************************/
acpi_operand_object *
acpi_ut_create_buffer_object (
ACPI_SIZE buffer_size)
{
acpi_operand_object *buffer_desc;
u8 *buffer;
ACPI_FUNCTION_TRACE_U32 ("Ut_create_buffer_object", buffer_size);
/*
* Create a new Buffer object
*/
buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
if (!buffer_desc) {
return_PTR (NULL);
}
/* Allocate the actual buffer */
buffer = ACPI_MEM_CALLOCATE (buffer_size);
if (!buffer) {
ACPI_REPORT_ERROR (("Create_buffer: could not allocate size %X\n",
(u32) buffer_size));
acpi_ut_remove_reference (buffer_desc);
return_PTR (NULL);
}
/* Complete buffer object initialization */
buffer_desc->buffer.flags |= AOPOBJ_DATA_VALID;
buffer_desc->buffer.pointer = buffer;
buffer_desc->buffer.length = (u32) buffer_size;
/* Return the new buffer descriptor */
return_PTR (buffer_desc);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: Acpi_ut_valid_internal_object * FUNCTION: Acpi_ut_valid_internal_object
...@@ -135,8 +188,7 @@ acpi_ut_valid_internal_object ( ...@@ -135,8 +188,7 @@ acpi_ut_valid_internal_object (
/* Check for a null pointer */ /* Check for a null pointer */
if (!object) { if (!object) {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n"));
"**** Null Object Ptr\n"));
return (FALSE); return (FALSE);
} }
...@@ -161,10 +213,17 @@ acpi_ut_valid_internal_object ( ...@@ -161,10 +213,17 @@ acpi_ut_valid_internal_object (
"**** Obj %p is a parser obj, not ACPI obj\n", object)); "**** Obj %p is a parser obj, not ACPI obj\n", object));
break; break;
case ACPI_DESC_TYPE_CACHED:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"**** Obj %p has already been released to internal cache\n", object));
break;
default: default:
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"**** Obj %p is of unknown type\n", object)); "**** Obj %p has unknown descriptor type %X\n", object,
ACPI_GET_DESCRIPTOR_TYPE (object)));
break; break;
} }
......
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