Commit 8f2297b6 authored by Len Brown's avatar Len Brown Committed by Len Brown

[ACPI] ACPICA 20041006 from Bob Moore

Signed-off-by: default avatarLen Brown <len.brown@intel.com>

Implemented support for the ACPI 3.0 Timer operator. This
ASL function implements a 64-bit timer with 100 nanosecond
granularity.

Defined a new OSL interface, acpi_os_get_timer. This
interface is used to implement the ACPI 3.0 Timer
operator. This allows the host OS to implement the timer
with the best clock available.  Also, it keeps the core
subsystem out of the clock handling business, since the
host OS (usually) performs this function.

Fixed an alignment issue on 64-bit platforms. The
hw_low_level_read/write() functions use a 64-bit address
which is part of the packed ACPI Generic Address
Structure. Since the structure is non-aligned, the
alignment macros are now used to extract the address to
a local variable before use.

Fixed a problem where the ToInteger operator assumed all
input strings were hexadecimal. The operator now handles
both decimal strings and hex strings (prefixed with "0x").

Fixed a problem where the string length in the string
object created as a result of the internal ConvertToString
procedure could be incorrect.  This potentially affected
all implicit conversions and also the ToDecimalString and
ToHexString operators.

Fixed two problems in the ToString operator. If the
length parameter was zero, an incorrect string object was
created and the value of the input length parameter was
inadvertently changed from zero to Ones.

Fixed a problem where the optional ResourceSource string
in the ExtendedIRQ resource macro was ignored.

