Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenexoparg6.c
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * 00004 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments 00005 * 00006 *****************************************************************************/ 00007 00008 /****************************************************************************** 00009 * 00010 * 1. Copyright Notice 00011 * 00012 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00013 * All rights reserved. 00014 * 00015 * 2. License 00016 * 00017 * 2.1. This is your license from Intel Corp. under its intellectual property 00018 * rights. You may have additional license terms from the party that provided 00019 * you this software, covering your right to use that party's intellectual 00020 * property rights. 00021 * 00022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00023 * copy of the source code appearing in this file ("Covered Code") an 00024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00025 * base code distributed originally by Intel ("Original Intel Code") to copy, 00026 * make derivatives, distribute, use and display any portion of the Covered 00027 * Code in any form, with the right to sublicense such rights; and 00028 * 00029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00030 * license (with the right to sublicense), under only those claims of Intel 00031 * patents that are infringed by the Original Intel Code, to make, use, sell, 00032 * offer to sell, and import the Covered Code and derivative works thereof 00033 * solely to the minimum extent necessary to exercise the above copyright 00034 * license, and in no event shall the patent license extend to any additions 00035 * to or modifications of the Original Intel Code. No other license or right 00036 * is granted directly or by implication, estoppel or otherwise; 00037 * 00038 * The above copyright and patent license is granted only if the following 00039 * conditions are met: 00040 * 00041 * 3. Conditions 00042 * 00043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00044 * Redistribution of source code of any substantial portion of the Covered 00045 * Code or modification with rights to further distribute source must include 00046 * the above Copyright Notice, the above License, this list of Conditions, 00047 * and the following Disclaimer and Export Compliance provision. In addition, 00048 * Licensee must cause all Covered Code to which Licensee contributes to 00049 * contain a file documenting the changes Licensee made to create that Covered 00050 * Code and the date of any change. Licensee must include in that file the 00051 * documentation of any changes made by any predecessor Licensee. Licensee 00052 * must include a prominent statement that the modification is derived, 00053 * directly or indirectly, from Original Intel Code. 00054 * 00055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00056 * Redistribution of source code of any substantial portion of the Covered 00057 * Code or modification without rights to further distribute source must 00058 * include the following Disclaimer and Export Compliance provision in the 00059 * documentation and/or other materials provided with distribution. In 00060 * addition, Licensee may not authorize further sublicense of source of any 00061 * portion of the Covered Code, and must include terms to the effect that the 00062 * license from Licensee to its licensee is limited to the intellectual 00063 * property embodied in the software Licensee provides to its licensee, and 00064 * not to intellectual property embodied in modifications its licensee may 00065 * make. 00066 * 00067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00068 * substantial portion of the Covered Code or modification must reproduce the 00069 * above Copyright Notice, and the following Disclaimer and Export Compliance 00070 * provision in the documentation and/or other materials provided with the 00071 * distribution. 00072 * 00073 * 3.4. Intel retains all right, title, and interest in and to the Original 00074 * Intel Code. 00075 * 00076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00077 * Intel shall be used in advertising or otherwise to promote the sale, use or 00078 * other dealings in products derived from or relating to the Covered Code 00079 * without prior written authorization from Intel. 00080 * 00081 * 4. Disclaimer and Export Compliance 00082 * 00083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00087 00088 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00089 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00090 * PARTICULAR PURPOSE. 00091 * 00092 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00093 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00094 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00095 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00096 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00097 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00098 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00099 * LIMITED REMEDY. 00100 * 00101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00102 * software or system incorporating such software without first obtaining any 00103 * required license or other approval from the U. S. Department of Commerce or 00104 * any other agency or department of the United States Government. In the 00105 * event Licensee exports any such software from the United States or 00106 * re-exports any such software from a foreign destination, Licensee shall 00107 * ensure that the distribution and export/re-export of the software is in 00108 * compliance with all laws, regulations, orders, or other restrictions of the 00109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00110 * any of its subsidiaries will export/re-export any technical data, process, 00111 * software, or service, directly or indirectly, to any country for which the 00112 * United States government or any agency thereof requires an export license, 00113 * other governmental approval, or letter of assurance, without first obtaining 00114 * such license, approval or letter. 00115 * 00116 *****************************************************************************/ 00117 00118 #define __EXOPARG6_C__ 00119 00120 #include "acpi.h" 00121 #include "accommon.h" 00122 #include "acinterp.h" 00123 #include "acparser.h" 00124 #include "amlcode.h" 00125 00126 00127 #define _COMPONENT ACPI_EXECUTER 00128 ACPI_MODULE_NAME ("exoparg6") 00129 00130 00131 00153 /* Local prototypes */ 00154 00155 static BOOLEAN 00156 AcpiExDoMatch ( 00157 UINT32 MatchOp, 00158 ACPI_OPERAND_OBJECT *PackageObj, 00159 ACPI_OPERAND_OBJECT *MatchObj); 00160 00161 00162 /******************************************************************************* 00163 * 00164 * FUNCTION: AcpiExDoMatch 00165 * 00166 * PARAMETERS: MatchOp - The AML match operand 00167 * PackageObj - Object from the target package 00168 * MatchObj - Object to be matched 00169 * 00170 * RETURN: TRUE if the match is successful, FALSE otherwise 00171 * 00172 * DESCRIPTION: Implements the low-level match for the ASL Match operator. 00173 * Package elements will be implicitly converted to the type of 00174 * the match object (Integer/Buffer/String). 00175 * 00176 ******************************************************************************/ 00177 00178 static BOOLEAN 00179 AcpiExDoMatch ( 00180 UINT32 MatchOp, 00181 ACPI_OPERAND_OBJECT *PackageObj, 00182 ACPI_OPERAND_OBJECT *MatchObj) 00183 { 00184 BOOLEAN LogicalResult = TRUE; 00185 ACPI_STATUS Status; 00186 00187 00188 /* 00189 * Note: Since the PackageObj/MatchObj ordering is opposite to that of 00190 * the standard logical operators, we have to reverse them when we call 00191 * DoLogicalOp in order to make the implicit conversion rules work 00192 * correctly. However, this means we have to flip the entire equation 00193 * also. A bit ugly perhaps, but overall, better than fussing the 00194 * parameters around at runtime, over and over again. 00195 * 00196 * Below, P[i] refers to the package element, M refers to the Match object. 00197 */ 00198 switch (MatchOp) 00199 { 00200 case MATCH_MTR: 00201 00202 /* Always true */ 00203 00204 break; 00205 00206 case MATCH_MEQ: 00207 00208 /* 00209 * True if equal: (P[i] == M) 00210 * Change to: (M == P[i]) 00211 */ 00212 Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, 00213 &LogicalResult); 00214 if (ACPI_FAILURE (Status)) 00215 { 00216 return (FALSE); 00217 } 00218 break; 00219 00220 case MATCH_MLE: 00221 00222 /* 00223 * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) 00224 * Change to: (M >= P[i]) (M NotLess than P[i]) 00225 */ 00226 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, 00227 &LogicalResult); 00228 if (ACPI_FAILURE (Status)) 00229 { 00230 return (FALSE); 00231 } 00232 LogicalResult = (BOOLEAN) !LogicalResult; 00233 break; 00234 00235 case MATCH_MLT: 00236 00237 /* 00238 * True if less than: (P[i] < M) 00239 * Change to: (M > P[i]) 00240 */ 00241 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, 00242 &LogicalResult); 00243 if (ACPI_FAILURE (Status)) 00244 { 00245 return (FALSE); 00246 } 00247 break; 00248 00249 case MATCH_MGE: 00250 00251 /* 00252 * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) 00253 * Change to: (M <= P[i]) (M NotGreater than P[i]) 00254 */ 00255 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, 00256 &LogicalResult); 00257 if (ACPI_FAILURE (Status)) 00258 { 00259 return (FALSE); 00260 } 00261 LogicalResult = (BOOLEAN)!LogicalResult; 00262 break; 00263 00264 case MATCH_MGT: 00265 00266 /* 00267 * True if greater than: (P[i] > M) 00268 * Change to: (M < P[i]) 00269 */ 00270 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, 00271 &LogicalResult); 00272 if (ACPI_FAILURE (Status)) 00273 { 00274 return (FALSE); 00275 } 00276 break; 00277 00278 default: 00279 00280 /* Undefined */ 00281 00282 return (FALSE); 00283 } 00284 00285 return LogicalResult; 00286 } 00287 00288 00289 /******************************************************************************* 00290 * 00291 * FUNCTION: AcpiExOpcode_6A_0T_1R 00292 * 00293 * PARAMETERS: WalkState - Current walk state 00294 * 00295 * RETURN: Status 00296 * 00297 * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value 00298 * 00299 ******************************************************************************/ 00300 00301 ACPI_STATUS 00302 AcpiExOpcode_6A_0T_1R ( 00303 ACPI_WALK_STATE *WalkState) 00304 { 00305 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 00306 ACPI_OPERAND_OBJECT *ReturnDesc = NULL; 00307 ACPI_STATUS Status = AE_OK; 00308 UINT64 Index; 00309 ACPI_OPERAND_OBJECT *ThisElement; 00310 00311 00312 ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, 00313 AcpiPsGetOpcodeName (WalkState->Opcode)); 00314 00315 00316 switch (WalkState->Opcode) 00317 { 00318 case AML_MATCH_OP: 00319 /* 00320 * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], 00321 * MatchOp2[3], MatchObj2[4], StartIndex[5]) 00322 */ 00323 00324 /* Validate both Match Term Operators (MTR, MEQ, etc.) */ 00325 00326 if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || 00327 (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) 00328 { 00329 ACPI_ERROR ((AE_INFO, "Match operator out of range")); 00330 Status = AE_AML_OPERAND_VALUE; 00331 goto Cleanup; 00332 } 00333 00334 /* Get the package StartIndex, validate against the package length */ 00335 00336 Index = Operand[5]->Integer.Value; 00337 if (Index >= Operand[0]->Package.Count) 00338 { 00339 ACPI_ERROR ((AE_INFO, 00340 "Index (0x%8.8X%8.8X) beyond package end (0x%X)", 00341 ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); 00342 Status = AE_AML_PACKAGE_LIMIT; 00343 goto Cleanup; 00344 } 00345 00346 /* Create an integer for the return value */ 00347 /* Default return value is ACPI_UINT64_MAX if no match found */ 00348 00349 ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX); 00350 if (!ReturnDesc) 00351 { 00352 Status = AE_NO_MEMORY; 00353 goto Cleanup; 00354 00355 } 00356 00357 /* 00358 * Examine each element until a match is found. Both match conditions 00359 * must be satisfied for a match to occur. Within the loop, 00360 * "continue" signifies that the current element does not match 00361 * and the next should be examined. 00362 * 00363 * Upon finding a match, the loop will terminate via "break" at 00364 * the bottom. If it terminates "normally", MatchValue will be 00365 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no 00366 * match was found. 00367 */ 00368 for ( ; Index < Operand[0]->Package.Count; Index++) 00369 { 00370 /* Get the current package element */ 00371 00372 ThisElement = Operand[0]->Package.Elements[Index]; 00373 00374 /* Treat any uninitialized (NULL) elements as non-matching */ 00375 00376 if (!ThisElement) 00377 { 00378 continue; 00379 } 00380 00381 /* 00382 * Both match conditions must be satisfied. Execution of a continue 00383 * (proceed to next iteration of enclosing for loop) signifies a 00384 * non-match. 00385 */ 00386 if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, 00387 ThisElement, Operand[2])) 00388 { 00389 continue; 00390 } 00391 00392 if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, 00393 ThisElement, Operand[4])) 00394 { 00395 continue; 00396 } 00397 00398 /* Match found: Index is the return value */ 00399 00400 ReturnDesc->Integer.Value = Index; 00401 break; 00402 } 00403 break; 00404 00405 00406 case AML_LOAD_TABLE_OP: 00407 00408 Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); 00409 break; 00410 00411 00412 default: 00413 00414 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 00415 WalkState->Opcode)); 00416 Status = AE_AML_BAD_OPCODE; 00417 goto Cleanup; 00418 } 00419 00420 00421 Cleanup: 00422 00423 /* Delete return object on error */ 00424 00425 if (ACPI_FAILURE (Status)) 00426 { 00427 AcpiUtRemoveReference (ReturnDesc); 00428 } 00429 00430 /* Save return object on success */ 00431 00432 else 00433 { 00434 WalkState->ResultObj = ReturnDesc; 00435 } 00436 00437 return_ACPI_STATUS (Status); 00438 } Generated on Sat May 26 2012 04:25:47 for ReactOS by
1.7.6.1
|