Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenexoparg3.c
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * 00004 * Module Name: exoparg3 - AML execution - opcodes with 3 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 __EXOPARG3_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 ("exoparg3") 00129 00130 00131 00154 /******************************************************************************* 00155 * 00156 * FUNCTION: AcpiExOpcode_3A_0T_0R 00157 * 00158 * PARAMETERS: WalkState - Current walk state 00159 * 00160 * RETURN: Status 00161 * 00162 * DESCRIPTION: Execute Triadic operator (3 operands) 00163 * 00164 ******************************************************************************/ 00165 00166 ACPI_STATUS 00167 AcpiExOpcode_3A_0T_0R ( 00168 ACPI_WALK_STATE *WalkState) 00169 { 00170 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 00171 ACPI_SIGNAL_FATAL_INFO *Fatal; 00172 ACPI_STATUS Status = AE_OK; 00173 00174 00175 ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, 00176 AcpiPsGetOpcodeName (WalkState->Opcode)); 00177 00178 00179 switch (WalkState->Opcode) 00180 { 00181 case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ 00182 00183 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 00184 "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", 00185 (UINT32) Operand[0]->Integer.Value, 00186 (UINT32) Operand[1]->Integer.Value, 00187 (UINT32) Operand[2]->Integer.Value)); 00188 00189 Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); 00190 if (Fatal) 00191 { 00192 Fatal->Type = (UINT32) Operand[0]->Integer.Value; 00193 Fatal->Code = (UINT32) Operand[1]->Integer.Value; 00194 Fatal->Argument = (UINT32) Operand[2]->Integer.Value; 00195 } 00196 00197 /* Always signal the OS! */ 00198 00199 Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); 00200 00201 /* Might return while OS is shutting down, just continue */ 00202 00203 ACPI_FREE (Fatal); 00204 break; 00205 00206 00207 default: 00208 00209 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 00210 WalkState->Opcode)); 00211 Status = AE_AML_BAD_OPCODE; 00212 goto Cleanup; 00213 } 00214 00215 00216 Cleanup: 00217 00218 return_ACPI_STATUS (Status); 00219 } 00220 00221 00222 /******************************************************************************* 00223 * 00224 * FUNCTION: AcpiExOpcode_3A_1T_1R 00225 * 00226 * PARAMETERS: WalkState - Current walk state 00227 * 00228 * RETURN: Status 00229 * 00230 * DESCRIPTION: Execute Triadic operator (3 operands) 00231 * 00232 ******************************************************************************/ 00233 00234 ACPI_STATUS 00235 AcpiExOpcode_3A_1T_1R ( 00236 ACPI_WALK_STATE *WalkState) 00237 { 00238 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 00239 ACPI_OPERAND_OBJECT *ReturnDesc = NULL; 00240 char *Buffer = NULL; 00241 ACPI_STATUS Status = AE_OK; 00242 UINT64 Index; 00243 ACPI_SIZE Length; 00244 00245 00246 ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, 00247 AcpiPsGetOpcodeName (WalkState->Opcode)); 00248 00249 00250 switch (WalkState->Opcode) 00251 { 00252 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ 00253 00254 /* 00255 * Create the return object. The Source operand is guaranteed to be 00256 * either a String or a Buffer, so just use its type. 00257 */ 00258 ReturnDesc = AcpiUtCreateInternalObject ( 00259 (Operand[0])->Common.Type); 00260 if (!ReturnDesc) 00261 { 00262 Status = AE_NO_MEMORY; 00263 goto Cleanup; 00264 } 00265 00266 /* Get the Integer values from the objects */ 00267 00268 Index = Operand[1]->Integer.Value; 00269 Length = (ACPI_SIZE) Operand[2]->Integer.Value; 00270 00271 /* 00272 * If the index is beyond the length of the String/Buffer, or if the 00273 * requested length is zero, return a zero-length String/Buffer 00274 */ 00275 if (Index >= Operand[0]->String.Length) 00276 { 00277 Length = 0; 00278 } 00279 00280 /* Truncate request if larger than the actual String/Buffer */ 00281 00282 else if ((Index + Length) > Operand[0]->String.Length) 00283 { 00284 Length = (ACPI_SIZE) Operand[0]->String.Length - 00285 (ACPI_SIZE) Index; 00286 } 00287 00288 /* Strings always have a sub-pointer, not so for buffers */ 00289 00290 switch ((Operand[0])->Common.Type) 00291 { 00292 case ACPI_TYPE_STRING: 00293 00294 /* Always allocate a new buffer for the String */ 00295 00296 Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); 00297 if (!Buffer) 00298 { 00299 Status = AE_NO_MEMORY; 00300 goto Cleanup; 00301 } 00302 break; 00303 00304 case ACPI_TYPE_BUFFER: 00305 00306 /* If the requested length is zero, don't allocate a buffer */ 00307 00308 if (Length > 0) 00309 { 00310 /* Allocate a new buffer for the Buffer */ 00311 00312 Buffer = ACPI_ALLOCATE_ZEROED (Length); 00313 if (!Buffer) 00314 { 00315 Status = AE_NO_MEMORY; 00316 goto Cleanup; 00317 } 00318 } 00319 break; 00320 00321 default: /* Should not happen */ 00322 00323 Status = AE_AML_OPERAND_TYPE; 00324 goto Cleanup; 00325 } 00326 00327 if (Buffer) 00328 { 00329 /* We have a buffer, copy the portion requested */ 00330 00331 ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, 00332 Length); 00333 } 00334 00335 /* Set the length of the new String/Buffer */ 00336 00337 ReturnDesc->String.Pointer = Buffer; 00338 ReturnDesc->String.Length = (UINT32) Length; 00339 00340 /* Mark buffer initialized */ 00341 00342 ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; 00343 break; 00344 00345 00346 default: 00347 00348 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 00349 WalkState->Opcode)); 00350 Status = AE_AML_BAD_OPCODE; 00351 goto Cleanup; 00352 } 00353 00354 /* Store the result in the target */ 00355 00356 Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); 00357 00358 Cleanup: 00359 00360 /* Delete return object on error */ 00361 00362 if (ACPI_FAILURE (Status) || WalkState->ResultObj) 00363 { 00364 AcpiUtRemoveReference (ReturnDesc); 00365 WalkState->ResultObj = NULL; 00366 } 00367 00368 /* Set the return object and exit */ 00369 00370 else 00371 { 00372 WalkState->ResultObj = ReturnDesc; 00373 } 00374 return_ACPI_STATUS (Status); 00375 } 00376 00377 Generated on Sat May 26 2012 04:25:47 for ReactOS by
1.7.6.1
|