exoparg6.c revision 73a3090a2160fb01317f5a44af6ee5a064a29625
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/****************************************************************************** 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Module Name: exoparg6 - AML execution - opcodes with 6 arguments 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *****************************************************************************/ 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 877848130e53b06c22fe37a7b6acbb82bb3e9bfbaBob Moore * Copyright (C) 2000 - 2012, Intel Corp. 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All rights reserved. 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or without 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modification, are permitted provided that the following conditions 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are met: 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1. Redistributions of source code must retain the above copyright 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * notice, this list of conditions, and the following disclaimer, 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * without modification. 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2. Redistributions in binary form must reproduce at minimum a disclaimer 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * substantially similar to the "NO WARRANTY" disclaimer below 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ("Disclaimer") and any redistribution must be conditioned upon 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * including a substantially similar Disclaimer requirement for further 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * binary redistribution. 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3. Neither the names of the above-listed copyright holders nor the names 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * of any contributors may be used to endorse or promote products derived 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from this software without specific prior written permission. 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alternatively, this software may be distributed under the terms of the 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License ("GPL") version 2 as published by the Free 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Software Foundation. 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NO WARRANTY 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * POSSIBILITY OF SUCH DAMAGES. 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acpi.h> 45e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "accommon.h" 46e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acinterp.h" 47e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acparser.h" 48e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "amlcode.h" 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _COMPONENT ACPI_EXECUTER 514be44fcd3bf648b782f4460fd06dfae6c42ded4bLen BrownACPI_MODULE_NAME("exoparg6") 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*! 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Naming convention for AML interpreter execution routines. 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The routines that begin execution of AML opcodes are named with a common 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * convention based upon the number of arguments, the number of target operands, 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * and whether or not a value is returned: 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * AcpiExOpcode_xA_yT_zR 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Where: 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * xA - ARGUMENTS: The number of arguments (input operands) that are 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * required for this opcode type (1 through 6 args). 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * yT - TARGETS: The number of targets (output operands) that are required 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * for this opcode type (0, 1, or 2 targets). 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * zR - RETURN VALUE: Indicates whether this opcode type returns a value 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * as the function return (0 or 1). 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The AcpiExOpcode* functions are called via the Dispatcher component with 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * fully resolved operands. 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds!*/ 7444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore/* Local prototypes */ 7544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moorestatic u8 764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ex_do_match(u32 match_op, 774be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *package_obj, 784be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *match_obj); 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ex_do_match 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: match_op - The AML match operand 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * package_obj - Object from the target package 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * match_obj - Object to be matched 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: TRUE if the match is successful, FALSE otherwise 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Implements the low-level match for the ASL Match operator. 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Package elements will be implicitly converted to the type of 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the match object (Integer/Buffer/String). 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moorestatic u8 974be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ex_do_match(u32 match_op, 984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *package_obj, 994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *match_obj) 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u8 logical_result = TRUE; 1024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Note: Since the package_obj/match_obj ordering is opposite to that of 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the standard logical operators, we have to reverse them when we call 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * do_logical_op in order to make the implicit conversion rules work 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * correctly. However, this means we have to flip the entire equation 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * also. A bit ugly perhaps, but overall, better than fussing the 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * parameters around at runtime, over and over again. 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Below, P[i] refers to the package element, M refers to the Match object. 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (match_op) { 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MTR: 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Always true */ 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MEQ: 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * True if equal: (P[i] == M) 1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Change to: (M == P[i]) 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 1284be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ex_do_logical_op(AML_LEQUAL_OP, match_obj, package_obj, 1294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &logical_result); 1304be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MLE: 1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Change to: (M >= P[i]) (M not_less than P[i]) 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1414be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 1424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, 1434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &logical_result); 1444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown logical_result = (u8) ! logical_result; 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MLT: 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * True if less than: (P[i] < M) 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Change to: (M > P[i]) 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 1574be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, 1584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown package_obj, &logical_result); 1594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MGE: 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Change to: (M <= P[i]) (M not_greater than P[i]) 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 1714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, 1724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown package_obj, &logical_result); 1734be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown logical_result = (u8) ! logical_result; 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case MATCH_MGT: 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * True if greater than: (P[i] > M) 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Change to: (M < P[i]) 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1854be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 1864be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, 1874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &logical_result); 1884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Undefined */ 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 20068aafc35161dcc9d365a32c2f9f077aedc61754dBob Moore return (logical_result); 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ex_opcode_6A_0T_1R 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: walk_state - Current walk state 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object **operand = &walk_state->operands[0]; 2184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *return_desc = NULL; 2194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status = AE_OK; 2205df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore u64 index; 2214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *this_element; 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 223b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, 2244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ps_get_opcode_name(walk_state->opcode)); 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (walk_state->opcode) { 2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case AML_MATCH_OP: 2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Match (search_pkg[0], match_op1[1], match_obj1[2], 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * match_op2[3], match_obj2[4], start_index[5]) 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Validate both Match Term Operators (MTR, MEQ, etc.) */ 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || 2364be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { 237b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, "Match operator out of range")); 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_AML_OPERAND_VALUE; 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds goto cleanup; 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Get the package start_index, validate against the package length */ 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 24444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore index = operand[5]->integer.value; 24544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore if (index >= operand[0]->package.count) { 246b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, 247f6a22b0bc417042e83117f52ab1a03696af185abBob Moore "Index (0x%8.8X%8.8X) beyond package end (0x%X)", 248b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_FORMAT_UINT64(index), 249b8e4d89357fc434618a59c1047cac72641191805Bob Moore operand[0]->package.count)); 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_AML_PACKAGE_LIMIT; 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds goto cleanup; 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Create an integer for the return value */ 2555df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore /* Default return value is ACPI_UINT64_MAX if no match found */ 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2575df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX); 2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!return_desc) { 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_NO_MEMORY; 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds goto cleanup; 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Examine each element until a match is found. Both match conditions 2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * must be satisfied for a match to occur. Within the loop, 2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "continue" signifies that the current element does not match 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * and the next should be examined. 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Upon finding a match, the loop will terminate via "break" at 27173a3090a2160fb01317f5a44af6ee5a064a29625Bob Moore * the bottom. If it terminates "normally", match_value will be 2725df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * match was found. 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2754be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown for (; index < operand[0]->package.count; index++) { 27652fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Get the current package element */ 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds this_element = operand[0]->package.elements[index]; 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Treat any uninitialized (NULL) elements as non-matching */ 2821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!this_element) { 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds continue; 2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Both match conditions must be satisfied. Execution of a continue 2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (proceed to next iteration of enclosing for loop) signifies a 2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * non-match. 2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2924be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (!acpi_ex_do_match((u32) operand[1]->integer.value, 2934be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_element, operand[2])) { 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds continue; 2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2974be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (!acpi_ex_do_match((u32) operand[3]->integer.value, 2984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_element, operand[4])) { 2991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds continue; 3001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Match found: Index is the return value */ 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_desc->integer.value = index; 3051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case AML_LOAD_TABLE_OP: 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3114be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ex_load_table_op(walk_state, &return_desc); 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 316f6a22b0bc417042e83117f52ab1a03696af185abBob Moore ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", 317b8e4d89357fc434618a59c1047cac72641191805Bob Moore walk_state->opcode)); 3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_AML_BAD_OPCODE; 3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds goto cleanup; 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3224be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown cleanup: 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Delete return object on error */ 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3264be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 3274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_remove_reference(return_desc); 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3304b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore /* Save return object on success */ 3314b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore 3324b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore else { 3334b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore walk_state->result_obj = return_desc; 3344b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore } 3354b6e16cf2bacbf328535097fa74f1494b1873c54Bob Moore 3364be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 338