exstore.c revision 100966
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 5100966Siwasaki * $Revision: 168 $ 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 "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, 17877424Smsmith * Storing an object into a Name "container" 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)) 18999679Siwasaki { 19099679Siwasaki case INTERNAL_TYPE_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 20299679Siwasaki /*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", 27391116Smsmith ACPI_HIWORD (SourceDesc->Integer.Value), 27491116Smsmith ACPI_LOWORD (SourceDesc->Integer.Value))); 27577424Smsmith break; 27677424Smsmith 27777424Smsmith 27877424Smsmith case ACPI_TYPE_BUFFER: 27977424Smsmith 28091116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", 28191116Smsmith (UINT32) SourceDesc->Buffer.Length)); 28277424Smsmith break; 28377424Smsmith 28477424Smsmith 28577424Smsmith case ACPI_TYPE_STRING: 28677424Smsmith 28785756Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", SourceDesc->String.Pointer)); 28877424Smsmith break; 28977424Smsmith 29077424Smsmith 29177424Smsmith case ACPI_TYPE_PACKAGE: 29277424Smsmith 29391116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", 29491116Smsmith SourceDesc->Package.Elements)); 29577424Smsmith break; 29677424Smsmith 29777424Smsmith 29877424Smsmith default: 29977424Smsmith 30091116Smsmith ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", 30199679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc)); 30277424Smsmith break; 30371867Smsmith } 30467754Smsmith 30599146Siwasaki ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); 30671867Smsmith break; 30771867Smsmith 30871867Smsmith 30971867Smsmith default: 31071867Smsmith 31199679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n", 31277424Smsmith RefDesc->Reference.Opcode)); 31391116Smsmith ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); 31471867Smsmith 31571867Smsmith Status = AE_AML_INTERNAL; 31671867Smsmith break; 31799679Siwasaki } 31871867Smsmith 31971867Smsmith return_ACPI_STATUS (Status); 32071867Smsmith} 32171867Smsmith 32271867Smsmith 32371867Smsmith/******************************************************************************* 32471867Smsmith * 32577424Smsmith * FUNCTION: AcpiExStoreObjectToIndex 32671867Smsmith * 32787031Smsmith * PARAMETERS: *SourceDesc - Value to be stored 32887031Smsmith * *DestDesc - Named object to receive the value 32987031Smsmith * WalkState - Current walk state 33071867Smsmith * 33171867Smsmith * RETURN: Status 33271867Smsmith * 33387031Smsmith * DESCRIPTION: Store the object to indexed Buffer or Package element 33471867Smsmith * 33571867Smsmith ******************************************************************************/ 33671867Smsmith 33771867SmsmithACPI_STATUS 33877424SmsmithAcpiExStoreObjectToIndex ( 33985756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 34091116Smsmith ACPI_OPERAND_OBJECT *IndexDesc, 34171867Smsmith ACPI_WALK_STATE *WalkState) 34271867Smsmith{ 34371867Smsmith ACPI_STATUS Status = AE_OK; 34471867Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 34591116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 34671867Smsmith UINT8 Value = 0; 34771867Smsmith 34871867Smsmith 34991116Smsmith ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex"); 35071867Smsmith 35171867Smsmith 35271867Smsmith /* 35371867Smsmith * Destination must be a reference pointer, and 35471867Smsmith * must point to either a buffer or a package 35571867Smsmith */ 35691116Smsmith switch (IndexDesc->Reference.TargetType) 35771867Smsmith { 35871867Smsmith case ACPI_TYPE_PACKAGE: 35971867Smsmith /* 36071867Smsmith * Storing to a package element is not simple. The source must be 36167754Smsmith * evaluated and converted to the type of the destination and then the 36267754Smsmith * source is copied into the destination - we can't just point to the 36367754Smsmith * source object. 36467754Smsmith */ 36591116Smsmith /* 36691116Smsmith * The object at *(IndexDesc->Reference.Where) is the 36791116Smsmith * element within the package that is to be modified. 36891116Smsmith */ 36991116Smsmith ObjDesc = *(IndexDesc->Reference.Where); 37085756Smsmith 37191116Smsmith /* Do the conversion/store */ 37267754Smsmith 37391116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, 37491116Smsmith WalkState); 37591116Smsmith if (ACPI_FAILURE (Status)) 37691116Smsmith { 37791116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 37891116Smsmith "Could not store object to indexed package element\n")); 37991116Smsmith return_ACPI_STATUS (Status); 38091116Smsmith } 38167754Smsmith 38291116Smsmith /* 38391116Smsmith * If a new object was created, we must install it as the new 38491116Smsmith * package element 38591116Smsmith */ 38691116Smsmith if (NewDesc != ObjDesc) 38791116Smsmith { 38891116Smsmith AcpiUtRemoveReference (ObjDesc); 38991116Smsmith *(IndexDesc->Reference.Where) = NewDesc; 39067754Smsmith } 39171867Smsmith break; 39267754Smsmith 39367754Smsmith 39471867Smsmith case ACPI_TYPE_BUFFER_FIELD: 39577424Smsmith 39667754Smsmith /* 39791116Smsmith * Store into a Buffer (not actually a real BufferField) at a 39887031Smsmith * location defined by an Index. 39967754Smsmith * 40087031Smsmith * The first 8-bit element of the source object is written to the 40187031Smsmith * 8-bit Buffer location defined by the Index destination object, 40287031Smsmith * according to the ACPI 2.0 specification. 40367754Smsmith */ 40467754Smsmith 40567754Smsmith /* 40687031Smsmith * Make sure the target is a Buffer 40767754Smsmith */ 40891116Smsmith ObjDesc = IndexDesc->Reference.Object; 40999679Siwasaki if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) 41067754Smsmith { 41171867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 41267754Smsmith } 41367754Smsmith 41467754Smsmith /* 41567754Smsmith * The assignment of the individual elements will be slightly 41667754Smsmith * different for each source type. 41767754Smsmith */ 41899679Siwasaki switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 41967754Smsmith { 42071867Smsmith case ACPI_TYPE_INTEGER: 42187031Smsmith 42287031Smsmith /* Use the least-significant byte of the integer */ 42387031Smsmith 42487031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 42567754Smsmith break; 42667754Smsmith 42787031Smsmith case ACPI_TYPE_BUFFER: 42877424Smsmith 42987031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 43067754Smsmith break; 43167754Smsmith 43287031Smsmith case ACPI_TYPE_STRING: 43377424Smsmith 43499679Siwasaki Value = (UINT8) SourceDesc->String.Pointer[0]; 43567754Smsmith break; 43667754Smsmith 43767754Smsmith default: 43877424Smsmith 43987031Smsmith /* All other types are invalid */ 44077424Smsmith 44182367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 44287031Smsmith "Source must be Integer/Buffer/String type, not %s\n", 44399679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 44487031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 44567754Smsmith } 44687031Smsmith 44787031Smsmith /* Store the source value into the target buffer byte */ 44887031Smsmith 44991116Smsmith ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; 45071867Smsmith break; 45167754Smsmith 45267754Smsmith 45371867Smsmith default: 45491116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 45587031Smsmith "Target is not a Package or BufferField\n")); 45671867Smsmith Status = AE_AML_OPERAND_TYPE; 45767754Smsmith break; 45871867Smsmith } 45967754Smsmith 46071867Smsmith return_ACPI_STATUS (Status); 46171867Smsmith} 46267754Smsmith 46367754Smsmith 46471867Smsmith/******************************************************************************* 46571867Smsmith * 46677424Smsmith * FUNCTION: AcpiExStoreObjectToNode 46771867Smsmith * 46887031Smsmith * PARAMETERS: SourceDesc - Value to be stored 46987031Smsmith * Node - Named object to receive the value 47087031Smsmith * WalkState - Current walk state 47171867Smsmith * 47271867Smsmith * RETURN: Status 47371867Smsmith * 47471867Smsmith * DESCRIPTION: Store the object to the named object. 47571867Smsmith * 47671867Smsmith * The Assignment of an object to a named object is handled here 47787031Smsmith * The value passed in will replace the current value (if any) 47871867Smsmith * with the input value. 47971867Smsmith * 48071867Smsmith * When storing into an object the data is converted to the 48171867Smsmith * target object type then stored in the object. This means 48271867Smsmith * that the target object type (for an initialized target) will 48371867Smsmith * not be changed by a store operation. 48471867Smsmith * 48587031Smsmith * Assumes parameters are already validated. 48671867Smsmith * 48771867Smsmith ******************************************************************************/ 48867754Smsmith 48971867SmsmithACPI_STATUS 49077424SmsmithAcpiExStoreObjectToNode ( 49171867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 49271867Smsmith ACPI_NAMESPACE_NODE *Node, 49371867Smsmith ACPI_WALK_STATE *WalkState) 49471867Smsmith{ 49571867Smsmith ACPI_STATUS Status = AE_OK; 49671867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 49791116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 49891116Smsmith ACPI_OBJECT_TYPE TargetType; 49967754Smsmith 50071867Smsmith 50191116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); 50271867Smsmith 50383174Smsmith 50471867Smsmith /* 50571867Smsmith * Get current type of the node, and object attached to Node 50671867Smsmith */ 50771867Smsmith TargetType = AcpiNsGetType (Node); 50871867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 50971867Smsmith 51099146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 51199679Siwasaki SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 51291116Smsmith Node, AcpiUtGetTypeName (TargetType))); 51371867Smsmith 51471867Smsmith /* 51571867Smsmith * Resolve the source object to an actual value 51677424Smsmith * (If it is a reference object) 51771867Smsmith */ 51877424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 51971867Smsmith if (ACPI_FAILURE (Status)) 52071867Smsmith { 52171867Smsmith return_ACPI_STATUS (Status); 52271867Smsmith } 52371867Smsmith 52471867Smsmith /* 52577424Smsmith * Do the actual store operation 52671867Smsmith */ 52771867Smsmith switch (TargetType) 52871867Smsmith { 52977424Smsmith case ACPI_TYPE_BUFFER_FIELD: 53077424Smsmith case INTERNAL_TYPE_REGION_FIELD: 53177424Smsmith case INTERNAL_TYPE_BANK_FIELD: 53277424Smsmith case INTERNAL_TYPE_INDEX_FIELD: 53371867Smsmith 53477424Smsmith /* 53577424Smsmith * For fields, copy the source data to the target field. 53677424Smsmith */ 53777424Smsmith Status = AcpiExWriteDataToField (SourceDesc, TargetDesc); 53867754Smsmith break; 53967754Smsmith 54067754Smsmith 54171867Smsmith case ACPI_TYPE_INTEGER: 54271867Smsmith case ACPI_TYPE_STRING: 54371867Smsmith case ACPI_TYPE_BUFFER: 54467754Smsmith 54577424Smsmith /* 54671867Smsmith * These target types are all of type Integer/String/Buffer, and 54771867Smsmith * therefore support implicit conversion before the store. 54877424Smsmith * 54977424Smsmith * Copy and/or convert the source object to a new target object 55067754Smsmith */ 55191116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); 55271867Smsmith if (ACPI_FAILURE (Status)) 55367754Smsmith { 55471867Smsmith return_ACPI_STATUS (Status); 55567754Smsmith } 55667754Smsmith 55791116Smsmith if (NewDesc != TargetDesc) 55891116Smsmith { 55991116Smsmith /* 56091116Smsmith * Store the new NewDesc as the new value of the Name, and set 56191116Smsmith * the Name's type to that of the value being stored in it. 56291116Smsmith * SourceDesc reference count is incremented by AttachObject. 56391116Smsmith */ 56491116Smsmith Status = AcpiNsAttachObject (Node, NewDesc, TargetType); 56585756Smsmith 56699146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 56791116Smsmith "Store %s into %s via Convert/Attach\n", 56899679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), 56999679Siwasaki AcpiUtGetObjectTypeName (NewDesc))); 57091116Smsmith } 57167754Smsmith break; 57267754Smsmith 57377424Smsmith 57467754Smsmith default: 57567754Smsmith 57699146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 57784491Smsmith "Storing %s (%p) directly into node (%p), no implicit conversion\n", 57899679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 57984491Smsmith 58071867Smsmith /* No conversions for all other types. Just attach the source object */ 58167754Smsmith 58299679Siwasaki Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc)); 58371867Smsmith break; 58471867Smsmith } 58567754Smsmith 58671867Smsmith return_ACPI_STATUS (Status); 58771867Smsmith} 58867754Smsmith 58967754Smsmith 590