exstoren.c revision 83174
1233541Sjchandra 2233541Sjchandra/****************************************************************************** 3233541Sjchandra * 4233541Sjchandra * Module Name: exstoren - AML Interpreter object store support, 5233541Sjchandra * Store to Node (namespace object) 6233541Sjchandra * $Revision: 40 $ 7233541Sjchandra * 8233541Sjchandra *****************************************************************************/ 9233541Sjchandra 10233541Sjchandra/****************************************************************************** 11233541Sjchandra * 12233541Sjchandra * 1. Copyright Notice 13233541Sjchandra * 14233541Sjchandra * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 15279388Sjchandra * All rights reserved. 16233541Sjchandra * 17233541Sjchandra * 2. License 18233541Sjchandra * 19233541Sjchandra * 2.1. This is your license from Intel Corp. under its intellectual property 20233541Sjchandra * rights. You may have additional license terms from the party that provided 21233541Sjchandra * you this software, covering your right to use that party's intellectual 22233541Sjchandra * property rights. 23233541Sjchandra * 24233541Sjchandra * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 25233541Sjchandra * copy of the source code appearing in this file ("Covered Code") an 26233541Sjchandra * irrevocable, perpetual, worldwide license under Intel's copyrights in the 27233541Sjchandra * base code distributed originally by Intel ("Original Intel Code") to copy, 28233541Sjchandra * make derivatives, distribute, use and display any portion of the Covered 29233541Sjchandra * Code in any form, with the right to sublicense such rights; and 30233541Sjchandra * 31233541Sjchandra * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 32233541Sjchandra * license (with the right to sublicense), under only those claims of Intel 33233541Sjchandra * patents that are infringed by the Original Intel Code, to make, use, sell, 34233541Sjchandra * offer to sell, and import the Covered Code and derivative works thereof 35233541Sjchandra * solely to the minimum extent necessary to exercise the above copyright 36233541Sjchandra * license, and in no event shall the patent license extend to any additions 37256046Sjchandra * to or modifications of the Original Intel Code. No other license or right 38233541Sjchandra * is granted directly or by implication, estoppel or otherwise; 39233541Sjchandra * 40233541Sjchandra * The above copyright and patent license is granted only if the following 41233541Sjchandra * conditions are met: 42233541Sjchandra * 43233541Sjchandra * 3. Conditions 44233541Sjchandra * 45233541Sjchandra * 3.1. Redistribution of Source with Rights to Further Distribute Source. 46233541Sjchandra * Redistribution of source code of any substantial portion of the Covered 47233541Sjchandra * Code or modification with rights to further distribute source must include 48233541Sjchandra * the above Copyright Notice, the above License, this list of Conditions, 49233541Sjchandra * and the following Disclaimer and Export Compliance provision. In addition, 50233541Sjchandra * Licensee must cause all Covered Code to which Licensee contributes to 51233541Sjchandra * contain a file documenting the changes Licensee made to create that Covered 52233541Sjchandra * Code and the date of any change. Licensee must include in that file the 53233541Sjchandra * documentation of any changes made by any predecessor Licensee. Licensee 54233541Sjchandra * must include a prominent statement that the modification is derived, 55233541Sjchandra * directly or indirectly, from Original Intel Code. 56233541Sjchandra * 57233541Sjchandra * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 58233541Sjchandra * Redistribution of source code of any substantial portion of the Covered 59233541Sjchandra * Code or modification without rights to further distribute source must 60233541Sjchandra * include the following Disclaimer and Export Compliance provision in the 61233541Sjchandra * documentation and/or other materials provided with distribution. In 62233541Sjchandra * addition, Licensee may not authorize further sublicense of source of any 63233541Sjchandra * portion of the Covered Code, and must include terms to the effect that the 64233541Sjchandra * license from Licensee to its licensee is limited to the intellectual 65233541Sjchandra * property embodied in the software Licensee provides to its licensee, and 66233541Sjchandra * not to intellectual property embodied in modifications its licensee may 67233541Sjchandra * make. 68233541Sjchandra * 69233541Sjchandra * 3.3. Redistribution of Executable. Redistribution in executable form of any 70256045Sjchandra * substantial portion of the Covered Code or modification must reproduce the 71233541Sjchandra * above Copyright Notice, and the following Disclaimer and Export Compliance 72233541Sjchandra * provision in the documentation and/or other materials provided with the 73256046Sjchandra * distribution. 74233541Sjchandra * 75233541Sjchandra * 3.4. Intel retains all right, title, and interest in and to the Original 76233541Sjchandra * Intel Code. 77233541Sjchandra * 78233541Sjchandra * 3.5. Neither the name Intel nor any other trademark owned or controlled by 79233541Sjchandra * Intel shall be used in advertising or otherwise to promote the sale, use or 80233541Sjchandra * other dealings in products derived from or relating to the Covered Code 81233541Sjchandra * without prior written authorization from Intel. 82233541Sjchandra * 83233541Sjchandra * 4. Disclaimer and Export Compliance 84233541Sjchandra * 85233541Sjchandra * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 86233541Sjchandra * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 87233541Sjchandra * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 88233541Sjchandra * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 89233541Sjchandra * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 90233541Sjchandra * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 91233541Sjchandra * PARTICULAR PURPOSE. 92233541Sjchandra * 93233541Sjchandra * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 94233541Sjchandra * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 95233541Sjchandra * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 96233541Sjchandra * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 97233541Sjchandra * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 98233541Sjchandra * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 99233541Sjchandra * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 100233541Sjchandra * LIMITED REMEDY. 101256045Sjchandra * 102233541Sjchandra * 4.3. Licensee shall not export, either directly or indirectly, any of this 103233541Sjchandra * software or system incorporating such software without first obtaining any 104233541Sjchandra * required license or other approval from the U. S. Department of Commerce or 105233541Sjchandra * any other agency or department of the United States Government. In the 106233541Sjchandra * event Licensee exports any such software from the United States or 107233541Sjchandra * re-exports any such software from a foreign destination, Licensee shall 108233541Sjchandra * ensure that the distribution and export/re-export of the software is in 109233541Sjchandra * compliance with all laws, regulations, orders, or other restrictions of the 110233541Sjchandra * U.S. Export Administration Regulations. Licensee agrees that neither it nor 111233541Sjchandra * any of its subsidiaries will export/re-export any technical data, process, 112233541Sjchandra * software, or service, directly or indirectly, to any country for which the 113233541Sjchandra * United States government or any agency thereof requires an export license, 114233541Sjchandra * other governmental approval, or letter of assurance, without first obtaining 115233541Sjchandra * such license, approval or letter. 116233541Sjchandra * 117233541Sjchandra *****************************************************************************/ 118256046Sjchandra 119233541Sjchandra#define __EXSTOREN_C__ 120233541Sjchandra 121233541Sjchandra#include "acpi.h" 122233541Sjchandra#include "acparser.h" 123256045Sjchandra#include "acdispat.h" 124256045Sjchandra#include "acinterp.h" 125256045Sjchandra#include "amlcode.h" 126256045Sjchandra#include "acnamesp.h" 127256045Sjchandra#include "actables.h" 128256045Sjchandra 129233541Sjchandra 130256045Sjchandra#define _COMPONENT ACPI_EXECUTER 131233541Sjchandra MODULE_NAME ("exstoren") 132256045Sjchandra 133256045Sjchandra 134233541Sjchandra/******************************************************************************* 135233541Sjchandra * 136233541Sjchandra * FUNCTION: AcpiExResolveObject 137233541Sjchandra * 138279388Sjchandra * PARAMETERS: SourceDescPtr - Pointer to the source object 139233541Sjchandra * TargetType - Current type of the target 140233541Sjchandra * WalkState - Current walk state 141233541Sjchandra * 142256046Sjchandra * RETURN: Status, resolved object in SourceDescPtr. 143233541Sjchandra * 144233541Sjchandra * DESCRIPTION: Resolve an object. If the object is a reference, dereference 145233541Sjchandra * it and return the actual object in the SourceDescPtr. 146233541Sjchandra * 147233541Sjchandra ******************************************************************************/ 148233541Sjchandra 149233541SjchandraACPI_STATUS 150233541SjchandraAcpiExResolveObject ( 151233541Sjchandra ACPI_OPERAND_OBJECT **SourceDescPtr, 152233541Sjchandra ACPI_OBJECT_TYPE8 TargetType, 153233541Sjchandra ACPI_WALK_STATE *WalkState) 154256046Sjchandra{ 155233541Sjchandra ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; 156233541Sjchandra ACPI_STATUS Status = AE_OK; 157233541Sjchandra 158256046Sjchandra 159256046Sjchandra FUNCTION_TRACE ("ExResolveObject"); 160256046Sjchandra 161256046Sjchandra 162256046Sjchandra /* 163256046Sjchandra * Ensure we have a Source that can be stored in the target 164256046Sjchandra */ 165256046Sjchandra switch (TargetType) 166256046Sjchandra { 167256046Sjchandra 168256046Sjchandra /* This case handles the "interchangeable" types Integer, String, and Buffer. */ 169256046Sjchandra 170256046Sjchandra /* 171256046Sjchandra * These cases all require only Integers or values that 172256046Sjchandra * can be converted to Integers (Strings or Buffers) 173256046Sjchandra */ 174256046Sjchandra case ACPI_TYPE_BUFFER_FIELD: 175256046Sjchandra case INTERNAL_TYPE_REGION_FIELD: 176256046Sjchandra case INTERNAL_TYPE_BANK_FIELD: 177256046Sjchandra case INTERNAL_TYPE_INDEX_FIELD: 178256046Sjchandra 179256046Sjchandra /* 180256046Sjchandra * Stores into a Field/Region or into a Buffer/String 181256046Sjchandra * are all essentially the same. 182256046Sjchandra */ 183233541Sjchandra case ACPI_TYPE_INTEGER: 184233541Sjchandra case ACPI_TYPE_STRING: 185233541Sjchandra case ACPI_TYPE_BUFFER: 186233541Sjchandra 187233541Sjchandra 188233541Sjchandra /* TBD: FIX - check for source==REF, resolve, then check type */ 189233541Sjchandra 190233541Sjchandra /* 191233541Sjchandra * If SourceDesc is not a valid type, try to resolve it to one. 192233541Sjchandra */ 193233541Sjchandra if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && 194233541Sjchandra (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && 195233541Sjchandra (SourceDesc->Common.Type != ACPI_TYPE_STRING)) 196233541Sjchandra { 197233541Sjchandra /* 198233541Sjchandra * Initially not a valid type, convert 199233541Sjchandra */ 200233541Sjchandra Status = AcpiExResolveToValue (SourceDescPtr, WalkState); 201233541Sjchandra if (ACPI_SUCCESS (Status) && 202233541Sjchandra (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && 203233541Sjchandra (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && 204233541Sjchandra (SourceDesc->Common.Type != ACPI_TYPE_STRING)) 205233541Sjchandra { 206233541Sjchandra /* 207233541Sjchandra * Conversion successful but still not a valid type 208233541Sjchandra */ 209233541Sjchandra ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 210233541Sjchandra "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 211233541Sjchandra AcpiUtGetTypeName ((*SourceDescPtr)->Common.Type), 212233541Sjchandra AcpiUtGetTypeName (TargetType))); 213256045Sjchandra Status = AE_AML_OPERAND_TYPE; 214256045Sjchandra } 215256045Sjchandra } 216256045Sjchandra break; 217233541Sjchandra 218233541Sjchandra 219256045Sjchandra case INTERNAL_TYPE_ALIAS: 220233541Sjchandra 221233541Sjchandra /* 222256045Sjchandra * Aliases are resolved by AcpiExPrepOperands 223233541Sjchandra */ 224256045Sjchandra ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n")); 225233541Sjchandra Status = AE_AML_INTERNAL; 226233541Sjchandra break; 227233541Sjchandra 228256045Sjchandra 229233541Sjchandra case ACPI_TYPE_PACKAGE: 230256046Sjchandra default: 231256046Sjchandra 232256046Sjchandra /* 233256046Sjchandra * All other types than Alias and the various Fields come here, 234256046Sjchandra * including the untyped case - ACPI_TYPE_ANY. 235256046Sjchandra */ 236256046Sjchandra break; 237233541Sjchandra } 238256046Sjchandra 239256046Sjchandra return_ACPI_STATUS (Status); 240256046Sjchandra} 241256046Sjchandra 242256046Sjchandra 243256046Sjchandra/******************************************************************************* 244256046Sjchandra * 245233541Sjchandra * FUNCTION: AcpiExStoreObject 246256046Sjchandra * 247233541Sjchandra * PARAMETERS: SourceDesc - Object to store 248233541Sjchandra * TargetType - Current type of the target 249233541Sjchandra * TargetDescPtr - Pointer to the target 250233541Sjchandra * WalkState - Current walk state 251233541Sjchandra * 252233541Sjchandra * RETURN: Status 253233541Sjchandra * 254233541Sjchandra * DESCRIPTION: "Store" an object to another object. This may include 255233541Sjchandra * converting the source type to the target type (implicit 256233541Sjchandra * conversion), and a copy of the value of the source to 257233541Sjchandra * the target. 258233541Sjchandra * 259233541Sjchandra ******************************************************************************/ 260233541Sjchandra 261233541SjchandraACPI_STATUS 262233541SjchandraAcpiExStoreObject ( 263233541Sjchandra ACPI_OPERAND_OBJECT *SourceDesc, 264233541Sjchandra ACPI_OBJECT_TYPE8 TargetType, 265233541Sjchandra ACPI_OPERAND_OBJECT **TargetDescPtr, 266233541Sjchandra ACPI_WALK_STATE *WalkState) 267233541Sjchandra{ 268233541Sjchandra ACPI_OPERAND_OBJECT *TargetDesc = *TargetDescPtr; 269233541Sjchandra ACPI_STATUS Status = AE_OK; 270233541Sjchandra 271233541Sjchandra 272233541Sjchandra FUNCTION_TRACE ("ExStoreObject"); 273233541Sjchandra 274233541Sjchandra 275233541Sjchandra /* 276233541Sjchandra * Perform the "implicit conversion" of the source to the current type 277233541Sjchandra * of the target - As per the ACPI specification. 278233541Sjchandra * 279233541Sjchandra * If no conversion performed, SourceDesc is left alone, otherwise it 280233541Sjchandra * is updated with a new object. 281256046Sjchandra */ 282233541Sjchandra Status = AcpiExConvertToTargetType (TargetType, &SourceDesc, WalkState); 283233541Sjchandra if (ACPI_FAILURE (Status)) 284233541Sjchandra { 285233541Sjchandra return_ACPI_STATUS (Status); 286233541Sjchandra } 287233541Sjchandra 288233541Sjchandra /* 289256046Sjchandra * We now have two objects of identical types, and we can perform a 290233541Sjchandra * copy of the *value* of the source object. 291233541Sjchandra */ 292233541Sjchandra switch (TargetType) 293233541Sjchandra { 294233541Sjchandra case ACPI_TYPE_ANY: 295233541Sjchandra case INTERNAL_TYPE_DEF_ANY: 296233541Sjchandra 297233541Sjchandra /* 298233541Sjchandra * The target namespace node is uninitialized (has no target object), 299233541Sjchandra * and will take on the type of the source object 300233541Sjchandra */ 301233541Sjchandra *TargetDescPtr = SourceDesc; 302233541Sjchandra break; 303233541Sjchandra 304233541Sjchandra 305233541Sjchandra case ACPI_TYPE_INTEGER: 306233541Sjchandra 307233541Sjchandra TargetDesc->Integer.Value = SourceDesc->Integer.Value; 308233541Sjchandra 309233541Sjchandra /* Truncate value if we are executing from a 32-bit ACPI table */ 310233541Sjchandra 311233541Sjchandra AcpiExTruncateFor32bitTable (TargetDesc, WalkState); 312233541Sjchandra break; 313233541Sjchandra 314233541Sjchandra case ACPI_TYPE_STRING: 315233541Sjchandra 316233541Sjchandra Status = AcpiExCopyStringToString (SourceDesc, TargetDesc); 317233541Sjchandra break; 318233541Sjchandra 319233541Sjchandra 320233541Sjchandra case ACPI_TYPE_BUFFER: 321233541Sjchandra 322233541Sjchandra Status = AcpiExCopyBufferToBuffer (SourceDesc, TargetDesc); 323233541Sjchandra break; 324256045Sjchandra 325233541Sjchandra 326233541Sjchandra case ACPI_TYPE_PACKAGE: 327233541Sjchandra 328233541Sjchandra /* 329233541Sjchandra * TBD: [Unhandled] Not real sure what to do here 330233541Sjchandra */ 331233541Sjchandra Status = AE_NOT_IMPLEMENTED; 332233541Sjchandra break; 333233541Sjchandra 334233541Sjchandra 335233541Sjchandra default: 336233541Sjchandra 337233541Sjchandra /* 338233541Sjchandra * All other types come here. 339233541Sjchandra */ 340233541Sjchandra ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", 341233541Sjchandra AcpiUtGetTypeName (TargetType))); 342233541Sjchandra 343233541Sjchandra Status = AE_NOT_IMPLEMENTED; 344233541Sjchandra break; 345233541Sjchandra } 346233541Sjchandra 347256045Sjchandra 348233541Sjchandra return_ACPI_STATUS (Status); 349233541Sjchandra} 350233541Sjchandra 351233541Sjchandra 352233541Sjchandra