1 1.1 jruoho /****************************************************************************** 2 1.1 jruoho * 3 1.1 jruoho * Module Name: exstore - AML Interpreter object store support 4 1.1 jruoho * 5 1.1 jruoho *****************************************************************************/ 6 1.1 jruoho 7 1.1.1.15 christos /****************************************************************************** 8 1.1.1.15 christos * 9 1.1.1.15 christos * 1. Copyright Notice 10 1.1.1.15 christos * 11 1.1.1.16 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 1.1 jruoho * All rights reserved. 13 1.1 jruoho * 14 1.1.1.15 christos * 2. License 15 1.1.1.15 christos * 16 1.1.1.15 christos * 2.1. This is your license from Intel Corp. under its intellectual property 17 1.1.1.15 christos * rights. You may have additional license terms from the party that provided 18 1.1.1.15 christos * you this software, covering your right to use that party's intellectual 19 1.1.1.15 christos * property rights. 20 1.1.1.15 christos * 21 1.1.1.15 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 1.1.1.15 christos * copy of the source code appearing in this file ("Covered Code") an 23 1.1.1.15 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 1.1.1.15 christos * base code distributed originally by Intel ("Original Intel Code") to copy, 25 1.1.1.15 christos * make derivatives, distribute, use and display any portion of the Covered 26 1.1.1.15 christos * Code in any form, with the right to sublicense such rights; and 27 1.1.1.15 christos * 28 1.1.1.15 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 1.1.1.15 christos * license (with the right to sublicense), under only those claims of Intel 30 1.1.1.15 christos * patents that are infringed by the Original Intel Code, to make, use, sell, 31 1.1.1.15 christos * offer to sell, and import the Covered Code and derivative works thereof 32 1.1.1.15 christos * solely to the minimum extent necessary to exercise the above copyright 33 1.1.1.15 christos * license, and in no event shall the patent license extend to any additions 34 1.1.1.15 christos * to or modifications of the Original Intel Code. No other license or right 35 1.1.1.15 christos * is granted directly or by implication, estoppel or otherwise; 36 1.1.1.15 christos * 37 1.1.1.15 christos * The above copyright and patent license is granted only if the following 38 1.1.1.15 christos * conditions are met: 39 1.1.1.15 christos * 40 1.1.1.15 christos * 3. Conditions 41 1.1.1.15 christos * 42 1.1.1.15 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 1.1.1.15 christos * Redistribution of source code of any substantial portion of the Covered 44 1.1.1.15 christos * Code or modification with rights to further distribute source must include 45 1.1.1.15 christos * the above Copyright Notice, the above License, this list of Conditions, 46 1.1.1.15 christos * and the following Disclaimer and Export Compliance provision. In addition, 47 1.1.1.15 christos * Licensee must cause all Covered Code to which Licensee contributes to 48 1.1.1.15 christos * contain a file documenting the changes Licensee made to create that Covered 49 1.1.1.15 christos * Code and the date of any change. Licensee must include in that file the 50 1.1.1.15 christos * documentation of any changes made by any predecessor Licensee. Licensee 51 1.1.1.15 christos * must include a prominent statement that the modification is derived, 52 1.1.1.15 christos * directly or indirectly, from Original Intel Code. 53 1.1.1.15 christos * 54 1.1.1.15 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 1.1.1.15 christos * Redistribution of source code of any substantial portion of the Covered 56 1.1.1.15 christos * Code or modification without rights to further distribute source must 57 1.1.1.15 christos * include the following Disclaimer and Export Compliance provision in the 58 1.1.1.15 christos * documentation and/or other materials provided with distribution. In 59 1.1.1.15 christos * addition, Licensee may not authorize further sublicense of source of any 60 1.1.1.15 christos * portion of the Covered Code, and must include terms to the effect that the 61 1.1.1.15 christos * license from Licensee to its licensee is limited to the intellectual 62 1.1.1.15 christos * property embodied in the software Licensee provides to its licensee, and 63 1.1.1.15 christos * not to intellectual property embodied in modifications its licensee may 64 1.1.1.15 christos * make. 65 1.1.1.15 christos * 66 1.1.1.15 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 1.1.1.15 christos * substantial portion of the Covered Code or modification must reproduce the 68 1.1.1.15 christos * above Copyright Notice, and the following Disclaimer and Export Compliance 69 1.1.1.15 christos * provision in the documentation and/or other materials provided with the 70 1.1.1.15 christos * distribution. 71 1.1.1.15 christos * 72 1.1.1.15 christos * 3.4. Intel retains all right, title, and interest in and to the Original 73 1.1.1.15 christos * Intel Code. 74 1.1.1.15 christos * 75 1.1.1.15 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 1.1.1.15 christos * Intel shall be used in advertising or otherwise to promote the sale, use or 77 1.1.1.15 christos * other dealings in products derived from or relating to the Covered Code 78 1.1.1.15 christos * without prior written authorization from Intel. 79 1.1.1.15 christos * 80 1.1.1.15 christos * 4. Disclaimer and Export Compliance 81 1.1.1.15 christos * 82 1.1.1.15 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 1.1.1.15 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 1.1.1.15 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 1.1.1.15 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 1.1.1.15 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 1.1.1.15 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 1.1.1.15 christos * PARTICULAR PURPOSE. 89 1.1.1.15 christos * 90 1.1.1.15 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 1.1.1.15 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 1.1.1.15 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 1.1.1.15 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 1.1.1.15 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 1.1.1.15 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 1.1.1.15 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 1.1.1.15 christos * LIMITED REMEDY. 98 1.1.1.15 christos * 99 1.1.1.15 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 1.1.1.15 christos * software or system incorporating such software without first obtaining any 101 1.1.1.15 christos * required license or other approval from the U. S. Department of Commerce or 102 1.1.1.15 christos * any other agency or department of the United States Government. In the 103 1.1.1.15 christos * event Licensee exports any such software from the United States or 104 1.1.1.15 christos * re-exports any such software from a foreign destination, Licensee shall 105 1.1.1.15 christos * ensure that the distribution and export/re-export of the software is in 106 1.1.1.15 christos * compliance with all laws, regulations, orders, or other restrictions of the 107 1.1.1.15 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 1.1.1.15 christos * any of its subsidiaries will export/re-export any technical data, process, 109 1.1.1.15 christos * software, or service, directly or indirectly, to any country for which the 110 1.1.1.15 christos * United States government or any agency thereof requires an export license, 111 1.1.1.15 christos * other governmental approval, or letter of assurance, without first obtaining 112 1.1.1.15 christos * such license, approval or letter. 113 1.1.1.15 christos * 114 1.1.1.15 christos ***************************************************************************** 115 1.1.1.15 christos * 116 1.1.1.15 christos * Alternatively, you may choose to be licensed under the terms of the 117 1.1.1.15 christos * following license: 118 1.1.1.15 christos * 119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without 120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions 121 1.1.1.2 jruoho * are met: 122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright 123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer, 124 1.1.1.2 jruoho * without modification. 125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below 127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon 128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further 129 1.1.1.2 jruoho * binary redistribution. 130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names 131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived 132 1.1.1.2 jruoho * from this software without specific prior written permission. 133 1.1.1.2 jruoho * 134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 1.1.1.12 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 1.1.1.15 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 1.1.1.15 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 1.1.1.15 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 1.1.1.15 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 1.1.1.15 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 1.1.1.15 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 1.1.1.15 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 1.1.1.15 christos * 146 1.1.1.15 christos * Alternatively, you may choose to be licensed under the terms of the 147 1.1.1.15 christos * GNU General Public License ("GPL") version 2 as published by the Free 148 1.1.1.15 christos * Software Foundation. 149 1.1.1.15 christos * 150 1.1.1.15 christos *****************************************************************************/ 151 1.1 jruoho 152 1.1 jruoho #include "acpi.h" 153 1.1 jruoho #include "accommon.h" 154 1.1 jruoho #include "acdispat.h" 155 1.1 jruoho #include "acinterp.h" 156 1.1 jruoho #include "amlcode.h" 157 1.1 jruoho #include "acnamesp.h" 158 1.1 jruoho 159 1.1 jruoho 160 1.1 jruoho #define _COMPONENT ACPI_EXECUTER 161 1.1 jruoho ACPI_MODULE_NAME ("exstore") 162 1.1 jruoho 163 1.1 jruoho /* Local prototypes */ 164 1.1 jruoho 165 1.1 jruoho static ACPI_STATUS 166 1.1 jruoho AcpiExStoreObjectToIndex ( 167 1.1 jruoho ACPI_OPERAND_OBJECT *ValDesc, 168 1.1 jruoho ACPI_OPERAND_OBJECT *DestDesc, 169 1.1 jruoho ACPI_WALK_STATE *WalkState); 170 1.1 jruoho 171 1.1.1.3 christos static ACPI_STATUS 172 1.1.1.3 christos AcpiExStoreDirectToNode ( 173 1.1.1.3 christos ACPI_OPERAND_OBJECT *SourceDesc, 174 1.1.1.3 christos ACPI_NAMESPACE_NODE *Node, 175 1.1.1.3 christos ACPI_WALK_STATE *WalkState); 176 1.1.1.3 christos 177 1.1 jruoho 178 1.1 jruoho /******************************************************************************* 179 1.1 jruoho * 180 1.1 jruoho * FUNCTION: AcpiExStore 181 1.1 jruoho * 182 1.1 jruoho * PARAMETERS: *SourceDesc - Value to be stored 183 1.1.1.3 christos * *DestDesc - Where to store it. Must be an NS node 184 1.1.1.3 christos * or ACPI_OPERAND_OBJECT of type 185 1.1 jruoho * Reference; 186 1.1 jruoho * WalkState - Current walk state 187 1.1 jruoho * 188 1.1 jruoho * RETURN: Status 189 1.1 jruoho * 190 1.1 jruoho * DESCRIPTION: Store the value described by SourceDesc into the location 191 1.1.1.3 christos * described by DestDesc. Called by various interpreter 192 1.1 jruoho * functions to store the result of an operation into 193 1.1 jruoho * the destination operand -- not just simply the actual "Store" 194 1.1 jruoho * ASL operator. 195 1.1 jruoho * 196 1.1 jruoho ******************************************************************************/ 197 1.1 jruoho 198 1.1 jruoho ACPI_STATUS 199 1.1 jruoho AcpiExStore ( 200 1.1 jruoho ACPI_OPERAND_OBJECT *SourceDesc, 201 1.1 jruoho ACPI_OPERAND_OBJECT *DestDesc, 202 1.1 jruoho ACPI_WALK_STATE *WalkState) 203 1.1 jruoho { 204 1.1 jruoho ACPI_STATUS Status = AE_OK; 205 1.1 jruoho ACPI_OPERAND_OBJECT *RefDesc = DestDesc; 206 1.1 jruoho 207 1.1 jruoho 208 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); 209 1.1 jruoho 210 1.1 jruoho 211 1.1 jruoho /* Validate parameters */ 212 1.1 jruoho 213 1.1 jruoho if (!SourceDesc || !DestDesc) 214 1.1 jruoho { 215 1.1 jruoho ACPI_ERROR ((AE_INFO, "Null parameter")); 216 1.1 jruoho return_ACPI_STATUS (AE_AML_NO_OPERAND); 217 1.1 jruoho } 218 1.1 jruoho 219 1.1 jruoho /* DestDesc can be either a namespace node or an ACPI object */ 220 1.1 jruoho 221 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) 222 1.1 jruoho { 223 1.1 jruoho /* 224 1.1 jruoho * Dest is a namespace node, 225 1.1 jruoho * Storing an object into a Named node. 226 1.1 jruoho */ 227 1.1 jruoho Status = AcpiExStoreObjectToNode (SourceDesc, 228 1.1.1.6 christos (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, 229 1.1.1.6 christos ACPI_IMPLICIT_CONVERSION); 230 1.1 jruoho 231 1.1 jruoho return_ACPI_STATUS (Status); 232 1.1 jruoho } 233 1.1 jruoho 234 1.1 jruoho /* Destination object must be a Reference or a Constant object */ 235 1.1 jruoho 236 1.1 jruoho switch (DestDesc->Common.Type) 237 1.1 jruoho { 238 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE: 239 1.1.1.3 christos 240 1.1 jruoho break; 241 1.1 jruoho 242 1.1 jruoho case ACPI_TYPE_INTEGER: 243 1.1 jruoho 244 1.1 jruoho /* Allow stores to Constants -- a Noop as per ACPI spec */ 245 1.1 jruoho 246 1.1 jruoho if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) 247 1.1 jruoho { 248 1.1 jruoho return_ACPI_STATUS (AE_OK); 249 1.1 jruoho } 250 1.1 jruoho 251 1.1.1.12 christos ACPI_FALLTHROUGH; 252 1.1 jruoho 253 1.1 jruoho default: 254 1.1 jruoho 255 1.1 jruoho /* Destination is not a Reference object */ 256 1.1 jruoho 257 1.1 jruoho ACPI_ERROR ((AE_INFO, 258 1.1.1.6 christos "Target is not a Reference or Constant object - [%s] %p", 259 1.1 jruoho AcpiUtGetObjectTypeName (DestDesc), DestDesc)); 260 1.1 jruoho 261 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 262 1.1 jruoho } 263 1.1 jruoho 264 1.1 jruoho /* 265 1.1 jruoho * Examine the Reference class. These cases are handled: 266 1.1 jruoho * 267 1.1 jruoho * 1) Store to Name (Change the object associated with a name) 268 1.1 jruoho * 2) Store to an indexed area of a Buffer or Package 269 1.1 jruoho * 3) Store to a Method Local or Arg 270 1.1 jruoho * 4) Store to the debug object 271 1.1 jruoho */ 272 1.1 jruoho switch (RefDesc->Reference.Class) 273 1.1 jruoho { 274 1.1 jruoho case ACPI_REFCLASS_REFOF: 275 1.1 jruoho 276 1.1 jruoho /* Storing an object into a Name "container" */ 277 1.1 jruoho 278 1.1 jruoho Status = AcpiExStoreObjectToNode (SourceDesc, 279 1.1.1.6 christos RefDesc->Reference.Object, 280 1.1.1.6 christos WalkState, ACPI_IMPLICIT_CONVERSION); 281 1.1 jruoho break; 282 1.1 jruoho 283 1.1 jruoho case ACPI_REFCLASS_INDEX: 284 1.1 jruoho 285 1.1 jruoho /* Storing to an Index (pointer into a packager or buffer) */ 286 1.1 jruoho 287 1.1 jruoho Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); 288 1.1 jruoho break; 289 1.1 jruoho 290 1.1 jruoho case ACPI_REFCLASS_LOCAL: 291 1.1 jruoho case ACPI_REFCLASS_ARG: 292 1.1 jruoho 293 1.1 jruoho /* Store to a method local/arg */ 294 1.1 jruoho 295 1.1 jruoho Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, 296 1.1.1.6 christos RefDesc->Reference.Value, SourceDesc, WalkState); 297 1.1 jruoho break; 298 1.1 jruoho 299 1.1 jruoho case ACPI_REFCLASS_DEBUG: 300 1.1 jruoho /* 301 1.1 jruoho * Storing to the Debug object causes the value stored to be 302 1.1 jruoho * displayed and otherwise has no effect -- see ACPI Specification 303 1.1 jruoho */ 304 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 305 1.1.1.6 christos "**** Write to Debug Object: Object %p [%s] ****:\n\n", 306 1.1 jruoho SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); 307 1.1 jruoho 308 1.1 jruoho ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); 309 1.1 jruoho break; 310 1.1 jruoho 311 1.1 jruoho default: 312 1.1 jruoho 313 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", 314 1.1 jruoho RefDesc->Reference.Class)); 315 1.1 jruoho ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); 316 1.1 jruoho 317 1.1 jruoho Status = AE_AML_INTERNAL; 318 1.1 jruoho break; 319 1.1 jruoho } 320 1.1 jruoho 321 1.1 jruoho return_ACPI_STATUS (Status); 322 1.1 jruoho } 323 1.1 jruoho 324 1.1 jruoho 325 1.1 jruoho /******************************************************************************* 326 1.1 jruoho * 327 1.1 jruoho * FUNCTION: AcpiExStoreObjectToIndex 328 1.1 jruoho * 329 1.1 jruoho * PARAMETERS: *SourceDesc - Value to be stored 330 1.1 jruoho * *DestDesc - Named object to receive the value 331 1.1 jruoho * WalkState - Current walk state 332 1.1 jruoho * 333 1.1 jruoho * RETURN: Status 334 1.1 jruoho * 335 1.1 jruoho * DESCRIPTION: Store the object to indexed Buffer or Package element 336 1.1 jruoho * 337 1.1 jruoho ******************************************************************************/ 338 1.1 jruoho 339 1.1 jruoho static ACPI_STATUS 340 1.1 jruoho AcpiExStoreObjectToIndex ( 341 1.1 jruoho ACPI_OPERAND_OBJECT *SourceDesc, 342 1.1 jruoho ACPI_OPERAND_OBJECT *IndexDesc, 343 1.1 jruoho ACPI_WALK_STATE *WalkState) 344 1.1 jruoho { 345 1.1 jruoho ACPI_STATUS Status = AE_OK; 346 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc; 347 1.1 jruoho ACPI_OPERAND_OBJECT *NewDesc; 348 1.1 jruoho UINT8 Value = 0; 349 1.1 jruoho UINT32 i; 350 1.1 jruoho 351 1.1 jruoho 352 1.1 jruoho ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); 353 1.1 jruoho 354 1.1 jruoho 355 1.1 jruoho /* 356 1.1 jruoho * Destination must be a reference pointer, and 357 1.1 jruoho * must point to either a buffer or a package 358 1.1 jruoho */ 359 1.1 jruoho switch (IndexDesc->Reference.TargetType) 360 1.1 jruoho { 361 1.1 jruoho case ACPI_TYPE_PACKAGE: 362 1.1 jruoho /* 363 1.1 jruoho * Storing to a package element. Copy the object and replace 364 1.1 jruoho * any existing object with the new object. No implicit 365 1.1 jruoho * conversion is performed. 366 1.1 jruoho * 367 1.1 jruoho * The object at *(IndexDesc->Reference.Where) is the 368 1.1 jruoho * element within the package that is to be modified. 369 1.1 jruoho * The parent package object is at IndexDesc->Reference.Object 370 1.1 jruoho */ 371 1.1 jruoho ObjDesc = *(IndexDesc->Reference.Where); 372 1.1 jruoho 373 1.1 jruoho if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && 374 1.1 jruoho SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) 375 1.1 jruoho { 376 1.1 jruoho /* This is a DDBHandle, just add a reference to it */ 377 1.1 jruoho 378 1.1 jruoho AcpiUtAddReference (SourceDesc); 379 1.1 jruoho NewDesc = SourceDesc; 380 1.1 jruoho } 381 1.1 jruoho else 382 1.1 jruoho { 383 1.1 jruoho /* Normal object, copy it */ 384 1.1 jruoho 385 1.1.1.6 christos Status = AcpiUtCopyIobjectToIobject ( 386 1.1.1.6 christos SourceDesc, &NewDesc, WalkState); 387 1.1 jruoho if (ACPI_FAILURE (Status)) 388 1.1 jruoho { 389 1.1 jruoho return_ACPI_STATUS (Status); 390 1.1 jruoho } 391 1.1 jruoho } 392 1.1 jruoho 393 1.1 jruoho if (ObjDesc) 394 1.1 jruoho { 395 1.1 jruoho /* Decrement reference count by the ref count of the parent package */ 396 1.1 jruoho 397 1.1 jruoho for (i = 0; 398 1.1 jruoho i < ((ACPI_OPERAND_OBJECT *) 399 1.1 jruoho IndexDesc->Reference.Object)->Common.ReferenceCount; 400 1.1 jruoho i++) 401 1.1 jruoho { 402 1.1 jruoho AcpiUtRemoveReference (ObjDesc); 403 1.1 jruoho } 404 1.1 jruoho } 405 1.1 jruoho 406 1.1 jruoho *(IndexDesc->Reference.Where) = NewDesc; 407 1.1 jruoho 408 1.1 jruoho /* Increment ref count by the ref count of the parent package-1 */ 409 1.1 jruoho 410 1.1 jruoho for (i = 1; 411 1.1 jruoho i < ((ACPI_OPERAND_OBJECT *) 412 1.1 jruoho IndexDesc->Reference.Object)->Common.ReferenceCount; 413 1.1 jruoho i++) 414 1.1 jruoho { 415 1.1 jruoho AcpiUtAddReference (NewDesc); 416 1.1 jruoho } 417 1.1 jruoho 418 1.1 jruoho break; 419 1.1 jruoho 420 1.1 jruoho case ACPI_TYPE_BUFFER_FIELD: 421 1.1 jruoho /* 422 1.1 jruoho * Store into a Buffer or String (not actually a real BufferField) 423 1.1 jruoho * at a location defined by an Index. 424 1.1 jruoho * 425 1.1 jruoho * The first 8-bit element of the source object is written to the 426 1.1 jruoho * 8-bit Buffer location defined by the Index destination object, 427 1.1 jruoho * according to the ACPI 2.0 specification. 428 1.1 jruoho */ 429 1.1 jruoho 430 1.1 jruoho /* 431 1.1 jruoho * Make sure the target is a Buffer or String. An error should 432 1.1 jruoho * not happen here, since the ReferenceObject was constructed 433 1.1 jruoho * by the INDEX_OP code. 434 1.1 jruoho */ 435 1.1 jruoho ObjDesc = IndexDesc->Reference.Object; 436 1.1 jruoho if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && 437 1.1 jruoho (ObjDesc->Common.Type != ACPI_TYPE_STRING)) 438 1.1 jruoho { 439 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 440 1.1 jruoho } 441 1.1 jruoho 442 1.1 jruoho /* 443 1.1 jruoho * The assignment of the individual elements will be slightly 444 1.1 jruoho * different for each source type. 445 1.1 jruoho */ 446 1.1 jruoho switch (SourceDesc->Common.Type) 447 1.1 jruoho { 448 1.1 jruoho case ACPI_TYPE_INTEGER: 449 1.1 jruoho 450 1.1 jruoho /* Use the least-significant byte of the integer */ 451 1.1 jruoho 452 1.1 jruoho Value = (UINT8) (SourceDesc->Integer.Value); 453 1.1 jruoho break; 454 1.1 jruoho 455 1.1 jruoho case ACPI_TYPE_BUFFER: 456 1.1 jruoho case ACPI_TYPE_STRING: 457 1.1 jruoho 458 1.1 jruoho /* Note: Takes advantage of common string/buffer fields */ 459 1.1 jruoho 460 1.1 jruoho Value = SourceDesc->Buffer.Pointer[0]; 461 1.1 jruoho break; 462 1.1 jruoho 463 1.1 jruoho default: 464 1.1 jruoho 465 1.1 jruoho /* All other types are invalid */ 466 1.1 jruoho 467 1.1 jruoho ACPI_ERROR ((AE_INFO, 468 1.1.1.6 christos "Source must be type [Integer/Buffer/String], found [%s]", 469 1.1 jruoho AcpiUtGetObjectTypeName (SourceDesc))); 470 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 471 1.1 jruoho } 472 1.1 jruoho 473 1.1 jruoho /* Store the source value into the target buffer byte */ 474 1.1 jruoho 475 1.1 jruoho ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; 476 1.1 jruoho break; 477 1.1 jruoho 478 1.1 jruoho default: 479 1.1 jruoho ACPI_ERROR ((AE_INFO, 480 1.1.1.6 christos "Target is not of type [Package/BufferField]")); 481 1.1.1.6 christos Status = AE_AML_TARGET_TYPE; 482 1.1 jruoho break; 483 1.1 jruoho } 484 1.1 jruoho 485 1.1 jruoho return_ACPI_STATUS (Status); 486 1.1 jruoho } 487 1.1 jruoho 488 1.1 jruoho 489 1.1 jruoho /******************************************************************************* 490 1.1 jruoho * 491 1.1 jruoho * FUNCTION: AcpiExStoreObjectToNode 492 1.1 jruoho * 493 1.1 jruoho * PARAMETERS: SourceDesc - Value to be stored 494 1.1 jruoho * Node - Named object to receive the value 495 1.1 jruoho * WalkState - Current walk state 496 1.1 jruoho * ImplicitConversion - Perform implicit conversion (yes/no) 497 1.1 jruoho * 498 1.1 jruoho * RETURN: Status 499 1.1 jruoho * 500 1.1 jruoho * DESCRIPTION: Store the object to the named object. 501 1.1 jruoho * 502 1.1.1.6 christos * The assignment of an object to a named object is handled here. 503 1.1.1.6 christos * The value passed in will replace the current value (if any) 504 1.1.1.6 christos * with the input value. 505 1.1.1.6 christos * 506 1.1.1.6 christos * When storing into an object the data is converted to the 507 1.1.1.6 christos * target object type then stored in the object. This means 508 1.1.1.6 christos * that the target object type (for an initialized target) will 509 1.1.1.6 christos * not be changed by a store operation. A CopyObject can change 510 1.1.1.6 christos * the target type, however. 511 1.1.1.3 christos * 512 1.1.1.6 christos * The ImplicitConversion flag is set to NO/FALSE only when 513 1.1.1.6 christos * storing to an ArgX -- as per the rules of the ACPI spec. 514 1.1 jruoho * 515 1.1.1.6 christos * Assumes parameters are already validated. 516 1.1 jruoho * 517 1.1 jruoho ******************************************************************************/ 518 1.1 jruoho 519 1.1 jruoho ACPI_STATUS 520 1.1 jruoho AcpiExStoreObjectToNode ( 521 1.1 jruoho ACPI_OPERAND_OBJECT *SourceDesc, 522 1.1 jruoho ACPI_NAMESPACE_NODE *Node, 523 1.1 jruoho ACPI_WALK_STATE *WalkState, 524 1.1 jruoho UINT8 ImplicitConversion) 525 1.1 jruoho { 526 1.1 jruoho ACPI_STATUS Status = AE_OK; 527 1.1 jruoho ACPI_OPERAND_OBJECT *TargetDesc; 528 1.1 jruoho ACPI_OPERAND_OBJECT *NewDesc; 529 1.1 jruoho ACPI_OBJECT_TYPE TargetType; 530 1.1 jruoho 531 1.1 jruoho 532 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); 533 1.1 jruoho 534 1.1 jruoho 535 1.1 jruoho /* Get current type of the node, and object attached to Node */ 536 1.1 jruoho 537 1.1 jruoho TargetType = AcpiNsGetType (Node); 538 1.1 jruoho TargetDesc = AcpiNsGetAttachedObject (Node); 539 1.1 jruoho 540 1.1.1.6 christos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n", 541 1.1 jruoho SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), 542 1.1.1.6 christos Node, AcpiUtGetTypeName (TargetType))); 543 1.1.1.6 christos 544 1.1.1.6 christos /* Only limited target types possible for everything except CopyObject */ 545 1.1.1.6 christos 546 1.1.1.8 christos if (WalkState->Opcode != AML_COPY_OBJECT_OP) 547 1.1.1.6 christos { 548 1.1.1.6 christos /* 549 1.1.1.6 christos * Only CopyObject allows all object types to be overwritten. For 550 1.1.1.6 christos * TargetRef(s), there are restrictions on the object types that 551 1.1.1.6 christos * are allowed. 552 1.1.1.6 christos * 553 1.1.1.6 christos * Allowable operations/typing for Store: 554 1.1.1.6 christos * 555 1.1.1.6 christos * 1) Simple Store 556 1.1.1.6 christos * Integer --> Integer (Named/Local/Arg) 557 1.1.1.6 christos * String --> String (Named/Local/Arg) 558 1.1.1.6 christos * Buffer --> Buffer (Named/Local/Arg) 559 1.1.1.6 christos * Package --> Package (Named/Local/Arg) 560 1.1.1.6 christos * 561 1.1.1.6 christos * 2) Store with implicit conversion 562 1.1.1.6 christos * Integer --> String or Buffer (Named) 563 1.1.1.6 christos * String --> Integer or Buffer (Named) 564 1.1.1.6 christos * Buffer --> Integer or String (Named) 565 1.1.1.6 christos */ 566 1.1.1.6 christos switch (TargetType) 567 1.1.1.6 christos { 568 1.1.1.6 christos case ACPI_TYPE_PACKAGE: 569 1.1.1.6 christos /* 570 1.1.1.6 christos * Here, can only store a package to an existing package. 571 1.1.1.6 christos * Storing a package to a Local/Arg is OK, and handled 572 1.1.1.6 christos * elsewhere. 573 1.1.1.6 christos */ 574 1.1.1.6 christos if (WalkState->Opcode == AML_STORE_OP) 575 1.1.1.6 christos { 576 1.1.1.6 christos if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) 577 1.1.1.6 christos { 578 1.1.1.6 christos ACPI_ERROR ((AE_INFO, 579 1.1.1.6 christos "Cannot assign type [%s] to [Package] " 580 1.1.1.6 christos "(source must be type Pkg)", 581 1.1.1.6 christos AcpiUtGetObjectTypeName (SourceDesc))); 582 1.1.1.6 christos 583 1.1.1.6 christos return_ACPI_STATUS (AE_AML_TARGET_TYPE); 584 1.1.1.6 christos } 585 1.1.1.6 christos break; 586 1.1.1.6 christos } 587 1.1.1.6 christos 588 1.1.1.12 christos ACPI_FALLTHROUGH; 589 1.1.1.6 christos 590 1.1.1.6 christos case ACPI_TYPE_DEVICE: 591 1.1.1.6 christos case ACPI_TYPE_EVENT: 592 1.1.1.6 christos case ACPI_TYPE_MUTEX: 593 1.1.1.6 christos case ACPI_TYPE_REGION: 594 1.1.1.6 christos case ACPI_TYPE_POWER: 595 1.1.1.6 christos case ACPI_TYPE_PROCESSOR: 596 1.1.1.6 christos case ACPI_TYPE_THERMAL: 597 1.1.1.6 christos 598 1.1.1.6 christos ACPI_ERROR ((AE_INFO, 599 1.1.1.6 christos "Target must be [Buffer/Integer/String/Reference]" 600 1.1.1.6 christos ", found [%s] (%4.4s)", 601 1.1.1.6 christos AcpiUtGetTypeName (Node->Type), Node->Name.Ascii)); 602 1.1.1.6 christos 603 1.1.1.6 christos return_ACPI_STATUS (AE_AML_TARGET_TYPE); 604 1.1.1.6 christos 605 1.1.1.6 christos default: 606 1.1.1.6 christos break; 607 1.1.1.6 christos } 608 1.1.1.6 christos } 609 1.1 jruoho 610 1.1 jruoho /* 611 1.1 jruoho * Resolve the source object to an actual value 612 1.1 jruoho * (If it is a reference object) 613 1.1 jruoho */ 614 1.1 jruoho Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); 615 1.1 jruoho if (ACPI_FAILURE (Status)) 616 1.1 jruoho { 617 1.1 jruoho return_ACPI_STATUS (Status); 618 1.1 jruoho } 619 1.1 jruoho 620 1.1 jruoho /* Do the actual store operation */ 621 1.1 jruoho 622 1.1 jruoho switch (TargetType) 623 1.1 jruoho { 624 1.1 jruoho /* 625 1.1.1.3 christos * The simple data types all support implicit source operand 626 1.1.1.3 christos * conversion before the store. 627 1.1 jruoho */ 628 1.1.1.6 christos case ACPI_TYPE_INTEGER: 629 1.1.1.6 christos case ACPI_TYPE_STRING: 630 1.1.1.6 christos case ACPI_TYPE_BUFFER: 631 1.1.1.3 christos 632 1.1.1.8 christos if ((WalkState->Opcode == AML_COPY_OBJECT_OP) || 633 1.1.1.3 christos !ImplicitConversion) 634 1.1.1.3 christos { 635 1.1.1.3 christos /* 636 1.1.1.3 christos * However, CopyObject and Stores to ArgX do not perform 637 1.1.1.3 christos * an implicit conversion, as per the ACPI specification. 638 1.1.1.3 christos * A direct store is performed instead. 639 1.1.1.3 christos */ 640 1.1.1.6 christos Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); 641 1.1.1.3 christos break; 642 1.1.1.3 christos } 643 1.1.1.3 christos 644 1.1.1.3 christos /* Store with implicit source operand conversion support */ 645 1.1.1.3 christos 646 1.1 jruoho Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, 647 1.1.1.3 christos &NewDesc, WalkState); 648 1.1 jruoho if (ACPI_FAILURE (Status)) 649 1.1 jruoho { 650 1.1 jruoho return_ACPI_STATUS (Status); 651 1.1 jruoho } 652 1.1 jruoho 653 1.1 jruoho if (NewDesc != TargetDesc) 654 1.1 jruoho { 655 1.1 jruoho /* 656 1.1 jruoho * Store the new NewDesc as the new value of the Name, and set 657 1.1 jruoho * the Name's type to that of the value being stored in it. 658 1.1 jruoho * SourceDesc reference count is incremented by AttachObject. 659 1.1 jruoho * 660 1.1.1.3 christos * Note: This may change the type of the node if an explicit 661 1.1.1.3 christos * store has been performed such that the node/object type 662 1.1.1.3 christos * has been changed. 663 1.1 jruoho */ 664 1.1.1.6 christos Status = AcpiNsAttachObject ( 665 1.1.1.6 christos Node, NewDesc, NewDesc->Common.Type); 666 1.1 jruoho 667 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 668 1.1.1.6 christos "Store type [%s] into [%s] via Convert/Attach\n", 669 1.1 jruoho AcpiUtGetObjectTypeName (SourceDesc), 670 1.1 jruoho AcpiUtGetObjectTypeName (NewDesc))); 671 1.1 jruoho } 672 1.1 jruoho break; 673 1.1 jruoho 674 1.1.1.3 christos case ACPI_TYPE_BUFFER_FIELD: 675 1.1.1.3 christos case ACPI_TYPE_LOCAL_REGION_FIELD: 676 1.1.1.3 christos case ACPI_TYPE_LOCAL_BANK_FIELD: 677 1.1.1.3 christos case ACPI_TYPE_LOCAL_INDEX_FIELD: 678 1.1.1.3 christos /* 679 1.1.1.3 christos * For all fields, always write the source data to the target 680 1.1.1.3 christos * field. Any required implicit source operand conversion is 681 1.1.1.3 christos * performed in the function below as necessary. Note, field 682 1.1.1.3 christos * objects must retain their original type permanently. 683 1.1.1.3 christos */ 684 1.1.1.3 christos Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, 685 1.1.1.3 christos &WalkState->ResultObj); 686 1.1.1.3 christos break; 687 1.1 jruoho 688 1.1 jruoho default: 689 1.1.1.3 christos /* 690 1.1.1.6 christos * CopyObject operator: No conversions for all other types. 691 1.1.1.6 christos * Instead, directly store a copy of the source object. 692 1.1.1.3 christos * 693 1.1.1.6 christos * This is the ACPI spec-defined behavior for the CopyObject 694 1.1.1.6 christos * operator. (Note, for this default case, all normal 695 1.1.1.6 christos * Store/Target operations exited above with an error). 696 1.1.1.3 christos */ 697 1.1.1.6 christos Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); 698 1.1 jruoho break; 699 1.1 jruoho } 700 1.1 jruoho 701 1.1 jruoho return_ACPI_STATUS (Status); 702 1.1 jruoho } 703 1.1 jruoho 704 1.1 jruoho 705 1.1.1.3 christos /******************************************************************************* 706 1.1.1.3 christos * 707 1.1.1.3 christos * FUNCTION: AcpiExStoreDirectToNode 708 1.1.1.3 christos * 709 1.1.1.3 christos * PARAMETERS: SourceDesc - Value to be stored 710 1.1.1.3 christos * Node - Named object to receive the value 711 1.1.1.3 christos * WalkState - Current walk state 712 1.1.1.3 christos * 713 1.1.1.3 christos * RETURN: Status 714 1.1.1.3 christos * 715 1.1.1.3 christos * DESCRIPTION: "Store" an object directly to a node. This involves a copy 716 1.1.1.3 christos * and an attach. 717 1.1.1.3 christos * 718 1.1.1.3 christos ******************************************************************************/ 719 1.1.1.3 christos 720 1.1.1.3 christos static ACPI_STATUS 721 1.1.1.3 christos AcpiExStoreDirectToNode ( 722 1.1.1.3 christos ACPI_OPERAND_OBJECT *SourceDesc, 723 1.1.1.3 christos ACPI_NAMESPACE_NODE *Node, 724 1.1.1.3 christos ACPI_WALK_STATE *WalkState) 725 1.1.1.3 christos { 726 1.1.1.3 christos ACPI_STATUS Status; 727 1.1.1.3 christos ACPI_OPERAND_OBJECT *NewDesc; 728 1.1.1.3 christos 729 1.1.1.3 christos 730 1.1.1.3 christos ACPI_FUNCTION_TRACE (ExStoreDirectToNode); 731 1.1.1.3 christos 732 1.1.1.3 christos 733 1.1.1.3 christos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 734 1.1.1.3 christos "Storing [%s] (%p) directly into node [%s] (%p)" 735 1.1.1.3 christos " with no implicit conversion\n", 736 1.1.1.3 christos AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, 737 1.1.1.3 christos AcpiUtGetTypeName (Node->Type), Node)); 738 1.1.1.3 christos 739 1.1.1.3 christos /* Copy the source object to a new object */ 740 1.1.1.3 christos 741 1.1.1.3 christos Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); 742 1.1.1.3 christos if (ACPI_FAILURE (Status)) 743 1.1.1.3 christos { 744 1.1.1.3 christos return_ACPI_STATUS (Status); 745 1.1.1.3 christos } 746 1.1.1.3 christos 747 1.1.1.3 christos /* Attach the new object to the node */ 748 1.1.1.3 christos 749 1.1.1.3 christos Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); 750 1.1.1.3 christos AcpiUtRemoveReference (NewDesc); 751 1.1.1.3 christos return_ACPI_STATUS (Status); 752 1.1.1.3 christos } 753