Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/exstore.c need to be fixed.

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