Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenexstore.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: exstore - AML Interpreter object store support 00004 * 00005 *****************************************************************************/ 00006 00007 /****************************************************************************** 00008 * 00009 * 1. Copyright Notice 00010 * 00011 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00012 * All rights reserved. 00013 * 00014 * 2. License 00015 * 00016 * 2.1. This is your license from Intel Corp. under its intellectual property 00017 * rights. You may have additional license terms from the party that provided 00018 * you this software, covering your right to use that party's intellectual 00019 * property rights. 00020 * 00021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00022 * copy of the source code appearing in this file ("Covered Code") an 00023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00024 * base code distributed originally by Intel ("Original Intel Code") to copy, 00025 * make derivatives, distribute, use and display any portion of the Covered 00026 * Code in any form, with the right to sublicense such rights; and 00027 * 00028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00029 * license (with the right to sublicense), under only those claims of Intel 00030 * patents that are infringed by the Original Intel Code, to make, use, sell, 00031 * offer to sell, and import the Covered Code and derivative works thereof 00032 * solely to the minimum extent necessary to exercise the above copyright 00033 * license, and in no event shall the patent license extend to any additions 00034 * to or modifications of the Original Intel Code. No other license or right 00035 * is granted directly or by implication, estoppel or otherwise; 00036 * 00037 * The above copyright and patent license is granted only if the following 00038 * conditions are met: 00039 * 00040 * 3. Conditions 00041 * 00042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00043 * Redistribution of source code of any substantial portion of the Covered 00044 * Code or modification with rights to further distribute source must include 00045 * the above Copyright Notice, the above License, this list of Conditions, 00046 * and the following Disclaimer and Export Compliance provision. In addition, 00047 * Licensee must cause all Covered Code to which Licensee contributes to 00048 * contain a file documenting the changes Licensee made to create that Covered 00049 * Code and the date of any change. Licensee must include in that file the 00050 * documentation of any changes made by any predecessor Licensee. Licensee 00051 * must include a prominent statement that the modification is derived, 00052 * directly or indirectly, from Original Intel Code. 00053 * 00054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00055 * Redistribution of source code of any substantial portion of the Covered 00056 * Code or modification without rights to further distribute source must 00057 * include the following Disclaimer and Export Compliance provision in the 00058 * documentation and/or other materials provided with distribution. In 00059 * addition, Licensee may not authorize further sublicense of source of any 00060 * portion of the Covered Code, and must include terms to the effect that the 00061 * license from Licensee to its licensee is limited to the intellectual 00062 * property embodied in the software Licensee provides to its licensee, and 00063 * not to intellectual property embodied in modifications its licensee may 00064 * make. 00065 * 00066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00067 * substantial portion of the Covered Code or modification must reproduce the 00068 * above Copyright Notice, and the following Disclaimer and Export Compliance 00069 * provision in the documentation and/or other materials provided with the 00070 * distribution. 00071 * 00072 * 3.4. Intel retains all right, title, and interest in and to the Original 00073 * Intel Code. 00074 * 00075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00076 * Intel shall be used in advertising or otherwise to promote the sale, use or 00077 * other dealings in products derived from or relating to the Covered Code 00078 * without prior written authorization from Intel. 00079 * 00080 * 4. Disclaimer and Export Compliance 00081 * 00082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00088 * PARTICULAR PURPOSE. 00089 * 00090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00097 * LIMITED REMEDY. 00098 * 00099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00100 * software or system incorporating such software without first obtaining any 00101 * required license or other approval from the U. S. Department of Commerce or 00102 * any other agency or department of the United States Government. In the 00103 * event Licensee exports any such software from the United States or 00104 * re-exports any such software from a foreign destination, Licensee shall 00105 * ensure that the distribution and export/re-export of the software is in 00106 * compliance with all laws, regulations, orders, or other restrictions of the 00107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00108 * any of its subsidiaries will export/re-export any technical data, process, 00109 * software, or service, directly or indirectly, to any country for which the 00110 * United States government or any agency thereof requires an export license, 00111 * other governmental approval, or letter of assurance, without first obtaining 00112 * such license, approval or letter. 00113 * 00114 *****************************************************************************/ 00115 00116 #define __EXSTORE_C__ 00117 00118 #include "acpi.h" 00119 #include "accommon.h" 00120 #include "acdispat.h" 00121 #include "acinterp.h" 00122 #include "amlcode.h" 00123 #include "acnamesp.h" 00124 00125 00126 #define _COMPONENT ACPI_EXECUTER 00127 ACPI_MODULE_NAME ("exstore") 00128 00129 /* Local prototypes */ 00130 00131 static ACPI_STATUS 00132 AcpiExStoreObjectToIndex ( 00133 ACPI_OPERAND_OBJECT *ValDesc, 00134 ACPI_OPERAND_OBJECT *DestDesc, 00135 ACPI_WALK_STATE *WalkState); 00136 00137 00138 /******************************************************************************* 00139 * 00140 * FUNCTION: AcpiExStore 00141 * 00142 * PARAMETERS: *SourceDesc - Value to be stored 00143 * *DestDesc - Where to store it. Must be an NS node 00144 * or an ACPI_OPERAND_OBJECT of type 00145 * Reference; 00146 * WalkState - Current walk state 00147 * 00148 * RETURN: Status 00149 * 00150 * DESCRIPTION: Store the value described by SourceDesc into the location 00151 * described by DestDesc. Called by various interpreter 00152 * functions to store the result of an operation into 00153 * the destination operand -- not just simply the actual "Store" 00154 * ASL operator. 00155 * 00156 ******************************************************************************/ 00157 00158 ACPI_STATUS 00159 AcpiExStore ( 00160 ACPI_OPERAND_OBJECT *SourceDesc, 00161 ACPI_OPERAND_OBJECT *DestDesc, 00162 ACPI_WALK_STATE *WalkState) 00163 { 00164 ACPI_STATUS Status = AE_OK; 00165 ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 00166 00167 00168 ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); 00169 00170 00171 /* Validate parameters */ 00172 00173 if (!SourceDesc || !DestDesc) 00174 { 00175 ACPI_ERROR ((AE_INFO, "Null parameter")); 00176 return_ACPI_STATUS (AE_AML_NO_OPERAND); 00177 } 00178 00179 /* DestDesc can be either a namespace node or an ACPI object */ 00180 00181 if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 00182 { 00183 /* 00184 * Dest is a namespace node, 00185 * Storing an object into a Named node. 00186 */ 00187 Status = AcpiExStoreObjectToNode (SourceDesc, 00188 (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, 00189 ACPI_IMPLICIT_CONVERSION); 00190 00191 return_ACPI_STATUS (Status); 00192 } 00193 00194 /* Destination object must be a Reference or a Constant object */ 00195 00196 switch (DestDesc->Common.Type) 00197 { 00198 case ACPI_TYPE_LOCAL_REFERENCE: 00199 break; 00200 00201 case ACPI_TYPE_INTEGER: 00202 00203 /* Allow stores to Constants -- a Noop as per ACPI spec */ 00204 00205 if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) 00206 { 00207 return_ACPI_STATUS (AE_OK); 00208 } 00209 00210 /*lint -fallthrough */ 00211 00212 default: 00213 00214 /* Destination is not a Reference object */ 00215 00216 ACPI_ERROR ((AE_INFO, 00217 "Target is not a Reference or Constant object - %s [%p]", 00218 AcpiUtGetObjectTypeName (DestDesc), DestDesc)); 00219 00220 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 00221 } 00222 00223 /* 00224 * Examine the Reference class. These cases are handled: 00225 * 00226 * 1) Store to Name (Change the object associated with a name) 00227 * 2) Store to an indexed area of a Buffer or Package 00228 * 3) Store to a Method Local or Arg 00229 * 4) Store to the debug object 00230 */ 00231 switch (RefDesc->Reference.Class) 00232 { 00233 case ACPI_REFCLASS_REFOF: 00234 00235 /* Storing an object into a Name "container" */ 00236 00237 Status = AcpiExStoreObjectToNode (SourceDesc, 00238 RefDesc->Reference.Object, 00239 WalkState, ACPI_IMPLICIT_CONVERSION); 00240 break; 00241 00242 00243 case ACPI_REFCLASS_INDEX: 00244 00245 /* Storing to an Index (pointer into a packager or buffer) */ 00246 00247 Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 00248 break; 00249 00250 00251 case ACPI_REFCLASS_LOCAL: 00252 case ACPI_REFCLASS_ARG: 00253 00254 /* Store to a method local/arg */ 00255 00256 Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, 00257 RefDesc->Reference.Value, SourceDesc, WalkState); 00258 break; 00259 00260 00261 case ACPI_REFCLASS_DEBUG: 00262 00263 /* 00264 * Storing to the Debug object causes the value stored to be 00265 * displayed and otherwise has no effect -- see ACPI Specification 00266 */ 00267 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00268 "**** Write to Debug Object: Object %p %s ****:\n\n", 00269 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); 00270 00271 ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); 00272 break; 00273 00274 00275 default: 00276 00277 ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", 00278 RefDesc->Reference.Class)); 00279 ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); 00280 00281 Status = AE_AML_INTERNAL; 00282 break; 00283 } 00284 00285 return_ACPI_STATUS (Status); 00286 } 00287 00288 00289 /******************************************************************************* 00290 * 00291 * FUNCTION: AcpiExStoreObjectToIndex 00292 * 00293 * PARAMETERS: *SourceDesc - Value to be stored 00294 * *DestDesc - Named object to receive the value 00295 * WalkState - Current walk state 00296 * 00297 * RETURN: Status 00298 * 00299 * DESCRIPTION: Store the object to indexed Buffer or Package element 00300 * 00301 ******************************************************************************/ 00302 00303 static ACPI_STATUS 00304 AcpiExStoreObjectToIndex ( 00305 ACPI_OPERAND_OBJECT *SourceDesc, 00306 ACPI_OPERAND_OBJECT *IndexDesc, 00307 ACPI_WALK_STATE *WalkState) 00308 { 00309 ACPI_STATUS Status = AE_OK; 00310 ACPI_OPERAND_OBJECT *ObjDesc; 00311 ACPI_OPERAND_OBJECT *NewDesc; 00312 UINT8 Value = 0; 00313 UINT32 i; 00314 00315 00316 ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); 00317 00318 00319 /* 00320 * Destination must be a reference pointer, and 00321 * must point to either a buffer or a package 00322 */ 00323 switch (IndexDesc->Reference.TargetType) 00324 { 00325 case ACPI_TYPE_PACKAGE: 00326 /* 00327 * Storing to a package element. Copy the object and replace 00328 * any existing object with the new object. No implicit 00329 * conversion is performed. 00330 * 00331 * The object at *(IndexDesc->Reference.Where) is the 00332 * element within the package that is to be modified. 00333 * The parent package object is at IndexDesc->Reference.Object 00334 */ 00335 ObjDesc = *(IndexDesc->Reference.Where); 00336 00337 if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && 00338 SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) 00339 { 00340 /* This is a DDBHandle, just add a reference to it */ 00341 00342 AcpiUtAddReference (SourceDesc); 00343 NewDesc = SourceDesc; 00344 } 00345 else 00346 { 00347 /* Normal object, copy it */ 00348 00349 Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); 00350 if (ACPI_FAILURE (Status)) 00351 { 00352 return_ACPI_STATUS (Status); 00353 } 00354 } 00355 00356 if (ObjDesc) 00357 { 00358 /* Decrement reference count by the ref count of the parent package */ 00359 00360 for (i = 0; 00361 i < ((ACPI_OPERAND_OBJECT *) 00362 IndexDesc->Reference.Object)->Common.ReferenceCount; 00363 i++) 00364 { 00365 AcpiUtRemoveReference (ObjDesc); 00366 } 00367 } 00368 00369 *(IndexDesc->Reference.Where) = NewDesc; 00370 00371 /* Increment ref count by the ref count of the parent package-1 */ 00372 00373 for (i = 1; 00374 i < ((ACPI_OPERAND_OBJECT *) 00375 IndexDesc->Reference.Object)->Common.ReferenceCount; 00376 i++) 00377 { 00378 AcpiUtAddReference (NewDesc); 00379 } 00380 00381 break; 00382 00383 00384 case ACPI_TYPE_BUFFER_FIELD: 00385 00386 /* 00387 * Store into a Buffer or String (not actually a real BufferField) 00388 * at a location defined by an Index. 00389 * 00390 * The first 8-bit element of the source object is written to the 00391 * 8-bit Buffer location defined by the Index destination object, 00392 * according to the ACPI 2.0 specification. 00393 */ 00394 00395 /* 00396 * Make sure the target is a Buffer or String. An error should 00397 * not happen here, since the ReferenceObject was constructed 00398 * by the INDEX_OP code. 00399 */ 00400 ObjDesc = IndexDesc->Reference.Object; 00401 if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && 00402 (ObjDesc->Common.Type != ACPI_TYPE_STRING)) 00403 { 00404 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 00405 } 00406 00407 /* 00408 * The assignment of the individual elements will be slightly 00409 * different for each source type. 00410 */ 00411 switch (SourceDesc->Common.Type) 00412 { 00413 case ACPI_TYPE_INTEGER: 00414 00415 /* Use the least-significant byte of the integer */ 00416 00417 Value = (UINT8) (SourceDesc->Integer.Value); 00418 break; 00419 00420 case ACPI_TYPE_BUFFER: 00421 case ACPI_TYPE_STRING: 00422 00423 /* Note: Takes advantage of common string/buffer fields */ 00424 00425 Value = SourceDesc->Buffer.Pointer[0]; 00426 break; 00427 00428 default: 00429 00430 /* All other types are invalid */ 00431 00432 ACPI_ERROR ((AE_INFO, 00433 "Source must be Integer/Buffer/String type, not %s", 00434 AcpiUtGetObjectTypeName (SourceDesc))); 00435 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 00436 } 00437 00438 /* Store the source value into the target buffer byte */ 00439 00440 ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; 00441 break; 00442 00443 00444 default: 00445 ACPI_ERROR ((AE_INFO, 00446 "Target is not a Package or BufferField")); 00447 Status = AE_AML_OPERAND_TYPE; 00448 break; 00449 } 00450 00451 return_ACPI_STATUS (Status); 00452 } 00453 00454 00455 /******************************************************************************* 00456 * 00457 * FUNCTION: AcpiExStoreObjectToNode 00458 * 00459 * PARAMETERS: SourceDesc - Value to be stored 00460 * Node - Named object to receive the value 00461 * WalkState - Current walk state 00462 * ImplicitConversion - Perform implicit conversion (yes/no) 00463 * 00464 * RETURN: Status 00465 * 00466 * DESCRIPTION: Store the object to the named object. 00467 * 00468 * The Assignment of an object to a named object is handled here 00469 * The value passed in will replace the current value (if any) 00470 * with the input value. 00471 * 00472 * When storing into an object the data is converted to the 00473 * target object type then stored in the object. This means 00474 * that the target object type (for an initialized target) will 00475 * not be changed by a store operation. 00476 * 00477 * Assumes parameters are already validated. 00478 * 00479 ******************************************************************************/ 00480 00481 ACPI_STATUS 00482 AcpiExStoreObjectToNode ( 00483 ACPI_OPERAND_OBJECT *SourceDesc, 00484 ACPI_NAMESPACE_NODE *Node, 00485 ACPI_WALK_STATE *WalkState, 00486 UINT8 ImplicitConversion) 00487 { 00488 ACPI_STATUS Status = AE_OK; 00489 ACPI_OPERAND_OBJECT *TargetDesc; 00490 ACPI_OPERAND_OBJECT *NewDesc; 00491 ACPI_OBJECT_TYPE TargetType; 00492 00493 00494 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); 00495 00496 00497 /* Get current type of the node, and object attached to Node */ 00498 00499 TargetType = AcpiNsGetType (Node); 00500 TargetDesc = AcpiNsGetAttachedObject (Node); 00501 00502 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 00503 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 00504 Node, AcpiUtGetTypeName (TargetType))); 00505 00506 /* 00507 * Resolve the source object to an actual value 00508 * (If it is a reference object) 00509 */ 00510 Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 00511 if (ACPI_FAILURE (Status)) 00512 { 00513 return_ACPI_STATUS (Status); 00514 } 00515 00516 /* If no implicit conversion, drop into the default case below */ 00517 00518 if ((!ImplicitConversion) || 00519 ((WalkState->Opcode == AML_COPY_OP) && 00520 (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && 00521 (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && 00522 (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) 00523 { 00524 /* 00525 * Force execution of default (no implicit conversion). Note: 00526 * CopyObject does not perform an implicit conversion, as per the ACPI 00527 * spec -- except in case of region/bank/index fields -- because these 00528 * objects must retain their original type permanently. 00529 */ 00530 TargetType = ACPI_TYPE_ANY; 00531 } 00532 00533 /* Do the actual store operation */ 00534 00535 switch (TargetType) 00536 { 00537 case ACPI_TYPE_BUFFER_FIELD: 00538 case ACPI_TYPE_LOCAL_REGION_FIELD: 00539 case ACPI_TYPE_LOCAL_BANK_FIELD: 00540 case ACPI_TYPE_LOCAL_INDEX_FIELD: 00541 00542 /* For fields, copy the source data to the target field. */ 00543 00544 Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, 00545 &WalkState->ResultObj); 00546 break; 00547 00548 00549 case ACPI_TYPE_INTEGER: 00550 case ACPI_TYPE_STRING: 00551 case ACPI_TYPE_BUFFER: 00552 00553 /* 00554 * These target types are all of type Integer/String/Buffer, and 00555 * therefore support implicit conversion before the store. 00556 * 00557 * Copy and/or convert the source object to a new target object 00558 */ 00559 Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, 00560 &NewDesc, WalkState); 00561 if (ACPI_FAILURE (Status)) 00562 { 00563 return_ACPI_STATUS (Status); 00564 } 00565 00566 if (NewDesc != TargetDesc) 00567 { 00568 /* 00569 * Store the new NewDesc as the new value of the Name, and set 00570 * the Name's type to that of the value being stored in it. 00571 * SourceDesc reference count is incremented by AttachObject. 00572 * 00573 * Note: This may change the type of the node if an explicit store 00574 * has been performed such that the node/object type has been 00575 * changed. 00576 */ 00577 Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 00578 00579 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00580 "Store %s into %s via Convert/Attach\n", 00581 AcpiUtGetObjectTypeName (SourceDesc), 00582 AcpiUtGetObjectTypeName (NewDesc))); 00583 } 00584 break; 00585 00586 00587 default: 00588 00589 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00590 "Storing %s (%p) directly into node (%p) with no implicit conversion\n", 00591 AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 00592 00593 /* No conversions for all other types. Just attach the source object */ 00594 00595 Status = AcpiNsAttachObject (Node, SourceDesc, 00596 SourceDesc->Common.Type); 00597 break; 00598 } 00599 00600 return_ACPI_STATUS (Status); 00601 } 00602 00603 Generated on Mon May 28 2012 04:27:02 for ReactOS by
1.7.6.1
|