Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenexstoren.c
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * 00004 * Module Name: exstoren - AML Interpreter object store support, 00005 * Store to Node (namespace object) 00006 * 00007 *****************************************************************************/ 00008 00009 /****************************************************************************** 00010 * 00011 * 1. Copyright Notice 00012 * 00013 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00014 * All rights reserved. 00015 * 00016 * 2. License 00017 * 00018 * 2.1. This is your license from Intel Corp. under its intellectual property 00019 * rights. You may have additional license terms from the party that provided 00020 * you this software, covering your right to use that party's intellectual 00021 * property rights. 00022 * 00023 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00024 * copy of the source code appearing in this file ("Covered Code") an 00025 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00026 * base code distributed originally by Intel ("Original Intel Code") to copy, 00027 * make derivatives, distribute, use and display any portion of the Covered 00028 * Code in any form, with the right to sublicense such rights; and 00029 * 00030 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00031 * license (with the right to sublicense), under only those claims of Intel 00032 * patents that are infringed by the Original Intel Code, to make, use, sell, 00033 * offer to sell, and import the Covered Code and derivative works thereof 00034 * solely to the minimum extent necessary to exercise the above copyright 00035 * license, and in no event shall the patent license extend to any additions 00036 * to or modifications of the Original Intel Code. No other license or right 00037 * is granted directly or by implication, estoppel or otherwise; 00038 * 00039 * The above copyright and patent license is granted only if the following 00040 * conditions are met: 00041 * 00042 * 3. Conditions 00043 * 00044 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00045 * Redistribution of source code of any substantial portion of the Covered 00046 * Code or modification with rights to further distribute source must include 00047 * the above Copyright Notice, the above License, this list of Conditions, 00048 * and the following Disclaimer and Export Compliance provision. In addition, 00049 * Licensee must cause all Covered Code to which Licensee contributes to 00050 * contain a file documenting the changes Licensee made to create that Covered 00051 * Code and the date of any change. Licensee must include in that file the 00052 * documentation of any changes made by any predecessor Licensee. Licensee 00053 * must include a prominent statement that the modification is derived, 00054 * directly or indirectly, from Original Intel Code. 00055 * 00056 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00057 * Redistribution of source code of any substantial portion of the Covered 00058 * Code or modification without rights to further distribute source must 00059 * include the following Disclaimer and Export Compliance provision in the 00060 * documentation and/or other materials provided with distribution. In 00061 * addition, Licensee may not authorize further sublicense of source of any 00062 * portion of the Covered Code, and must include terms to the effect that the 00063 * license from Licensee to its licensee is limited to the intellectual 00064 * property embodied in the software Licensee provides to its licensee, and 00065 * not to intellectual property embodied in modifications its licensee may 00066 * make. 00067 * 00068 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00069 * substantial portion of the Covered Code or modification must reproduce the 00070 * above Copyright Notice, and the following Disclaimer and Export Compliance 00071 * provision in the documentation and/or other materials provided with the 00072 * distribution. 00073 * 00074 * 3.4. Intel retains all right, title, and interest in and to the Original 00075 * Intel Code. 00076 * 00077 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00078 * Intel shall be used in advertising or otherwise to promote the sale, use or 00079 * other dealings in products derived from or relating to the Covered Code 00080 * without prior written authorization from Intel. 00081 * 00082 * 4. Disclaimer and Export Compliance 00083 * 00084 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00085 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00086 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00087 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 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 __EXSTOREN_C__ 00119 00120 #include "acpi.h" 00121 #include "accommon.h" 00122 #include "acinterp.h" 00123 #include "amlcode.h" 00124 00125 00126 #define _COMPONENT ACPI_EXECUTER 00127 ACPI_MODULE_NAME ("exstoren") 00128 00129 00130 /******************************************************************************* 00131 * 00132 * FUNCTION: AcpiExResolveObject 00133 * 00134 * PARAMETERS: SourceDescPtr - Pointer to the source object 00135 * TargetType - Current type of the target 00136 * WalkState - Current walk state 00137 * 00138 * RETURN: Status, resolved object in SourceDescPtr. 00139 * 00140 * DESCRIPTION: Resolve an object. If the object is a reference, dereference 00141 * it and return the actual object in the SourceDescPtr. 00142 * 00143 ******************************************************************************/ 00144 00145 ACPI_STATUS 00146 AcpiExResolveObject ( 00147 ACPI_OPERAND_OBJECT **SourceDescPtr, 00148 ACPI_OBJECT_TYPE TargetType, 00149 ACPI_WALK_STATE *WalkState) 00150 { 00151 ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; 00152 ACPI_STATUS Status = AE_OK; 00153 00154 00155 ACPI_FUNCTION_TRACE (ExResolveObject); 00156 00157 00158 /* Ensure we have a Target that can be stored to */ 00159 00160 switch (TargetType) 00161 { 00162 case ACPI_TYPE_BUFFER_FIELD: 00163 case ACPI_TYPE_LOCAL_REGION_FIELD: 00164 case ACPI_TYPE_LOCAL_BANK_FIELD: 00165 case ACPI_TYPE_LOCAL_INDEX_FIELD: 00166 /* 00167 * These cases all require only Integers or values that 00168 * can be converted to Integers (Strings or Buffers) 00169 */ 00170 00171 case ACPI_TYPE_INTEGER: 00172 case ACPI_TYPE_STRING: 00173 case ACPI_TYPE_BUFFER: 00174 00175 /* 00176 * Stores into a Field/Region or into a Integer/Buffer/String 00177 * are all essentially the same. This case handles the 00178 * "interchangeable" types Integer, String, and Buffer. 00179 */ 00180 if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 00181 { 00182 /* Resolve a reference object first */ 00183 00184 Status = AcpiExResolveToValue (SourceDescPtr, WalkState); 00185 if (ACPI_FAILURE (Status)) 00186 { 00187 break; 00188 } 00189 } 00190 00191 /* For CopyObject, no further validation necessary */ 00192 00193 if (WalkState->Opcode == AML_COPY_OP) 00194 { 00195 break; 00196 } 00197 00198 /* Must have a Integer, Buffer, or String */ 00199 00200 if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && 00201 (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && 00202 (SourceDesc->Common.Type != ACPI_TYPE_STRING) && 00203 !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 00204 (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) 00205 { 00206 /* Conversion successful but still not a valid type */ 00207 00208 ACPI_ERROR ((AE_INFO, 00209 "Cannot assign type %s to %s (must be type Int/Str/Buf)", 00210 AcpiUtGetObjectTypeName (SourceDesc), 00211 AcpiUtGetTypeName (TargetType))); 00212 Status = AE_AML_OPERAND_TYPE; 00213 } 00214 break; 00215 00216 00217 case ACPI_TYPE_LOCAL_ALIAS: 00218 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 00219 00220 /* 00221 * All aliases should have been resolved earlier, during the 00222 * operand resolution phase. 00223 */ 00224 ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); 00225 Status = AE_AML_INTERNAL; 00226 break; 00227 00228 00229 case ACPI_TYPE_PACKAGE: 00230 default: 00231 00232 /* 00233 * All other types than Alias and the various Fields come here, 00234 * including the untyped case - ACPI_TYPE_ANY. 00235 */ 00236 break; 00237 } 00238 00239 return_ACPI_STATUS (Status); 00240 } 00241 00242 00243 /******************************************************************************* 00244 * 00245 * FUNCTION: AcpiExStoreObjectToObject 00246 * 00247 * PARAMETERS: SourceDesc - Object to store 00248 * DestDesc - Object to receive a copy of the source 00249 * NewDesc - New object if DestDesc is obsoleted 00250 * WalkState - Current walk state 00251 * 00252 * RETURN: Status 00253 * 00254 * DESCRIPTION: "Store" an object to another object. This may include 00255 * converting the source type to the target type (implicit 00256 * conversion), and a copy of the value of the source to 00257 * the target. 00258 * 00259 * The Assignment of an object to another (not named) object 00260 * is handled here. 00261 * The Source passed in will replace the current value (if any) 00262 * with the input value. 00263 * 00264 * When storing into an object the data is converted to the 00265 * target object type then stored in the object. This means 00266 * that the target object type (for an initialized target) will 00267 * not be changed by a store operation. 00268 * 00269 * This module allows destination types of Number, String, 00270 * Buffer, and Package. 00271 * 00272 * Assumes parameters are already validated. NOTE: SourceDesc 00273 * resolution (from a reference object) must be performed by 00274 * the caller if necessary. 00275 * 00276 ******************************************************************************/ 00277 00278 ACPI_STATUS 00279 AcpiExStoreObjectToObject ( 00280 ACPI_OPERAND_OBJECT *SourceDesc, 00281 ACPI_OPERAND_OBJECT *DestDesc, 00282 ACPI_OPERAND_OBJECT **NewDesc, 00283 ACPI_WALK_STATE *WalkState) 00284 { 00285 ACPI_OPERAND_OBJECT *ActualSrcDesc; 00286 ACPI_STATUS Status = AE_OK; 00287 00288 00289 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); 00290 00291 00292 ActualSrcDesc = SourceDesc; 00293 if (!DestDesc) 00294 { 00295 /* 00296 * There is no destination object (An uninitialized node or 00297 * package element), so we can simply copy the source object 00298 * creating a new destination object 00299 */ 00300 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); 00301 return_ACPI_STATUS (Status); 00302 } 00303 00304 if (SourceDesc->Common.Type != DestDesc->Common.Type) 00305 { 00306 /* 00307 * The source type does not match the type of the destination. 00308 * Perform the "implicit conversion" of the source to the current type 00309 * of the target as per the ACPI specification. 00310 * 00311 * If no conversion performed, ActualSrcDesc = SourceDesc. 00312 * Otherwise, ActualSrcDesc is a temporary object to hold the 00313 * converted object. 00314 */ 00315 Status = AcpiExConvertToTargetType (DestDesc->Common.Type, 00316 SourceDesc, &ActualSrcDesc, WalkState); 00317 if (ACPI_FAILURE (Status)) 00318 { 00319 return_ACPI_STATUS (Status); 00320 } 00321 00322 if (SourceDesc == ActualSrcDesc) 00323 { 00324 /* 00325 * No conversion was performed. Return the SourceDesc as the 00326 * new object. 00327 */ 00328 *NewDesc = SourceDesc; 00329 return_ACPI_STATUS (AE_OK); 00330 } 00331 } 00332 00333 /* 00334 * We now have two objects of identical types, and we can perform a 00335 * copy of the *value* of the source object. 00336 */ 00337 switch (DestDesc->Common.Type) 00338 { 00339 case ACPI_TYPE_INTEGER: 00340 00341 DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; 00342 00343 /* Truncate value if we are executing from a 32-bit ACPI table */ 00344 00345 AcpiExTruncateFor32bitTable (DestDesc); 00346 break; 00347 00348 case ACPI_TYPE_STRING: 00349 00350 Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); 00351 break; 00352 00353 case ACPI_TYPE_BUFFER: 00354 00355 Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); 00356 break; 00357 00358 case ACPI_TYPE_PACKAGE: 00359 00360 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, 00361 WalkState); 00362 break; 00363 00364 default: 00365 /* 00366 * All other types come here. 00367 */ 00368 ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", 00369 AcpiUtGetObjectTypeName (DestDesc))); 00370 00371 Status = AE_NOT_IMPLEMENTED; 00372 break; 00373 } 00374 00375 if (ActualSrcDesc != SourceDesc) 00376 { 00377 /* Delete the intermediate (temporary) source object */ 00378 00379 AcpiUtRemoveReference (ActualSrcDesc); 00380 } 00381 00382 *NewDesc = DestDesc; 00383 return_ACPI_STATUS (Status); 00384 } 00385 00386 Generated on Sun May 27 2012 04:27:17 for ReactOS by
1.7.6.1
|