Simplified the interfaces to the internal division
functions, reducing code size and complexity.
parent e2e6ee06
......@@ -658,7 +658,9 @@ acpi_ds_exec_end_op (
acpi_gbl_exception_handler &&
!(status & AE_CODE_CONTROL)) {
acpi_ex_exit_interpreter ();
status = acpi_gbl_exception_handler (status);
status = acpi_gbl_exception_handler (status,
walk_state->method_node->name.integer, walk_state->opcode,
walk_state->aml_offset, NULL);
acpi_ex_enter_interpreter ();
}
......
......@@ -58,7 +58,7 @@
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new Integer object is returned
* Opcode - AML opcode
* Flags - Used for string conversion
*
* RETURN: Status
*
......@@ -70,7 +70,7 @@ acpi_status
acpi_ex_convert_to_integer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u16 opcode)
u32 flags)
{
union acpi_operand_object *return_desc;
u8 *pointer;
......@@ -128,10 +128,12 @@ acpi_ex_convert_to_integer (
case ACPI_TYPE_STRING:
/*
* Convert string to an integer - the string must be hexadecimal
* as per the ACPI specification
* Convert string to an integer - for most cases, the string must be
* hexadecimal as per the ACPI specification. The only exception (as
* of ACPI 3.0) is that the to_integer() operator allows both decimal
* and hexadecimal strings (hex prefixed with "0x").
*/
status = acpi_ut_strtoul64 ((char *) pointer, 16, &result);
status = acpi_ut_strtoul64 ((char *) pointer, flags, &result);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
......@@ -171,18 +173,6 @@ acpi_ex_convert_to_integer (
/* Save the Result */
return_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 (opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
}
......@@ -195,7 +185,6 @@ acpi_ex_convert_to_integer (
* PARAMETERS: obj_desc - Object to be converted. Must be an
* Integer, Buffer, or String
* result_desc - Where the new buffer object is returned
* Opcode - AML opcode
*
* RETURN: Status
*
......@@ -206,8 +195,7 @@ acpi_ex_convert_to_integer (
acpi_status
acpi_ex_convert_to_buffer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u16 opcode)
union acpi_operand_object **result_desc)
{
union acpi_operand_object *return_desc;
u8 *new_buf;
......@@ -271,18 +259,6 @@ acpi_ex_convert_to_buffer (
/* Mark buffer initialized */
return_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 (opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
}
......@@ -351,7 +327,7 @@ acpi_ex_convert_to_ascii (
digit = integer;
for (j = 0; j < i; j++) {
(void) acpi_ut_short_divide (&digit, 10, &digit, &remainder);
(void) acpi_ut_short_divide (digit, 10, &digit, &remainder);
}
/* Handle leading zeros */
......@@ -407,7 +383,6 @@ acpi_ex_convert_to_ascii (
* Integer, Buffer, or String
* result_desc - Where the string object is returned
* Type - String flags (base and conversion type)
* Opcode - AML opcode
*
* RETURN: Status
*
......@@ -419,8 +394,7 @@ acpi_status
acpi_ex_convert_to_string (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u32 type,
u16 opcode)
u32 type)
{
union acpi_operand_object *return_desc;
u8 *new_buf;
......@@ -479,6 +453,7 @@ acpi_ex_convert_to_string (
/* Null terminate at the correct place */
return_desc->string.length = string_length;
new_buf [string_length] = 0;
break;
......@@ -527,8 +502,10 @@ acpi_ex_convert_to_string (
new_buf = return_desc->buffer.pointer;
/* Convert buffer bytes to hex or decimal values (separated by commas) */
/*
* Convert buffer bytes to hex or decimal values
* (separated by commas)
*/
for (i = 0; i < obj_desc->buffer.length; i++) {
new_buf += acpi_ex_convert_to_ascii (
(acpi_integer) obj_desc->buffer.pointer[i], base,
......@@ -551,17 +528,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
* essentially removing it from the stack.
*/
if (*result_desc == obj_desc) {
if (opcode != AML_STORE_OP) {
acpi_ut_remove_reference (obj_desc);
}
}
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
}
......@@ -641,7 +607,7 @@ acpi_ex_convert_to_target_type (
* a Buffer or a String to an Integer if necessary.
*/
status = acpi_ex_convert_to_integer (source_desc, result_desc,
walk_state->opcode);
16);
break;
......@@ -652,7 +618,7 @@ acpi_ex_convert_to_target_type (
* Integer or Buffer if necessary
*/
status = acpi_ex_convert_to_string (source_desc, result_desc,
ACPI_IMPLICIT_CONVERT_HEX, walk_state->opcode);
ACPI_IMPLICIT_CONVERT_HEX);
break;
......@@ -662,8 +628,7 @@ acpi_ex_convert_to_target_type (
* The operand must be a Buffer. We can convert an
* Integer or String if necessary
*/
status = acpi_ex_convert_to_buffer (source_desc, result_desc,
walk_state->opcode);
status = acpi_ex_convert_to_buffer (source_desc, result_desc);
break;
......
......@@ -258,18 +258,16 @@ acpi_ex_do_concatenate (
*/
switch (ACPI_GET_OBJECT_TYPE (operand0)) {
case ACPI_TYPE_INTEGER:
status = acpi_ex_convert_to_integer (operand1, &local_operand1,
walk_state->opcode);
status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
break;
case ACPI_TYPE_STRING:
status = acpi_ex_convert_to_string (operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX, walk_state->opcode);
ACPI_IMPLICIT_CONVERT_HEX);
break;
case ACPI_TYPE_BUFFER:
status = acpi_ex_convert_to_buffer (operand1, &local_operand1,
walk_state->opcode);
status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
break;
default:
......@@ -588,16 +586,16 @@ acpi_ex_do_logical_op (
*/
switch (ACPI_GET_OBJECT_TYPE (operand0)) {
case ACPI_TYPE_INTEGER:
status = acpi_ex_convert_to_integer (operand1, &local_operand1, opcode);
status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
break;
case ACPI_TYPE_STRING:
status = acpi_ex_convert_to_string (operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX, opcode);
ACPI_IMPLICIT_CONVERT_HEX);
break;
case ACPI_TYPE_BUFFER:
status = acpi_ex_convert_to_buffer (operand1, &local_operand1, opcode);
status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
break;
default:
......
......@@ -67,7 +67,7 @@
* Where:
*
* xA - ARGUMENTS: The number of arguments (input operands) that are
* required for this opcode type (1 through 6 args).
* required for this opcode type (0 through 6 args).
* yT - TARGETS: The number of targets (output operands) that are required
* for this opcode type (0, 1, or 2 targets).
* zR - RETURN VALUE: Indicates whether this opcode type returns a value
......@@ -85,8 +85,7 @@
*
* RETURN: Status
*
* DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
* object stack
* DESCRIPTION: Execute operator with no operands, one return value
*
******************************************************************************/
......@@ -100,6 +99,7 @@ acpi_ex_opcode_0A_0T_1R (
ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
switch (walk_state->opcode) {
......@@ -403,7 +403,7 @@ acpi_ex_opcode_1A_1T_1R (
/* Each BCD digit is one nybble wide */
for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
(void) acpi_ut_short_divide (&digit, 10, &digit, &temp32);
(void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
/* Insert the BCD digit that resides in the remainder from above */
......@@ -500,28 +500,27 @@ acpi_ex_opcode_1A_1T_1R (
case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
status = acpi_ex_convert_to_string (operand[0], &return_desc,
ACPI_EXPLICIT_CONVERT_DECIMAL, walk_state->opcode);
ACPI_EXPLICIT_CONVERT_DECIMAL);
break;
case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
status = acpi_ex_convert_to_string (operand[0], &return_desc,
ACPI_EXPLICIT_CONVERT_HEX, walk_state->opcode);
ACPI_EXPLICIT_CONVERT_HEX);
break;
case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
status = acpi_ex_convert_to_buffer (operand[0], &return_desc,
walk_state->opcode);
status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
break;
case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
status = acpi_ex_convert_to_integer (operand[0], &return_desc,
walk_state->opcode);
ACPI_ANY_BASE);
break;
......
......@@ -199,7 +199,8 @@ acpi_ex_opcode_2A_2T_1R (
acpi_status status;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
/*
......@@ -222,8 +223,10 @@ acpi_ex_opcode_2A_2T_1R (
/* Quotient to return_desc1, remainder to return_desc2 */
status = acpi_ut_divide (&operand[0]->integer.value, &operand[1]->integer.value,
&return_desc1->integer.value, &return_desc2->integer.value);
status = acpi_ut_divide (operand[0]->integer.value,
operand[1]->integer.value,
&return_desc1->integer.value,
&return_desc2->integer.value);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
......@@ -297,7 +300,8 @@ acpi_ex_opcode_2A_1T_1R (
acpi_size length;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
/*
......@@ -330,15 +334,17 @@ acpi_ex_opcode_2A_1T_1R (
/* return_desc will contain the remainder */
status = acpi_ut_divide (&operand[0]->integer.value,
&operand[1]->integer.value,
NULL, &return_desc->integer.value);
status = acpi_ut_divide (operand[0]->integer.value,
operand[1]->integer.value,
NULL,
&return_desc->integer.value);
break;
case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
status = acpi_ex_do_concatenate (operand[0], operand[1], &return_desc, walk_state);
status = acpi_ex_do_concatenate (operand[0], operand[1],
&return_desc, walk_state);
break;
......@@ -349,24 +355,24 @@ acpi_ex_opcode_2A_1T_1R (
* been converted.) Copy the raw buffer data to a new object of type String.
*/
/* Get the length of the new string */
/*
* Get the length of the new string. It is the smallest of:
* 1) Length of the input buffer
* 2) Max length as specified in the to_string operator
* 3) Length of input buffer up to a zero byte (null terminator)
*
* NOTE: A length of zero is ok, and will create a zero-length, null
* terminated string.
*/
length = 0;
if (operand[1]->integer.value == 0) {
/* Handle optional length value */
operand[1]->integer.value = ACPI_INTEGER_MAX;
}
while ((length < operand[0]->buffer.length) &&
(length < operand[1]->integer.value) &&
(operand[0]->buffer.pointer[length])) {
length++;
}
if (length > ACPI_MAX_STRING_CONVERSION) {
status = AE_AML_STRING_LIMIT;
goto cleanup;
if (length > ACPI_MAX_STRING_CONVERSION) {
status = AE_AML_STRING_LIMIT;
goto cleanup;
}
}
/* Allocate a new string (Length + 1 for null terminator) */
......@@ -512,7 +518,8 @@ acpi_ex_opcode_2A_0T_1R (
u8 logical_result = FALSE;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
/* Create the internal return object */
......
......@@ -121,7 +121,7 @@ acpi_ex_system_memory_space_handler (
* Hardware does not support non-aligned data transfers, we must verify
* the request.
*/
(void) acpi_ut_short_divide ((acpi_integer *) &address, length, NULL, &remainder);
(void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder);
if (remainder != 0) {
return_ACPI_STATUS (AE_AML_ALIGNMENT);
}
......
......@@ -398,8 +398,7 @@ acpi_ex_resolve_operands (
* But we can implicitly convert from a STRING or BUFFER
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_integer (obj_desc, stack_ptr,
walk_state->opcode);
status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, 16);
if (ACPI_FAILURE (status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
......@@ -421,8 +420,7 @@ acpi_ex_resolve_operands (
* But we can implicitly convert from a STRING or INTEGER
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr,
walk_state->opcode);
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
if (ACPI_FAILURE (status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
......@@ -445,7 +443,7 @@ acpi_ex_resolve_operands (
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_string (obj_desc, stack_ptr,
ACPI_IMPLICIT_CONVERT_HEX, walk_state->opcode);
ACPI_IMPLICIT_CONVERT_HEX);
if (ACPI_FAILURE (status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
......@@ -497,8 +495,7 @@ acpi_ex_resolve_operands (
/* Highest priority conversion is to type Buffer */
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr,
walk_state->opcode);
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
......
......@@ -280,25 +280,25 @@ acpi_ex_digits_needed (
{
u32 num_digits;
acpi_integer current_value;
acpi_integer quotient;
ACPI_FUNCTION_TRACE ("ex_digits_needed");
/*
* acpi_integer is unsigned, so we don't worry about a '-'
*/
if ((current_value = value) == 0) {
/* acpi_integer is unsigned, so we don't worry about a '-' prefix */
if (value == 0) {
return_VALUE (1);
}
current_value = value;
num_digits = 0;
/* Count the digits in the requested base */
while (current_value) {
(void) acpi_ut_short_divide (&current_value, base, &quotient, NULL);
(void) acpi_ut_short_divide (current_value, base, &current_value, NULL);
num_digits++;
current_value = quotient;
}
return_VALUE (num_digits);
......@@ -361,7 +361,6 @@ acpi_ex_unsigned_integer_to_string (
u32 count;
u32 digits_needed;
u32 remainder;
acpi_integer quotient;
ACPI_FUNCTION_ENTRY ();
......@@ -371,9 +370,8 @@ acpi_ex_unsigned_integer_to_string (
out_string[digits_needed] = 0;
for (count = digits_needed; count > 0; count--) {
(void) acpi_ut_short_divide (&value, 10, &quotient, &remainder);
(void) acpi_ut_short_divide (value, 10, &value, &remainder);
out_string[count-1] = (char) ('0' + remainder);\
value = quotient;
}
}
......
......@@ -709,6 +709,7 @@ acpi_hw_low_level_read (
u32 *value,
struct acpi_generic_address *reg)
{
u64 address;
acpi_status status;
......@@ -720,8 +721,14 @@ acpi_hw_low_level_read (
* a non-zero address within. However, don't return an error
* because the PM1A/B code must not fail if B isn't present.
*/
if ((!reg) ||
(!reg->address)) {
if (!reg) {
return (AE_OK);
}
/* Get a local copy of the address. Handles possible alignment issues */
address = ACPI_MOVE_64_TO_64 (&address, &reg->address);
if (!address) {
return (AE_OK);
}
*value = 0;
......@@ -734,14 +741,14 @@ acpi_hw_low_level_read (
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
status = acpi_os_read_memory (
(acpi_physical_address) reg->address,
(acpi_physical_address) address,
value, width);
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
status = acpi_os_read_port ((acpi_io_address) reg->address,
status = acpi_os_read_port ((acpi_io_address) address,
value, width);
break;
......@@ -754,7 +761,7 @@ acpi_hw_low_level_read (
ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
*value, width,
ACPI_FORMAT_UINT64 (reg->address),
ACPI_FORMAT_UINT64 (address),
acpi_ut_get_region_name (reg->address_space_id)));
return (status);
......@@ -781,6 +788,7 @@ acpi_hw_low_level_write (
u32 value,
struct acpi_generic_address *reg)
{
u64 address;
acpi_status status;
......@@ -792,8 +800,14 @@ acpi_hw_low_level_write (
* a non-zero address within. However, don't return an error
* because the PM1A/B code must not fail if B isn't present.
*/
if ((!reg) ||
(!reg->address)) {
if (!reg) {
return (AE_OK);
}
/* Get a local copy of the address. Handles possible alignment issues */
address = ACPI_MOVE_64_TO_64 (&address, &reg->address);
if (!address) {
return (AE_OK);
}
......@@ -805,14 +819,14 @@ acpi_hw_low_level_write (
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
status = acpi_os_write_memory (
(acpi_physical_address) reg->address,
(acpi_physical_address) address,
value, width);
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
status = acpi_os_write_port ((acpi_io_address) reg->address,
status = acpi_os_write_port ((acpi_io_address) address,
value, width);
break;
......@@ -825,7 +839,7 @@ acpi_hw_low_level_write (
ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
value, width,
ACPI_FORMAT_UINT64 (reg->address),
ACPI_FORMAT_UINT64 (address),
acpi_ut_get_region_name (reg->address_space_id)));
return (status);
......
......@@ -149,10 +149,9 @@ acpi_get_timer_duration (
u32 end_ticks,
u32 *time_elapsed)
{
u32 delta_ticks = 0;
union uint64_overlay normalized_ticks;
acpi_status status;
acpi_integer out_quotient;
u32 delta_ticks;
acpi_integer quotient;
ACPI_FUNCTION_TRACE ("acpi_get_timer_duration");
......@@ -164,7 +163,7 @@ acpi_get_timer_duration (
/*
* Compute Tick Delta:
* Handle (max one) timer rollovers on 24- versus 32-bit timers.
* Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
*/
if (start_ticks < end_ticks) {
delta_ticks = end_ticks - start_ticks;
......@@ -181,22 +180,20 @@ acpi_get_timer_duration (
delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
}
}
else {
else /* start_ticks == end_ticks */ {
*time_elapsed = 0;
return_ACPI_STATUS (AE_OK);
}
/*
* Compute Duration (Requires a 64-bit divide):
* Compute Duration (Requires a 64-bit multiply and divide):
*
* time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
*/
normalized_ticks.full = ((u64) delta_ticks) * 1000000;
status = acpi_ut_short_divide (&normalized_ticks.full, PM_TIMER_FREQUENCY,
&out_quotient, NULL);
status = acpi_ut_short_divide (((u64) delta_ticks) * 1000000,
PM_TIMER_FREQUENCY, &quotient, NULL);
*time_elapsed = (u32) out_quotient;
*time_elapsed = (u32) quotient;
return_ACPI_STATUS (status);
}
......
......@@ -129,10 +129,9 @@ union acpi_parse_object*
acpi_ps_alloc_op (
u16 opcode)
{
union acpi_parse_object *op = NULL;
u32 size;
u8 flags;
union acpi_parse_object *op;
const struct acpi_opcode_info *op_info;
u8 flags = ACPI_PARSEOP_GENERIC;
ACPI_FUNCTION_ENTRY ();
......@@ -140,32 +139,28 @@ acpi_ps_alloc_op (
op_info = acpi_ps_get_opcode_info (opcode);
/* Allocate the minimum required size object */
/* Determine type of parse_op required */
if (op_info->flags & AML_DEFER) {
size = sizeof (struct acpi_parse_obj_named);
flags = ACPI_PARSEOP_DEFERRED;
}
else if (op_info->flags & AML_NAMED) {
size = sizeof (struct acpi_parse_obj_named);
flags = ACPI_PARSEOP_NAMED;
}
else if (opcode == AML_INT_BYTELIST_OP) {
size = sizeof (struct acpi_parse_obj_named);
flags = ACPI_PARSEOP_BYTELIST;
}
else {
size = sizeof (struct acpi_parse_obj_common);
flags = ACPI_PARSEOP_GENERIC;
}
if (size == sizeof (struct acpi_parse_obj_common)) {
/*
* The generic op is by far the most common (16 to 1)
*/
/* Allocate the minimum required size object */
if (flags == ACPI_PARSEOP_GENERIC) {
/* The generic op (default) is by far the most common (16 to 1) */
op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE);
}
else {
/* Extended parseop */
op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT);
}
......
......@@ -74,7 +74,6 @@ acpi_rs_get_byte_stream_length (
{
acpi_size byte_stream_size_needed = 0;
acpi_size segment_size;
struct acpi_resource_ext_irq *ex_irq = NULL;
u8 done = FALSE;
......@@ -91,8 +90,8 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_IRQ:
/*
* IRQ Resource
* For an IRQ Resource, Byte 3, although optional, will
* always be created - it holds IRQ information.
* For an IRQ Resource, Byte 3, although optional, will always be
* created - it holds IRQ information.
*/
segment_size = 4;
break;
......@@ -108,8 +107,8 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_START_DPF:
/*
* Start Dependent Functions Resource
* For a start_dependent_functions Resource, Byte 1,
* although optional, will always be created.
* For a start_dependent_functions Resource, Byte 1, although
* optional, will always be created.
*/
segment_size = 2;
break;
......@@ -141,10 +140,9 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_VENDOR:
/*
* Vendor Defined Resource
* For a Vendor Specific resource, if the Length is
* between 1 and 7 it will be created as a Small
* Resource data type, otherwise it is a Large
* Resource data type.
* For a Vendor Specific resource, if the Length is between 1 and 7
* it will be created as a Small Resource data type, otherwise it
* is a Large Resource data type.
*/
if (linked_list->data.vendor_specific.length > 7) {
segment_size = 3;
......@@ -191,10 +189,9 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_ADDRESS16:
/*
* 16-Bit Address Resource
* The base size of this byte stream is 16. If a
* Resource Source string is not NULL, add 1 for
* the Index + the length of the null terminated
* string Resource Source + 1 for the null.
* The base size of this byte stream is 16. If a Resource Source
* string is not NULL, add 1 for the Index + the length of the null
* terminated string Resource Source + 1 for the null.
*/
segment_size = 16;
......@@ -223,10 +220,9 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_ADDRESS64:
/*
* 64-Bit Address Resource
* The base size of this byte stream is 46. If a Resource
* Source string is not NULL, add 1 for the Index + the
* length of the null terminated string Resource Source +
* 1 for the null.
* The base size of this byte stream is 46. If a resource_source
* string is not NULL, add 1 for the Index + the length of the null
* terminated string Resource Source + 1 for the null.
*/
segment_size = 46;
......@@ -239,9 +235,8 @@ acpi_rs_get_byte_stream_length (
case ACPI_RSTYPE_EXT_IRQ:
/*
* Extended IRQ Resource
* The base size of this byte stream is 9. This is for an
* Interrupt table length of 1. For each additional
* interrupt, add 4.
* The base size of this byte stream is 9. This is for an Interrupt
* table length of 1. For each additional interrupt, add 4.
* If a Resource Source string is not NULL, add 1 for the
* Index + the length of the null terminated string
* Resource Source + 1 for the null.
......@@ -249,7 +244,7 @@ acpi_rs_get_byte_stream_length (
segment_size = 9 +
(((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
if (ex_irq && ex_irq->resource_source.string_ptr) {
if (linked_list->data.extended_irq.resource_source.string_ptr) {
segment_size += linked_list->data.extended_irq.resource_source.string_length;
segment_size++;
}
......@@ -257,8 +252,7 @@ acpi_rs_get_byte_stream_length (
default:
/*
* If we get here, everything is out of sync,
* so exit with an error
* If we get here, everything is out of sync, exit with error
*/
return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
......@@ -366,7 +360,6 @@ acpi_rs_get_list_length (
/*
* 32-Bit Memory Range Resource
*/
bytes_consumed = 20;
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32);
......@@ -395,14 +388,12 @@ acpi_rs_get_list_length (
bytes_consumed = temp16 + 3;
/*
* Resource Source Index and Resource Source are
* optional elements. Check the length of the
* Bytestream. If it is greater than 43, that
* means that an Index exists and is followed by
* a null termininated string. Therefore, set
* the temp variable to the length minus the minimum
* byte stream length plus the byte for the Index to
* determine the size of the NULL terminiated string.
* Resource Source Index and Resource Source are optional elements.
* Check the length of the Bytestream. If it is greater than 43,
* that means that an Index exists and is followed by a null
* terminated string. Therefore, set the temp variable to the
* length minus the minimum byte stream length plus the byte for
* the Index to determine the size of the NULL terminated string.
*/
if (43 < temp16) {
temp8 = (u8) (temp16 - 44);
......@@ -433,14 +424,12 @@ acpi_rs_get_list_length (
bytes_consumed = temp16 + 3;
/*
* Resource Source Index and Resource Source are
* optional elements. Check the length of the
* Bytestream. If it is greater than 23, that
* means that an Index exists and is followed by
* a null termininated string. Therefore, set
* the temp variable to the length minus the minimum
* byte stream length plus the byte for the Index to
* determine the size of the NULL terminiated string.
* Resource Source Index and Resource Source are optional elements.
* Check the length of the Bytestream. If it is greater than 23,
* that means that an Index exists and is followed by a null
* terminated string. Therefore, set the temp variable to the
* length minus the minimum byte stream length plus the byte for
* the Index to determine the size of the NULL terminated string.
*/
if (23 < temp16) {
temp8 = (u8) (temp16 - 24);
......@@ -471,14 +460,12 @@ acpi_rs_get_list_length (
bytes_consumed = temp16 + 3;
/*
* Resource Source Index and Resource Source are
* optional elements. Check the length of the
* Bytestream. If it is greater than 13, that
* means that an Index exists and is followed by
* a null termininated string. Therefore, set
* the temp variable to the length minus the minimum
* byte stream length plus the byte for the Index to
* determine the size of the NULL terminiated string.
* Resource Source Index and Resource Source are optional elements.
* Check the length of the Bytestream. If it is greater than 13,
* that means that an Index exists and is followed by a null
* terminated string. Therefore, set the temp variable to the
* length minus the minimum byte stream length plus the byte for
* the Index to determine the size of the NULL terminated string.
*/
if (13 < temp16) {
temp8 = (u8) (temp16 - 14);
......@@ -509,9 +496,8 @@ acpi_rs_get_list_length (
bytes_consumed = temp16 + 3;
/*
* Point past the length field and the
* Interrupt vector flags to save off the
* Interrupt table length to the Temp8 variable.
* Point past the length field and the Interrupt vector flags to
* save off the Interrupt table length to the Temp8 variable.
*/
buffer += 3;
temp8 = *buffer;
......@@ -523,14 +509,12 @@ acpi_rs_get_list_length (
additional_bytes = (u8) ((temp8 - 1) * 4);
/*
* Resource Source Index and Resource Source are
* optional elements. Check the length of the
* Bytestream. If it is greater than 9, that
* means that an Index exists and is followed by
* a null termininated string. Therefore, set
* the temp variable to the length minus the minimum
* byte stream length plus the byte for the Index to
* determine the size of the NULL terminiated string.
* Resource Source Index and Resource Source are optional elements.
* Check the length of the Bytestream. If it is greater than 9,
* that means that an Index exists and is followed by a null
* terminated string. Therefore, set the temp variable to the
* length minus the minimum byte stream length plus the byte for
* the Index to determine the size of the NULL terminated string.
*/
if (9 + additional_bytes < temp16) {
temp8 = (u8) (temp16 - (9 + additional_bytes));
......@@ -565,9 +549,8 @@ acpi_rs_get_list_length (
bytes_consumed = 3;
}
/*
* Point past the descriptor
*/
/* Point past the descriptor */
++buffer;
/*
......@@ -595,9 +578,8 @@ acpi_rs_get_list_length (
buffer = byte_stream_buffer;
bytes_consumed = 3;
/*
* Point past the descriptor
*/
/* Point past the descriptor */
++buffer;
/*
......
......@@ -621,6 +621,10 @@ acpi_ut_add_reference (
return_VOID;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Incremented]\n",
object, object->common.reference_count));
/* Increment the reference count */
(void) acpi_ut_update_object_reference (object, REF_INCREMENT);
......@@ -664,8 +668,9 @@ acpi_ut_remove_reference (
return_VOID;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n",
object, object->common.reference_count));
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Decremented]\n",
object, object->common.reference_count));
/*
* Decrement the reference count, and only actually delete the object
......
......@@ -59,7 +59,7 @@
*
* FUNCTION: acpi_ut_short_divide
*
* PARAMETERS: in_dividend - Pointer to the dividend
* PARAMETERS: Dividend - 64-bit dividend
* Divisor - 32-bit divisor
* out_quotient - Pointer to where the quotient is returned
* out_remainder - Pointer to where the remainder is returned
......@@ -74,19 +74,18 @@
acpi_status
acpi_ut_short_divide (
acpi_integer *in_dividend,
acpi_integer dividend,
u32 divisor,
acpi_integer *out_quotient,
u32 *out_remainder)
{
union uint64_overlay dividend;
union uint64_overlay dividend_ovl;
union uint64_overlay quotient;
u32 remainder32;
ACPI_FUNCTION_TRACE ("ut_short_divide");
dividend.full = *in_dividend;
/* Always check for a zero divisor */
......@@ -95,13 +94,15 @@ acpi_ut_short_divide (
return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
}
dividend_ovl.full = dividend;
/*
* The quotient is 64 bits, the remainder is always 32 bits,
* and is generated by the second divide.
*/
ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor,
ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor,
quotient.part.hi, remainder32);
ACPI_DIV_64_BY_32 (remainder32, dividend.part.lo, divisor,
ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor,
quotient.part.lo, remainder32);
/* Return only what was requested */
......@@ -121,8 +122,8 @@ acpi_ut_short_divide (
*
* FUNCTION: acpi_ut_divide
*
* PARAMETERS: in_dividend - Pointer to the dividend
* in_divisor - Pointer to the divisor
* PARAMETERS: in_dividend - Dividend
* in_divisor - Divisor
* out_quotient - Pointer to where the quotient is returned
* out_remainder - Pointer to where the remainder is returned
*
......@@ -134,8 +135,8 @@ acpi_ut_short_divide (
acpi_status
acpi_ut_divide (
acpi_integer *in_dividend,
acpi_integer *in_divisor,
acpi_integer in_dividend,
acpi_integer in_divisor,
acpi_integer *out_quotient,
acpi_integer *out_remainder)
{
......@@ -155,13 +156,13 @@ acpi_ut_divide (
/* Always check for a zero divisor */
if (*in_divisor == 0) {
if (in_divisor == 0) {
ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
}
divisor.full = *in_divisor;
dividend.full = *in_dividend;
divisor.full = in_divisor;
dividend.full = in_dividend;
if (divisor.part.hi == 0) {
/*
* 1) Simplest case is where the divisor is 32 bits, we can
......@@ -269,7 +270,7 @@ acpi_ut_divide (
acpi_status
acpi_ut_short_divide (
acpi_integer *in_dividend,
acpi_integer in_dividend,
u32 divisor,
acpi_integer *out_quotient,
u32 *out_remainder)
......@@ -288,10 +289,10 @@ acpi_ut_short_divide (
/* Return only what was requested */
if (out_quotient) {
*out_quotient = *in_dividend / divisor;
*out_quotient = in_dividend / divisor;
}
if (out_remainder) {
*out_remainder = (u32) *in_dividend % divisor;
*out_remainder = (u32) in_dividend % divisor;
}
return_ACPI_STATUS (AE_OK);
......@@ -299,8 +300,8 @@ acpi_ut_short_divide (
acpi_status
acpi_ut_divide (
acpi_integer *in_dividend,
acpi_integer *in_divisor,
acpi_integer in_dividend,
acpi_integer in_divisor,
acpi_integer *out_quotient,
acpi_integer *out_remainder)
{
......@@ -309,7 +310,7 @@ acpi_ut_divide (
/* Always check for a zero divisor */
if (*in_divisor == 0) {
if (in_divisor == 0) {
ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
}
......@@ -318,10 +319,10 @@ acpi_ut_divide (
/* Return only what was requested */
if (out_quotient) {
*out_quotient = *in_dividend / *in_divisor;
*out_quotient = in_dividend / in_divisor;
}
if (out_remainder) {
*out_remainder = *in_dividend % *in_divisor;
*out_remainder = in_dividend % in_divisor;
}
return_ACPI_STATUS (AE_OK);
......
......@@ -356,16 +356,15 @@ acpi_ut_valid_acpi_character (
* FUNCTION: acpi_ut_strtoul64
*
* PARAMETERS: String - Null terminated string
* Terminater - Where a pointer to the terminating byte is returned
* Base - Radix of the string
* Base - Radix of the string: 10, 16, or ACPI_ANY_BASE
* ret_integer - Where the converted integer is returned
*
* RETURN: Converted value
* RETURN: Status and Converted value
*
* DESCRIPTION: Convert a string into an unsigned value.
* NOTE: Does not support Octal strings, not needed.
*
******************************************************************************/
#define NEGATIVE 1
#define POSITIVE 0
acpi_status
acpi_ut_strtoul64 (
......@@ -373,50 +372,40 @@ acpi_ut_strtoul64 (
u32 base,
acpi_integer *ret_integer)
{
u32 index;
u32 this_digit;
acpi_integer return_value = 0;
acpi_status status = AE_OK;
acpi_integer dividend;
acpi_integer quotient;
*ret_integer = 0;
ACPI_FUNCTION_TRACE ("ut_stroul64");
switch (base) {
case 0:
case 8:
case ACPI_ANY_BASE:
case 10:
case 16:
break;
default:
/*
* The specified Base parameter is not in the domain of
* this function:
*/
return (AE_BAD_PARAMETER);
/* Invalid Base */
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* skip over any white space in the buffer:
*/
/* Skip over any white space in the buffer */
while (ACPI_IS_SPACE (*string) || *string == '\t') {
++string;
}
/*
* If the input parameter Base is zero, then we need to
* determine if it is octal, decimal, or hexadecimal:
* determine if it is decimal or hexadecimal:
*/
if (base == 0) {
if (*string == '0') {
if (ACPI_TOLOWER (*(++string)) == 'x') {
base = 16;
++string;
}
else {
base = 8;
}
if ((*string == '0') &&
(ACPI_TOLOWER (*(++string)) == 'x')) {
base = 16;
++string;
}
else {
base = 10;
......@@ -424,76 +413,67 @@ acpi_ut_strtoul64 (
}
/*
* For octal and hexadecimal bases, skip over the leading
* For hexadecimal base, skip over the leading
* 0 or 0x, if they are present.
*/
if (base == 8 && *string == '0') {
string++;
}
if (base == 16 &&
*string == '0' &&
ACPI_TOLOWER (*(++string)) == 'x') {
string++;
}
/* Main loop: convert the string to an unsigned long */
/* Main loop: convert the string to a 64-bit integer */
while (*string) {
if (ACPI_IS_DIGIT (*string)) {
index = ((u8) *string) - '0';
/* Convert ASCII 0-9 to Decimal value */
this_digit = ((u8) *string) - '0';
}
else {
index = (u8) ACPI_TOUPPER (*string);
if (ACPI_IS_UPPER ((char) index)) {
index = index - 'A' + 10;
this_digit = (u8) ACPI_TOUPPER (*string);
if (ACPI_IS_UPPER ((char) this_digit)) {
/* Convert ASCII Hex char to value */
this_digit = this_digit - 'A' + 10;
}
else {
goto error_exit;
}
}
if (index >= base) {
/* Check to see if digit is out of range */
if (this_digit >= base) {
goto error_exit;
}
/* Check to see if value is out of range: */
/* Divide the digit into the correct position */
dividend = ACPI_INTEGER_MAX - (acpi_integer) index;
(void) acpi_ut_short_divide (&dividend, base, &quotient, NULL);
(void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit),
base, &quotient, NULL);
if (return_value > quotient) {
goto error_exit;
}
return_value *= base;
return_value += index;
return_value += this_digit;
++string;
}
*ret_integer = return_value;
return (status);
return_ACPI_STATUS (AE_OK);
error_exit:
switch (base) {
case 8:
status = AE_BAD_OCTAL_CONSTANT;
break;
case 10:
status = AE_BAD_DECIMAL_CONSTANT;
break;
case 16:
status = AE_BAD_HEX_CONSTANT;
break;
/* Base was set/validated above */
default:
/* Base validated above */
break;
if (base == 10) {
return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
}
else {
return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
}
return (status);
}
......
......@@ -64,7 +64,7 @@
/* Version string */
#define ACPI_CA_VERSION 0x20040924
#define ACPI_CA_VERSION 0x20041006
/*
* OS name, used for the _OS object. The _OS object is essentially obsolete,
......
......@@ -83,22 +83,20 @@ acpi_status
acpi_ex_convert_to_integer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u16 opcode);
u32 flags);
acpi_status
acpi_ex_convert_to_buffer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u16 opcode);
union acpi_operand_object **result_desc);
acpi_status
acpi_ex_convert_to_string (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u32 type,
u16 opcode);
u32 type);
/* Types for String conversion */
/* Types for ->String conversion */
#define ACPI_EXPLICIT_BYTE_COPY 0x00000000
#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001
......
......@@ -838,7 +838,11 @@ acpi_status (*acpi_init_handler) (
typedef
acpi_status (*acpi_exception_handler) (
acpi_status status);
acpi_status aml_status,
acpi_name name,
u16 opcode,
u32 aml_offset,
void *context);
/* Address Spaces (For Operation Regions) */
......
......@@ -694,14 +694,14 @@ acpi_ut_print_string (
acpi_status
acpi_ut_divide (
acpi_integer *in_dividend,
acpi_integer *in_divisor,
acpi_integer in_dividend,
acpi_integer in_divisor,
acpi_integer *out_quotient,
acpi_integer *out_remainder);
acpi_status
acpi_ut_short_divide (
acpi_integer *in_dividend,
acpi_integer in_dividend,
u32 divisor,
acpi_integer *out_quotient,
u32 *out_remainder);
......@@ -720,6 +720,10 @@ acpi_ut_strtoul64 (
u32 base,
acpi_integer *ret_integer);
/* Values for Base above (16=Hex, 10=Decimal) */
#define ACPI_ANY_BASE 0
char *
acpi_ut_strupr (
char *src_string);
......
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