2 /******************************************************************************
4 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2004, R. Byron Moore
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
46 #include <acpi/acpi.h>
47 #include <acpi/acinterp.h>
48 #include <acpi/acparser.h>
49 #include <acpi/amlcode.h>
52 #define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exoparg6")
57 * Naming convention for AML interpreter execution routines.
59 * The routines that begin execution of AML opcodes are named with a common
60 * convention based upon the number of arguments, the number of target operands,
61 * and whether or not a value is returned:
63 * AcpiExOpcode_xA_yT_zR
67 * xA - ARGUMENTS: The number of arguments (input operands) that are
68 * required for this opcode type (1 through 6 args).
69 * yT - TARGETS: The number of targets (output operands) that are required
70 * for this opcode type (0, 1, or 2 targets).
71 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
72 * as the function return (0 or 1).
74 * The AcpiExOpcode* functions are called via the Dispatcher component with
75 * fully resolved operands.
79 /*******************************************************************************
81 * FUNCTION: acpi_ex_do_match
83 * PARAMETERS: match_op - The AML match operand
84 * package_value - Value from the target package
85 * match_value - Value to be matched
87 * RETURN: TRUE if the match is successful, FALSE otherwise
89 * DESCRIPTION: Implements the low-level match for the ASL Match operator
91 ******************************************************************************/
96 acpi_integer package_value,
97 acpi_integer match_value)
101 case MATCH_MTR: /* always true */
106 case MATCH_MEQ: /* true if equal */
108 if (package_value != match_value) {
114 case MATCH_MLE: /* true if less than or equal */
116 if (package_value > match_value) {
122 case MATCH_MLT: /* true if less than */
124 if (package_value >= match_value) {
130 case MATCH_MGE: /* true if greater than or equal */
132 if (package_value < match_value) {
138 case MATCH_MGT: /* true if greater than */
140 if (package_value <= match_value) {
146 default: /* undefined */
156 /*******************************************************************************
158 * FUNCTION: acpi_ex_opcode_6A_0T_1R
160 * PARAMETERS: walk_state - Current walk state
164 * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
166 ******************************************************************************/
169 acpi_ex_opcode_6A_0T_1R (
170 struct acpi_walk_state *walk_state)
172 union acpi_operand_object **operand = &walk_state->operands[0];
173 union acpi_operand_object *return_desc = NULL;
174 acpi_status status = AE_OK;
176 union acpi_operand_object *this_element;
179 ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
182 switch (walk_state->opcode) {
185 * Match (search_package[0], match_op1[1], match_object1[2],
186 * match_op2[3], match_object2[4], start_index[5])
189 /* Validate match comparison sub-opcodes */
191 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
192 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
193 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "operation encoding out of range\n"));
194 status = AE_AML_OPERAND_VALUE;
198 index = (u32) operand[5]->integer.value;
199 if (index >= (u32) operand[0]->package.count) {
200 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n"));
201 status = AE_AML_PACKAGE_LIMIT;
205 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
207 status = AE_NO_MEMORY;
212 /* Default return value if no match found */
214 return_desc->integer.value = ACPI_INTEGER_MAX;
217 * Examine each element until a match is found. Within the loop,
218 * "continue" signifies that the current element does not match
219 * and the next should be examined.
221 * Upon finding a match, the loop will terminate via "break" at
222 * the bottom. If it terminates "normally", match_value will be -1
223 * (its initial value) indicating that no match was found. When
224 * returned as a Number, this will produce the Ones value as specified.
226 for ( ; index < operand[0]->package.count; index++) {
227 this_element = operand[0]->package.elements[index];
230 * Treat any NULL or non-numeric elements as non-matching.
233 ACPI_GET_OBJECT_TYPE (this_element) != ACPI_TYPE_INTEGER) {
238 * "continue" (proceed to next iteration of enclosing
239 * "for" loop) signifies a non-match.
241 if (!acpi_ex_do_match ((u32) operand[1]->integer.value,
242 this_element->integer.value, operand[2]->integer.value)) {
246 if (!acpi_ex_do_match ((u32) operand[3]->integer.value,
247 this_element->integer.value, operand[4]->integer.value)) {
251 /* Match found: Index is the return value */
253 return_desc->integer.value = index;
260 case AML_LOAD_TABLE_OP:
262 status = acpi_ex_load_table_op (walk_state, &return_desc);
268 ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
269 walk_state->opcode));
270 status = AE_AML_BAD_OPCODE;
275 walk_state->result_obj = return_desc;
280 /* Delete return object on error */
282 if (ACPI_FAILURE (status)) {
283 acpi_ut_remove_reference (return_desc);
286 return_ACPI_STATUS (status);