Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:02

0001 /******************************************************************************
0002  *
0003  * Module Name: exstore - AML Interpreter object store support
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "acdispat.h"
0155 #include "acinterp.h"
0156 #include "amlcode.h"
0157 #include "acnamesp.h"
0158 
0159 
0160 #define _COMPONENT          ACPI_EXECUTER
0161         ACPI_MODULE_NAME    ("exstore")
0162 
0163 /* Local prototypes */
0164 
0165 static ACPI_STATUS
0166 AcpiExStoreObjectToIndex (
0167     ACPI_OPERAND_OBJECT     *ValDesc,
0168     ACPI_OPERAND_OBJECT     *DestDesc,
0169     ACPI_WALK_STATE         *WalkState);
0170 
0171 static ACPI_STATUS
0172 AcpiExStoreDirectToNode (
0173     ACPI_OPERAND_OBJECT     *SourceDesc,
0174     ACPI_NAMESPACE_NODE     *Node,
0175     ACPI_WALK_STATE         *WalkState);
0176 
0177 
0178 /*******************************************************************************
0179  *
0180  * FUNCTION:    AcpiExStore
0181  *
0182  * PARAMETERS:  *SourceDesc         - Value to be stored
0183  *              *DestDesc           - Where to store it. Must be an NS node
0184  *                                    or ACPI_OPERAND_OBJECT of type
0185  *                                    Reference;
0186  *              WalkState           - Current walk state
0187  *
0188  * RETURN:      Status
0189  *
0190  * DESCRIPTION: Store the value described by SourceDesc into the location
0191  *              described by DestDesc. Called by various interpreter
0192  *              functions to store the result of an operation into
0193  *              the destination operand -- not just simply the actual "Store"
0194  *              ASL operator.
0195  *
0196  ******************************************************************************/
0197 
0198 ACPI_STATUS
0199 AcpiExStore (
0200     ACPI_OPERAND_OBJECT     *SourceDesc,
0201     ACPI_OPERAND_OBJECT     *DestDesc,
0202     ACPI_WALK_STATE         *WalkState)
0203 {
0204     ACPI_STATUS             Status = AE_OK;
0205     ACPI_OPERAND_OBJECT     *RefDesc = DestDesc;
0206 
0207 
0208     ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
0209 
0210 
0211     /* Validate parameters */
0212 
0213     if (!SourceDesc || !DestDesc)
0214     {
0215         ACPI_ERROR ((AE_INFO, "Null parameter"));
0216         return_ACPI_STATUS (AE_AML_NO_OPERAND);
0217     }
0218 
0219     /* DestDesc can be either a namespace node or an ACPI object */
0220 
0221     if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
0222     {
0223         /*
0224          * Dest is a namespace node,
0225          * Storing an object into a Named node.
0226          */
0227         Status = AcpiExStoreObjectToNode (SourceDesc,
0228             (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
0229             ACPI_IMPLICIT_CONVERSION);
0230 
0231         return_ACPI_STATUS (Status);
0232     }
0233 
0234     /* Destination object must be a Reference or a Constant object */
0235 
0236     switch (DestDesc->Common.Type)
0237     {
0238     case ACPI_TYPE_LOCAL_REFERENCE:
0239 
0240         break;
0241 
0242     case ACPI_TYPE_INTEGER:
0243 
0244         /* Allow stores to Constants -- a Noop as per ACPI spec */
0245 
0246         if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
0247         {
0248             return_ACPI_STATUS (AE_OK);
0249         }
0250 
0251         ACPI_FALLTHROUGH;
0252 
0253     default:
0254 
0255         /* Destination is not a Reference object */
0256 
0257         ACPI_ERROR ((AE_INFO,
0258             "Target is not a Reference or Constant object - [%s] %p",
0259             AcpiUtGetObjectTypeName (DestDesc), DestDesc));
0260 
0261         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0262     }
0263 
0264     /*
0265      * Examine the Reference class. These cases are handled:
0266      *
0267      * 1) Store to Name (Change the object associated with a name)
0268      * 2) Store to an indexed area of a Buffer or Package
0269      * 3) Store to a Method Local or Arg
0270      * 4) Store to the debug object
0271      */
0272     switch (RefDesc->Reference.Class)
0273     {
0274     case ACPI_REFCLASS_REFOF:
0275 
0276         /* Storing an object into a Name "container" */
0277 
0278         Status = AcpiExStoreObjectToNode (SourceDesc,
0279             RefDesc->Reference.Object,
0280             WalkState, ACPI_IMPLICIT_CONVERSION);
0281         break;
0282 
0283     case ACPI_REFCLASS_INDEX:
0284 
0285         /* Storing to an Index (pointer into a packager or buffer) */
0286 
0287         Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
0288         break;
0289 
0290     case ACPI_REFCLASS_LOCAL:
0291     case ACPI_REFCLASS_ARG:
0292 
0293         /* Store to a method local/arg  */
0294 
0295         Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
0296             RefDesc->Reference.Value, SourceDesc, WalkState);
0297         break;
0298 
0299     case ACPI_REFCLASS_DEBUG:
0300         /*
0301          * Storing to the Debug object causes the value stored to be
0302          * displayed and otherwise has no effect -- see ACPI Specification
0303          */
0304         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0305             "**** Write to Debug Object: Object %p [%s] ****:\n\n",
0306             SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
0307 
0308         ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
0309         break;
0310 
0311     default:
0312 
0313         ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
0314             RefDesc->Reference.Class));
0315         ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
0316 
0317         Status = AE_AML_INTERNAL;
0318         break;
0319     }
0320 
0321     return_ACPI_STATUS (Status);
0322 }
0323 
0324 
0325 /*******************************************************************************
0326  *
0327  * FUNCTION:    AcpiExStoreObjectToIndex
0328  *
0329  * PARAMETERS:  *SourceDesc             - Value to be stored
0330  *              *DestDesc               - Named object to receive the value
0331  *              WalkState               - Current walk state
0332  *
0333  * RETURN:      Status
0334  *
0335  * DESCRIPTION: Store the object to indexed Buffer or Package element
0336  *
0337  ******************************************************************************/
0338 
0339 static ACPI_STATUS
0340 AcpiExStoreObjectToIndex (
0341     ACPI_OPERAND_OBJECT     *SourceDesc,
0342     ACPI_OPERAND_OBJECT     *IndexDesc,
0343     ACPI_WALK_STATE         *WalkState)
0344 {
0345     ACPI_STATUS             Status = AE_OK;
0346     ACPI_OPERAND_OBJECT     *ObjDesc;
0347     ACPI_OPERAND_OBJECT     *NewDesc;
0348     UINT8                   Value = 0;
0349     UINT32                  i;
0350 
0351 
0352     ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
0353 
0354 
0355     /*
0356      * Destination must be a reference pointer, and
0357      * must point to either a buffer or a package
0358      */
0359     switch (IndexDesc->Reference.TargetType)
0360     {
0361     case ACPI_TYPE_PACKAGE:
0362         /*
0363          * Storing to a package element. Copy the object and replace
0364          * any existing object with the new object. No implicit
0365          * conversion is performed.
0366          *
0367          * The object at *(IndexDesc->Reference.Where) is the
0368          * element within the package that is to be modified.
0369          * The parent package object is at IndexDesc->Reference.Object
0370          */
0371         ObjDesc = *(IndexDesc->Reference.Where);
0372 
0373         if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
0374             SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
0375         {
0376             /* This is a DDBHandle, just add a reference to it */
0377 
0378             AcpiUtAddReference (SourceDesc);
0379             NewDesc = SourceDesc;
0380         }
0381         else
0382         {
0383             /* Normal object, copy it */
0384 
0385             Status = AcpiUtCopyIobjectToIobject (
0386                 SourceDesc, &NewDesc, WalkState);
0387             if (ACPI_FAILURE (Status))
0388             {
0389                 return_ACPI_STATUS (Status);
0390             }
0391         }
0392 
0393         if (ObjDesc)
0394         {
0395             /* Decrement reference count by the ref count of the parent package */
0396 
0397             for (i = 0;
0398                  i < ((ACPI_OPERAND_OBJECT *)
0399                         IndexDesc->Reference.Object)->Common.ReferenceCount;
0400                  i++)
0401             {
0402                 AcpiUtRemoveReference (ObjDesc);
0403             }
0404         }
0405 
0406         *(IndexDesc->Reference.Where) = NewDesc;
0407 
0408         /* Increment ref count by the ref count of the parent package-1 */
0409 
0410         for (i = 1;
0411              i < ((ACPI_OPERAND_OBJECT *)
0412                     IndexDesc->Reference.Object)->Common.ReferenceCount;
0413              i++)
0414         {
0415             AcpiUtAddReference (NewDesc);
0416         }
0417 
0418         break;
0419 
0420     case ACPI_TYPE_BUFFER_FIELD:
0421         /*
0422          * Store into a Buffer or String (not actually a real BufferField)
0423          * at a location defined by an Index.
0424          *
0425          * The first 8-bit element of the source object is written to the
0426          * 8-bit Buffer location defined by the Index destination object,
0427          * according to the ACPI 2.0 specification.
0428          */
0429 
0430         /*
0431          * Make sure the target is a Buffer or String. An error should
0432          * not happen here, since the ReferenceObject was constructed
0433          * by the INDEX_OP code.
0434          */
0435         ObjDesc = IndexDesc->Reference.Object;
0436         if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
0437             (ObjDesc->Common.Type != ACPI_TYPE_STRING))
0438         {
0439             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0440         }
0441 
0442         /*
0443          * The assignment of the individual elements will be slightly
0444          * different for each source type.
0445          */
0446         switch (SourceDesc->Common.Type)
0447         {
0448         case ACPI_TYPE_INTEGER:
0449 
0450             /* Use the least-significant byte of the integer */
0451 
0452             Value = (UINT8) (SourceDesc->Integer.Value);
0453             break;
0454 
0455         case ACPI_TYPE_BUFFER:
0456         case ACPI_TYPE_STRING:
0457 
0458             /* Note: Takes advantage of common string/buffer fields */
0459 
0460             Value = SourceDesc->Buffer.Pointer[0];
0461             break;
0462 
0463         default:
0464 
0465             /* All other types are invalid */
0466 
0467             ACPI_ERROR ((AE_INFO,
0468                 "Source must be type [Integer/Buffer/String], found [%s]",
0469                 AcpiUtGetObjectTypeName (SourceDesc)));
0470             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0471         }
0472 
0473         /* Store the source value into the target buffer byte */
0474 
0475         ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
0476         break;
0477 
0478     default:
0479         ACPI_ERROR ((AE_INFO,
0480             "Target is not of type [Package/BufferField]"));
0481         Status = AE_AML_TARGET_TYPE;
0482         break;
0483     }
0484 
0485     return_ACPI_STATUS (Status);
0486 }
0487 
0488 
0489 /*******************************************************************************
0490  *
0491  * FUNCTION:    AcpiExStoreObjectToNode
0492  *
0493  * PARAMETERS:  SourceDesc              - Value to be stored
0494  *              Node                    - Named object to receive the value
0495  *              WalkState               - Current walk state
0496  *              ImplicitConversion      - Perform implicit conversion (yes/no)
0497  *
0498  * RETURN:      Status
0499  *
0500  * DESCRIPTION: Store the object to the named object.
0501  *
0502  * The assignment of an object to a named object is handled here.
0503  * The value passed in will replace the current value (if any)
0504  * with the input value.
0505  *
0506  * When storing into an object the data is converted to the
0507  * target object type then stored in the object. This means
0508  * that the target object type (for an initialized target) will
0509  * not be changed by a store operation. A CopyObject can change
0510  * the target type, however.
0511  *
0512  * The ImplicitConversion flag is set to NO/FALSE only when
0513  * storing to an ArgX -- as per the rules of the ACPI spec.
0514  *
0515  * Assumes parameters are already validated.
0516  *
0517  ******************************************************************************/
0518 
0519 ACPI_STATUS
0520 AcpiExStoreObjectToNode (
0521     ACPI_OPERAND_OBJECT     *SourceDesc,
0522     ACPI_NAMESPACE_NODE     *Node,
0523     ACPI_WALK_STATE         *WalkState,
0524     UINT8                   ImplicitConversion)
0525 {
0526     ACPI_STATUS             Status = AE_OK;
0527     ACPI_OPERAND_OBJECT     *TargetDesc;
0528     ACPI_OPERAND_OBJECT     *NewDesc;
0529     ACPI_OBJECT_TYPE        TargetType;
0530 
0531 
0532     ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
0533 
0534 
0535     /* Get current type of the node, and object attached to Node */
0536 
0537     TargetType = AcpiNsGetType (Node);
0538     TargetDesc = AcpiNsGetAttachedObject (Node);
0539 
0540     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n",
0541         SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
0542         Node, AcpiUtGetTypeName (TargetType)));
0543 
0544     /* Only limited target types possible for everything except CopyObject */
0545 
0546     if (WalkState->Opcode != AML_COPY_OBJECT_OP)
0547     {
0548         /*
0549          * Only CopyObject allows all object types to be overwritten. For
0550          * TargetRef(s), there are restrictions on the object types that
0551          * are allowed.
0552          *
0553          * Allowable operations/typing for Store:
0554          *
0555          * 1) Simple Store
0556          *      Integer     --> Integer (Named/Local/Arg)
0557          *      String      --> String  (Named/Local/Arg)
0558          *      Buffer      --> Buffer  (Named/Local/Arg)
0559          *      Package     --> Package (Named/Local/Arg)
0560          *
0561          * 2) Store with implicit conversion
0562          *      Integer     --> String or Buffer  (Named)
0563          *      String      --> Integer or Buffer (Named)
0564          *      Buffer      --> Integer or String (Named)
0565          */
0566         switch (TargetType)
0567         {
0568         case ACPI_TYPE_PACKAGE:
0569             /*
0570              * Here, can only store a package to an existing package.
0571              * Storing a package to a Local/Arg is OK, and handled
0572              * elsewhere.
0573              */
0574             if (WalkState->Opcode == AML_STORE_OP)
0575             {
0576                 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
0577                 {
0578                     ACPI_ERROR ((AE_INFO,
0579                         "Cannot assign type [%s] to [Package] "
0580                         "(source must be type Pkg)",
0581                         AcpiUtGetObjectTypeName (SourceDesc)));
0582 
0583                     return_ACPI_STATUS (AE_AML_TARGET_TYPE);
0584                 }
0585                 break;
0586             }
0587 
0588             ACPI_FALLTHROUGH;
0589 
0590         case ACPI_TYPE_DEVICE:
0591         case ACPI_TYPE_EVENT:
0592         case ACPI_TYPE_MUTEX:
0593         case ACPI_TYPE_REGION:
0594         case ACPI_TYPE_POWER:
0595         case ACPI_TYPE_PROCESSOR:
0596         case ACPI_TYPE_THERMAL:
0597 
0598             ACPI_ERROR ((AE_INFO,
0599                 "Target must be [Buffer/Integer/String/Reference]"
0600                 ", found [%s] (%4.4s)",
0601                 AcpiUtGetTypeName (Node->Type), Node->Name.Ascii));
0602 
0603             return_ACPI_STATUS (AE_AML_TARGET_TYPE);
0604 
0605         default:
0606             break;
0607         }
0608     }
0609 
0610     /*
0611      * Resolve the source object to an actual value
0612      * (If it is a reference object)
0613      */
0614     Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
0615     if (ACPI_FAILURE (Status))
0616     {
0617         return_ACPI_STATUS (Status);
0618     }
0619 
0620     /* Do the actual store operation */
0621 
0622     switch (TargetType)
0623     {
0624         /*
0625          * The simple data types all support implicit source operand
0626          * conversion before the store.
0627          */
0628     case ACPI_TYPE_INTEGER:
0629     case ACPI_TYPE_STRING:
0630     case ACPI_TYPE_BUFFER:
0631 
0632         if ((WalkState->Opcode == AML_COPY_OBJECT_OP) ||
0633             !ImplicitConversion)
0634         {
0635             /*
0636              * However, CopyObject and Stores to ArgX do not perform
0637              * an implicit conversion, as per the ACPI specification.
0638              * A direct store is performed instead.
0639              */
0640             Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState);
0641             break;
0642         }
0643 
0644         /* Store with implicit source operand conversion support */
0645 
0646         Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
0647             &NewDesc, WalkState);
0648         if (ACPI_FAILURE (Status))
0649         {
0650             return_ACPI_STATUS (Status);
0651         }
0652 
0653         if (NewDesc != TargetDesc)
0654         {
0655             /*
0656              * Store the new NewDesc as the new value of the Name, and set
0657              * the Name's type to that of the value being stored in it.
0658              * SourceDesc reference count is incremented by AttachObject.
0659              *
0660              * Note: This may change the type of the node if an explicit
0661              * store has been performed such that the node/object type
0662              * has been changed.
0663              */
0664             Status = AcpiNsAttachObject (
0665                 Node, NewDesc, NewDesc->Common.Type);
0666 
0667             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0668                 "Store type [%s] into [%s] via Convert/Attach\n",
0669                 AcpiUtGetObjectTypeName (SourceDesc),
0670                 AcpiUtGetObjectTypeName (NewDesc)));
0671         }
0672         break;
0673 
0674     case ACPI_TYPE_BUFFER_FIELD:
0675     case ACPI_TYPE_LOCAL_REGION_FIELD:
0676     case ACPI_TYPE_LOCAL_BANK_FIELD:
0677     case ACPI_TYPE_LOCAL_INDEX_FIELD:
0678         /*
0679          * For all fields, always write the source data to the target
0680          * field. Any required implicit source operand conversion is
0681          * performed in the function below as necessary. Note, field
0682          * objects must retain their original type permanently.
0683          */
0684         Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
0685             &WalkState->ResultObj);
0686         break;
0687 
0688     default:
0689         /*
0690          * CopyObject operator: No conversions for all other types.
0691          * Instead, directly store a copy of the source object.
0692          *
0693          * This is the ACPI spec-defined behavior for the CopyObject
0694          * operator. (Note, for this default case, all normal
0695          * Store/Target operations exited above with an error).
0696          */
0697         Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState);
0698         break;
0699     }
0700 
0701     return_ACPI_STATUS (Status);
0702 }
0703 
0704 
0705 /*******************************************************************************
0706  *
0707  * FUNCTION:    AcpiExStoreDirectToNode
0708  *
0709  * PARAMETERS:  SourceDesc              - Value to be stored
0710  *              Node                    - Named object to receive the value
0711  *              WalkState               - Current walk state
0712  *
0713  * RETURN:      Status
0714  *
0715  * DESCRIPTION: "Store" an object directly to a node. This involves a copy
0716  *              and an attach.
0717  *
0718  ******************************************************************************/
0719 
0720 static ACPI_STATUS
0721 AcpiExStoreDirectToNode (
0722     ACPI_OPERAND_OBJECT     *SourceDesc,
0723     ACPI_NAMESPACE_NODE     *Node,
0724     ACPI_WALK_STATE         *WalkState)
0725 {
0726     ACPI_STATUS             Status;
0727     ACPI_OPERAND_OBJECT     *NewDesc;
0728 
0729 
0730     ACPI_FUNCTION_TRACE (ExStoreDirectToNode);
0731 
0732 
0733     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0734         "Storing [%s] (%p) directly into node [%s] (%p)"
0735         " with no implicit conversion\n",
0736         AcpiUtGetObjectTypeName (SourceDesc), SourceDesc,
0737         AcpiUtGetTypeName (Node->Type), Node));
0738 
0739     /* Copy the source object to a new object */
0740 
0741     Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
0742     if (ACPI_FAILURE (Status))
0743     {
0744         return_ACPI_STATUS (Status);
0745     }
0746 
0747     /* Attach the new object to the node */
0748 
0749     Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
0750     AcpiUtRemoveReference (NewDesc);
0751     return_ACPI_STATUS (Status);
0752 }