exstore.c revision 167802
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 5167802Sjkim * $Revision: 1.203 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 13167802Sjkim * Some or all of this work - Copyright (c) 1999 - 2007, 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 120151600Sobrien#include <contrib/dev/acpica/acpi.h> 121151600Sobrien#include <contrib/dev/acpica/acdispat.h> 122151600Sobrien#include <contrib/dev/acpica/acinterp.h> 123151600Sobrien#include <contrib/dev/acpica/amlcode.h> 124151600Sobrien#include <contrib/dev/acpica/acnamesp.h> 125151937Sjkim#include <contrib/dev/acpica/acparser.h> 12667754Smsmith 12767754Smsmith 12877424Smsmith#define _COMPONENT ACPI_EXECUTER 12991116Smsmith ACPI_MODULE_NAME ("exstore") 13067754Smsmith 131151937Sjkim/* Local prototypes */ 13267754Smsmith 133151937Sjkimstatic void 134151937SjkimAcpiExDoDebugObject ( 135151937Sjkim ACPI_OPERAND_OBJECT *SourceDesc, 136151937Sjkim UINT32 Level, 137151937Sjkim UINT32 Index); 138151937Sjkim 139151937Sjkimstatic ACPI_STATUS 140151937SjkimAcpiExStoreObjectToIndex ( 141151937Sjkim ACPI_OPERAND_OBJECT *ValDesc, 142151937Sjkim ACPI_OPERAND_OBJECT *DestDesc, 143151937Sjkim ACPI_WALK_STATE *WalkState); 144151937Sjkim 145151937Sjkim 14667754Smsmith/******************************************************************************* 14767754Smsmith * 148151937Sjkim * FUNCTION: AcpiExDoDebugObject 149151937Sjkim * 150151937Sjkim * PARAMETERS: SourceDesc - Value to be stored 151151937Sjkim * Level - Indentation level (used for packages) 152151937Sjkim * Index - Current package element, zero if not pkg 153151937Sjkim * 154151937Sjkim * RETURN: None 155151937Sjkim * 156151937Sjkim * DESCRIPTION: Handles stores to the Debug Object. 157151937Sjkim * 158151937Sjkim ******************************************************************************/ 159151937Sjkim 160151937Sjkimstatic void 161151937SjkimAcpiExDoDebugObject ( 162151937Sjkim ACPI_OPERAND_OBJECT *SourceDesc, 163151937Sjkim UINT32 Level, 164151937Sjkim UINT32 Index) 165151937Sjkim{ 166151937Sjkim UINT32 i; 167151937Sjkim 168151937Sjkim 169167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); 170151937Sjkim 171151937Sjkim 172151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", 173151937Sjkim Level, " ")); 174151937Sjkim 175151937Sjkim /* Display index for package output only */ 176151937Sjkim 177151937Sjkim if (Index > 0) 178151937Sjkim { 179151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 180151937Sjkim "(%.2u) ", Index -1)); 181151937Sjkim } 182151937Sjkim 183151937Sjkim if (!SourceDesc) 184151937Sjkim { 185151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n")); 186151937Sjkim return_VOID; 187151937Sjkim } 188151937Sjkim 189151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) 190151937Sjkim { 191151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ", 192151937Sjkim AcpiUtGetObjectTypeName (SourceDesc))); 193151937Sjkim 194151937Sjkim if (!AcpiUtValidInternalObject (SourceDesc)) 195151937Sjkim { 196151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 197151937Sjkim "%p, Invalid Internal Object!\n", SourceDesc)); 198151937Sjkim return_VOID; 199151937Sjkim } 200151937Sjkim } 201151937Sjkim else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) 202151937Sjkim { 203151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", 204151937Sjkim AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), 205151937Sjkim SourceDesc)); 206151937Sjkim return_VOID; 207151937Sjkim } 208151937Sjkim else 209151937Sjkim { 210151937Sjkim return_VOID; 211151937Sjkim } 212151937Sjkim 213151937Sjkim switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 214151937Sjkim { 215151937Sjkim case ACPI_TYPE_INTEGER: 216151937Sjkim 217151937Sjkim /* Output correct integer width */ 218151937Sjkim 219151937Sjkim if (AcpiGbl_IntegerByteWidth == 4) 220151937Sjkim { 221151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", 222151937Sjkim (UINT32) SourceDesc->Integer.Value)); 223151937Sjkim } 224151937Sjkim else 225151937Sjkim { 226151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", 227151937Sjkim ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); 228151937Sjkim } 229151937Sjkim break; 230151937Sjkim 231151937Sjkim case ACPI_TYPE_BUFFER: 232151937Sjkim 233151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", 234151937Sjkim (UINT32) SourceDesc->Buffer.Length)); 235151937Sjkim ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, 236167802Sjkim (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); 237151937Sjkim break; 238151937Sjkim 239151937Sjkim case ACPI_TYPE_STRING: 240151937Sjkim 241151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", 242151937Sjkim SourceDesc->String.Length, SourceDesc->String.Pointer)); 243151937Sjkim break; 244151937Sjkim 245151937Sjkim case ACPI_TYPE_PACKAGE: 246151937Sjkim 247151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n", 248151937Sjkim SourceDesc->Package.Count)); 249151937Sjkim 250151937Sjkim /* Output the entire contents of the package */ 251151937Sjkim 252151937Sjkim for (i = 0; i < SourceDesc->Package.Count; i++) 253151937Sjkim { 254151937Sjkim AcpiExDoDebugObject (SourceDesc->Package.Elements[i], 255151937Sjkim Level+4, i+1); 256151937Sjkim } 257151937Sjkim break; 258151937Sjkim 259151937Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 260151937Sjkim 261151937Sjkim if (SourceDesc->Reference.Opcode == AML_INDEX_OP) 262151937Sjkim { 263151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", 264151937Sjkim AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode), 265151937Sjkim SourceDesc->Reference.Offset)); 266151937Sjkim } 267151937Sjkim else 268151937Sjkim { 269151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n", 270151937Sjkim AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); 271151937Sjkim } 272151937Sjkim 273151937Sjkim 274151937Sjkim if (SourceDesc->Reference.Object) 275151937Sjkim { 276151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == 277151937Sjkim ACPI_DESC_TYPE_NAMED) 278151937Sjkim { 279151937Sjkim AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) 280151937Sjkim SourceDesc->Reference.Object)->Object, 281151937Sjkim Level+4, 0); 282151937Sjkim } 283151937Sjkim else 284151937Sjkim { 285151937Sjkim AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); 286151937Sjkim } 287151937Sjkim } 288151937Sjkim else if (SourceDesc->Reference.Node) 289151937Sjkim { 290151937Sjkim AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, 291151937Sjkim Level+4, 0); 292151937Sjkim } 293151937Sjkim break; 294151937Sjkim 295151937Sjkim default: 296151937Sjkim 297151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n", 298151937Sjkim SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); 299151937Sjkim break; 300151937Sjkim } 301151937Sjkim 302151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); 303151937Sjkim return_VOID; 304151937Sjkim} 305151937Sjkim 306151937Sjkim 307151937Sjkim/******************************************************************************* 308151937Sjkim * 30977424Smsmith * FUNCTION: AcpiExStore 31067754Smsmith * 31185756Smsmith * PARAMETERS: *SourceDesc - Value to be stored 31277424Smsmith * *DestDesc - Where to store it. Must be an NS node 31377424Smsmith * or an ACPI_OPERAND_OBJECT of type 31487031Smsmith * Reference; 31587031Smsmith * WalkState - Current walk state 31667754Smsmith * 31767754Smsmith * RETURN: Status 31867754Smsmith * 31985756Smsmith * DESCRIPTION: Store the value described by SourceDesc into the location 32067754Smsmith * described by DestDesc. Called by various interpreter 32167754Smsmith * functions to store the result of an operation into 32291116Smsmith * the destination operand -- not just simply the actual "Store" 32387031Smsmith * ASL operator. 32467754Smsmith * 32567754Smsmith ******************************************************************************/ 32667754Smsmith 32767754SmsmithACPI_STATUS 32877424SmsmithAcpiExStore ( 32985756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 33067754Smsmith ACPI_OPERAND_OBJECT *DestDesc, 33167754Smsmith ACPI_WALK_STATE *WalkState) 33267754Smsmith{ 33367754Smsmith ACPI_STATUS Status = AE_OK; 33471867Smsmith ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 33567754Smsmith 33667754Smsmith 337167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); 33867754Smsmith 33967754Smsmith 34067754Smsmith /* Validate parameters */ 34167754Smsmith 34285756Smsmith if (!SourceDesc || !DestDesc) 34367754Smsmith { 344167802Sjkim ACPI_ERROR ((AE_INFO, "Null parameter")); 34567754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 34667754Smsmith } 34767754Smsmith 34871867Smsmith /* DestDesc can be either a namespace node or an ACPI object */ 34967754Smsmith 35091116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 35167754Smsmith { 35277424Smsmith /* 35371867Smsmith * Dest is a namespace node, 354107325Siwasaki * Storing an object into a Named node. 35571867Smsmith */ 35685756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, 357128212Snjl (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, 358128212Snjl ACPI_IMPLICIT_CONVERSION); 35967754Smsmith 36071867Smsmith return_ACPI_STATUS (Status); 36167754Smsmith } 36267754Smsmith 36399679Siwasaki /* Destination object must be a Reference or a Constant object */ 36467754Smsmith 36599679Siwasaki switch (ACPI_GET_OBJECT_TYPE (DestDesc)) 366102550Siwasaki { 367107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 36899679Siwasaki break; 36999679Siwasaki 37099679Siwasaki case ACPI_TYPE_INTEGER: 37199679Siwasaki 37299679Siwasaki /* Allow stores to Constants -- a Noop as per ACPI spec */ 37399679Siwasaki 37499679Siwasaki if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) 37599679Siwasaki { 37699679Siwasaki return_ACPI_STATUS (AE_OK); 37799679Siwasaki } 37899679Siwasaki 379104470Siwasaki /*lint -fallthrough */ 38099679Siwasaki 38199679Siwasaki default: 38299679Siwasaki 383126372Snjl /* Destination is not a Reference object */ 38467754Smsmith 385167802Sjkim ACPI_ERROR ((AE_INFO, 386167802Sjkim "Target is not a Reference or Constant object - %s [%p]", 387138287Smarks AcpiUtGetObjectTypeName (DestDesc), DestDesc)); 38867754Smsmith 38991116Smsmith ACPI_DUMP_STACK_ENTRY (SourceDesc); 39091116Smsmith ACPI_DUMP_STACK_ENTRY (DestDesc); 39191116Smsmith ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore", 39299679Siwasaki 2, "Target is not a Reference or Constant object"); 39367754Smsmith 39467754Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 39567754Smsmith } 39667754Smsmith 39777424Smsmith /* 39871867Smsmith * Examine the Reference opcode. These cases are handled: 39971867Smsmith * 40071867Smsmith * 1) Store to Name (Change the object associated with a name) 40171867Smsmith * 2) Store to an indexed area of a Buffer or Package 40271867Smsmith * 3) Store to a Method Local or Arg 40371867Smsmith * 4) Store to the debug object 40471867Smsmith */ 40577424Smsmith switch (RefDesc->Reference.Opcode) 40667754Smsmith { 407100966Siwasaki case AML_REF_OF_OP: 40867754Smsmith 40971867Smsmith /* Storing an object into a Name "container" */ 41071867Smsmith 411151937Sjkim Status = AcpiExStoreObjectToNode (SourceDesc, 412151937Sjkim RefDesc->Reference.Object, 413151937Sjkim WalkState, ACPI_IMPLICIT_CONVERSION); 41471867Smsmith break; 41567754Smsmith 41667754Smsmith 41767754Smsmith case AML_INDEX_OP: 41867754Smsmith 41971867Smsmith /* Storing to an Index (pointer into a packager or buffer) */ 42067754Smsmith 42185756Smsmith Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 42271867Smsmith break; 42371867Smsmith 42471867Smsmith 42571867Smsmith case AML_LOCAL_OP: 42677424Smsmith case AML_ARG_OP: 42771867Smsmith 42877424Smsmith /* Store to a method local/arg */ 42971867Smsmith 43077424Smsmith Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, 431151937Sjkim RefDesc->Reference.Offset, SourceDesc, WalkState); 43271867Smsmith break; 43371867Smsmith 43471867Smsmith 43571867Smsmith case AML_DEBUG_OP: 43671867Smsmith 43767754Smsmith /* 43871867Smsmith * Storing to the Debug object causes the value stored to be 43971867Smsmith * displayed and otherwise has no effect -- see ACPI Specification 44067754Smsmith */ 441138287Smarks ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 442138287Smarks "**** Write to Debug Object: Object %p %s ****:\n\n", 443138287Smarks SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); 44477424Smsmith 445151937Sjkim AcpiExDoDebugObject (SourceDesc, 0, 0); 44671867Smsmith break; 44771867Smsmith 44871867Smsmith 44971867Smsmith default: 45071867Smsmith 451167802Sjkim ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X", 45277424Smsmith RefDesc->Reference.Opcode)); 45391116Smsmith ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); 45471867Smsmith 45571867Smsmith Status = AE_AML_INTERNAL; 45671867Smsmith break; 45799679Siwasaki } 45871867Smsmith 45971867Smsmith return_ACPI_STATUS (Status); 46071867Smsmith} 46171867Smsmith 46271867Smsmith 46371867Smsmith/******************************************************************************* 46471867Smsmith * 46577424Smsmith * FUNCTION: AcpiExStoreObjectToIndex 46671867Smsmith * 46787031Smsmith * PARAMETERS: *SourceDesc - Value to be stored 46887031Smsmith * *DestDesc - Named object to receive the value 46987031Smsmith * WalkState - Current walk state 47071867Smsmith * 47171867Smsmith * RETURN: Status 47271867Smsmith * 47387031Smsmith * DESCRIPTION: Store the object to indexed Buffer or Package element 47471867Smsmith * 47571867Smsmith ******************************************************************************/ 47671867Smsmith 477151937Sjkimstatic ACPI_STATUS 47877424SmsmithAcpiExStoreObjectToIndex ( 47985756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 48091116Smsmith ACPI_OPERAND_OBJECT *IndexDesc, 48171867Smsmith ACPI_WALK_STATE *WalkState) 48271867Smsmith{ 48371867Smsmith ACPI_STATUS Status = AE_OK; 48471867Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 48591116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 48671867Smsmith UINT8 Value = 0; 487126372Snjl UINT32 i; 48871867Smsmith 48971867Smsmith 490167802Sjkim ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); 49171867Smsmith 49271867Smsmith 49371867Smsmith /* 49471867Smsmith * Destination must be a reference pointer, and 49571867Smsmith * must point to either a buffer or a package 49671867Smsmith */ 49791116Smsmith switch (IndexDesc->Reference.TargetType) 49871867Smsmith { 49971867Smsmith case ACPI_TYPE_PACKAGE: 50071867Smsmith /* 501138287Smarks * Storing to a package element. Copy the object and replace 502138287Smarks * any existing object with the new object. No implicit 503138287Smarks * conversion is performed. 504138287Smarks * 50591116Smsmith * The object at *(IndexDesc->Reference.Where) is the 50691116Smsmith * element within the package that is to be modified. 507126372Snjl * The parent package object is at IndexDesc->Reference.Object 50891116Smsmith */ 50991116Smsmith ObjDesc = *(IndexDesc->Reference.Where); 51085756Smsmith 511138287Smarks Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); 51291116Smsmith if (ACPI_FAILURE (Status)) 51391116Smsmith { 51491116Smsmith return_ACPI_STATUS (Status); 51591116Smsmith } 51667754Smsmith 517138287Smarks if (ObjDesc) 51891116Smsmith { 519138287Smarks /* Decrement reference count by the ref count of the parent package */ 520104470Siwasaki 521151937Sjkim for (i = 0; 522151937Sjkim i < ((ACPI_OPERAND_OBJECT *) 523151937Sjkim IndexDesc->Reference.Object)->Common.ReferenceCount; 524151937Sjkim i++) 525104470Siwasaki { 526138287Smarks AcpiUtRemoveReference (ObjDesc); 527104470Siwasaki } 528138287Smarks } 529151937Sjkim 530138287Smarks *(IndexDesc->Reference.Where) = NewDesc; 531126372Snjl 532151937Sjkim /* Increment ref count by the ref count of the parent package-1 */ 533126372Snjl 534151937Sjkim for (i = 1; 535151937Sjkim i < ((ACPI_OPERAND_OBJECT *) 536151937Sjkim IndexDesc->Reference.Object)->Common.ReferenceCount; 537151937Sjkim i++) 538138287Smarks { 539138287Smarks AcpiUtAddReference (NewDesc); 54067754Smsmith } 541151937Sjkim 54271867Smsmith break; 54367754Smsmith 54467754Smsmith 54571867Smsmith case ACPI_TYPE_BUFFER_FIELD: 54677424Smsmith 54767754Smsmith /* 548138287Smarks * Store into a Buffer or String (not actually a real BufferField) 549138287Smarks * at a location defined by an Index. 55067754Smsmith * 55187031Smsmith * The first 8-bit element of the source object is written to the 55287031Smsmith * 8-bit Buffer location defined by the Index destination object, 55387031Smsmith * according to the ACPI 2.0 specification. 55467754Smsmith */ 55567754Smsmith 55667754Smsmith /* 557138287Smarks * Make sure the target is a Buffer or String. An error should 558138287Smarks * not happen here, since the ReferenceObject was constructed 559138287Smarks * by the INDEX_OP code. 56067754Smsmith */ 56191116Smsmith ObjDesc = IndexDesc->Reference.Object; 562138287Smarks if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) && 563138287Smarks (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) 56467754Smsmith { 56571867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 56667754Smsmith } 56767754Smsmith 56867754Smsmith /* 56967754Smsmith * The assignment of the individual elements will be slightly 57067754Smsmith * different for each source type. 57167754Smsmith */ 57299679Siwasaki switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) 57367754Smsmith { 57471867Smsmith case ACPI_TYPE_INTEGER: 57587031Smsmith 57687031Smsmith /* Use the least-significant byte of the integer */ 57787031Smsmith 57887031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 57967754Smsmith break; 58067754Smsmith 58187031Smsmith case ACPI_TYPE_BUFFER: 582138287Smarks case ACPI_TYPE_STRING: 58377424Smsmith 584138287Smarks /* Note: Takes advantage of common string/buffer fields */ 585138287Smarks 58687031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 58767754Smsmith break; 58867754Smsmith 58967754Smsmith default: 59077424Smsmith 59187031Smsmith /* All other types are invalid */ 59277424Smsmith 593167802Sjkim ACPI_ERROR ((AE_INFO, 594167802Sjkim "Source must be Integer/Buffer/String type, not %s", 59599679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 59687031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 59767754Smsmith } 59887031Smsmith 59987031Smsmith /* Store the source value into the target buffer byte */ 60087031Smsmith 60191116Smsmith ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; 60271867Smsmith break; 60367754Smsmith 60467754Smsmith 60571867Smsmith default: 606167802Sjkim ACPI_ERROR ((AE_INFO, 607167802Sjkim "Target is not a Package or BufferField")); 60871867Smsmith Status = AE_AML_OPERAND_TYPE; 60967754Smsmith break; 61071867Smsmith } 61167754Smsmith 61271867Smsmith return_ACPI_STATUS (Status); 61371867Smsmith} 61467754Smsmith 61567754Smsmith 61671867Smsmith/******************************************************************************* 61771867Smsmith * 61877424Smsmith * FUNCTION: AcpiExStoreObjectToNode 61971867Smsmith * 62087031Smsmith * PARAMETERS: SourceDesc - Value to be stored 62187031Smsmith * Node - Named object to receive the value 62287031Smsmith * WalkState - Current walk state 623128212Snjl * ImplicitConversion - Perform implicit conversion (yes/no) 62471867Smsmith * 62571867Smsmith * RETURN: Status 62671867Smsmith * 62771867Smsmith * DESCRIPTION: Store the object to the named object. 62871867Smsmith * 62971867Smsmith * The Assignment of an object to a named object is handled here 63087031Smsmith * The value passed in will replace the current value (if any) 63171867Smsmith * with the input value. 63271867Smsmith * 63371867Smsmith * When storing into an object the data is converted to the 63471867Smsmith * target object type then stored in the object. This means 63571867Smsmith * that the target object type (for an initialized target) will 63671867Smsmith * not be changed by a store operation. 63771867Smsmith * 63887031Smsmith * Assumes parameters are already validated. 63971867Smsmith * 64071867Smsmith ******************************************************************************/ 64167754Smsmith 64271867SmsmithACPI_STATUS 64377424SmsmithAcpiExStoreObjectToNode ( 64471867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 64571867Smsmith ACPI_NAMESPACE_NODE *Node, 646128212Snjl ACPI_WALK_STATE *WalkState, 647128212Snjl UINT8 ImplicitConversion) 64871867Smsmith{ 64971867Smsmith ACPI_STATUS Status = AE_OK; 65071867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 65191116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 65291116Smsmith ACPI_OBJECT_TYPE TargetType; 65367754Smsmith 65471867Smsmith 655167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); 65671867Smsmith 65783174Smsmith 658151937Sjkim /* Get current type of the node, and object attached to Node */ 659151937Sjkim 66071867Smsmith TargetType = AcpiNsGetType (Node); 66171867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 66271867Smsmith 66399146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 66499679Siwasaki SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 66591116Smsmith Node, AcpiUtGetTypeName (TargetType))); 66671867Smsmith 66771867Smsmith /* 66871867Smsmith * Resolve the source object to an actual value 66977424Smsmith * (If it is a reference object) 67071867Smsmith */ 67177424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 67271867Smsmith if (ACPI_FAILURE (Status)) 67371867Smsmith { 67471867Smsmith return_ACPI_STATUS (Status); 67571867Smsmith } 67671867Smsmith 677128212Snjl /* If no implicit conversion, drop into the default case below */ 678128212Snjl 679151937Sjkim if ((!ImplicitConversion) || (WalkState->Opcode == AML_COPY_OP)) 680128212Snjl { 681128212Snjl /* Force execution of default (no implicit conversion) */ 682128212Snjl 683128212Snjl TargetType = ACPI_TYPE_ANY; 684128212Snjl } 685128212Snjl 686151937Sjkim /* Do the actual store operation */ 687151937Sjkim 68871867Smsmith switch (TargetType) 68971867Smsmith { 69077424Smsmith case ACPI_TYPE_BUFFER_FIELD: 691107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 692107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 693107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 69471867Smsmith 695151937Sjkim /* For fields, copy the source data to the target field. */ 696151937Sjkim 697151937Sjkim Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, 698151937Sjkim &WalkState->ResultObj); 69967754Smsmith break; 70067754Smsmith 70167754Smsmith 70271867Smsmith case ACPI_TYPE_INTEGER: 70371867Smsmith case ACPI_TYPE_STRING: 70471867Smsmith case ACPI_TYPE_BUFFER: 70567754Smsmith 70677424Smsmith /* 70771867Smsmith * These target types are all of type Integer/String/Buffer, and 70871867Smsmith * therefore support implicit conversion before the store. 70977424Smsmith * 71077424Smsmith * Copy and/or convert the source object to a new target object 71167754Smsmith */ 712151937Sjkim Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, 713151937Sjkim &NewDesc, WalkState); 71471867Smsmith if (ACPI_FAILURE (Status)) 71567754Smsmith { 71671867Smsmith return_ACPI_STATUS (Status); 71767754Smsmith } 71867754Smsmith 71991116Smsmith if (NewDesc != TargetDesc) 72091116Smsmith { 72191116Smsmith /* 72291116Smsmith * Store the new NewDesc as the new value of the Name, and set 72391116Smsmith * the Name's type to that of the value being stored in it. 72491116Smsmith * SourceDesc reference count is incremented by AttachObject. 725104470Siwasaki * 726104470Siwasaki * Note: This may change the type of the node if an explicit store 727104470Siwasaki * has been performed such that the node/object type has been 728104470Siwasaki * changed. 72991116Smsmith */ 730104470Siwasaki Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 73185756Smsmith 73299146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 73391116Smsmith "Store %s into %s via Convert/Attach\n", 73499679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), 73599679Siwasaki AcpiUtGetObjectTypeName (NewDesc))); 73691116Smsmith } 73767754Smsmith break; 73867754Smsmith 73977424Smsmith 74067754Smsmith default: 74167754Smsmith 74299146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 743151937Sjkim "Storing %s (%p) directly into node (%p) with no implicit conversion\n", 74499679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 74584491Smsmith 74671867Smsmith /* No conversions for all other types. Just attach the source object */ 74767754Smsmith 748151937Sjkim Status = AcpiNsAttachObject (Node, SourceDesc, 749151937Sjkim ACPI_GET_OBJECT_TYPE (SourceDesc)); 75071867Smsmith break; 75171867Smsmith } 75267754Smsmith 75371867Smsmith return_ACPI_STATUS (Status); 75471867Smsmith} 75567754Smsmith 75667754Smsmith 757