X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Fexecuter%2Fexoparg6.c;h=f0c0ba6eb408999f0a66b4ca3b46b9f3697a8a55;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=c9020af1cf533f9e0024e0428faeff5d676e42ce;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c index c9020af1c..f0c0ba6eb 100644 --- a/drivers/acpi/executer/exoparg6.c +++ b/drivers/acpi/executer/exoparg6.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2004, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,16 +42,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg6") - +ACPI_MODULE_NAME("exoparg6") /*! * Naming convention for AML interpreter execution routines. @@ -74,85 +71,135 @@ * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ - +/* Local prototypes */ +static u8 +acpi_ex_do_match(u32 match_op, + union acpi_operand_object *package_obj, + union acpi_operand_object *match_obj); /******************************************************************************* * * FUNCTION: acpi_ex_do_match * * PARAMETERS: match_op - The AML match operand - * package_value - Value from the target package - * match_value - Value to be matched + * package_obj - Object from the target package + * match_obj - Object to be matched * * RETURN: TRUE if the match is successful, FALSE otherwise * - * DESCRIPTION: Implements the low-level match for the ASL Match operator + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). * ******************************************************************************/ -u8 -acpi_ex_do_match ( - u32 match_op, - acpi_integer package_value, - acpi_integer match_value) +static u8 +acpi_ex_do_match(u32 match_op, + union acpi_operand_object *package_obj, + union acpi_operand_object *match_obj) { - + u8 logical_result = TRUE; + acpi_status status; + + /* + * Note: Since the package_obj/match_obj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * do_logical_op in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ switch (match_op) { - case MATCH_MTR: /* always true */ + case MATCH_MTR: - break; + /* Always true */ + break; - case MATCH_MEQ: /* true if equal */ + case MATCH_MEQ: - if (package_value != match_value) { + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + status = + acpi_ex_do_logical_op(AML_LEQUAL_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; + case MATCH_MLE: - case MATCH_MLE: /* true if less than or equal */ - - if (package_value > match_value) { + /* + * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) + * Change to: (M >= P[i]) (M not_less than P[i]) + */ + status = + acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } + logical_result = (u8) ! logical_result; break; + case MATCH_MLT: - case MATCH_MLT: /* true if less than */ - - if (package_value >= match_value) { + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + status = + acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, + package_obj, &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; + case MATCH_MGE: - case MATCH_MGE: /* true if greater than or equal */ - - if (package_value < match_value) { + /* + * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) + * Change to: (M <= P[i]) (M not_greater than P[i]) + */ + status = + acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, + package_obj, &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } + logical_result = (u8) ! logical_result; break; + case MATCH_MGT: - case MATCH_MGT: /* true if greater than */ - - if (package_value <= match_value) { + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + status = + acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; + default: - default: /* undefined */ + /* Undefined */ return (FALSE); } - - return TRUE; + return logical_result; } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_6A_0T_1R @@ -165,44 +212,48 @@ acpi_ex_do_match ( * ******************************************************************************/ -acpi_status -acpi_ex_opcode_6A_0T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - acpi_status status = AE_OK; - u32 index; - union acpi_operand_object *this_element; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + acpi_status status = AE_OK; + acpi_integer index; + union acpi_operand_object *this_element; + ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, + acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { case AML_MATCH_OP: /* - * Match (search_package[0], match_op1[1], match_object1[2], - * match_op2[3], match_object2[4], start_index[5]) + * Match (search_pkg[0], match_op1[1], match_obj1[2], + * match_op2[3], match_obj2[4], start_index[5]) */ - /* Validate match comparison sub-opcodes */ + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || - (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "operation encoding out of range\n")); + (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { + ACPI_ERROR((AE_INFO, "Match operator out of range")); status = AE_AML_OPERAND_VALUE; goto cleanup; } - index = (u32) operand[5]->integer.value; - if (index >= (u32) operand[0]->package.count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n")); + /* Get the package start_index, validate against the package length */ + + index = operand[5]->integer.value; + if (index >= operand[0]->package.count) { + ACPI_ERROR((AE_INFO, + "Index (%X%8.8X) beyond package end (%X)", + ACPI_FORMAT_UINT64(index), + operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + /* Create an integer for the return value */ + + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -214,37 +265,40 @@ acpi_ex_opcode_6A_0T_1R ( return_desc->integer.value = ACPI_INTEGER_MAX; /* - * Examine each element until a match is found. Within the loop, + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, * "continue" signifies that the current element does not match * and the next should be examined. * * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", match_value will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. + * the bottom. If it terminates "normally", match_value will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. */ - for ( ; index < operand[0]->package.count; index++) { + for (; index < operand[0]->package.count; index++) { + + /* Get the current package element */ + this_element = operand[0]->package.elements[index]; - /* - * Treat any NULL or non-numeric elements as non-matching. - */ - if (!this_element || - ACPI_GET_OBJECT_TYPE (this_element) != ACPI_TYPE_INTEGER) { + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!this_element) { continue; } /* - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. */ - if (!acpi_ex_do_match ((u32) operand[1]->integer.value, - this_element->integer.value, operand[2]->integer.value)) { + if (!acpi_ex_do_match((u32) operand[1]->integer.value, + this_element, operand[2])) { continue; } - if (!acpi_ex_do_match ((u32) operand[3]->integer.value, - this_element->integer.value, operand[4]->integer.value)) { + if (!acpi_ex_do_match((u32) operand[3]->integer.value, + this_element, operand[4])) { continue; } @@ -253,35 +307,30 @@ acpi_ex_opcode_6A_0T_1R ( return_desc->integer.value = index; break; } - break; - case AML_LOAD_TABLE_OP: - status = acpi_ex_load_table_op (walk_state, &return_desc); + status = acpi_ex_load_table_op(walk_state, &return_desc); break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } - walk_state->result_obj = return_desc; - -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); }