exstoren.c revision 123315
133965Sjdp 233965Sjdp/****************************************************************************** 3130570Sobrien * 433965Sjdp * Module Name: exstoren - AML Interpreter object store support, 5130570Sobrien * Store to Node (namespace object) 633965Sjdp * $Revision: 56 $ 733965Sjdp * 8130570Sobrien *****************************************************************************/ 9130570Sobrien 10130570Sobrien/****************************************************************************** 1133965Sjdp * 12130570Sobrien * 1. Copyright Notice 13130570Sobrien * 14130570Sobrien * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 15130570Sobrien * All rights reserved. 16130570Sobrien * 17130570Sobrien * 2. License 18130570Sobrien * 19130570Sobrien * 2.1. This is your license from Intel Corp. under its intellectual property 20130570Sobrien * rights. You may have additional license terms from the party that provided 21130570Sobrien * you this software, covering your right to use that party's intellectual 22130570Sobrien * property rights. 23130570Sobrien * 24130570Sobrien * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 25130570Sobrien * copy of the source code appearing in this file ("Covered Code") an 26130570Sobrien * irrevocable, perpetual, worldwide license under Intel's copyrights in the 27130570Sobrien * base code distributed originally by Intel ("Original Intel Code") to copy, 28130570Sobrien * make derivatives, distribute, use and display any portion of the Covered 29130570Sobrien * Code in any form, with the right to sublicense such rights; and 30130570Sobrien * 31130570Sobrien * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 32130570Sobrien * license (with the right to sublicense), under only those claims of Intel 33130570Sobrien * patents that are infringed by the Original Intel Code, to make, use, sell, 34130570Sobrien * offer to sell, and import the Covered Code and derivative works thereof 35130570Sobrien * solely to the minimum extent necessary to exercise the above copyright 36130570Sobrien * license, and in no event shall the patent license extend to any additions 37130570Sobrien * to or modifications of the Original Intel Code. No other license or right 38130570Sobrien * is granted directly or by implication, estoppel or otherwise; 39130570Sobrien * 40130570Sobrien * The above copyright and patent license is granted only if the following 41130570Sobrien * conditions are met: 42130570Sobrien * 43130570Sobrien * 3. Conditions 44130570Sobrien * 45130570Sobrien * 3.1. Redistribution of Source with Rights to Further Distribute Source. 46130570Sobrien * Redistribution of source code of any substantial portion of the Covered 47130570Sobrien * Code or modification with rights to further distribute source must include 48130570Sobrien * the above Copyright Notice, the above License, this list of Conditions, 49130570Sobrien * and the following Disclaimer and Export Compliance provision. In addition, 50130570Sobrien * Licensee must cause all Covered Code to which Licensee contributes to 51130570Sobrien * contain a file documenting the changes Licensee made to create that Covered 52130570Sobrien * Code and the date of any change. Licensee must include in that file the 53130570Sobrien * documentation of any changes made by any predecessor Licensee. Licensee 54130570Sobrien * must include a prominent statement that the modification is derived, 55130570Sobrien * directly or indirectly, from Original Intel Code. 56130570Sobrien * 57130570Sobrien * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 58130570Sobrien * Redistribution of source code of any substantial portion of the Covered 59130570Sobrien * Code or modification without rights to further distribute source must 60130570Sobrien * include the following Disclaimer and Export Compliance provision in the 61130570Sobrien * documentation and/or other materials provided with distribution. In 62130570Sobrien * addition, Licensee may not authorize further sublicense of source of any 63130570Sobrien * portion of the Covered Code, and must include terms to the effect that the 64130570Sobrien * license from Licensee to its licensee is limited to the intellectual 65130570Sobrien * property embodied in the software Licensee provides to its licensee, and 66130570Sobrien * not to intellectual property embodied in modifications its licensee may 67130570Sobrien * make. 68130570Sobrien * 69130570Sobrien * 3.3. Redistribution of Executable. Redistribution in executable form of any 70130570Sobrien * substantial portion of the Covered Code or modification must reproduce the 71130570Sobrien * above Copyright Notice, and the following Disclaimer and Export Compliance 72130570Sobrien * provision in the documentation and/or other materials provided with the 73130570Sobrien * distribution. 74130570Sobrien * 75130570Sobrien * 3.4. Intel retains all right, title, and interest in and to the Original 76130570Sobrien * Intel Code. 77130570Sobrien * 78130570Sobrien * 3.5. Neither the name Intel nor any other trademark owned or controlled by 79130570Sobrien * Intel shall be used in advertising or otherwise to promote the sale, use or 80130570Sobrien * other dealings in products derived from or relating to the Covered Code 81130570Sobrien * without prior written authorization from Intel. 82130570Sobrien * 83130570Sobrien * 4. Disclaimer and Export Compliance 84130570Sobrien * 85130570Sobrien * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 86130570Sobrien * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 87130570Sobrien * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 88130570Sobrien * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 89130570Sobrien * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 90130570Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 91130570Sobrien * PARTICULAR PURPOSE. 92130570Sobrien * 93130570Sobrien * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 94130570Sobrien * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 95130570Sobrien * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 96130570Sobrien * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 97130570Sobrien * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 98130570Sobrien * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 99130570Sobrien * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 100130570Sobrien * LIMITED REMEDY. 101130570Sobrien * 102130570Sobrien * 4.3. Licensee shall not export, either directly or indirectly, any of this 103130570Sobrien * software or system incorporating such software without first obtaining any 104130570Sobrien * required license or other approval from the U. S. Department of Commerce or 105130570Sobrien * any other agency or department of the United States Government. In the 106130570Sobrien * event Licensee exports any such software from the United States or 107130570Sobrien * re-exports any such software from a foreign destination, Licensee shall 108130570Sobrien * ensure that the distribution and export/re-export of the software is in 109130570Sobrien * compliance with all laws, regulations, orders, or other restrictions of the 110130570Sobrien * U.S. Export Administration Regulations. Licensee agrees that neither it nor 111130570Sobrien * any of its subsidiaries will export/re-export any technical data, process, 112130570Sobrien * software, or service, directly or indirectly, to any country for which the 113130570Sobrien * United States government or any agency thereof requires an export license, 114130570Sobrien * other governmental approval, or letter of assurance, without first obtaining 115130570Sobrien * such license, approval or letter. 116130570Sobrien * 117130570Sobrien *****************************************************************************/ 118130570Sobrien 119130570Sobrien#define __EXSTOREN_C__ 120130570Sobrien 121130570Sobrien#include "acpi.h" 122130570Sobrien#include "acinterp.h" 123130570Sobrien#include "amlcode.h" 124130570Sobrien 125130570Sobrien 126130570Sobrien#define _COMPONENT ACPI_EXECUTER 127130570Sobrien ACPI_MODULE_NAME ("exstoren") 128130570Sobrien 129130570Sobrien 130130570Sobrien/******************************************************************************* 131130570Sobrien * 132130570Sobrien * FUNCTION: AcpiExResolveObject 133130570Sobrien * 134130570Sobrien * PARAMETERS: SourceDescPtr - Pointer to the source object 135130570Sobrien * TargetType - Current type of the target 136130570Sobrien * WalkState - Current walk state 137130570Sobrien * 138130570Sobrien * RETURN: Status, resolved object in SourceDescPtr. 139130570Sobrien * 140130570Sobrien * DESCRIPTION: Resolve an object. If the object is a reference, dereference 141130570Sobrien * it and return the actual object in the SourceDescPtr. 142130570Sobrien * 143130570Sobrien ******************************************************************************/ 144130570Sobrien 145130570SobrienACPI_STATUS 146130570SobrienAcpiExResolveObject ( 147130570Sobrien ACPI_OPERAND_OBJECT **SourceDescPtr, 148130570Sobrien ACPI_OBJECT_TYPE TargetType, 149130570Sobrien ACPI_WALK_STATE *WalkState) 150130570Sobrien{ 151130570Sobrien ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; 152130570Sobrien ACPI_STATUS Status = AE_OK; 153130570Sobrien 154130570Sobrien 155130570Sobrien ACPI_FUNCTION_TRACE ("ExResolveObject"); 156130570Sobrien 157130570Sobrien 158130570Sobrien /* 159130570Sobrien * Ensure we have a Target that can be stored to 160130570Sobrien */ 161130570Sobrien switch (TargetType) 162130570Sobrien { 163130570Sobrien case ACPI_TYPE_BUFFER_FIELD: 164130570Sobrien case ACPI_TYPE_LOCAL_REGION_FIELD: 165130570Sobrien case ACPI_TYPE_LOCAL_BANK_FIELD: 166130570Sobrien case ACPI_TYPE_LOCAL_INDEX_FIELD: 167130570Sobrien /* 168130570Sobrien * These cases all require only Integers or values that 169130570Sobrien * can be converted to Integers (Strings or Buffers) 170130570Sobrien */ 171130570Sobrien 172130570Sobrien case ACPI_TYPE_INTEGER: 173130570Sobrien case ACPI_TYPE_STRING: 174130570Sobrien case ACPI_TYPE_BUFFER: 175130570Sobrien 176130570Sobrien /* 177130570Sobrien * Stores into a Field/Region or into a Integer/Buffer/String 178130570Sobrien * are all essentially the same. This case handles the 179130570Sobrien * "interchangeable" types Integer, String, and Buffer. 180130570Sobrien */ 181130570Sobrien if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) 182130570Sobrien { 183130570Sobrien /* Resolve a reference object first */ 184130570Sobrien 185130570Sobrien Status = AcpiExResolveToValue (SourceDescPtr, WalkState); 186130570Sobrien if (ACPI_FAILURE (Status)) 187130570Sobrien { 188130570Sobrien break; 189130570Sobrien } 190130570Sobrien } 191130570Sobrien 192130570Sobrien /* 193130570Sobrien * Must have a Integer, Buffer, or String 194130570Sobrien */ 195130570Sobrien if ((ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) && 196130570Sobrien (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) && 197130570Sobrien (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) && 198130570Sobrien !((ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) && (SourceDesc->Reference.Opcode == AML_LOAD_OP))) 199130570Sobrien { 200130570Sobrien /* 201130570Sobrien * Conversion successful but still not a valid type 202130570Sobrien */ 203130570Sobrien ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204130570Sobrien "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 205130570Sobrien AcpiUtGetObjectTypeName (SourceDesc), 206130570Sobrien AcpiUtGetTypeName (TargetType))); 207130570Sobrien Status = AE_AML_OPERAND_TYPE; 208130570Sobrien } 209130570Sobrien break; 210130570Sobrien 211130570Sobrien 212130570Sobrien case ACPI_TYPE_LOCAL_ALIAS: 213130570Sobrien 214130570Sobrien /* 215130570Sobrien * Aliases are resolved by AcpiExPrepOperands 216130570Sobrien */ 217130570Sobrien ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n")); 218130570Sobrien Status = AE_AML_INTERNAL; 219130570Sobrien break; 220130570Sobrien 221130570Sobrien 222130570Sobrien case ACPI_TYPE_PACKAGE: 223130570Sobrien default: 224130570Sobrien 225130570Sobrien /* 226130570Sobrien * All other types than Alias and the various Fields come here, 227130570Sobrien * including the untyped case - ACPI_TYPE_ANY. 228130570Sobrien */ 229130570Sobrien break; 230130570Sobrien } 231130570Sobrien 232130570Sobrien return_ACPI_STATUS (Status); 233130570Sobrien} 234130570Sobrien 235130570Sobrien 236130570Sobrien/******************************************************************************* 237130570Sobrien * 238130570Sobrien * FUNCTION: AcpiExStoreObjectToObject 239130570Sobrien * 240130570Sobrien * PARAMETERS: SourceDesc - Object to store 241130570Sobrien * DestDesc - Object to receive a copy of the source 242130570Sobrien * NewDesc - New object if DestDesc is obsoleted 243130570Sobrien * WalkState - Current walk state 244218822Sdim * 245218822Sdim * RETURN: Status 246218822Sdim * 247218822Sdim * DESCRIPTION: "Store" an object to another object. This may include 248218822Sdim * converting the source type to the target type (implicit 249218822Sdim * conversion), and a copy of the value of the source to 250218822Sdim * the target. 251218822Sdim * 252218822Sdim * The Assignment of an object to another (not named) object 253218822Sdim * is handled here. 254218822Sdim * The Source passed in will replace the current value (if any) 255218822Sdim * with the input value. 256218822Sdim * 257218822Sdim * When storing into an object the data is converted to the 258218822Sdim * target object type then stored in the object. This means 259218822Sdim * that the target object type (for an initialized target) will 260218822Sdim * not be changed by a store operation. 261218822Sdim * 262218822Sdim * This module allows destination types of Number, String, 263218822Sdim * Buffer, and Package. 264218822Sdim * 265218822Sdim * Assumes parameters are already validated. NOTE: SourceDesc 266218822Sdim * resolution (from a reference object) must be performed by 267218822Sdim * the caller if necessary. 268218822Sdim * 269218822Sdim ******************************************************************************/ 270218822Sdim 271218822SdimACPI_STATUS 272218822SdimAcpiExStoreObjectToObject ( 273218822Sdim ACPI_OPERAND_OBJECT *SourceDesc, 274218822Sdim ACPI_OPERAND_OBJECT *DestDesc, 275218822Sdim ACPI_OPERAND_OBJECT **NewDesc, 276218822Sdim ACPI_WALK_STATE *WalkState) 277218822Sdim{ 278218822Sdim ACPI_OPERAND_OBJECT *ActualSrcDesc; 279218822Sdim ACPI_STATUS Status = AE_OK; 280218822Sdim 281218822Sdim 282218822Sdim ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToObject", SourceDesc); 283218822Sdim 284218822Sdim 285218822Sdim ActualSrcDesc = SourceDesc; 286218822Sdim if (!DestDesc) 287218822Sdim { 288218822Sdim /* 289218822Sdim * There is no destination object (An uninitialized node or 290218822Sdim * package element), so we can simply copy the source object 291218822Sdim * creating a new destination object 292218822Sdim */ 293218822Sdim Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); 294218822Sdim return_ACPI_STATUS (Status); 295218822Sdim } 296218822Sdim 297218822Sdim if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_GET_OBJECT_TYPE (DestDesc)) 298218822Sdim { 299218822Sdim /* 300218822Sdim * The source type does not match the type of the destination. 301218822Sdim * Perform the "implicit conversion" of the source to the current type 302218822Sdim * of the target as per the ACPI specification. 303218822Sdim * 304218822Sdim * If no conversion performed, ActualSrcDesc = SourceDesc. 305218822Sdim * Otherwise, ActualSrcDesc is a temporary object to hold the 306218822Sdim * converted object. 307218822Sdim */ 308218822Sdim Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), SourceDesc, 309218822Sdim &ActualSrcDesc, WalkState); 310218822Sdim if (ACPI_FAILURE (Status)) 311218822Sdim { 312218822Sdim return_ACPI_STATUS (Status); 313218822Sdim } 314218822Sdim 315218822Sdim if (SourceDesc == ActualSrcDesc) 316218822Sdim { 317218822Sdim /* 318218822Sdim * No conversion was performed. Return the SourceDesc as the 319218822Sdim * new object. 320218822Sdim */ 321218822Sdim *NewDesc = SourceDesc; 322218822Sdim return_ACPI_STATUS (AE_OK); 323218822Sdim } 324218822Sdim } 325218822Sdim 326218822Sdim /* 327218822Sdim * We now have two objects of identical types, and we can perform a 328218822Sdim * copy of the *value* of the source object. 329218822Sdim */ 330218822Sdim switch (ACPI_GET_OBJECT_TYPE (DestDesc)) 331218822Sdim { 332218822Sdim case ACPI_TYPE_INTEGER: 333218822Sdim 334218822Sdim DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; 335218822Sdim 336218822Sdim /* Truncate value if we are executing from a 32-bit ACPI table */ 337218822Sdim 338218822Sdim AcpiExTruncateFor32bitTable (DestDesc); 339218822Sdim break; 340218822Sdim 341218822Sdim case ACPI_TYPE_STRING: 342218822Sdim 343218822Sdim Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); 344218822Sdim break; 345218822Sdim 346218822Sdim case ACPI_TYPE_BUFFER: 347218822Sdim 348218822Sdim Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); 349218822Sdim break; 350218822Sdim 351218822Sdim case ACPI_TYPE_PACKAGE: 352218822Sdim 353218822Sdim Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, WalkState); 354218822Sdim break; 355218822Sdim 356218822Sdim default: 357218822Sdim /* 358218822Sdim * All other types come here. 359218822Sdim */ 360218822Sdim ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", 361218822Sdim AcpiUtGetObjectTypeName (DestDesc))); 362218822Sdim 363218822Sdim Status = AE_NOT_IMPLEMENTED; 364218822Sdim break; 365218822Sdim } 366218822Sdim 367218822Sdim if (ActualSrcDesc != SourceDesc) 368218822Sdim { 369218822Sdim /* Delete the intermediate (temporary) source object */ 370218822Sdim 371218822Sdim AcpiUtRemoveReference (ActualSrcDesc); 372218822Sdim } 373218822Sdim 374218822Sdim *NewDesc = DestDesc; 375218822Sdim return_ACPI_STATUS (Status); 376218822Sdim} 377218822Sdim 378218822Sdim 379218822Sdim