exstore.c revision 250838
167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: exstore - AML Interpreter object store support
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
767754Smsmith/*
867754Smsmith * Copyright (C) 2000 - 2013, Intel Corp.
967754Smsmith * All rights reserved.
1067754Smsmith *
11202771Sjkim * Redistribution and use in source and binary forms, with or without
1270243Smsmith * modification, are permitted provided that the following conditions
1367754Smsmith * are met:
1467754Smsmith * 1. Redistributions of source code must retain the above copyright
1567754Smsmith *    notice, this list of conditions, and the following disclaimer,
1667754Smsmith *    without modification.
1767754Smsmith * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1867754Smsmith *    substantially similar to the "NO WARRANTY" disclaimer below
1967754Smsmith *    ("Disclaimer") and any redistribution must be conditioned upon
2067754Smsmith *    including a substantially similar Disclaimer requirement for further
2167754Smsmith *    binary redistribution.
2267754Smsmith * 3. Neither the names of the above-listed copyright holders nor the names
2367754Smsmith *    of any contributors may be used to endorse or promote products derived
2467754Smsmith *    from this software without specific prior written permission.
2567754Smsmith *
2667754Smsmith * Alternatively, this software may be distributed under the terms of the
2767754Smsmith * GNU General Public License ("GPL") version 2 as published by the Free
2867754Smsmith * Software Foundation.
2967754Smsmith *
3067754Smsmith * NO WARRANTY
3167754Smsmith * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3267754Smsmith * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3367754Smsmith * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3467754Smsmith * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3567754Smsmith * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3667754Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3767754Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3867754Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3967754Smsmith * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4067754Smsmith * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4167754Smsmith * POSSIBILITY OF SUCH DAMAGES.
4267754Smsmith */
4367754Smsmith
4467754Smsmith#define __EXSTORE_C__
4567754Smsmith
4667754Smsmith#include <contrib/dev/acpica/include/acpi.h>
4767754Smsmith#include <contrib/dev/acpica/include/accommon.h>
4867754Smsmith#include <contrib/dev/acpica/include/acdispat.h>
4967754Smsmith#include <contrib/dev/acpica/include/acinterp.h>
5067754Smsmith#include <contrib/dev/acpica/include/amlcode.h>
5167754Smsmith#include <contrib/dev/acpica/include/acnamesp.h>
5267754Smsmith
5367754Smsmith
5467754Smsmith#define _COMPONENT          ACPI_EXECUTER
5567754Smsmith        ACPI_MODULE_NAME    ("exstore")
5667754Smsmith
5767754Smsmith/* Local prototypes */
5867754Smsmith
5967754Smsmithstatic ACPI_STATUS
6067754SmsmithAcpiExStoreObjectToIndex (
6167754Smsmith    ACPI_OPERAND_OBJECT     *ValDesc,
6267754Smsmith    ACPI_OPERAND_OBJECT     *DestDesc,
6367754Smsmith    ACPI_WALK_STATE         *WalkState);
6467754Smsmith
6567754Smsmith
6667754Smsmith/*******************************************************************************
6767754Smsmith *
6867754Smsmith * FUNCTION:    AcpiExStore
6967754Smsmith *
7067754Smsmith * PARAMETERS:  *SourceDesc         - Value to be stored
7167754Smsmith *              *DestDesc           - Where to store it. Must be an NS node
7267754Smsmith *                                    or ACPI_OPERAND_OBJECT of type
7367754Smsmith *                                    Reference;
7467754Smsmith *              WalkState           - Current walk state
7567754Smsmith *
7667754Smsmith * RETURN:      Status
7767754Smsmith *
7867754Smsmith * DESCRIPTION: Store the value described by SourceDesc into the location
7967754Smsmith *              described by DestDesc. Called by various interpreter
8067754Smsmith *              functions to store the result of an operation into
8167754Smsmith *              the destination operand -- not just simply the actual "Store"
8267754Smsmith *              ASL operator.
8367754Smsmith *
8467754Smsmith ******************************************************************************/
8567754Smsmith
8667754SmsmithACPI_STATUS
8767754SmsmithAcpiExStore (
8867754Smsmith    ACPI_OPERAND_OBJECT     *SourceDesc,
8967754Smsmith    ACPI_OPERAND_OBJECT     *DestDesc,
9067754Smsmith    ACPI_WALK_STATE         *WalkState)
9167754Smsmith{
9267754Smsmith    ACPI_STATUS             Status = AE_OK;
9367754Smsmith    ACPI_OPERAND_OBJECT     *RefDesc = DestDesc;
9467754Smsmith
9567754Smsmith
9667754Smsmith    ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
9767754Smsmith
9867754Smsmith
9967754Smsmith    /* Validate parameters */
10067754Smsmith
10167754Smsmith    if (!SourceDesc || !DestDesc)
10267754Smsmith    {
10367754Smsmith        ACPI_ERROR ((AE_INFO, "Null parameter"));
10467754Smsmith        return_ACPI_STATUS (AE_AML_NO_OPERAND);
10567754Smsmith    }
10667754Smsmith
10767754Smsmith    /* DestDesc can be either a namespace node or an ACPI object */
10867754Smsmith
10967754Smsmith    if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
11067754Smsmith    {
11167754Smsmith        /*
11267754Smsmith         * Dest is a namespace node,
11367754Smsmith         * Storing an object into a Named node.
11467754Smsmith         */
11567754Smsmith        Status = AcpiExStoreObjectToNode (SourceDesc,
11677424Smsmith                    (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
11767754Smsmith                    ACPI_IMPLICIT_CONVERSION);
118193341Sjkim
119193341Sjkim        return_ACPI_STATUS (Status);
120193341Sjkim    }
121193341Sjkim
122193341Sjkim    /* Destination object must be a Reference or a Constant object */
123193341Sjkim
12467754Smsmith    switch (DestDesc->Common.Type)
12567754Smsmith    {
12677424Smsmith    case ACPI_TYPE_LOCAL_REFERENCE:
12791116Smsmith
12867754Smsmith        break;
129151937Sjkim
13067754Smsmith    case ACPI_TYPE_INTEGER:
131151937Sjkim
132151937Sjkim        /* Allow stores to Constants -- a Noop as per ACPI spec */
133151937Sjkim
134151937Sjkim        if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
135151937Sjkim        {
136151937Sjkim            return_ACPI_STATUS (AE_OK);
137151937Sjkim        }
13867754Smsmith
13967754Smsmith        /*lint -fallthrough */
14077424Smsmith
14167754Smsmith    default:
14285756Smsmith
14377424Smsmith        /* Destination is not a Reference object */
14477424Smsmith
14587031Smsmith        ACPI_ERROR ((AE_INFO,
14687031Smsmith            "Target is not a Reference or Constant object - %s [%p]",
14767754Smsmith            AcpiUtGetObjectTypeName (DestDesc), DestDesc));
14867754Smsmith
14967754Smsmith        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
15085756Smsmith    }
15167754Smsmith
15267754Smsmith    /*
15391116Smsmith     * Examine the Reference class. These cases are handled:
15487031Smsmith     *
15567754Smsmith     * 1) Store to Name (Change the object associated with a name)
15667754Smsmith     * 2) Store to an indexed area of a Buffer or Package
15767754Smsmith     * 3) Store to a Method Local or Arg
15867754Smsmith     * 4) Store to the debug object
15977424Smsmith     */
16085756Smsmith    switch (RefDesc->Reference.Class)
16167754Smsmith    {
16267754Smsmith    case ACPI_REFCLASS_REFOF:
16367754Smsmith
16467754Smsmith        /* Storing an object into a Name "container" */
16571867Smsmith
16667754Smsmith        Status = AcpiExStoreObjectToNode (SourceDesc,
16767754Smsmith                    RefDesc->Reference.Object,
168167802Sjkim                    WalkState, ACPI_IMPLICIT_CONVERSION);
16967754Smsmith        break;
17067754Smsmith
17167754Smsmith    case ACPI_REFCLASS_INDEX:
17267754Smsmith
17385756Smsmith        /* Storing to an Index (pointer into a packager or buffer) */
17467754Smsmith
175167802Sjkim        Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
17667754Smsmith        break;
17767754Smsmith
17867754Smsmith    case ACPI_REFCLASS_LOCAL:
17971867Smsmith    case ACPI_REFCLASS_ARG:
18067754Smsmith
18191116Smsmith        /* Store to a method local/arg  */
18267754Smsmith
18377424Smsmith        Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
18471867Smsmith                    RefDesc->Reference.Value, SourceDesc, WalkState);
185107325Siwasaki        break;
18671867Smsmith
18785756Smsmith    case ACPI_REFCLASS_DEBUG:
188128212Snjl        /*
189128212Snjl         * Storing to the Debug object causes the value stored to be
19067754Smsmith         * displayed and otherwise has no effect -- see ACPI Specification
19171867Smsmith         */
19267754Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
19367754Smsmith            "**** Write to Debug Object: Object %p %s ****:\n\n",
19499679Siwasaki            SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
19567754Smsmith
196193267Sjkim        ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
197102550Siwasaki        break;
198107325Siwasaki
19999679Siwasaki    default:
20099679Siwasaki
20199679Siwasaki        ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
20299679Siwasaki            RefDesc->Reference.Class));
20399679Siwasaki        ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
20499679Siwasaki
20599679Siwasaki        Status = AE_AML_INTERNAL;
20699679Siwasaki        break;
20799679Siwasaki    }
20899679Siwasaki
20999679Siwasaki    return_ACPI_STATUS (Status);
210104470Siwasaki}
21199679Siwasaki
21299679Siwasaki
21399679Siwasaki/*******************************************************************************
214126372Snjl *
21567754Smsmith * FUNCTION:    AcpiExStoreObjectToIndex
216167802Sjkim *
217167802Sjkim * PARAMETERS:  *SourceDesc             - Value to be stored
218138287Smarks *              *DestDesc               - Named object to receive the value
21967754Smsmith *              WalkState               - Current walk state
22067754Smsmith *
22167754Smsmith * RETURN:      Status
22267754Smsmith *
22377424Smsmith * DESCRIPTION: Store the object to indexed Buffer or Package element
224193267Sjkim *
22571867Smsmith ******************************************************************************/
22671867Smsmith
22771867Smsmithstatic ACPI_STATUS
22871867SmsmithAcpiExStoreObjectToIndex (
22971867Smsmith    ACPI_OPERAND_OBJECT     *SourceDesc,
23071867Smsmith    ACPI_OPERAND_OBJECT     *IndexDesc,
231193267Sjkim    ACPI_WALK_STATE         *WalkState)
23267754Smsmith{
233193267Sjkim    ACPI_STATUS             Status = AE_OK;
23467754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
23571867Smsmith    ACPI_OPERAND_OBJECT     *NewDesc;
23671867Smsmith    UINT8                   Value = 0;
237151937Sjkim    UINT32                  i;
238151937Sjkim
239151937Sjkim
24071867Smsmith    ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
24167754Smsmith
24267754Smsmith
243193267Sjkim    /*
24467754Smsmith     * Destination must be a reference pointer, and
24571867Smsmith     * must point to either a buffer or a package
24667754Smsmith     */
24785756Smsmith    switch (IndexDesc->Reference.TargetType)
24871867Smsmith    {
24971867Smsmith    case ACPI_TYPE_PACKAGE:
25071867Smsmith        /*
251193267Sjkim         * Storing to a package element. Copy the object and replace
252193267Sjkim         * any existing object with the new object. No implicit
25371867Smsmith         * conversion is performed.
25477424Smsmith         *
25571867Smsmith         * The object at *(IndexDesc->Reference.Where) is the
256193267Sjkim         * element within the package that is to be modified.
257193267Sjkim         * The parent package object is at IndexDesc->Reference.Object
25871867Smsmith         */
25971867Smsmith        ObjDesc = *(IndexDesc->Reference.Where);
26071867Smsmith
261193267Sjkim        if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
26271867Smsmith            SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
26367754Smsmith        {
26471867Smsmith            /* This is a DDBHandle, just add a reference to it */
26571867Smsmith
26667754Smsmith            AcpiUtAddReference (SourceDesc);
267138287Smarks            NewDesc = SourceDesc;
268138287Smarks        }
269138287Smarks        else
27077424Smsmith        {
271204773Sjkim            /* Normal object, copy it */
27271867Smsmith
27371867Smsmith            Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
27471867Smsmith            if (ACPI_FAILURE (Status))
27571867Smsmith            {
27671867Smsmith                return_ACPI_STATUS (Status);
277204773Sjkim            }
278193267Sjkim        }
279193267Sjkim
28071867Smsmith        if (ObjDesc)
28171867Smsmith        {
28271867Smsmith            /* Decrement reference count by the ref count of the parent package */
28399679Siwasaki
28471867Smsmith            for (i = 0;
28571867Smsmith                 i < ((ACPI_OPERAND_OBJECT *)
28671867Smsmith                        IndexDesc->Reference.Object)->Common.ReferenceCount;
28771867Smsmith                 i++)
28871867Smsmith            {
28971867Smsmith                AcpiUtRemoveReference (ObjDesc);
29071867Smsmith            }
29177424Smsmith        }
29271867Smsmith
29387031Smsmith        *(IndexDesc->Reference.Where) = NewDesc;
29487031Smsmith
29587031Smsmith        /* Increment ref count by the ref count of the parent package-1 */
29671867Smsmith
29771867Smsmith        for (i = 1;
29871867Smsmith             i < ((ACPI_OPERAND_OBJECT *)
29987031Smsmith                    IndexDesc->Reference.Object)->Common.ReferenceCount;
30071867Smsmith             i++)
30171867Smsmith        {
30271867Smsmith            AcpiUtAddReference (NewDesc);
303151937Sjkim        }
30477424Smsmith
30585756Smsmith        break;
30691116Smsmith
30771867Smsmith    case ACPI_TYPE_BUFFER_FIELD:
30871867Smsmith        /*
30971867Smsmith         * Store into a Buffer or String (not actually a real BufferField)
31071867Smsmith         * at a location defined by an Index.
31191116Smsmith         *
31271867Smsmith         * The first 8-bit element of the source object is written to the
313126372Snjl         * 8-bit Buffer location defined by the Index destination object,
31471867Smsmith         * according to the ACPI 2.0 specification.
31571867Smsmith         */
316167802Sjkim
31771867Smsmith        /*
31871867Smsmith         * Make sure the target is a Buffer or String. An error should
31971867Smsmith         * not happen here, since the ReferenceObject was constructed
32071867Smsmith         * by the INDEX_OP code.
32171867Smsmith         */
32271867Smsmith        ObjDesc = IndexDesc->Reference.Object;
32391116Smsmith        if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
32471867Smsmith            (ObjDesc->Common.Type != ACPI_TYPE_STRING))
32571867Smsmith        {
32671867Smsmith            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
327138287Smarks        }
328138287Smarks
329138287Smarks        /*
330138287Smarks         * The assignment of the individual elements will be slightly
33191116Smsmith         * different for each source type.
33291116Smsmith         */
333126372Snjl        switch (SourceDesc->Common.Type)
33491116Smsmith        {
33591116Smsmith        case ACPI_TYPE_INTEGER:
33685756Smsmith
337193267Sjkim            /* Use the least-significant byte of the integer */
338193267Sjkim
33991116Smsmith            Value = (UINT8) (SourceDesc->Integer.Value);
340193267Sjkim            break;
341193267Sjkim
342193267Sjkim        case ACPI_TYPE_BUFFER:
343193267Sjkim        case ACPI_TYPE_STRING:
34491116Smsmith
345193267Sjkim            /* Note: Takes advantage of common string/buffer fields */
346193267Sjkim
347193267Sjkim            Value = SourceDesc->Buffer.Pointer[0];
34867754Smsmith            break;
349193267Sjkim
350193267Sjkim        default:
351193267Sjkim
352193267Sjkim            /* All other types are invalid */
353193267Sjkim
354193267Sjkim            ACPI_ERROR ((AE_INFO,
355193267Sjkim                "Source must be Integer/Buffer/String type, not %s",
356138287Smarks                AcpiUtGetObjectTypeName (SourceDesc)));
35791116Smsmith            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
358138287Smarks        }
359104470Siwasaki
360151937Sjkim        /* Store the source value into the target buffer byte */
361151937Sjkim
362151937Sjkim        ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
363151937Sjkim        break;
364104470Siwasaki
365138287Smarks    default:
366104470Siwasaki        ACPI_ERROR ((AE_INFO,
367138287Smarks            "Target is not a Package or BufferField"));
368151937Sjkim        Status = AE_AML_OPERAND_TYPE;
369138287Smarks        break;
370126372Snjl    }
371151937Sjkim
372126372Snjl    return_ACPI_STATUS (Status);
373151937Sjkim}
374151937Sjkim
375151937Sjkim
376151937Sjkim/*******************************************************************************
377138287Smarks *
378138287Smarks * FUNCTION:    AcpiExStoreObjectToNode
37967754Smsmith *
380151937Sjkim * PARAMETERS:  SourceDesc              - Value to be stored
38171867Smsmith *              Node                    - Named object to receive the value
38267754Smsmith *              WalkState               - Current walk state
38367754Smsmith *              ImplicitConversion      - Perform implicit conversion (yes/no)
38471867Smsmith *
38577424Smsmith * RETURN:      Status
38667754Smsmith *
387138287Smarks * DESCRIPTION: Store the object to the named object.
388138287Smarks *
38967754Smsmith *              The Assignment of an object to a named object is handled here
39087031Smsmith *              The value passed in will replace the current value (if any)
39187031Smsmith *              with the input value.
39287031Smsmith *
39367754Smsmith *              When storing into an object the data is converted to the
39467754Smsmith *              target object type then stored in the object. This means
39567754Smsmith *              that the target object type (for an initialized target) will
396138287Smarks *              not be changed by a store operation.
397138287Smarks *
398138287Smarks *              Assumes parameters are already validated.
39967754Smsmith *
40091116Smsmith ******************************************************************************/
401193267Sjkim
402193267SjkimACPI_STATUS
40367754SmsmithAcpiExStoreObjectToNode (
40471867Smsmith    ACPI_OPERAND_OBJECT     *SourceDesc,
40567754Smsmith    ACPI_NAMESPACE_NODE     *Node,
40667754Smsmith    ACPI_WALK_STATE         *WalkState,
40767754Smsmith    UINT8                   ImplicitConversion)
40867754Smsmith{
40967754Smsmith    ACPI_STATUS             Status = AE_OK;
41067754Smsmith    ACPI_OPERAND_OBJECT     *TargetDesc;
411193267Sjkim    ACPI_OPERAND_OBJECT     *NewDesc;
41267754Smsmith    ACPI_OBJECT_TYPE        TargetType;
41371867Smsmith
41487031Smsmith
41587031Smsmith    ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
41687031Smsmith
41787031Smsmith
41867754Smsmith    /* Get current type of the node, and object attached to Node */
41967754Smsmith
42087031Smsmith    TargetType = AcpiNsGetType (Node);
421138287Smarks    TargetDesc = AcpiNsGetAttachedObject (Node);
42277424Smsmith
423138287Smarks    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
424138287Smarks        SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
42587031Smsmith              Node, AcpiUtGetTypeName (TargetType)));
42667754Smsmith
42767754Smsmith    /*
42867754Smsmith     * Resolve the source object to an actual value
42977424Smsmith     * (If it is a reference object)
43087031Smsmith     */
43177424Smsmith    Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
432167802Sjkim    if (ACPI_FAILURE (Status))
433167802Sjkim    {
43499679Siwasaki        return_ACPI_STATUS (Status);
43587031Smsmith    }
43667754Smsmith
43787031Smsmith    /* If no implicit conversion, drop into the default case below */
43887031Smsmith
43987031Smsmith    if ((!ImplicitConversion) ||
440193267Sjkim          ((WalkState->Opcode == AML_COPY_OP) &&
44171867Smsmith           (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&
44267754Smsmith           (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&
44367754Smsmith           (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))
44471867Smsmith    {
445167802Sjkim        /*
446167802Sjkim         * Force execution of default (no implicit conversion). Note:
44771867Smsmith         * CopyObject does not perform an implicit conversion, as per the ACPI
44867754Smsmith         * spec -- except in case of region/bank/index fields -- because these
44971867Smsmith         * objects must retain their original type permanently.
45067754Smsmith         */
45171867Smsmith        TargetType = ACPI_TYPE_ANY;
45271867Smsmith    }
45367754Smsmith
45467754Smsmith    /* Do the actual store operation */
45571867Smsmith
45671867Smsmith    switch (TargetType)
45777424Smsmith    {
45871867Smsmith    case ACPI_TYPE_BUFFER_FIELD:
45987031Smsmith    case ACPI_TYPE_LOCAL_REGION_FIELD:
46087031Smsmith    case ACPI_TYPE_LOCAL_BANK_FIELD:
46187031Smsmith    case ACPI_TYPE_LOCAL_INDEX_FIELD:
462128212Snjl
46371867Smsmith        /* For fields, copy the source data to the target field. */
46471867Smsmith
46571867Smsmith        Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
46671867Smsmith                    &WalkState->ResultObj);
46771867Smsmith        break;
46871867Smsmith
46987031Smsmith    case ACPI_TYPE_INTEGER:
47071867Smsmith    case ACPI_TYPE_STRING:
47171867Smsmith    case ACPI_TYPE_BUFFER:
47271867Smsmith        /*
47371867Smsmith         * These target types are all of type Integer/String/Buffer, and
47471867Smsmith         * therefore support implicit conversion before the store.
47571867Smsmith         *
47671867Smsmith         * Copy and/or convert the source object to a new target object
47787031Smsmith         */
47871867Smsmith        Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
47971867Smsmith                    &NewDesc, WalkState);
48067754Smsmith        if (ACPI_FAILURE (Status))
48171867Smsmith        {
48277424Smsmith            return_ACPI_STATUS (Status);
48371867Smsmith        }
48471867Smsmith
485128212Snjl        if (NewDesc != TargetDesc)
486128212Snjl        {
48771867Smsmith            /*
48871867Smsmith             * Store the new NewDesc as the new value of the Name, and set
48971867Smsmith             * the Name's type to that of the value being stored in it.
49091116Smsmith             * SourceDesc reference count is incremented by AttachObject.
49191116Smsmith             *
49267754Smsmith             * Note: This may change the type of the node if an explicit store
49371867Smsmith             * has been performed such that the node/object type has been
494167802Sjkim             * changed.
49571867Smsmith             */
49683174Smsmith            Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
497151937Sjkim
498151937Sjkim            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
49971867Smsmith                "Store %s into %s via Convert/Attach\n",
50071867Smsmith                AcpiUtGetObjectTypeName (SourceDesc),
50171867Smsmith                AcpiUtGetObjectTypeName (NewDesc)));
50299146Siwasaki        }
50399679Siwasaki        break;
50491116Smsmith
50571867Smsmith    default:
50671867Smsmith
50771867Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
50877424Smsmith            "Storing [%s] (%p) directly into node [%s] (%p)"
50971867Smsmith            " with no implicit conversion\n",
51077424Smsmith            AcpiUtGetObjectTypeName (SourceDesc), SourceDesc,
51171867Smsmith            AcpiUtGetObjectTypeName (TargetDesc), Node));
51271867Smsmith
51371867Smsmith        /*
51471867Smsmith         * No conversions for all other types. Directly store a copy of
51571867Smsmith         * the source object. NOTE: This is a departure from the ACPI
516128212Snjl         * spec, which states "If conversion is impossible, abort the
517128212Snjl         * running control method".
518193267Sjkim         *
519193267Sjkim         * This code implements "If conversion is impossible, treat the
520193267Sjkim         * Store operation as a CopyObject".
521193267Sjkim         */
522193267Sjkim        Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
523128212Snjl        if (ACPI_FAILURE (Status))
524193267Sjkim        {
525193267Sjkim            return_ACPI_STATUS (Status);
526193267Sjkim        }
527193267Sjkim
528193267Sjkim        Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
529193267Sjkim        AcpiUtRemoveReference (NewDesc);
530128212Snjl        break;
531128212Snjl    }
532128212Snjl
533151937Sjkim    return_ACPI_STATUS (Status);
534151937Sjkim}
53571867Smsmith