No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / intel-public / acpica / dist / executer / exstore.c
blob8ec8a23cffd7f4e08ae66f440e86623d589694e1
2 /******************************************************************************
4 * Module Name: exstore - AML Interpreter object store support
6 *****************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13 * All rights reserved.
15 * 2. License
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
117 #define __EXSTORE_C__
119 #include "acpi.h"
120 #include "accommon.h"
121 #include "acdispat.h"
122 #include "acinterp.h"
123 #include "amlcode.h"
124 #include "acnamesp.h"
127 #define _COMPONENT ACPI_EXECUTER
128 ACPI_MODULE_NAME ("exstore")
130 /* Local prototypes */
132 static void
133 AcpiExDoDebugObject (
134 ACPI_OPERAND_OBJECT *SourceDesc,
135 UINT32 Level,
136 UINT32 Index);
138 static ACPI_STATUS
139 AcpiExStoreObjectToIndex (
140 ACPI_OPERAND_OBJECT *ValDesc,
141 ACPI_OPERAND_OBJECT *DestDesc,
142 ACPI_WALK_STATE *WalkState);
145 /*******************************************************************************
147 * FUNCTION: AcpiExDoDebugObject
149 * PARAMETERS: SourceDesc - Value to be stored
150 * Level - Indentation level (used for packages)
151 * Index - Current package element, zero if not pkg
153 * RETURN: None
155 * DESCRIPTION: Handles stores to the Debug Object.
157 ******************************************************************************/
159 static void
160 AcpiExDoDebugObject (
161 ACPI_OPERAND_OBJECT *SourceDesc,
162 UINT32 Level,
163 UINT32 Index)
165 UINT32 i;
168 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
171 /* Print line header as long as we are not in the middle of an object display */
173 if (!((Level > 0) && Index == 0))
175 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
176 Level, " "));
179 /* Display index for package output only */
181 if (Index > 0)
183 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
184 "(%.2u) ", Index -1));
187 if (!SourceDesc)
189 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n"));
190 return_VOID;
193 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
195 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s ",
196 AcpiUtGetObjectTypeName (SourceDesc)));
198 if (!AcpiUtValidInternalObject (SourceDesc))
200 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
201 "%p, Invalid Internal Object!\n", SourceDesc));
202 return_VOID;
205 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
207 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
208 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
209 SourceDesc));
210 return_VOID;
212 else
214 return_VOID;
217 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
219 switch (SourceDesc->Common.Type)
221 case ACPI_TYPE_INTEGER:
223 /* Output correct integer width */
225 if (AcpiGbl_IntegerByteWidth == 4)
227 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
228 (UINT32) SourceDesc->Integer.Value));
230 else
232 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
233 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value)));
235 break;
237 case ACPI_TYPE_BUFFER:
239 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
240 (UINT32) SourceDesc->Buffer.Length));
241 ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer,
242 (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256);
243 break;
245 case ACPI_TYPE_STRING:
247 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
248 SourceDesc->String.Length, SourceDesc->String.Pointer));
249 break;
251 case ACPI_TYPE_PACKAGE:
253 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Contains 0x%.2X Elements]\n",
254 SourceDesc->Package.Count));
256 /* Output the entire contents of the package */
258 for (i = 0; i < SourceDesc->Package.Count; i++)
260 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
261 Level+4, i+1);
263 break;
265 case ACPI_TYPE_LOCAL_REFERENCE:
267 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ",
268 AcpiUtGetReferenceName (SourceDesc)));
270 /* Decode the reference */
272 switch (SourceDesc->Reference.Class)
274 case ACPI_REFCLASS_INDEX:
276 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n",
277 SourceDesc->Reference.Value));
278 break;
280 case ACPI_REFCLASS_TABLE:
282 /* Case for DdbHandle */
284 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n",
285 SourceDesc->Reference.Value));
286 return;
288 default:
289 break;
292 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, " "));
294 /* Check for valid node first, then valid object */
296 if (SourceDesc->Reference.Node)
298 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
299 ACPI_DESC_TYPE_NAMED)
301 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
302 " %p - Not a valid namespace node\n",
303 SourceDesc->Reference.Node));
305 else
307 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Node %p [%4.4s] ",
308 SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii));
310 switch ((SourceDesc->Reference.Node)->Type)
312 /* These types have no attached object */
314 case ACPI_TYPE_DEVICE:
315 AcpiOsPrintf ("Device\n");
316 break;
318 case ACPI_TYPE_THERMAL:
319 AcpiOsPrintf ("Thermal Zone\n");
320 break;
322 default:
323 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
324 Level+4, 0);
325 break;
329 else if (SourceDesc->Reference.Object)
331 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
332 ACPI_DESC_TYPE_NAMED)
334 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
335 SourceDesc->Reference.Object)->Object,
336 Level+4, 0);
338 else
340 AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0);
343 break;
345 default:
347 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n",
348 SourceDesc));
349 break;
352 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
353 return_VOID;
357 /*******************************************************************************
359 * FUNCTION: AcpiExStore
361 * PARAMETERS: *SourceDesc - Value to be stored
362 * *DestDesc - Where to store it. Must be an NS node
363 * or an ACPI_OPERAND_OBJECT of type
364 * Reference;
365 * WalkState - Current walk state
367 * RETURN: Status
369 * DESCRIPTION: Store the value described by SourceDesc into the location
370 * described by DestDesc. Called by various interpreter
371 * functions to store the result of an operation into
372 * the destination operand -- not just simply the actual "Store"
373 * ASL operator.
375 ******************************************************************************/
377 ACPI_STATUS
378 AcpiExStore (
379 ACPI_OPERAND_OBJECT *SourceDesc,
380 ACPI_OPERAND_OBJECT *DestDesc,
381 ACPI_WALK_STATE *WalkState)
383 ACPI_STATUS Status = AE_OK;
384 ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
387 ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
390 /* Validate parameters */
392 if (!SourceDesc || !DestDesc)
394 ACPI_ERROR ((AE_INFO, "Null parameter"));
395 return_ACPI_STATUS (AE_AML_NO_OPERAND);
398 /* DestDesc can be either a namespace node or an ACPI object */
400 if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
403 * Dest is a namespace node,
404 * Storing an object into a Named node.
406 Status = AcpiExStoreObjectToNode (SourceDesc,
407 (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
408 ACPI_IMPLICIT_CONVERSION);
410 return_ACPI_STATUS (Status);
413 /* Destination object must be a Reference or a Constant object */
415 switch (DestDesc->Common.Type)
417 case ACPI_TYPE_LOCAL_REFERENCE:
418 break;
420 case ACPI_TYPE_INTEGER:
422 /* Allow stores to Constants -- a Noop as per ACPI spec */
424 if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
426 return_ACPI_STATUS (AE_OK);
429 /*lint -fallthrough */
431 default:
433 /* Destination is not a Reference object */
435 ACPI_ERROR ((AE_INFO,
436 "Target is not a Reference or Constant object - %s [%p]",
437 AcpiUtGetObjectTypeName (DestDesc), DestDesc));
439 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
443 * Examine the Reference class. These cases are handled:
445 * 1) Store to Name (Change the object associated with a name)
446 * 2) Store to an indexed area of a Buffer or Package
447 * 3) Store to a Method Local or Arg
448 * 4) Store to the debug object
450 switch (RefDesc->Reference.Class)
452 case ACPI_REFCLASS_REFOF:
454 /* Storing an object into a Name "container" */
456 Status = AcpiExStoreObjectToNode (SourceDesc,
457 RefDesc->Reference.Object,
458 WalkState, ACPI_IMPLICIT_CONVERSION);
459 break;
462 case ACPI_REFCLASS_INDEX:
464 /* Storing to an Index (pointer into a packager or buffer) */
466 Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
467 break;
470 case ACPI_REFCLASS_LOCAL:
471 case ACPI_REFCLASS_ARG:
473 /* Store to a method local/arg */
475 Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
476 RefDesc->Reference.Value, SourceDesc, WalkState);
477 break;
480 case ACPI_REFCLASS_DEBUG:
483 * Storing to the Debug object causes the value stored to be
484 * displayed and otherwise has no effect -- see ACPI Specification
486 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
487 "**** Write to Debug Object: Object %p %s ****:\n\n",
488 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
490 AcpiExDoDebugObject (SourceDesc, 0, 0);
491 break;
494 default:
496 ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X",
497 RefDesc->Reference.Class));
498 ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
500 Status = AE_AML_INTERNAL;
501 break;
504 return_ACPI_STATUS (Status);
508 /*******************************************************************************
510 * FUNCTION: AcpiExStoreObjectToIndex
512 * PARAMETERS: *SourceDesc - Value to be stored
513 * *DestDesc - Named object to receive the value
514 * WalkState - Current walk state
516 * RETURN: Status
518 * DESCRIPTION: Store the object to indexed Buffer or Package element
520 ******************************************************************************/
522 static ACPI_STATUS
523 AcpiExStoreObjectToIndex (
524 ACPI_OPERAND_OBJECT *SourceDesc,
525 ACPI_OPERAND_OBJECT *IndexDesc,
526 ACPI_WALK_STATE *WalkState)
528 ACPI_STATUS Status = AE_OK;
529 ACPI_OPERAND_OBJECT *ObjDesc;
530 ACPI_OPERAND_OBJECT *NewDesc;
531 UINT8 Value = 0;
532 UINT32 i;
535 ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
539 * Destination must be a reference pointer, and
540 * must point to either a buffer or a package
542 switch (IndexDesc->Reference.TargetType)
544 case ACPI_TYPE_PACKAGE:
546 * Storing to a package element. Copy the object and replace
547 * any existing object with the new object. No implicit
548 * conversion is performed.
550 * The object at *(IndexDesc->Reference.Where) is the
551 * element within the package that is to be modified.
552 * The parent package object is at IndexDesc->Reference.Object
554 ObjDesc = *(IndexDesc->Reference.Where);
556 if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
557 SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
559 /* This is a DDBHandle, just add a reference to it */
561 AcpiUtAddReference (SourceDesc);
562 NewDesc = SourceDesc;
564 else
566 /* Normal object, copy it */
568 Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
569 if (ACPI_FAILURE (Status))
571 return_ACPI_STATUS (Status);
575 if (ObjDesc)
577 /* Decrement reference count by the ref count of the parent package */
579 for (i = 0;
580 i < ((ACPI_OPERAND_OBJECT *)
581 IndexDesc->Reference.Object)->Common.ReferenceCount;
582 i++)
584 AcpiUtRemoveReference (ObjDesc);
588 *(IndexDesc->Reference.Where) = NewDesc;
590 /* Increment ref count by the ref count of the parent package-1 */
592 for (i = 1;
593 i < ((ACPI_OPERAND_OBJECT *)
594 IndexDesc->Reference.Object)->Common.ReferenceCount;
595 i++)
597 AcpiUtAddReference (NewDesc);
600 break;
603 case ACPI_TYPE_BUFFER_FIELD:
606 * Store into a Buffer or String (not actually a real BufferField)
607 * at a location defined by an Index.
609 * The first 8-bit element of the source object is written to the
610 * 8-bit Buffer location defined by the Index destination object,
611 * according to the ACPI 2.0 specification.
615 * Make sure the target is a Buffer or String. An error should
616 * not happen here, since the ReferenceObject was constructed
617 * by the INDEX_OP code.
619 ObjDesc = IndexDesc->Reference.Object;
620 if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
621 (ObjDesc->Common.Type != ACPI_TYPE_STRING))
623 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
627 * The assignment of the individual elements will be slightly
628 * different for each source type.
630 switch (SourceDesc->Common.Type)
632 case ACPI_TYPE_INTEGER:
634 /* Use the least-significant byte of the integer */
636 Value = (UINT8) (SourceDesc->Integer.Value);
637 break;
639 case ACPI_TYPE_BUFFER:
640 case ACPI_TYPE_STRING:
642 /* Note: Takes advantage of common string/buffer fields */
644 Value = SourceDesc->Buffer.Pointer[0];
645 break;
647 default:
649 /* All other types are invalid */
651 ACPI_ERROR ((AE_INFO,
652 "Source must be Integer/Buffer/String type, not %s",
653 AcpiUtGetObjectTypeName (SourceDesc)));
654 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
657 /* Store the source value into the target buffer byte */
659 ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
660 break;
663 default:
664 ACPI_ERROR ((AE_INFO,
665 "Target is not a Package or BufferField"));
666 Status = AE_AML_OPERAND_TYPE;
667 break;
670 return_ACPI_STATUS (Status);
674 /*******************************************************************************
676 * FUNCTION: AcpiExStoreObjectToNode
678 * PARAMETERS: SourceDesc - Value to be stored
679 * Node - Named object to receive the value
680 * WalkState - Current walk state
681 * ImplicitConversion - Perform implicit conversion (yes/no)
683 * RETURN: Status
685 * DESCRIPTION: Store the object to the named object.
687 * The Assignment of an object to a named object is handled here
688 * The value passed in will replace the current value (if any)
689 * with the input value.
691 * When storing into an object the data is converted to the
692 * target object type then stored in the object. This means
693 * that the target object type (for an initialized target) will
694 * not be changed by a store operation.
696 * Assumes parameters are already validated.
698 ******************************************************************************/
700 ACPI_STATUS
701 AcpiExStoreObjectToNode (
702 ACPI_OPERAND_OBJECT *SourceDesc,
703 ACPI_NAMESPACE_NODE *Node,
704 ACPI_WALK_STATE *WalkState,
705 UINT8 ImplicitConversion)
707 ACPI_STATUS Status = AE_OK;
708 ACPI_OPERAND_OBJECT *TargetDesc;
709 ACPI_OPERAND_OBJECT *NewDesc;
710 ACPI_OBJECT_TYPE TargetType;
713 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
716 /* Get current type of the node, and object attached to Node */
718 TargetType = AcpiNsGetType (Node);
719 TargetDesc = AcpiNsGetAttachedObject (Node);
721 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
722 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
723 Node, AcpiUtGetTypeName (TargetType)));
726 * Resolve the source object to an actual value
727 * (If it is a reference object)
729 Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
730 if (ACPI_FAILURE (Status))
732 return_ACPI_STATUS (Status);
735 /* If no implicit conversion, drop into the default case below */
737 if ((!ImplicitConversion) ||
738 ((WalkState->Opcode == AML_COPY_OP) &&
739 (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&
740 (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&
741 (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))
744 * Force execution of default (no implicit conversion). Note:
745 * CopyObject does not perform an implicit conversion, as per the ACPI
746 * spec -- except in case of region/bank/index fields -- because these
747 * objects must retain their original type permanently.
749 TargetType = ACPI_TYPE_ANY;
752 /* Do the actual store operation */
754 switch (TargetType)
756 case ACPI_TYPE_BUFFER_FIELD:
757 case ACPI_TYPE_LOCAL_REGION_FIELD:
758 case ACPI_TYPE_LOCAL_BANK_FIELD:
759 case ACPI_TYPE_LOCAL_INDEX_FIELD:
761 /* For fields, copy the source data to the target field. */
763 Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
764 &WalkState->ResultObj);
765 break;
768 case ACPI_TYPE_INTEGER:
769 case ACPI_TYPE_STRING:
770 case ACPI_TYPE_BUFFER:
773 * These target types are all of type Integer/String/Buffer, and
774 * therefore support implicit conversion before the store.
776 * Copy and/or convert the source object to a new target object
778 Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
779 &NewDesc, WalkState);
780 if (ACPI_FAILURE (Status))
782 return_ACPI_STATUS (Status);
785 if (NewDesc != TargetDesc)
788 * Store the new NewDesc as the new value of the Name, and set
789 * the Name's type to that of the value being stored in it.
790 * SourceDesc reference count is incremented by AttachObject.
792 * Note: This may change the type of the node if an explicit store
793 * has been performed such that the node/object type has been
794 * changed.
796 Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
798 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
799 "Store %s into %s via Convert/Attach\n",
800 AcpiUtGetObjectTypeName (SourceDesc),
801 AcpiUtGetObjectTypeName (NewDesc)));
803 break;
806 default:
808 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
809 "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
810 AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));
812 /* No conversions for all other types. Just attach the source object */
814 Status = AcpiNsAttachObject (Node, SourceDesc,
815 SourceDesc->Common.Type);
816 break;
819 return_ACPI_STATUS (Status);