|
||||
Warning, cross-references for /kernel/drivers/acpica/exoparg6.c need to be fixed.
0001 0002 /****************************************************************************** 0003 * 0004 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments 0005 * 0006 *****************************************************************************/ 0007 0008 /****************************************************************************** 0009 * 0010 * 1. Copyright Notice 0011 * 0012 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0013 * All rights reserved. 0014 * 0015 * 2. License 0016 * 0017 * 2.1. This is your license from Intel Corp. under its intellectual property 0018 * rights. You may have additional license terms from the party that provided 0019 * you this software, covering your right to use that party's intellectual 0020 * property rights. 0021 * 0022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0023 * copy of the source code appearing in this file ("Covered Code") an 0024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0025 * base code distributed originally by Intel ("Original Intel Code") to copy, 0026 * make derivatives, distribute, use and display any portion of the Covered 0027 * Code in any form, with the right to sublicense such rights; and 0028 * 0029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0030 * license (with the right to sublicense), under only those claims of Intel 0031 * patents that are infringed by the Original Intel Code, to make, use, sell, 0032 * offer to sell, and import the Covered Code and derivative works thereof 0033 * solely to the minimum extent necessary to exercise the above copyright 0034 * license, and in no event shall the patent license extend to any additions 0035 * to or modifications of the Original Intel Code. No other license or right 0036 * is granted directly or by implication, estoppel or otherwise; 0037 * 0038 * The above copyright and patent license is granted only if the following 0039 * conditions are met: 0040 * 0041 * 3. Conditions 0042 * 0043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0044 * Redistribution of source code of any substantial portion of the Covered 0045 * Code or modification with rights to further distribute source must include 0046 * the above Copyright Notice, the above License, this list of Conditions, 0047 * and the following Disclaimer and Export Compliance provision. In addition, 0048 * Licensee must cause all Covered Code to which Licensee contributes to 0049 * contain a file documenting the changes Licensee made to create that Covered 0050 * Code and the date of any change. Licensee must include in that file the 0051 * documentation of any changes made by any predecessor Licensee. Licensee 0052 * must include a prominent statement that the modification is derived, 0053 * directly or indirectly, from Original Intel Code. 0054 * 0055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0056 * Redistribution of source code of any substantial portion of the Covered 0057 * Code or modification without rights to further distribute source must 0058 * include the following Disclaimer and Export Compliance provision in the 0059 * documentation and/or other materials provided with distribution. In 0060 * addition, Licensee may not authorize further sublicense of source of any 0061 * portion of the Covered Code, and must include terms to the effect that the 0062 * license from Licensee to its licensee is limited to the intellectual 0063 * property embodied in the software Licensee provides to its licensee, and 0064 * not to intellectual property embodied in modifications its licensee may 0065 * make. 0066 * 0067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0068 * substantial portion of the Covered Code or modification must reproduce the 0069 * above Copyright Notice, and the following Disclaimer and Export Compliance 0070 * provision in the documentation and/or other materials provided with the 0071 * distribution. 0072 * 0073 * 3.4. Intel retains all right, title, and interest in and to the Original 0074 * Intel Code. 0075 * 0076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0077 * Intel shall be used in advertising or otherwise to promote the sale, use or 0078 * other dealings in products derived from or relating to the Covered Code 0079 * without prior written authorization from Intel. 0080 * 0081 * 4. Disclaimer and Export Compliance 0082 * 0083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0087 0088 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0089 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0090 * PARTICULAR PURPOSE. 0091 * 0092 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0093 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0094 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0095 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0096 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0097 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0098 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0099 * LIMITED REMEDY. 0100 * 0101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0102 * software or system incorporating such software without first obtaining any 0103 * required license or other approval from the U. S. Department of Commerce or 0104 * any other agency or department of the United States Government. In the 0105 * event Licensee exports any such software from the United States or 0106 * re-exports any such software from a foreign destination, Licensee shall 0107 * ensure that the distribution and export/re-export of the software is in 0108 * compliance with all laws, regulations, orders, or other restrictions of the 0109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0110 * any of its subsidiaries will export/re-export any technical data, process, 0111 * software, or service, directly or indirectly, to any country for which the 0112 * United States government or any agency thereof requires an export license, 0113 * other governmental approval, or letter of assurance, without first obtaining 0114 * such license, approval or letter. 0115 * 0116 *****************************************************************************/ 0117 0118 #define __EXOPARG6_C__ 0119 0120 #include "acpi.h" 0121 #include "accommon.h" 0122 #include "acinterp.h" 0123 #include "acparser.h" 0124 #include "amlcode.h" 0125 0126 0127 #define _COMPONENT ACPI_EXECUTER 0128 ACPI_MODULE_NAME ("exoparg6") 0129 0130 0131 /*! 0132 * Naming convention for AML interpreter execution routines. 0133 * 0134 * The routines that begin execution of AML opcodes are named with a common 0135 * convention based upon the number of arguments, the number of target operands, 0136 * and whether or not a value is returned: 0137 * 0138 * AcpiExOpcode_xA_yT_zR 0139 * 0140 * Where: 0141 * 0142 * xA - ARGUMENTS: The number of arguments (input operands) that are 0143 * required for this opcode type (1 through 6 args). 0144 * yT - TARGETS: The number of targets (output operands) that are required 0145 * for this opcode type (0, 1, or 2 targets). 0146 * zR - RETURN VALUE: Indicates whether this opcode type returns a value 0147 * as the function return (0 or 1). 0148 * 0149 * The AcpiExOpcode* functions are called via the Dispatcher component with 0150 * fully resolved operands. 0151 !*/ 0152 0153 /* Local prototypes */ 0154 0155 static BOOLEAN 0156 AcpiExDoMatch ( 0157 UINT32 MatchOp, 0158 ACPI_OPERAND_OBJECT *PackageObj, 0159 ACPI_OPERAND_OBJECT *MatchObj); 0160 0161 0162 /******************************************************************************* 0163 * 0164 * FUNCTION: AcpiExDoMatch 0165 * 0166 * PARAMETERS: MatchOp - The AML match operand 0167 * PackageObj - Object from the target package 0168 * MatchObj - Object to be matched 0169 * 0170 * RETURN: TRUE if the match is successful, FALSE otherwise 0171 * 0172 * DESCRIPTION: Implements the low-level match for the ASL Match operator. 0173 * Package elements will be implicitly converted to the type of 0174 * the match object (Integer/Buffer/String). 0175 * 0176 ******************************************************************************/ 0177 0178 static BOOLEAN 0179 AcpiExDoMatch ( 0180 UINT32 MatchOp, 0181 ACPI_OPERAND_OBJECT *PackageObj, 0182 ACPI_OPERAND_OBJECT *MatchObj) 0183 { 0184 BOOLEAN LogicalResult = TRUE; 0185 ACPI_STATUS Status; 0186 0187 0188 /* 0189 * Note: Since the PackageObj/MatchObj ordering is opposite to that of 0190 * the standard logical operators, we have to reverse them when we call 0191 * DoLogicalOp in order to make the implicit conversion rules work 0192 * correctly. However, this means we have to flip the entire equation 0193 * also. A bit ugly perhaps, but overall, better than fussing the 0194 * parameters around at runtime, over and over again. 0195 * 0196 * Below, P[i] refers to the package element, M refers to the Match object. 0197 */ 0198 switch (MatchOp) 0199 { 0200 case MATCH_MTR: 0201 0202 /* Always true */ 0203 0204 break; 0205 0206 case MATCH_MEQ: 0207 0208 /* 0209 * True if equal: (P[i] == M) 0210 * Change to: (M == P[i]) 0211 */ 0212 Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, 0213 &LogicalResult); 0214 if (ACPI_FAILURE (Status)) 0215 { 0216 return (FALSE); 0217 } 0218 break; 0219 0220 case MATCH_MLE: 0221 0222 /* 0223 * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) 0224 * Change to: (M >= P[i]) (M NotLess than P[i]) 0225 */ 0226 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, 0227 &LogicalResult); 0228 if (ACPI_FAILURE (Status)) 0229 { 0230 return (FALSE); 0231 } 0232 LogicalResult = (BOOLEAN) !LogicalResult; 0233 break; 0234 0235 case MATCH_MLT: 0236 0237 /* 0238 * True if less than: (P[i] < M) 0239 * Change to: (M > P[i]) 0240 */ 0241 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, 0242 &LogicalResult); 0243 if (ACPI_FAILURE (Status)) 0244 { 0245 return (FALSE); 0246 } 0247 break; 0248 0249 case MATCH_MGE: 0250 0251 /* 0252 * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) 0253 * Change to: (M <= P[i]) (M NotGreater than P[i]) 0254 */ 0255 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, 0256 &LogicalResult); 0257 if (ACPI_FAILURE (Status)) 0258 { 0259 return (FALSE); 0260 } 0261 LogicalResult = (BOOLEAN)!LogicalResult; 0262 break; 0263 0264 case MATCH_MGT: 0265 0266 /* 0267 * True if greater than: (P[i] > M) 0268 * Change to: (M < P[i]) 0269 */ 0270 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, 0271 &LogicalResult); 0272 if (ACPI_FAILURE (Status)) 0273 { 0274 return (FALSE); 0275 } 0276 break; 0277 0278 default: 0279 0280 /* Undefined */ 0281 0282 return (FALSE); 0283 } 0284 0285 return LogicalResult; 0286 } 0287 0288 0289 /******************************************************************************* 0290 * 0291 * FUNCTION: AcpiExOpcode_6A_0T_1R 0292 * 0293 * PARAMETERS: WalkState - Current walk state 0294 * 0295 * RETURN: Status 0296 * 0297 * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value 0298 * 0299 ******************************************************************************/ 0300 0301 ACPI_STATUS 0302 AcpiExOpcode_6A_0T_1R ( 0303 ACPI_WALK_STATE *WalkState) 0304 { 0305 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 0306 ACPI_OPERAND_OBJECT *ReturnDesc = NULL; 0307 ACPI_STATUS Status = AE_OK; 0308 ACPI_INTEGER Index; 0309 ACPI_OPERAND_OBJECT *ThisElement; 0310 0311 0312 ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, 0313 AcpiPsGetOpcodeName (WalkState->Opcode)); 0314 0315 0316 switch (WalkState->Opcode) 0317 { 0318 case AML_MATCH_OP: 0319 /* 0320 * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], 0321 * MatchOp2[3], MatchObj2[4], StartIndex[5]) 0322 */ 0323 0324 /* Validate both Match Term Operators (MTR, MEQ, etc.) */ 0325 0326 if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || 0327 (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) 0328 { 0329 ACPI_ERROR ((AE_INFO, "Match operator out of range")); 0330 Status = AE_AML_OPERAND_VALUE; 0331 goto Cleanup; 0332 } 0333 0334 /* Get the package StartIndex, validate against the package length */ 0335 0336 Index = Operand[5]->Integer.Value; 0337 if (Index >= Operand[0]->Package.Count) 0338 { 0339 ACPI_ERROR ((AE_INFO, 0340 "Index (%X%8.8X) beyond package end (%X)", 0341 ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); 0342 Status = AE_AML_PACKAGE_LIMIT; 0343 goto Cleanup; 0344 } 0345 0346 /* Create an integer for the return value */ 0347 0348 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 0349 if (!ReturnDesc) 0350 { 0351 Status = AE_NO_MEMORY; 0352 goto Cleanup; 0353 0354 } 0355 0356 /* Default return value if no match found */ 0357 0358 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; 0359 0360 /* 0361 * Examine each element until a match is found. Both match conditions 0362 * must be satisfied for a match to occur. Within the loop, 0363 * "continue" signifies that the current element does not match 0364 * and the next should be examined. 0365 * 0366 * Upon finding a match, the loop will terminate via "break" at 0367 * the bottom. If it terminates "normally", MatchValue will be 0368 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no 0369 * match was found. 0370 */ 0371 for ( ; Index < Operand[0]->Package.Count; Index++) 0372 { 0373 /* Get the current package element */ 0374 0375 ThisElement = Operand[0]->Package.Elements[Index]; 0376 0377 /* Treat any uninitialized (NULL) elements as non-matching */ 0378 0379 if (!ThisElement) 0380 { 0381 continue; 0382 } 0383 0384 /* 0385 * Both match conditions must be satisfied. Execution of a continue 0386 * (proceed to next iteration of enclosing for loop) signifies a 0387 * non-match. 0388 */ 0389 if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, 0390 ThisElement, Operand[2])) 0391 { 0392 continue; 0393 } 0394 0395 if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, 0396 ThisElement, Operand[4])) 0397 { 0398 continue; 0399 } 0400 0401 /* Match found: Index is the return value */ 0402 0403 ReturnDesc->Integer.Value = Index; 0404 break; 0405 } 0406 break; 0407 0408 0409 case AML_LOAD_TABLE_OP: 0410 0411 Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); 0412 break; 0413 0414 0415 default: 0416 0417 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", 0418 WalkState->Opcode)); 0419 Status = AE_AML_BAD_OPCODE; 0420 goto Cleanup; 0421 } 0422 0423 0424 Cleanup: 0425 0426 /* Delete return object on error */ 0427 0428 if (ACPI_FAILURE (Status)) 0429 { 0430 AcpiUtRemoveReference (ReturnDesc); 0431 } 0432 0433 /* Save return object on success */ 0434 0435 else 0436 { 0437 WalkState->ResultObj = ReturnDesc; 0438 } 0439 0440 return_ACPI_STATUS (Status); 0441 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |