exstore.c revision 91116
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 591116Smsmith * $Revision: 162 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 1391116Smsmith * Some or all of this work - Copyright (c) 1999 - 2002, 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 "acparser.h" 12267754Smsmith#include "acdispat.h" 12367754Smsmith#include "acinterp.h" 12467754Smsmith#include "amlcode.h" 12567754Smsmith#include "acnamesp.h" 12667754Smsmith#include "actables.h" 12767754Smsmith 12867754Smsmith 12977424Smsmith#define _COMPONENT ACPI_EXECUTER 13091116Smsmith ACPI_MODULE_NAME ("exstore") 13167754Smsmith 13267754Smsmith 13367754Smsmith/******************************************************************************* 13467754Smsmith * 13577424Smsmith * FUNCTION: AcpiExStore 13667754Smsmith * 13785756Smsmith * PARAMETERS: *SourceDesc - Value to be stored 13877424Smsmith * *DestDesc - Where to store it. Must be an NS node 13977424Smsmith * or an ACPI_OPERAND_OBJECT of type 14087031Smsmith * Reference; 14187031Smsmith * WalkState - Current walk state 14267754Smsmith * 14367754Smsmith * RETURN: Status 14467754Smsmith * 14585756Smsmith * DESCRIPTION: Store the value described by SourceDesc into the location 14667754Smsmith * described by DestDesc. Called by various interpreter 14767754Smsmith * functions to store the result of an operation into 14891116Smsmith * the destination operand -- not just simply the actual "Store" 14987031Smsmith * ASL operator. 15067754Smsmith * 15167754Smsmith ******************************************************************************/ 15267754Smsmith 15367754SmsmithACPI_STATUS 15477424SmsmithAcpiExStore ( 15585756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 15667754Smsmith ACPI_OPERAND_OBJECT *DestDesc, 15767754Smsmith ACPI_WALK_STATE *WalkState) 15867754Smsmith{ 15967754Smsmith ACPI_STATUS Status = AE_OK; 16071867Smsmith ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 16167754Smsmith 16267754Smsmith 16391116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc); 16467754Smsmith 16567754Smsmith 16667754Smsmith /* Validate parameters */ 16767754Smsmith 16885756Smsmith if (!SourceDesc || !DestDesc) 16967754Smsmith { 17091116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); 17167754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 17267754Smsmith } 17367754Smsmith 17471867Smsmith /* DestDesc can be either a namespace node or an ACPI object */ 17567754Smsmith 17691116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 17767754Smsmith { 17877424Smsmith /* 17971867Smsmith * Dest is a namespace node, 18077424Smsmith * Storing an object into a Name "container" 18171867Smsmith */ 18285756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, 18371867Smsmith (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); 18467754Smsmith 18571867Smsmith return_ACPI_STATUS (Status); 18667754Smsmith } 18767754Smsmith 18871867Smsmith /* Destination object must be an object of type Reference */ 18967754Smsmith 19067754Smsmith if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE) 19167754Smsmith { 19267754Smsmith /* Destination is not an Reference */ 19367754Smsmith 19482367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 19582367Smsmith "Destination is not a ReferenceObj [%p]\n", DestDesc)); 19667754Smsmith 19791116Smsmith ACPI_DUMP_STACK_ENTRY (SourceDesc); 19891116Smsmith ACPI_DUMP_STACK_ENTRY (DestDesc); 19991116Smsmith ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore", 20071867Smsmith 2, "Target is not a ReferenceObj"); 20167754Smsmith 20267754Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 20367754Smsmith } 20467754Smsmith 20577424Smsmith /* 20671867Smsmith * Examine the Reference opcode. These cases are handled: 20771867Smsmith * 20871867Smsmith * 1) Store to Name (Change the object associated with a name) 20971867Smsmith * 2) Store to an indexed area of a Buffer or Package 21071867Smsmith * 3) Store to a Method Local or Arg 21171867Smsmith * 4) Store to the debug object 21271867Smsmith * 5) Store to a constant -- a noop 21371867Smsmith */ 21477424Smsmith switch (RefDesc->Reference.Opcode) 21567754Smsmith { 21667754Smsmith case AML_NAME_OP: 21767754Smsmith 21871867Smsmith /* Storing an object into a Name "container" */ 21971867Smsmith 22085756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, 22167754Smsmith WalkState); 22271867Smsmith break; 22367754Smsmith 22467754Smsmith 22567754Smsmith case AML_INDEX_OP: 22667754Smsmith 22771867Smsmith /* Storing to an Index (pointer into a packager or buffer) */ 22867754Smsmith 22985756Smsmith Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 23071867Smsmith break; 23171867Smsmith 23271867Smsmith 23371867Smsmith case AML_LOCAL_OP: 23477424Smsmith case AML_ARG_OP: 23571867Smsmith 23677424Smsmith /* Store to a method local/arg */ 23771867Smsmith 23877424Smsmith Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, 23985756Smsmith RefDesc->Reference.Offset, SourceDesc, WalkState); 24071867Smsmith break; 24171867Smsmith 24271867Smsmith 24371867Smsmith case AML_DEBUG_OP: 24471867Smsmith 24567754Smsmith /* 24671867Smsmith * Storing to the Debug object causes the value stored to be 24771867Smsmith * displayed and otherwise has no effect -- see ACPI Specification 24867754Smsmith */ 24983174Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Write to Debug Object: ****:\n\n")); 25077424Smsmith 25183174Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", 25285756Smsmith AcpiUtGetTypeName (SourceDesc->Common.Type))); 25377424Smsmith 25485756Smsmith switch (SourceDesc->Common.Type) 25571867Smsmith { 25677424Smsmith case ACPI_TYPE_INTEGER: 25777424Smsmith 25891116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n", 25991116Smsmith ACPI_HIWORD (SourceDesc->Integer.Value), 26091116Smsmith ACPI_LOWORD (SourceDesc->Integer.Value))); 26177424Smsmith break; 26277424Smsmith 26377424Smsmith 26477424Smsmith case ACPI_TYPE_BUFFER: 26577424Smsmith 26691116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", 26791116Smsmith (UINT32) SourceDesc->Buffer.Length)); 26877424Smsmith break; 26977424Smsmith 27077424Smsmith 27177424Smsmith case ACPI_TYPE_STRING: 27277424Smsmith 27385756Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", SourceDesc->String.Pointer)); 27477424Smsmith break; 27577424Smsmith 27677424Smsmith 27777424Smsmith case ACPI_TYPE_PACKAGE: 27877424Smsmith 27991116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", 28091116Smsmith SourceDesc->Package.Elements)); 28177424Smsmith break; 28277424Smsmith 28377424Smsmith 28477424Smsmith default: 28577424Smsmith 28691116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", 28791116Smsmith AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc)); 28877424Smsmith break; 28971867Smsmith } 29067754Smsmith 29183174Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n")); 29271867Smsmith break; 29371867Smsmith 29471867Smsmith 29571867Smsmith case AML_ZERO_OP: 29671867Smsmith case AML_ONE_OP: 29771867Smsmith case AML_ONES_OP: 29882367Smsmith case AML_REVISION_OP: 29971867Smsmith 30067754Smsmith /* 30191116Smsmith * Storing to a constant is a no-op according to the ACPI 30287031Smsmith * Specification. (Delete the reference descriptor, however.) 30371867Smsmith */ 30471867Smsmith break; 30571867Smsmith 30671867Smsmith 30771867Smsmith default: 30871867Smsmith 30987031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %02x\n", 31077424Smsmith RefDesc->Reference.Opcode)); 31191116Smsmith ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); 31271867Smsmith 31371867Smsmith Status = AE_AML_INTERNAL; 31471867Smsmith break; 31571867Smsmith 31677424Smsmith } /* switch (RefDesc->Reference.Opcode) */ 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; 38967754Smsmith } 39071867Smsmith break; 39167754Smsmith 39267754Smsmith 39371867Smsmith case ACPI_TYPE_BUFFER_FIELD: 39477424Smsmith 39567754Smsmith /* 39691116Smsmith * Store into a Buffer (not actually a real BufferField) at a 39787031Smsmith * location defined by an Index. 39867754Smsmith * 39987031Smsmith * The first 8-bit element of the source object is written to the 40087031Smsmith * 8-bit Buffer location defined by the Index destination object, 40187031Smsmith * according to the ACPI 2.0 specification. 40267754Smsmith */ 40367754Smsmith 40467754Smsmith /* 40587031Smsmith * Make sure the target is a Buffer 40667754Smsmith */ 40791116Smsmith ObjDesc = IndexDesc->Reference.Object; 40871867Smsmith if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER) 40967754Smsmith { 41071867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 41167754Smsmith } 41267754Smsmith 41367754Smsmith /* 41467754Smsmith * The assignment of the individual elements will be slightly 41567754Smsmith * different for each source type. 41667754Smsmith */ 41785756Smsmith switch (SourceDesc->Common.Type) 41867754Smsmith { 41971867Smsmith case ACPI_TYPE_INTEGER: 42087031Smsmith 42187031Smsmith /* Use the least-significant byte of the integer */ 42287031Smsmith 42387031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 42467754Smsmith break; 42567754Smsmith 42687031Smsmith case ACPI_TYPE_BUFFER: 42777424Smsmith 42887031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 42967754Smsmith break; 43067754Smsmith 43187031Smsmith case ACPI_TYPE_STRING: 43277424Smsmith 43387031Smsmith Value = SourceDesc->String.Pointer[0]; 43467754Smsmith break; 43567754Smsmith 43667754Smsmith default: 43777424Smsmith 43887031Smsmith /* All other types are invalid */ 43977424Smsmith 44082367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 44187031Smsmith "Source must be Integer/Buffer/String type, not %s\n", 44287031Smsmith AcpiUtGetTypeName (SourceDesc->Common.Type))); 44387031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 44467754Smsmith } 44587031Smsmith 44687031Smsmith /* Store the source value into the target buffer byte */ 44787031Smsmith 44891116Smsmith ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; 44971867Smsmith break; 45067754Smsmith 45167754Smsmith 45271867Smsmith default: 45391116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 45487031Smsmith "Target is not a Package or BufferField\n")); 45571867Smsmith Status = AE_AML_OPERAND_TYPE; 45667754Smsmith break; 45771867Smsmith } 45867754Smsmith 45971867Smsmith return_ACPI_STATUS (Status); 46071867Smsmith} 46167754Smsmith 46267754Smsmith 46371867Smsmith/******************************************************************************* 46471867Smsmith * 46577424Smsmith * FUNCTION: AcpiExStoreObjectToNode 46671867Smsmith * 46787031Smsmith * PARAMETERS: SourceDesc - Value to be stored 46887031Smsmith * Node - Named object to receive the value 46987031Smsmith * WalkState - Current walk state 47071867Smsmith * 47171867Smsmith * RETURN: Status 47271867Smsmith * 47371867Smsmith * DESCRIPTION: Store the object to the named object. 47471867Smsmith * 47571867Smsmith * The Assignment of an object to a named object is handled here 47687031Smsmith * The value passed in will replace the current value (if any) 47771867Smsmith * with the input value. 47871867Smsmith * 47971867Smsmith * When storing into an object the data is converted to the 48071867Smsmith * target object type then stored in the object. This means 48171867Smsmith * that the target object type (for an initialized target) will 48271867Smsmith * not be changed by a store operation. 48371867Smsmith * 48487031Smsmith * Assumes parameters are already validated. 48571867Smsmith * 48671867Smsmith ******************************************************************************/ 48767754Smsmith 48871867SmsmithACPI_STATUS 48977424SmsmithAcpiExStoreObjectToNode ( 49071867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 49171867Smsmith ACPI_NAMESPACE_NODE *Node, 49271867Smsmith ACPI_WALK_STATE *WalkState) 49371867Smsmith{ 49471867Smsmith ACPI_STATUS Status = AE_OK; 49571867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 49691116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 49791116Smsmith ACPI_OBJECT_TYPE TargetType; 49867754Smsmith 49971867Smsmith 50091116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); 50171867Smsmith 50283174Smsmith 50371867Smsmith /* 50471867Smsmith * Get current type of the node, and object attached to Node 50571867Smsmith */ 50671867Smsmith TargetType = AcpiNsGetType (Node); 50771867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 50871867Smsmith 50982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) into node %p(%s)\n", 51091116Smsmith SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), 51191116Smsmith Node, AcpiUtGetTypeName (TargetType))); 51271867Smsmith 51371867Smsmith /* 51471867Smsmith * Resolve the source object to an actual value 51577424Smsmith * (If it is a reference object) 51671867Smsmith */ 51777424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 51871867Smsmith if (ACPI_FAILURE (Status)) 51971867Smsmith { 52071867Smsmith return_ACPI_STATUS (Status); 52171867Smsmith } 52271867Smsmith 52371867Smsmith /* 52477424Smsmith * Do the actual store operation 52571867Smsmith */ 52671867Smsmith switch (TargetType) 52771867Smsmith { 52877424Smsmith case ACPI_TYPE_BUFFER_FIELD: 52977424Smsmith case INTERNAL_TYPE_REGION_FIELD: 53077424Smsmith case INTERNAL_TYPE_BANK_FIELD: 53177424Smsmith case INTERNAL_TYPE_INDEX_FIELD: 53271867Smsmith 53377424Smsmith /* 53477424Smsmith * For fields, copy the source data to the target field. 53577424Smsmith */ 53677424Smsmith Status = AcpiExWriteDataToField (SourceDesc, TargetDesc); 53767754Smsmith break; 53867754Smsmith 53967754Smsmith 54071867Smsmith case ACPI_TYPE_INTEGER: 54171867Smsmith case ACPI_TYPE_STRING: 54271867Smsmith case ACPI_TYPE_BUFFER: 54367754Smsmith 54477424Smsmith /* 54571867Smsmith * These target types are all of type Integer/String/Buffer, and 54671867Smsmith * therefore support implicit conversion before the store. 54777424Smsmith * 54877424Smsmith * Copy and/or convert the source object to a new target object 54967754Smsmith */ 55091116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); 55171867Smsmith if (ACPI_FAILURE (Status)) 55267754Smsmith { 55371867Smsmith return_ACPI_STATUS (Status); 55467754Smsmith } 55567754Smsmith 55691116Smsmith if (NewDesc != TargetDesc) 55791116Smsmith { 55891116Smsmith /* 55991116Smsmith * Store the new NewDesc as the new value of the Name, and set 56091116Smsmith * the Name's type to that of the value being stored in it. 56191116Smsmith * SourceDesc reference count is incremented by AttachObject. 56291116Smsmith */ 56391116Smsmith Status = AcpiNsAttachObject (Node, NewDesc, TargetType); 56485756Smsmith 56591116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 56691116Smsmith "Store %s into %s via Convert/Attach\n", 56791116Smsmith AcpiUtGetTypeName (SourceDesc->Common.Type), 56891116Smsmith AcpiUtGetTypeName (NewDesc->Common.Type))); 56991116Smsmith } 57067754Smsmith break; 57167754Smsmith 57277424Smsmith 57367754Smsmith default: 57467754Smsmith 57584491Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 57684491Smsmith "Storing %s (%p) directly into node (%p), no implicit conversion\n", 57784491Smsmith AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc, Node)); 57884491Smsmith 57971867Smsmith /* No conversions for all other types. Just attach the source object */ 58067754Smsmith 58171867Smsmith Status = AcpiNsAttachObject (Node, SourceDesc, SourceDesc->Common.Type); 58271867Smsmith break; 58371867Smsmith } 58467754Smsmith 58571867Smsmith return_ACPI_STATUS (Status); 58671867Smsmith} 58767754Smsmith 58867754Smsmith 589