exstore.c revision 193267
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exstore - AML Interpreter object store support 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12193267Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11777424Smsmith#define __EXSTORE_C__ 11867754Smsmith 119193251Sjkim#include "acpi.h" 120193267Sjkim#include "accommon.h" 121193251Sjkim#include "acdispat.h" 122193251Sjkim#include "acinterp.h" 123193251Sjkim#include "amlcode.h" 124193251Sjkim#include "acnamesp.h" 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_EXECUTER 12891116Smsmith ACPI_MODULE_NAME ("exstore") 12967754Smsmith 130151937Sjkim/* Local prototypes */ 13167754Smsmith 132151937Sjkimstatic void 133151937SjkimAcpiExDoDebugObject ( 134151937Sjkim ACPI_OPERAND_OBJECT *SourceDesc, 135151937Sjkim UINT32 Level, 136151937Sjkim UINT32 Index); 137151937Sjkim 138151937Sjkimstatic ACPI_STATUS 139151937SjkimAcpiExStoreObjectToIndex ( 140151937Sjkim ACPI_OPERAND_OBJECT *ValDesc, 141151937Sjkim ACPI_OPERAND_OBJECT *DestDesc, 142151937Sjkim ACPI_WALK_STATE *WalkState); 143151937Sjkim 144151937Sjkim 14567754Smsmith/******************************************************************************* 14667754Smsmith * 147151937Sjkim * FUNCTION: AcpiExDoDebugObject 148151937Sjkim * 149151937Sjkim * PARAMETERS: SourceDesc - Value to be stored 150151937Sjkim * Level - Indentation level (used for packages) 151151937Sjkim * Index - Current package element, zero if not pkg 152151937Sjkim * 153151937Sjkim * RETURN: None 154151937Sjkim * 155151937Sjkim * DESCRIPTION: Handles stores to the Debug Object. 156151937Sjkim * 157151937Sjkim ******************************************************************************/ 158151937Sjkim 159151937Sjkimstatic void 160151937SjkimAcpiExDoDebugObject ( 161151937Sjkim ACPI_OPERAND_OBJECT *SourceDesc, 162151937Sjkim UINT32 Level, 163151937Sjkim UINT32 Index) 164151937Sjkim{ 165151937Sjkim UINT32 i; 166151937Sjkim 167151937Sjkim 168167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); 169151937Sjkim 170151937Sjkim 171193267Sjkim /* Print line header as long as we are not in the middle of an object display */ 172151937Sjkim 173193267Sjkim if (!((Level > 0) && Index == 0)) 174193267Sjkim { 175193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", 176193267Sjkim Level, " ")); 177193267Sjkim } 178193267Sjkim 179151937Sjkim /* Display index for package output only */ 180151937Sjkim 181151937Sjkim if (Index > 0) 182151937Sjkim { 183151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 184151937Sjkim "(%.2u) ", Index -1)); 185151937Sjkim } 186151937Sjkim 187151937Sjkim if (!SourceDesc) 188151937Sjkim { 189193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n")); 190151937Sjkim return_VOID; 191151937Sjkim } 192151937Sjkim 193151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) 194151937Sjkim { 195193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s ", 196151937Sjkim AcpiUtGetObjectTypeName (SourceDesc))); 197151937Sjkim 198151937Sjkim if (!AcpiUtValidInternalObject (SourceDesc)) 199151937Sjkim { 200151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 201151937Sjkim "%p, Invalid Internal Object!\n", SourceDesc)); 202151937Sjkim return_VOID; 203151937Sjkim } 204151937Sjkim } 205151937Sjkim else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) 206151937Sjkim { 207151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", 208151937Sjkim AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), 209151937Sjkim SourceDesc)); 210151937Sjkim return_VOID; 211151937Sjkim } 212151937Sjkim else 213151937Sjkim { 214151937Sjkim return_VOID; 215151937Sjkim } 216151937Sjkim 217193267Sjkim /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ 218193267Sjkim 219193267Sjkim switch (SourceDesc->Common.Type) 220151937Sjkim { 221151937Sjkim case ACPI_TYPE_INTEGER: 222151937Sjkim 223151937Sjkim /* Output correct integer width */ 224151937Sjkim 225151937Sjkim if (AcpiGbl_IntegerByteWidth == 4) 226151937Sjkim { 227151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", 228151937Sjkim (UINT32) SourceDesc->Integer.Value)); 229151937Sjkim } 230151937Sjkim else 231151937Sjkim { 232151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", 233151937Sjkim ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); 234151937Sjkim } 235151937Sjkim break; 236151937Sjkim 237151937Sjkim case ACPI_TYPE_BUFFER: 238151937Sjkim 239151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", 240151937Sjkim (UINT32) SourceDesc->Buffer.Length)); 241151937Sjkim ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, 242167802Sjkim (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); 243151937Sjkim break; 244151937Sjkim 245151937Sjkim case ACPI_TYPE_STRING: 246151937Sjkim 247151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", 248151937Sjkim SourceDesc->String.Length, SourceDesc->String.Pointer)); 249151937Sjkim break; 250151937Sjkim 251151937Sjkim case ACPI_TYPE_PACKAGE: 252151937Sjkim 253193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Contains 0x%.2X Elements]\n", 254151937Sjkim SourceDesc->Package.Count)); 255151937Sjkim 256151937Sjkim /* Output the entire contents of the package */ 257151937Sjkim 258151937Sjkim for (i = 0; i < SourceDesc->Package.Count; i++) 259151937Sjkim { 260151937Sjkim AcpiExDoDebugObject (SourceDesc->Package.Elements[i], 261151937Sjkim Level+4, i+1); 262151937Sjkim } 263151937Sjkim break; 264151937Sjkim 265151937Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 266151937Sjkim 267193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ", 268193267Sjkim AcpiUtGetReferenceName (SourceDesc))); 269193267Sjkim 270193267Sjkim /* Decode the reference */ 271193267Sjkim 272193267Sjkim switch (SourceDesc->Reference.Class) 273151937Sjkim { 274193267Sjkim case ACPI_REFCLASS_INDEX: 275193267Sjkim 276193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n", 277193267Sjkim SourceDesc->Reference.Value)); 278193267Sjkim break; 279193267Sjkim 280193267Sjkim case ACPI_REFCLASS_TABLE: 281193267Sjkim 282193267Sjkim /* Case for DdbHandle */ 283193267Sjkim 284193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n", 285193267Sjkim SourceDesc->Reference.Value)); 286193267Sjkim return; 287193267Sjkim 288193267Sjkim default: 289193267Sjkim break; 290151937Sjkim } 291193267Sjkim 292193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, " ")); 293193267Sjkim 294193267Sjkim /* Check for valid node first, then valid object */ 295193267Sjkim 296193267Sjkim if (SourceDesc->Reference.Node) 297151937Sjkim { 298193267Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != 299193267Sjkim ACPI_DESC_TYPE_NAMED) 300193267Sjkim { 301193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, 302193267Sjkim " %p - Not a valid namespace node\n", 303193267Sjkim SourceDesc->Reference.Node)); 304193267Sjkim } 305193267Sjkim else 306193267Sjkim { 307193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Node %p [%4.4s] ", 308193267Sjkim SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii)); 309151937Sjkim 310193267Sjkim switch ((SourceDesc->Reference.Node)->Type) 311193267Sjkim { 312193267Sjkim /* These types have no attached object */ 313151937Sjkim 314193267Sjkim case ACPI_TYPE_DEVICE: 315193267Sjkim AcpiOsPrintf ("Device\n"); 316193267Sjkim break; 317193267Sjkim 318193267Sjkim case ACPI_TYPE_THERMAL: 319193267Sjkim AcpiOsPrintf ("Thermal Zone\n"); 320193267Sjkim break; 321193267Sjkim 322193267Sjkim default: 323193267Sjkim AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, 324193267Sjkim Level+4, 0); 325193267Sjkim break; 326193267Sjkim } 327193267Sjkim } 328193267Sjkim } 329193267Sjkim else if (SourceDesc->Reference.Object) 330151937Sjkim { 331151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == 332151937Sjkim ACPI_DESC_TYPE_NAMED) 333151937Sjkim { 334151937Sjkim AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) 335151937Sjkim SourceDesc->Reference.Object)->Object, 336151937Sjkim Level+4, 0); 337151937Sjkim } 338151937Sjkim else 339151937Sjkim { 340151937Sjkim AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); 341151937Sjkim } 342151937Sjkim } 343151937Sjkim break; 344151937Sjkim 345151937Sjkim default: 346151937Sjkim 347193267Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", 348193267Sjkim SourceDesc)); 349151937Sjkim break; 350151937Sjkim } 351151937Sjkim 352151937Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); 353151937Sjkim return_VOID; 354151937Sjkim} 355151937Sjkim 356151937Sjkim 357151937Sjkim/******************************************************************************* 358151937Sjkim * 35977424Smsmith * FUNCTION: AcpiExStore 36067754Smsmith * 36185756Smsmith * PARAMETERS: *SourceDesc - Value to be stored 36277424Smsmith * *DestDesc - Where to store it. Must be an NS node 36377424Smsmith * or an ACPI_OPERAND_OBJECT of type 36487031Smsmith * Reference; 36587031Smsmith * WalkState - Current walk state 36667754Smsmith * 36767754Smsmith * RETURN: Status 36867754Smsmith * 36985756Smsmith * DESCRIPTION: Store the value described by SourceDesc into the location 37067754Smsmith * described by DestDesc. Called by various interpreter 37167754Smsmith * functions to store the result of an operation into 37291116Smsmith * the destination operand -- not just simply the actual "Store" 37387031Smsmith * ASL operator. 37467754Smsmith * 37567754Smsmith ******************************************************************************/ 37667754Smsmith 37767754SmsmithACPI_STATUS 37877424SmsmithAcpiExStore ( 37985756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 38067754Smsmith ACPI_OPERAND_OBJECT *DestDesc, 38167754Smsmith ACPI_WALK_STATE *WalkState) 38267754Smsmith{ 38367754Smsmith ACPI_STATUS Status = AE_OK; 38471867Smsmith ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 38567754Smsmith 38667754Smsmith 387167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); 38867754Smsmith 38967754Smsmith 39067754Smsmith /* Validate parameters */ 39167754Smsmith 39285756Smsmith if (!SourceDesc || !DestDesc) 39367754Smsmith { 394167802Sjkim ACPI_ERROR ((AE_INFO, "Null parameter")); 39567754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 39667754Smsmith } 39767754Smsmith 39871867Smsmith /* DestDesc can be either a namespace node or an ACPI object */ 39967754Smsmith 40091116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 40167754Smsmith { 40277424Smsmith /* 40371867Smsmith * Dest is a namespace node, 404107325Siwasaki * Storing an object into a Named node. 40571867Smsmith */ 40685756Smsmith Status = AcpiExStoreObjectToNode (SourceDesc, 407128212Snjl (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, 408128212Snjl ACPI_IMPLICIT_CONVERSION); 40967754Smsmith 41071867Smsmith return_ACPI_STATUS (Status); 41167754Smsmith } 41267754Smsmith 41399679Siwasaki /* Destination object must be a Reference or a Constant object */ 41467754Smsmith 415193267Sjkim switch (DestDesc->Common.Type) 416102550Siwasaki { 417107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 41899679Siwasaki break; 41999679Siwasaki 42099679Siwasaki case ACPI_TYPE_INTEGER: 42199679Siwasaki 42299679Siwasaki /* Allow stores to Constants -- a Noop as per ACPI spec */ 42399679Siwasaki 42499679Siwasaki if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) 42599679Siwasaki { 42699679Siwasaki return_ACPI_STATUS (AE_OK); 42799679Siwasaki } 42899679Siwasaki 429104470Siwasaki /*lint -fallthrough */ 43099679Siwasaki 43199679Siwasaki default: 43299679Siwasaki 433126372Snjl /* Destination is not a Reference object */ 43467754Smsmith 435167802Sjkim ACPI_ERROR ((AE_INFO, 436167802Sjkim "Target is not a Reference or Constant object - %s [%p]", 437138287Smarks AcpiUtGetObjectTypeName (DestDesc), DestDesc)); 43867754Smsmith 43967754Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 44067754Smsmith } 44167754Smsmith 44277424Smsmith /* 443193267Sjkim * Examine the Reference class. These cases are handled: 44471867Smsmith * 44571867Smsmith * 1) Store to Name (Change the object associated with a name) 44671867Smsmith * 2) Store to an indexed area of a Buffer or Package 44771867Smsmith * 3) Store to a Method Local or Arg 44871867Smsmith * 4) Store to the debug object 44971867Smsmith */ 450193267Sjkim switch (RefDesc->Reference.Class) 45167754Smsmith { 452193267Sjkim case ACPI_REFCLASS_REFOF: 45367754Smsmith 45471867Smsmith /* Storing an object into a Name "container" */ 45571867Smsmith 456151937Sjkim Status = AcpiExStoreObjectToNode (SourceDesc, 457151937Sjkim RefDesc->Reference.Object, 458151937Sjkim WalkState, ACPI_IMPLICIT_CONVERSION); 45971867Smsmith break; 46067754Smsmith 46167754Smsmith 462193267Sjkim case ACPI_REFCLASS_INDEX: 46367754Smsmith 46471867Smsmith /* Storing to an Index (pointer into a packager or buffer) */ 46567754Smsmith 46685756Smsmith Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 46771867Smsmith break; 46871867Smsmith 46971867Smsmith 470193267Sjkim case ACPI_REFCLASS_LOCAL: 471193267Sjkim case ACPI_REFCLASS_ARG: 47271867Smsmith 47377424Smsmith /* Store to a method local/arg */ 47471867Smsmith 475193267Sjkim Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, 476193267Sjkim RefDesc->Reference.Value, SourceDesc, WalkState); 47771867Smsmith break; 47871867Smsmith 47971867Smsmith 480193267Sjkim case ACPI_REFCLASS_DEBUG: 48171867Smsmith 48267754Smsmith /* 48371867Smsmith * Storing to the Debug object causes the value stored to be 48471867Smsmith * displayed and otherwise has no effect -- see ACPI Specification 48567754Smsmith */ 486138287Smarks ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 487138287Smarks "**** Write to Debug Object: Object %p %s ****:\n\n", 488138287Smarks SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); 48977424Smsmith 490151937Sjkim AcpiExDoDebugObject (SourceDesc, 0, 0); 49171867Smsmith break; 49271867Smsmith 49371867Smsmith 49471867Smsmith default: 49571867Smsmith 496193267Sjkim ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", 497193267Sjkim RefDesc->Reference.Class)); 498193267Sjkim ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); 49971867Smsmith 50071867Smsmith Status = AE_AML_INTERNAL; 50171867Smsmith break; 50299679Siwasaki } 50371867Smsmith 50471867Smsmith return_ACPI_STATUS (Status); 50571867Smsmith} 50671867Smsmith 50771867Smsmith 50871867Smsmith/******************************************************************************* 50971867Smsmith * 51077424Smsmith * FUNCTION: AcpiExStoreObjectToIndex 51171867Smsmith * 51287031Smsmith * PARAMETERS: *SourceDesc - Value to be stored 51387031Smsmith * *DestDesc - Named object to receive the value 51487031Smsmith * WalkState - Current walk state 51571867Smsmith * 51671867Smsmith * RETURN: Status 51771867Smsmith * 51887031Smsmith * DESCRIPTION: Store the object to indexed Buffer or Package element 51971867Smsmith * 52071867Smsmith ******************************************************************************/ 52171867Smsmith 522151937Sjkimstatic ACPI_STATUS 52377424SmsmithAcpiExStoreObjectToIndex ( 52485756Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 52591116Smsmith ACPI_OPERAND_OBJECT *IndexDesc, 52671867Smsmith ACPI_WALK_STATE *WalkState) 52771867Smsmith{ 52871867Smsmith ACPI_STATUS Status = AE_OK; 52971867Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 53091116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 53171867Smsmith UINT8 Value = 0; 532126372Snjl UINT32 i; 53371867Smsmith 53471867Smsmith 535167802Sjkim ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); 53671867Smsmith 53771867Smsmith 53871867Smsmith /* 53971867Smsmith * Destination must be a reference pointer, and 54071867Smsmith * must point to either a buffer or a package 54171867Smsmith */ 54291116Smsmith switch (IndexDesc->Reference.TargetType) 54371867Smsmith { 54471867Smsmith case ACPI_TYPE_PACKAGE: 54571867Smsmith /* 546138287Smarks * Storing to a package element. Copy the object and replace 547138287Smarks * any existing object with the new object. No implicit 548138287Smarks * conversion is performed. 549138287Smarks * 55091116Smsmith * The object at *(IndexDesc->Reference.Where) is the 55191116Smsmith * element within the package that is to be modified. 552126372Snjl * The parent package object is at IndexDesc->Reference.Object 55391116Smsmith */ 55491116Smsmith ObjDesc = *(IndexDesc->Reference.Where); 55585756Smsmith 556193267Sjkim if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && 557193267Sjkim SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) 55891116Smsmith { 559193267Sjkim /* This is a DDBHandle, just add a reference to it */ 560193267Sjkim 561193267Sjkim AcpiUtAddReference (SourceDesc); 562193267Sjkim NewDesc = SourceDesc; 56391116Smsmith } 564193267Sjkim else 565193267Sjkim { 566193267Sjkim /* Normal object, copy it */ 56767754Smsmith 568193267Sjkim Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); 569193267Sjkim if (ACPI_FAILURE (Status)) 570193267Sjkim { 571193267Sjkim return_ACPI_STATUS (Status); 572193267Sjkim } 573193267Sjkim } 574193267Sjkim 575138287Smarks if (ObjDesc) 57691116Smsmith { 577138287Smarks /* Decrement reference count by the ref count of the parent package */ 578104470Siwasaki 579151937Sjkim for (i = 0; 580151937Sjkim i < ((ACPI_OPERAND_OBJECT *) 581151937Sjkim IndexDesc->Reference.Object)->Common.ReferenceCount; 582151937Sjkim i++) 583104470Siwasaki { 584138287Smarks AcpiUtRemoveReference (ObjDesc); 585104470Siwasaki } 586138287Smarks } 587151937Sjkim 588138287Smarks *(IndexDesc->Reference.Where) = NewDesc; 589126372Snjl 590151937Sjkim /* Increment ref count by the ref count of the parent package-1 */ 591126372Snjl 592151937Sjkim for (i = 1; 593151937Sjkim i < ((ACPI_OPERAND_OBJECT *) 594151937Sjkim IndexDesc->Reference.Object)->Common.ReferenceCount; 595151937Sjkim i++) 596138287Smarks { 597138287Smarks AcpiUtAddReference (NewDesc); 59867754Smsmith } 599151937Sjkim 60071867Smsmith break; 60167754Smsmith 60267754Smsmith 60371867Smsmith case ACPI_TYPE_BUFFER_FIELD: 60477424Smsmith 60567754Smsmith /* 606138287Smarks * Store into a Buffer or String (not actually a real BufferField) 607138287Smarks * at a location defined by an Index. 60867754Smsmith * 60987031Smsmith * The first 8-bit element of the source object is written to the 61087031Smsmith * 8-bit Buffer location defined by the Index destination object, 61187031Smsmith * according to the ACPI 2.0 specification. 61267754Smsmith */ 61367754Smsmith 61467754Smsmith /* 615138287Smarks * Make sure the target is a Buffer or String. An error should 616138287Smarks * not happen here, since the ReferenceObject was constructed 617138287Smarks * by the INDEX_OP code. 61867754Smsmith */ 61991116Smsmith ObjDesc = IndexDesc->Reference.Object; 620193267Sjkim if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && 621193267Sjkim (ObjDesc->Common.Type != ACPI_TYPE_STRING)) 62267754Smsmith { 62371867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 62467754Smsmith } 62567754Smsmith 62667754Smsmith /* 62767754Smsmith * The assignment of the individual elements will be slightly 62867754Smsmith * different for each source type. 62967754Smsmith */ 630193267Sjkim switch (SourceDesc->Common.Type) 63167754Smsmith { 63271867Smsmith case ACPI_TYPE_INTEGER: 63387031Smsmith 63487031Smsmith /* Use the least-significant byte of the integer */ 63587031Smsmith 63687031Smsmith Value = (UINT8) (SourceDesc->Integer.Value); 63767754Smsmith break; 63867754Smsmith 63987031Smsmith case ACPI_TYPE_BUFFER: 640138287Smarks case ACPI_TYPE_STRING: 64177424Smsmith 642138287Smarks /* Note: Takes advantage of common string/buffer fields */ 643138287Smarks 64487031Smsmith Value = SourceDesc->Buffer.Pointer[0]; 64567754Smsmith break; 64667754Smsmith 64767754Smsmith default: 64877424Smsmith 64987031Smsmith /* All other types are invalid */ 65077424Smsmith 651167802Sjkim ACPI_ERROR ((AE_INFO, 652167802Sjkim "Source must be Integer/Buffer/String type, not %s", 65399679Siwasaki AcpiUtGetObjectTypeName (SourceDesc))); 65487031Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 65567754Smsmith } 65687031Smsmith 65787031Smsmith /* Store the source value into the target buffer byte */ 65887031Smsmith 659193267Sjkim ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; 66071867Smsmith break; 66167754Smsmith 66267754Smsmith 66371867Smsmith default: 664167802Sjkim ACPI_ERROR ((AE_INFO, 665167802Sjkim "Target is not a Package or BufferField")); 66671867Smsmith Status = AE_AML_OPERAND_TYPE; 66767754Smsmith break; 66871867Smsmith } 66967754Smsmith 67071867Smsmith return_ACPI_STATUS (Status); 67171867Smsmith} 67267754Smsmith 67367754Smsmith 67471867Smsmith/******************************************************************************* 67571867Smsmith * 67677424Smsmith * FUNCTION: AcpiExStoreObjectToNode 67771867Smsmith * 67887031Smsmith * PARAMETERS: SourceDesc - Value to be stored 67987031Smsmith * Node - Named object to receive the value 68087031Smsmith * WalkState - Current walk state 681128212Snjl * ImplicitConversion - Perform implicit conversion (yes/no) 68271867Smsmith * 68371867Smsmith * RETURN: Status 68471867Smsmith * 68571867Smsmith * DESCRIPTION: Store the object to the named object. 68671867Smsmith * 68771867Smsmith * The Assignment of an object to a named object is handled here 68887031Smsmith * The value passed in will replace the current value (if any) 68971867Smsmith * with the input value. 69071867Smsmith * 69171867Smsmith * When storing into an object the data is converted to the 69271867Smsmith * target object type then stored in the object. This means 69371867Smsmith * that the target object type (for an initialized target) will 69471867Smsmith * not be changed by a store operation. 69571867Smsmith * 69687031Smsmith * Assumes parameters are already validated. 69771867Smsmith * 69871867Smsmith ******************************************************************************/ 69967754Smsmith 70071867SmsmithACPI_STATUS 70177424SmsmithAcpiExStoreObjectToNode ( 70271867Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 70371867Smsmith ACPI_NAMESPACE_NODE *Node, 704128212Snjl ACPI_WALK_STATE *WalkState, 705128212Snjl UINT8 ImplicitConversion) 70671867Smsmith{ 70771867Smsmith ACPI_STATUS Status = AE_OK; 70871867Smsmith ACPI_OPERAND_OBJECT *TargetDesc; 70991116Smsmith ACPI_OPERAND_OBJECT *NewDesc; 71091116Smsmith ACPI_OBJECT_TYPE TargetType; 71167754Smsmith 71271867Smsmith 713167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); 71471867Smsmith 71583174Smsmith 716151937Sjkim /* Get current type of the node, and object attached to Node */ 717151937Sjkim 71871867Smsmith TargetType = AcpiNsGetType (Node); 71971867Smsmith TargetDesc = AcpiNsGetAttachedObject (Node); 72071867Smsmith 72199146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", 72299679Siwasaki SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 72391116Smsmith Node, AcpiUtGetTypeName (TargetType))); 72471867Smsmith 72571867Smsmith /* 72671867Smsmith * Resolve the source object to an actual value 72777424Smsmith * (If it is a reference object) 72871867Smsmith */ 72977424Smsmith Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 73071867Smsmith if (ACPI_FAILURE (Status)) 73171867Smsmith { 73271867Smsmith return_ACPI_STATUS (Status); 73371867Smsmith } 73471867Smsmith 735128212Snjl /* If no implicit conversion, drop into the default case below */ 736128212Snjl 737193267Sjkim if ((!ImplicitConversion) || 738193267Sjkim ((WalkState->Opcode == AML_COPY_OP) && 739193267Sjkim (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && 740193267Sjkim (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && 741193267Sjkim (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) 742128212Snjl { 743193267Sjkim /* 744193267Sjkim * Force execution of default (no implicit conversion). Note: 745193267Sjkim * CopyObject does not perform an implicit conversion, as per the ACPI 746193267Sjkim * spec -- except in case of region/bank/index fields -- because these 747193267Sjkim * objects must retain their original type permanently. 748193267Sjkim */ 749128212Snjl TargetType = ACPI_TYPE_ANY; 750128212Snjl } 751128212Snjl 752151937Sjkim /* Do the actual store operation */ 753151937Sjkim 75471867Smsmith switch (TargetType) 75571867Smsmith { 75677424Smsmith case ACPI_TYPE_BUFFER_FIELD: 757107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 758107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 759107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 76071867Smsmith 761151937Sjkim /* For fields, copy the source data to the target field. */ 762151937Sjkim 763151937Sjkim Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, 764151937Sjkim &WalkState->ResultObj); 76567754Smsmith break; 76667754Smsmith 76767754Smsmith 76871867Smsmith case ACPI_TYPE_INTEGER: 76971867Smsmith case ACPI_TYPE_STRING: 77071867Smsmith case ACPI_TYPE_BUFFER: 77167754Smsmith 77277424Smsmith /* 77371867Smsmith * These target types are all of type Integer/String/Buffer, and 77471867Smsmith * therefore support implicit conversion before the store. 77577424Smsmith * 77677424Smsmith * Copy and/or convert the source object to a new target object 77767754Smsmith */ 778151937Sjkim Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, 779151937Sjkim &NewDesc, WalkState); 78071867Smsmith if (ACPI_FAILURE (Status)) 78167754Smsmith { 78271867Smsmith return_ACPI_STATUS (Status); 78367754Smsmith } 78467754Smsmith 78591116Smsmith if (NewDesc != TargetDesc) 78691116Smsmith { 78791116Smsmith /* 78891116Smsmith * Store the new NewDesc as the new value of the Name, and set 78991116Smsmith * the Name's type to that of the value being stored in it. 79091116Smsmith * SourceDesc reference count is incremented by AttachObject. 791104470Siwasaki * 792104470Siwasaki * Note: This may change the type of the node if an explicit store 793104470Siwasaki * has been performed such that the node/object type has been 794104470Siwasaki * changed. 79591116Smsmith */ 796104470Siwasaki Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 79785756Smsmith 79899146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 79991116Smsmith "Store %s into %s via Convert/Attach\n", 80099679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), 80199679Siwasaki AcpiUtGetObjectTypeName (NewDesc))); 80291116Smsmith } 80367754Smsmith break; 80467754Smsmith 80577424Smsmith 80667754Smsmith default: 80767754Smsmith 80899146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 809151937Sjkim "Storing %s (%p) directly into node (%p) with no implicit conversion\n", 81099679Siwasaki AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); 81184491Smsmith 81271867Smsmith /* No conversions for all other types. Just attach the source object */ 81367754Smsmith 814151937Sjkim Status = AcpiNsAttachObject (Node, SourceDesc, 815193267Sjkim SourceDesc->Common.Type); 81671867Smsmith break; 81771867Smsmith } 81867754Smsmith 81971867Smsmith return_ACPI_STATUS (Status); 82071867Smsmith} 82167754Smsmith 82267754Smsmith 823