exstore.c revision 107325
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 5107325Siwasaki * $Revision: 174 $ 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, 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", 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; 390104470Siwasaki 391104470Siwasaki /* If same as the original source, add a reference */ 392104470Siwasaki 393104470Siwasaki if (NewDesc == SourceDesc) 394104470Siwasaki { 395104470Siwasaki AcpiUtAddReference (NewDesc); 396104470Siwasaki } 39767754Smsmith } 39871867Smsmith break; 39967754Smsmith 40067754Smsmith 40171867Smsmith case ACPI_TYPE_BUFFER_FIELD: 40277424Smsmith 40367754Smsmith /* 40491116Smsmith * Store into a Buffer (not actually a real BufferField) at a 40587031Smsmith * location defined by an Index. 40667754Smsmith * 40787031Smsmith * The first 8-bit element of the source object is written to the 40887031Smsmith * 8-bit Buffer location defined by the Index destination object, 40987031Smsmith * according to the ACPI 2.0 specification. 41067754Smsmith */ 41167754Smsmith 41267754Smsmith /* 41387031Smsmith * Make sure the target is a Buffer 41467754Smsmith */ 41591116Smsmith ObjDesc = IndexDesc->Reference.Object; 41699679Siwasaki if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) 41767754Smsmith { 41871867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 41967754Smsmith } 42067754Smsmith 42167754Smsmith /* 42267754Smsmith * The assignment of the individual elements will be slightly 42367754Smsmith * different for each source type. 42467754Smsmith */ 42599679Siwasaki switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 42667754Smsmith { 42771867Smsmith case ACPI_TYPE_INTEGER: 42887031Smsmith 42987031Smsmith /* Use the least-significant byte of the integer */ 43087031Smsmith 43187031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 43267754Smsmith break; 43367754Smsmith 43487031Smsmith case ACPI_TYPE_BUFFER: 43577424Smsmith 43687031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 43767754Smsmith break; 43867754Smsmith 43987031Smsmith case ACPI_TYPE_STRING: 44077424Smsmith 44199679Siwasaki Value = (UINT8) SourceDesc->String.Pointer[0]; 44267754Smsmith break; 44367754Smsmith 44467754Smsmith default: 44577424Smsmith 44687031Smsmith /* All other types are invalid */ 44777424Smsmith 44882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 44987031Smsmith "Source must be Integer/Buffer/String type, not %s\n", 45099679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 45187031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 45267754Smsmith } 45387031Smsmith 45487031Smsmith /* Store the source value into the target buffer byte */ 45587031Smsmith 45691116Smsmith ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; 45771867Smsmith break; 45867754Smsmith 45967754Smsmith 46071867Smsmith default: 46191116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 46287031Smsmith "Target is not a Package or BufferField\n")); 46371867Smsmith Status = AE_AML_OPERAND_TYPE; 46467754Smsmith break; 46571867Smsmith } 46667754Smsmith 46771867Smsmith return_ACPI_STATUS (Status); 46871867Smsmith} 46967754Smsmith 47067754Smsmith 47171867Smsmith/******************************************************************************* 47271867Smsmith * 47377424Smsmith * FUNCTION: AcpiExStoreObjectToNode 47471867Smsmith * 47587031Smsmith * PARAMETERS: SourceDesc - Value to be stored 47687031Smsmith * Node - Named object to receive the value 47787031Smsmith * WalkState - Current walk state 47871867Smsmith * 47971867Smsmith * RETURN: Status 48071867Smsmith * 48171867Smsmith * DESCRIPTION: Store the object to the named object. 48271867Smsmith * 48371867Smsmith * The Assignment of an object to a named object is handled here 48487031Smsmith * The value passed in will replace the current value (if any) 48571867Smsmith * with the input value. 48671867Smsmith * 48771867Smsmith * When storing into an object the data is converted to the 48871867Smsmith * target object type then stored in the object. This means 48971867Smsmith * that the target object type (for an initialized target) will 49071867Smsmith * not be changed by a store operation. 49171867Smsmith * 49287031Smsmith * Assumes parameters are already validated. 49371867Smsmith * 49471867Smsmith ******************************************************************************/ 49567754Smsmith 49671867SmsmithACPI_STATUS 49777424SmsmithAcpiExStoreObjectToNode ( 49871867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 49971867Smsmith ACPI_NAMESPACE_NODE *Node, 50071867Smsmith ACPI_WALK_STATE *WalkState) 50171867Smsmith{ 50271867Smsmith ACPI_STATUS Status = AE_OK; 50371867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 50491116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 50591116Smsmith ACPI_OBJECT_TYPE TargetType; 50667754Smsmith 50771867Smsmith 50891116Smsmith ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); 50971867Smsmith 51083174Smsmith 51171867Smsmith /* 51271867Smsmith * Get current type of the node, and object attached to Node 51371867Smsmith */ 51471867Smsmith TargetType = AcpiNsGetType (Node); 51571867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 51671867Smsmith 51799146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 51899679Siwasaki SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 51991116Smsmith Node, AcpiUtGetTypeName (TargetType))); 52071867Smsmith 52171867Smsmith /* 52271867Smsmith * Resolve the source object to an actual value 52377424Smsmith * (If it is a reference object) 52471867Smsmith */ 52577424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 52671867Smsmith if (ACPI_FAILURE (Status)) 52771867Smsmith { 52871867Smsmith return_ACPI_STATUS (Status); 52971867Smsmith } 53071867Smsmith 53171867Smsmith /* 53277424Smsmith * Do the actual store operation 53371867Smsmith */ 53471867Smsmith switch (TargetType) 53571867Smsmith { 53677424Smsmith case ACPI_TYPE_BUFFER_FIELD: 537107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 538107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 539107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 54071867Smsmith 54177424Smsmith /* 54277424Smsmith * For fields, copy the source data to the target field. 54377424Smsmith */ 544107325Siwasaki Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, &WalkState->ResultObj); 54567754Smsmith break; 54667754Smsmith 54767754Smsmith 54871867Smsmith case ACPI_TYPE_INTEGER: 54971867Smsmith case ACPI_TYPE_STRING: 55071867Smsmith case ACPI_TYPE_BUFFER: 55167754Smsmith 55277424Smsmith /* 55371867Smsmith * These target types are all of type Integer/String/Buffer, and 55471867Smsmith * therefore support implicit conversion before the store. 55577424Smsmith * 55677424Smsmith * Copy and/or convert the source object to a new target object 55767754Smsmith */ 55891116Smsmith Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); 55971867Smsmith if (ACPI_FAILURE (Status)) 56067754Smsmith { 56171867Smsmith return_ACPI_STATUS (Status); 56267754Smsmith } 56367754Smsmith 56491116Smsmith if (NewDesc != TargetDesc) 56591116Smsmith { 56691116Smsmith /* 56791116Smsmith * Store the new NewDesc as the new value of the Name, and set 56891116Smsmith * the Name's type to that of the value being stored in it. 56991116Smsmith * SourceDesc reference count is incremented by AttachObject. 570104470Siwasaki * 571104470Siwasaki * Note: This may change the type of the node if an explicit store 572104470Siwasaki * has been performed such that the node/object type has been 573104470Siwasaki * changed. 57491116Smsmith */ 575104470Siwasaki Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 57685756Smsmith 57799146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 57891116Smsmith "Store %s into %s via Convert/Attach\n", 57999679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), 58099679Siwasaki AcpiUtGetObjectTypeName (NewDesc))); 58191116Smsmith } 58267754Smsmith break; 58367754Smsmith 58477424Smsmith 58567754Smsmith default: 58667754Smsmith 58799146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 58884491Smsmith "Storing %s (%p) directly into node (%p), no implicit conversion\n", 58999679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 59084491Smsmith 59171867Smsmith /* No conversions for all other types. Just attach the source object */ 59267754Smsmith 59399679Siwasaki Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc)); 59471867Smsmith break; 59571867Smsmith } 59667754Smsmith 59771867Smsmith return_ACPI_STATUS (Status); 59871867Smsmith} 59967754Smsmith 60067754Smsmith 601