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