exstore.c revision 123315
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 5123315Snjl * $Revision: 177 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 13114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 1470243Smsmith * All rights reserved. 1567754Smsmith * 1667754Smsmith * 2. License 1767754Smsmith * 1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1967754Smsmith * rights. You may have additional license terms from the party that provided 2067754Smsmith * you this software, covering your right to use that party's intellectual 2167754Smsmith * property rights. 2267754Smsmith * 2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2867754Smsmith * Code in any form, with the right to sublicense such rights; and 2967754Smsmith * 3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3167754Smsmith * license (with the right to sublicense), under only those claims of Intel 3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3567754Smsmith * license, and in no event shall the patent license extend to any additions 3667754Smsmith * to or modifications of the Original Intel Code. No other license or right 3767754Smsmith * is granted directly or by implication, estoppel or otherwise; 3867754Smsmith * 3967754Smsmith * The above copyright and patent license is granted only if the following 4067754Smsmith * conditions are met: 4167754Smsmith * 4267754Smsmith * 3. Conditions 4367754Smsmith * 4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4567754Smsmith * Redistribution of source code of any substantial portion of the Covered 4667754Smsmith * Code or modification with rights to further distribute source must include 4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4867754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5167754Smsmith * Code and the date of any change. Licensee must include in that file the 5267754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5367754Smsmith * must include a prominent statement that the modification is derived, 5467754Smsmith * directly or indirectly, from Original Intel Code. 5567754Smsmith * 5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5767754Smsmith * Redistribution of source code of any substantial portion of the Covered 5867754Smsmith * Code or modification without rights to further distribute source must 5967754Smsmith * include the following Disclaimer and Export Compliance provision in the 6067754Smsmith * documentation and/or other materials provided with distribution. In 6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6367754Smsmith * license from Licensee to its licensee is limited to the intellectual 6467754Smsmith * property embodied in the software Licensee provides to its licensee, and 6567754Smsmith * not to intellectual property embodied in modifications its licensee may 6667754Smsmith * make. 6767754Smsmith * 6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7167754Smsmith * provision in the documentation and/or other materials provided with the 7267754Smsmith * distribution. 7367754Smsmith * 7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7567754Smsmith * Intel Code. 7667754Smsmith * 7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7967754Smsmith * other dealings in products derived from or relating to the Covered Code 8067754Smsmith * without prior written authorization from Intel. 8167754Smsmith * 8267754Smsmith * 4. Disclaimer and Export Compliance 8367754Smsmith * 8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8567754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9067754Smsmith * PARTICULAR PURPOSE. 9167754Smsmith * 9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9967754Smsmith * LIMITED REMEDY. 10067754Smsmith * 10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10267754Smsmith * software or system incorporating such software without first obtaining any 10367754Smsmith * required license or other approval from the U. S. Department of Commerce or 10467754Smsmith * any other agency or department of the United States Government. In the 10567754Smsmith * event Licensee exports any such software from the United States or 10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10767754Smsmith * ensure that the distribution and export/re-export of the software is in 10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11167754Smsmith * software, or service, directly or indirectly, to any country for which the 11267754Smsmith * United States government or any agency thereof requires an export license, 11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11467754Smsmith * such license, approval or letter. 11567754Smsmith * 11667754Smsmith *****************************************************************************/ 11767754Smsmith 11877424Smsmith#define __EXSTORE_C__ 11967754Smsmith 12067754Smsmith#include "acpi.h" 12167754Smsmith#include "acdispat.h" 12267754Smsmith#include "acinterp.h" 12367754Smsmith#include "amlcode.h" 12467754Smsmith#include "acnamesp.h" 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_EXECUTER 12891116Smsmith ACPI_MODULE_NAME ("exstore") 12967754Smsmith 13067754Smsmith 13167754Smsmith/******************************************************************************* 13267754Smsmith * 13377424Smsmith * FUNCTION: AcpiExStore 13467754Smsmith * 13585756Smsmith * PARAMETERS: *SourceDesc - Value to be stored 13677424Smsmith * *DestDesc - Where to store it. Must be an NS node 13777424Smsmith * or an ACPI_OPERAND_OBJECT of type 13887031Smsmith * Reference; 13987031Smsmith * WalkState - Current walk state 14067754Smsmith * 14167754Smsmith * RETURN: Status 14267754Smsmith * 14385756Smsmith * DESCRIPTION: Store the value described by SourceDesc into the location 14467754Smsmith * described by DestDesc. Called by various interpreter 14567754Smsmith * functions to store the result of an operation into 14691116Smsmith * the destination operand -- not just simply the actual "Store" 14787031Smsmith * ASL operator. 14867754Smsmith * 14967754Smsmith ******************************************************************************/ 15067754Smsmith 15167754SmsmithACPI_STATUS 15277424SmsmithAcpiExStore ( 15385756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 15467754Smsmith ACPI_OPERAND_OBJECT *DestDesc, 15567754Smsmith ACPI_WALK_STATE *WalkState) 15667754Smsmith{ 15767754Smsmith ACPI_STATUS Status = AE_OK; 15871867Smsmith ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 15967754Smsmith 16067754Smsmith 16191116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc); 16267754Smsmith 16367754Smsmith 16467754Smsmith /* Validate parameters */ 16567754Smsmith 16685756Smsmith if (!SourceDesc || !DestDesc) 16767754Smsmith { 16891116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); 16967754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 17067754Smsmith } 17167754Smsmith 17271867Smsmith /* DestDesc can be either a namespace node or an ACPI object */ 17367754Smsmith 17491116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 17567754Smsmith { 17677424Smsmith /* 17771867Smsmith * Dest is a namespace node, 178107325Siwasaki * Storing an object into a Named node. 17971867Smsmith */ 18085756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, 18171867Smsmith (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); 18267754Smsmith 18371867Smsmith return_ACPI_STATUS (Status); 18467754Smsmith } 18567754Smsmith 18699679Siwasaki /* Destination object must be a Reference or a Constant object */ 18767754Smsmith 18899679Siwasaki switch (ACPI_GET_OBJECT_TYPE (DestDesc)) 189102550Siwasaki { 190107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 19199679Siwasaki break; 19299679Siwasaki 19399679Siwasaki case ACPI_TYPE_INTEGER: 19499679Siwasaki 19599679Siwasaki /* Allow stores to Constants -- a Noop as per ACPI spec */ 19699679Siwasaki 19799679Siwasaki if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) 19899679Siwasaki { 19999679Siwasaki return_ACPI_STATUS (AE_OK); 20099679Siwasaki } 20199679Siwasaki 202104470Siwasaki /*lint -fallthrough */ 20399679Siwasaki 20499679Siwasaki default: 20599679Siwasaki 20667754Smsmith /* Destination is not an Reference */ 20767754Smsmith 20882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 20999679Siwasaki "Destination is not a Reference or Constant object [%p]\n", DestDesc)); 21067754Smsmith 21191116Smsmith ACPI_DUMP_STACK_ENTRY (SourceDesc); 21291116Smsmith ACPI_DUMP_STACK_ENTRY (DestDesc); 21391116Smsmith ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore", 21499679Siwasaki 2, "Target is not a Reference or Constant object"); 21567754Smsmith 21667754Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 21767754Smsmith } 21867754Smsmith 21977424Smsmith /* 22071867Smsmith * Examine the Reference opcode. These cases are handled: 22171867Smsmith * 22271867Smsmith * 1) Store to Name (Change the object associated with a name) 22371867Smsmith * 2) Store to an indexed area of a Buffer or Package 22471867Smsmith * 3) Store to a Method Local or Arg 22571867Smsmith * 4) Store to the debug object 22671867Smsmith */ 22777424Smsmith switch (RefDesc->Reference.Opcode) 22867754Smsmith { 22967754Smsmith case AML_NAME_OP: 230100966Siwasaki case AML_REF_OF_OP: 23167754Smsmith 23271867Smsmith /* Storing an object into a Name "container" */ 23371867Smsmith 23485756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, 23567754Smsmith WalkState); 23671867Smsmith break; 23767754Smsmith 23867754Smsmith 23967754Smsmith case AML_INDEX_OP: 24067754Smsmith 24171867Smsmith /* Storing to an Index (pointer into a packager or buffer) */ 24267754Smsmith 24385756Smsmith Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 24471867Smsmith break; 24571867Smsmith 24671867Smsmith 24771867Smsmith case AML_LOCAL_OP: 24877424Smsmith case AML_ARG_OP: 24971867Smsmith 25077424Smsmith /* Store to a method local/arg */ 25171867Smsmith 25277424Smsmith Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, 25385756Smsmith RefDesc->Reference.Offset, SourceDesc, WalkState); 25471867Smsmith break; 25571867Smsmith 25671867Smsmith 25771867Smsmith case AML_DEBUG_OP: 25871867Smsmith 25967754Smsmith /* 26071867Smsmith * Storing to the Debug object causes the value stored to be 26171867Smsmith * displayed and otherwise has no effect -- see ACPI Specification 26267754Smsmith */ 26399146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n")); 26477424Smsmith 26583174Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", 26699679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 26777424Smsmith 26899679Siwasaki switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 26971867Smsmith { 27077424Smsmith case ACPI_TYPE_INTEGER: 27177424Smsmith 27291116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n", 273123315Snjl ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); 27477424Smsmith break; 27577424Smsmith 27677424Smsmith 27777424Smsmith case ACPI_TYPE_BUFFER: 27877424Smsmith 27991116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", 28091116Smsmith (UINT32) SourceDesc->Buffer.Length)); 28177424Smsmith break; 28277424Smsmith 28377424Smsmith 28477424Smsmith case ACPI_TYPE_STRING: 28577424Smsmith 28685756Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", SourceDesc->String.Pointer)); 28777424Smsmith break; 28877424Smsmith 28977424Smsmith 29077424Smsmith case ACPI_TYPE_PACKAGE: 29177424Smsmith 29291116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", 29391116Smsmith SourceDesc->Package.Elements)); 29477424Smsmith break; 29577424Smsmith 29677424Smsmith 29777424Smsmith default: 29877424Smsmith 29991116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", 30099679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc)); 30177424Smsmith break; 30271867Smsmith } 30367754Smsmith 30499146Siwasaki ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); 30571867Smsmith break; 30671867Smsmith 30771867Smsmith 30871867Smsmith default: 30971867Smsmith 31099679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n", 31177424Smsmith RefDesc->Reference.Opcode)); 31291116Smsmith ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); 31371867Smsmith 31471867Smsmith Status = AE_AML_INTERNAL; 31571867Smsmith break; 31699679Siwasaki } 31771867Smsmith 31871867Smsmith return_ACPI_STATUS (Status); 31971867Smsmith} 32071867Smsmith 32171867Smsmith 32271867Smsmith/******************************************************************************* 32371867Smsmith * 32477424Smsmith * FUNCTION: AcpiExStoreObjectToIndex 32571867Smsmith * 32687031Smsmith * PARAMETERS: *SourceDesc - Value to be stored 32787031Smsmith * *DestDesc - Named object to receive the value 32887031Smsmith * WalkState - Current walk state 32971867Smsmith * 33071867Smsmith * RETURN: Status 33171867Smsmith * 33287031Smsmith * DESCRIPTION: Store the object to indexed Buffer or Package element 33371867Smsmith * 33471867Smsmith ******************************************************************************/ 33571867Smsmith 33671867SmsmithACPI_STATUS 33777424SmsmithAcpiExStoreObjectToIndex ( 33885756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 33991116Smsmith ACPI_OPERAND_OBJECT *IndexDesc, 34071867Smsmith ACPI_WALK_STATE *WalkState) 34171867Smsmith{ 34271867Smsmith ACPI_STATUS Status = AE_OK; 34371867Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 34491116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 34571867Smsmith UINT8 Value = 0; 34671867Smsmith 34771867Smsmith 34891116Smsmith ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex"); 34971867Smsmith 35071867Smsmith 35171867Smsmith /* 35271867Smsmith * Destination must be a reference pointer, and 35371867Smsmith * must point to either a buffer or a package 35471867Smsmith */ 35591116Smsmith switch (IndexDesc->Reference.TargetType) 35671867Smsmith { 35771867Smsmith case ACPI_TYPE_PACKAGE: 35871867Smsmith /* 35971867Smsmith * Storing to a package element is not simple. The source must be 36067754Smsmith * evaluated and converted to the type of the destination and then the 36167754Smsmith * source is copied into the destination - we can't just point to the 36267754Smsmith * source object. 36367754Smsmith */ 36491116Smsmith /* 36591116Smsmith * The object at *(IndexDesc->Reference.Where) is the 36691116Smsmith * element within the package that is to be modified. 36791116Smsmith */ 36891116Smsmith ObjDesc = *(IndexDesc->Reference.Where); 36985756Smsmith 37091116Smsmith /* Do the conversion/store */ 37167754Smsmith 37291116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, 37391116Smsmith WalkState); 37491116Smsmith if (ACPI_FAILURE (Status)) 37591116Smsmith { 37691116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 37791116Smsmith "Could not store object to indexed package element\n")); 37891116Smsmith return_ACPI_STATUS (Status); 37991116Smsmith } 38067754Smsmith 38191116Smsmith /* 38291116Smsmith * If a new object was created, we must install it as the new 38391116Smsmith * package element 38491116Smsmith */ 38591116Smsmith if (NewDesc != ObjDesc) 38691116Smsmith { 38791116Smsmith AcpiUtRemoveReference (ObjDesc); 38891116Smsmith *(IndexDesc->Reference.Where) = NewDesc; 389104470Siwasaki 390104470Siwasaki /* If same as the original source, add a reference */ 391104470Siwasaki 392104470Siwasaki if (NewDesc == SourceDesc) 393104470Siwasaki { 394104470Siwasaki AcpiUtAddReference (NewDesc); 395104470Siwasaki } 39667754Smsmith } 39771867Smsmith break; 39867754Smsmith 39967754Smsmith 40071867Smsmith case ACPI_TYPE_BUFFER_FIELD: 40177424Smsmith 40267754Smsmith /* 40391116Smsmith * Store into a Buffer (not actually a real BufferField) at a 40487031Smsmith * location defined by an Index. 40567754Smsmith * 40687031Smsmith * The first 8-bit element of the source object is written to the 40787031Smsmith * 8-bit Buffer location defined by the Index destination object, 40887031Smsmith * according to the ACPI 2.0 specification. 40967754Smsmith */ 41067754Smsmith 41167754Smsmith /* 41287031Smsmith * Make sure the target is a Buffer 41367754Smsmith */ 41491116Smsmith ObjDesc = IndexDesc->Reference.Object; 41599679Siwasaki if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) 41667754Smsmith { 41771867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 41867754Smsmith } 41967754Smsmith 42067754Smsmith /* 42167754Smsmith * The assignment of the individual elements will be slightly 42267754Smsmith * different for each source type. 42367754Smsmith */ 42499679Siwasaki switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 42567754Smsmith { 42671867Smsmith case ACPI_TYPE_INTEGER: 42787031Smsmith 42887031Smsmith /* Use the least-significant byte of the integer */ 42987031Smsmith 43087031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 43167754Smsmith break; 43267754Smsmith 43387031Smsmith case ACPI_TYPE_BUFFER: 43477424Smsmith 43587031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 43667754Smsmith break; 43767754Smsmith 43887031Smsmith case ACPI_TYPE_STRING: 43977424Smsmith 44099679Siwasaki Value = (UINT8) SourceDesc->String.Pointer[0]; 44167754Smsmith break; 44267754Smsmith 44367754Smsmith default: 44477424Smsmith 44587031Smsmith /* All other types are invalid */ 44677424Smsmith 44782367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 44887031Smsmith "Source must be Integer/Buffer/String type, not %s\n", 44999679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 45087031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 45167754Smsmith } 45287031Smsmith 45387031Smsmith /* Store the source value into the target buffer byte */ 45487031Smsmith 45591116Smsmith ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; 45671867Smsmith break; 45767754Smsmith 45867754Smsmith 45971867Smsmith default: 46091116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 46187031Smsmith "Target is not a Package or BufferField\n")); 46271867Smsmith Status = AE_AML_OPERAND_TYPE; 46367754Smsmith break; 46471867Smsmith } 46567754Smsmith 46671867Smsmith return_ACPI_STATUS (Status); 46771867Smsmith} 46867754Smsmith 46967754Smsmith 47071867Smsmith/******************************************************************************* 47171867Smsmith * 47277424Smsmith * FUNCTION: AcpiExStoreObjectToNode 47371867Smsmith * 47487031Smsmith * PARAMETERS: SourceDesc - Value to be stored 47587031Smsmith * Node - Named object to receive the value 47687031Smsmith * WalkState - Current walk state 47771867Smsmith * 47871867Smsmith * RETURN: Status 47971867Smsmith * 48071867Smsmith * DESCRIPTION: Store the object to the named object. 48171867Smsmith * 48271867Smsmith * The Assignment of an object to a named object is handled here 48387031Smsmith * The value passed in will replace the current value (if any) 48471867Smsmith * with the input value. 48571867Smsmith * 48671867Smsmith * When storing into an object the data is converted to the 48771867Smsmith * target object type then stored in the object. This means 48871867Smsmith * that the target object type (for an initialized target) will 48971867Smsmith * not be changed by a store operation. 49071867Smsmith * 49187031Smsmith * Assumes parameters are already validated. 49271867Smsmith * 49371867Smsmith ******************************************************************************/ 49467754Smsmith 49571867SmsmithACPI_STATUS 49677424SmsmithAcpiExStoreObjectToNode ( 49771867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 49871867Smsmith ACPI_NAMESPACE_NODE *Node, 49971867Smsmith ACPI_WALK_STATE *WalkState) 50071867Smsmith{ 50171867Smsmith ACPI_STATUS Status = AE_OK; 50271867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 50391116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 50491116Smsmith ACPI_OBJECT_TYPE TargetType; 50567754Smsmith 50671867Smsmith 50791116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); 50871867Smsmith 50983174Smsmith 51071867Smsmith /* 51171867Smsmith * Get current type of the node, and object attached to Node 51271867Smsmith */ 51371867Smsmith TargetType = AcpiNsGetType (Node); 51471867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 51571867Smsmith 51699146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 51799679Siwasaki SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 51891116Smsmith Node, AcpiUtGetTypeName (TargetType))); 51971867Smsmith 52071867Smsmith /* 52171867Smsmith * Resolve the source object to an actual value 52277424Smsmith * (If it is a reference object) 52371867Smsmith */ 52477424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 52571867Smsmith if (ACPI_FAILURE (Status)) 52671867Smsmith { 52771867Smsmith return_ACPI_STATUS (Status); 52871867Smsmith } 52971867Smsmith 53071867Smsmith /* 53177424Smsmith * Do the actual store operation 53271867Smsmith */ 53371867Smsmith switch (TargetType) 53471867Smsmith { 53577424Smsmith case ACPI_TYPE_BUFFER_FIELD: 536107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 537107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 538107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 53971867Smsmith 54077424Smsmith /* 54177424Smsmith * For fields, copy the source data to the target field. 54277424Smsmith */ 543107325Siwasaki Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, &WalkState->ResultObj); 54467754Smsmith break; 54567754Smsmith 54667754Smsmith 54771867Smsmith case ACPI_TYPE_INTEGER: 54871867Smsmith case ACPI_TYPE_STRING: 54971867Smsmith case ACPI_TYPE_BUFFER: 55067754Smsmith 55177424Smsmith /* 55271867Smsmith * These target types are all of type Integer/String/Buffer, and 55371867Smsmith * therefore support implicit conversion before the store. 55477424Smsmith * 55577424Smsmith * Copy and/or convert the source object to a new target object 55667754Smsmith */ 55791116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); 55871867Smsmith if (ACPI_FAILURE (Status)) 55967754Smsmith { 56071867Smsmith return_ACPI_STATUS (Status); 56167754Smsmith } 56267754Smsmith 56391116Smsmith if (NewDesc != TargetDesc) 56491116Smsmith { 56591116Smsmith /* 56691116Smsmith * Store the new NewDesc as the new value of the Name, and set 56791116Smsmith * the Name's type to that of the value being stored in it. 56891116Smsmith * SourceDesc reference count is incremented by AttachObject. 569104470Siwasaki * 570104470Siwasaki * Note: This may change the type of the node if an explicit store 571104470Siwasaki * has been performed such that the node/object type has been 572104470Siwasaki * changed. 57391116Smsmith */ 574104470Siwasaki Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 57585756Smsmith 57699146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 57791116Smsmith "Store %s into %s via Convert/Attach\n", 57899679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), 57999679Siwasaki AcpiUtGetObjectTypeName (NewDesc))); 58091116Smsmith } 58167754Smsmith break; 58267754Smsmith 58377424Smsmith 58467754Smsmith default: 58567754Smsmith 58699146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 58784491Smsmith "Storing %s (%p) directly into node (%p), no implicit conversion\n", 58899679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 58984491Smsmith 59071867Smsmith /* No conversions for all other types. Just attach the source object */ 59167754Smsmith 59299679Siwasaki Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc)); 59371867Smsmith break; 59471867Smsmith } 59567754Smsmith 59671867Smsmith return_ACPI_STATUS (Status); 59771867Smsmith} 59867754Smsmith 59967754Smsmith 600