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