dsobject.c revision 193259
1/******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 *              $Revision: 1.135 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
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.
21 *
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
28 *
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;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
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.
54 *
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.
66 *
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.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
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.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
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.
90 *
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.
99 *
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.
114 *
115 *****************************************************************************/
116
117#define __DSOBJECT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
123#include "acnamesp.h"
124#include "acinterp.h"
125
126#define _COMPONENT          ACPI_DISPATCHER
127        ACPI_MODULE_NAME    ("dsobject")
128
129/* Local prototypes */
130
131static ACPI_STATUS
132AcpiDsBuildInternalObject (
133    ACPI_WALK_STATE         *WalkState,
134    ACPI_PARSE_OBJECT       *Op,
135    ACPI_OPERAND_OBJECT     **ObjDescPtr);
136
137
138#ifndef ACPI_NO_METHOD_EXECUTION
139/*******************************************************************************
140 *
141 * FUNCTION:    AcpiDsBuildInternalObject
142 *
143 * PARAMETERS:  WalkState       - Current walk state
144 *              Op              - Parser object to be translated
145 *              ObjDescPtr      - Where the ACPI internal object is returned
146 *
147 * RETURN:      Status
148 *
149 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
150 *              Simple objects are any objects other than a package object!
151 *
152 ******************************************************************************/
153
154static ACPI_STATUS
155AcpiDsBuildInternalObject (
156    ACPI_WALK_STATE         *WalkState,
157    ACPI_PARSE_OBJECT       *Op,
158    ACPI_OPERAND_OBJECT     **ObjDescPtr)
159{
160    ACPI_OPERAND_OBJECT     *ObjDesc;
161    ACPI_STATUS             Status;
162
163
164    ACPI_FUNCTION_TRACE (DsBuildInternalObject);
165
166
167    *ObjDescPtr = NULL;
168    if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
169    {
170        /*
171         * This is a named object reference. If this name was
172         * previously looked up in the namespace, it was stored in this op.
173         * Otherwise, go ahead and look it up now
174         */
175        if (!Op->Common.Node)
176        {
177            Status = AcpiNsLookup (WalkState->ScopeInfo,
178                        Op->Common.Value.String,
179                        ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
180                        ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
181                        ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
182            if (ACPI_FAILURE (Status))
183            {
184                /* Check if we are resolving a named reference within a package */
185
186                if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) &&
187
188                    ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
189                     (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
190                {
191                    /*
192                     * We didn't find the target and we are populating elements
193                     * of a package - ignore if slack enabled. Some ASL code
194                     * contains dangling invalid references in packages and
195                     * expects that no exception will be issued. Leave the
196                     * element as a null element. It cannot be used, but it
197                     * can be overwritten by subsequent ASL code - this is
198                     * typically the case.
199                     */
200                    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
201                        "Ignoring unresolved reference in package [%4.4s]\n",
202                        WalkState->ScopeInfo->Scope.Node->Name.Ascii));
203
204                    return_ACPI_STATUS (AE_OK);
205                }
206                else
207                {
208                    ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status);
209                }
210
211                return_ACPI_STATUS (Status);
212            }
213        }
214    }
215
216    /* Create and init a new internal ACPI object */
217
218    ObjDesc = AcpiUtCreateInternalObject (
219                (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
220    if (!ObjDesc)
221    {
222        return_ACPI_STATUS (AE_NO_MEMORY);
223    }
224
225    Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode,
226                &ObjDesc);
227    if (ACPI_FAILURE (Status))
228    {
229        AcpiUtRemoveReference (ObjDesc);
230        return_ACPI_STATUS (Status);
231    }
232
233    *ObjDescPtr = ObjDesc;
234    return_ACPI_STATUS (AE_OK);
235}
236
237
238/*******************************************************************************
239 *
240 * FUNCTION:    AcpiDsBuildInternalBufferObj
241 *
242 * PARAMETERS:  WalkState       - Current walk state
243 *              Op              - Parser object to be translated
244 *              BufferLength    - Length of the buffer
245 *              ObjDescPtr      - Where the ACPI internal object is returned
246 *
247 * RETURN:      Status
248 *
249 * DESCRIPTION: Translate a parser Op package object to the equivalent
250 *              namespace object
251 *
252 ******************************************************************************/
253
254ACPI_STATUS
255AcpiDsBuildInternalBufferObj (
256    ACPI_WALK_STATE         *WalkState,
257    ACPI_PARSE_OBJECT       *Op,
258    UINT32                  BufferLength,
259    ACPI_OPERAND_OBJECT     **ObjDescPtr)
260{
261    ACPI_PARSE_OBJECT       *Arg;
262    ACPI_OPERAND_OBJECT     *ObjDesc;
263    ACPI_PARSE_OBJECT       *ByteList;
264    UINT32                  ByteListLength = 0;
265
266
267    ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
268
269
270    /*
271     * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
272     * The buffer object already exists (from the NS node), otherwise it must
273     * be created.
274     */
275    ObjDesc = *ObjDescPtr;
276    if (!ObjDesc)
277    {
278        /* Create a new buffer object */
279
280        ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
281        *ObjDescPtr = ObjDesc;
282        if (!ObjDesc)
283        {
284            return_ACPI_STATUS (AE_NO_MEMORY);
285        }
286    }
287
288    /*
289     * Second arg is the buffer data (optional) ByteList can be either
290     * individual bytes or a string initializer.  In either case, a
291     * ByteList appears in the AML.
292     */
293    Arg = Op->Common.Value.Arg;         /* skip first arg */
294
295    ByteList = Arg->Named.Next;
296    if (ByteList)
297    {
298        if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
299        {
300            ACPI_ERROR ((AE_INFO,
301                "Expecting bytelist, got AML opcode %X in op %p",
302                ByteList->Common.AmlOpcode, ByteList));
303
304            AcpiUtRemoveReference (ObjDesc);
305            return (AE_TYPE);
306        }
307
308        ByteListLength = (UINT32) ByteList->Common.Value.Integer;
309    }
310
311    /*
312     * The buffer length (number of bytes) will be the larger of:
313     * 1) The specified buffer length and
314     * 2) The length of the initializer byte list
315     */
316    ObjDesc->Buffer.Length = BufferLength;
317    if (ByteListLength > BufferLength)
318    {
319        ObjDesc->Buffer.Length = ByteListLength;
320    }
321
322    /* Allocate the buffer */
323
324    if (ObjDesc->Buffer.Length == 0)
325    {
326        ObjDesc->Buffer.Pointer = NULL;
327        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
328            "Buffer defined with zero length in AML, creating\n"));
329    }
330    else
331    {
332        ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED (
333                                        ObjDesc->Buffer.Length);
334        if (!ObjDesc->Buffer.Pointer)
335        {
336            AcpiUtDeleteObjectDesc (ObjDesc);
337            return_ACPI_STATUS (AE_NO_MEMORY);
338        }
339
340        /* Initialize buffer from the ByteList (if present) */
341
342        if (ByteList)
343        {
344            ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
345                         ByteListLength);
346        }
347    }
348
349    ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
350    Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
351    return_ACPI_STATUS (AE_OK);
352}
353
354
355/*******************************************************************************
356 *
357 * FUNCTION:    AcpiDsBuildInternalPackageObj
358 *
359 * PARAMETERS:  WalkState       - Current walk state
360 *              Op              - Parser object to be translated
361 *              ElementCount    - Number of elements in the package - this is
362 *                                the NumElements argument to Package()
363 *              ObjDescPtr      - Where the ACPI internal object is returned
364 *
365 * RETURN:      Status
366 *
367 * DESCRIPTION: Translate a parser Op package object to the equivalent
368 *              namespace object
369 *
370 * NOTE: The number of elements in the package will be always be the NumElements
371 * count, regardless of the number of elements in the package list. If
372 * NumElements is smaller, only that many package list elements are used.
373 * if NumElements is larger, the Package object is padded out with
374 * objects of type Uninitialized (as per ACPI spec.)
375 *
376 * Even though the ASL compilers do not allow NumElements to be smaller
377 * than the Package list length (for the fixed length package opcode), some
378 * BIOS code modifies the AML on the fly to adjust the NumElements, and
379 * this code compensates for that. This also provides compatibility with
380 * other AML interpreters.
381 *
382 ******************************************************************************/
383
384ACPI_STATUS
385AcpiDsBuildInternalPackageObj (
386    ACPI_WALK_STATE         *WalkState,
387    ACPI_PARSE_OBJECT       *Op,
388    UINT32                  ElementCount,
389    ACPI_OPERAND_OBJECT     **ObjDescPtr)
390{
391    ACPI_PARSE_OBJECT       *Arg;
392    ACPI_PARSE_OBJECT       *Parent;
393    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
394    ACPI_STATUS             Status = AE_OK;
395    ACPI_NATIVE_UINT        i;
396    UINT16                  Index;
397    UINT16                  ReferenceCount;
398
399
400    ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj);
401
402
403    /* Find the parent of a possibly nested package */
404
405    Parent = Op->Common.Parent;
406    while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
407           (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
408    {
409        Parent = Parent->Common.Parent;
410    }
411
412    /*
413     * If we are evaluating a Named package object "Name (xxxx, Package)",
414     * the package object already exists, otherwise it must be created.
415     */
416    ObjDesc = *ObjDescPtr;
417    if (!ObjDesc)
418    {
419        ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
420        *ObjDescPtr = ObjDesc;
421        if (!ObjDesc)
422        {
423            return_ACPI_STATUS (AE_NO_MEMORY);
424        }
425
426        ObjDesc->Package.Node = Parent->Common.Node;
427    }
428
429    /*
430     * Allocate the element array (array of pointers to the individual
431     * objects) based on the NumElements parameter. Add an extra pointer slot
432     * so that the list is always null terminated.
433     */
434    ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
435        ((ACPI_SIZE) ElementCount + 1) * sizeof (void *));
436
437    if (!ObjDesc->Package.Elements)
438    {
439        AcpiUtDeleteObjectDesc (ObjDesc);
440        return_ACPI_STATUS (AE_NO_MEMORY);
441    }
442
443    ObjDesc->Package.Count = ElementCount;
444
445    /*
446     * Initialize the elements of the package, up to the NumElements count.
447     * Package is automatically padded with uninitialized (NULL) elements
448     * if NumElements is greater than the package list length. Likewise,
449     * Package is truncated if NumElements is less than the list length.
450     */
451    Arg = Op->Common.Value.Arg;
452    Arg = Arg->Common.Next;
453    for (i = 0; Arg && (i < ElementCount); i++)
454    {
455        if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
456        {
457            /* This package element is already built, just get it */
458
459            ObjDesc->Package.Elements[i] =
460                ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node);
461        }
462        else
463        {
464            Status = AcpiDsBuildInternalObject (WalkState, Arg,
465                        &ObjDesc->Package.Elements[i]);
466        }
467
468        if (*ObjDescPtr)
469        {
470            /* Existing package, get existing reference count */
471
472            ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount;
473            if (ReferenceCount > 1)
474            {
475                /* Make new element ref count match original ref count */
476
477                for (Index = 0; Index < (ReferenceCount - 1); Index++)
478                {
479                    AcpiUtAddReference ((ObjDesc->Package.Elements[i]));
480                }
481            }
482        }
483
484        Arg = Arg->Common.Next;
485    }
486
487    if (!Arg)
488    {
489        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
490            "Package List length larger than NumElements count (%X), truncated\n",
491            ElementCount));
492    }
493
494    ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
495    Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
496    return_ACPI_STATUS (Status);
497}
498
499
500/*******************************************************************************
501 *
502 * FUNCTION:    AcpiDsCreateNode
503 *
504 * PARAMETERS:  WalkState       - Current walk state
505 *              Node            - NS Node to be initialized
506 *              Op              - Parser object to be translated
507 *
508 * RETURN:      Status
509 *
510 * DESCRIPTION: Create the object to be associated with a namespace node
511 *
512 ******************************************************************************/
513
514ACPI_STATUS
515AcpiDsCreateNode (
516    ACPI_WALK_STATE         *WalkState,
517    ACPI_NAMESPACE_NODE     *Node,
518    ACPI_PARSE_OBJECT       *Op)
519{
520    ACPI_STATUS             Status;
521    ACPI_OPERAND_OBJECT     *ObjDesc;
522
523
524    ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
525
526
527    /*
528     * Because of the execution pass through the non-control-method
529     * parts of the table, we can arrive here twice.  Only init
530     * the named object node the first time through
531     */
532    if (AcpiNsGetAttachedObject (Node))
533    {
534        return_ACPI_STATUS (AE_OK);
535    }
536
537    if (!Op->Common.Value.Arg)
538    {
539        /* No arguments, there is nothing to do */
540
541        return_ACPI_STATUS (AE_OK);
542    }
543
544    /* Build an internal object for the argument(s) */
545
546    Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg,
547                &ObjDesc);
548    if (ACPI_FAILURE (Status))
549    {
550        return_ACPI_STATUS (Status);
551    }
552
553    /* Re-type the object according to its argument */
554
555    Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc);
556
557    /* Attach obj to node */
558
559    Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
560
561    /* Remove local reference to the object */
562
563    AcpiUtRemoveReference (ObjDesc);
564    return_ACPI_STATUS (Status);
565}
566
567#endif /* ACPI_NO_METHOD_EXECUTION */
568
569
570/*******************************************************************************
571 *
572 * FUNCTION:    AcpiDsInitObjectFromOp
573 *
574 * PARAMETERS:  WalkState       - Current walk state
575 *              Op              - Parser op used to init the internal object
576 *              Opcode          - AML opcode associated with the object
577 *              RetObjDesc      - Namespace object to be initialized
578 *
579 * RETURN:      Status
580 *
581 * DESCRIPTION: Initialize a namespace object from a parser Op and its
582 *              associated arguments.  The namespace object is a more compact
583 *              representation of the Op and its arguments.
584 *
585 ******************************************************************************/
586
587ACPI_STATUS
588AcpiDsInitObjectFromOp (
589    ACPI_WALK_STATE         *WalkState,
590    ACPI_PARSE_OBJECT       *Op,
591    UINT16                  Opcode,
592    ACPI_OPERAND_OBJECT     **RetObjDesc)
593{
594    const ACPI_OPCODE_INFO  *OpInfo;
595    ACPI_OPERAND_OBJECT     *ObjDesc;
596    ACPI_STATUS             Status = AE_OK;
597
598
599    ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
600
601
602    ObjDesc = *RetObjDesc;
603    OpInfo = AcpiPsGetOpcodeInfo (Opcode);
604    if (OpInfo->Class == AML_CLASS_UNKNOWN)
605    {
606        /* Unknown opcode */
607
608        return_ACPI_STATUS (AE_TYPE);
609    }
610
611    /* Perform per-object initialization */
612
613    switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
614    {
615    case ACPI_TYPE_BUFFER:
616
617        /*
618         * Defer evaluation of Buffer TermArg operand
619         */
620        ObjDesc->Buffer.Node      = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
621                                        WalkState->Operands[0]);
622        ObjDesc->Buffer.AmlStart  = Op->Named.Data;
623        ObjDesc->Buffer.AmlLength = Op->Named.Length;
624        break;
625
626
627    case ACPI_TYPE_PACKAGE:
628
629        /*
630         * Defer evaluation of Package TermArg operand
631         */
632        ObjDesc->Package.Node      = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
633                                        WalkState->Operands[0]);
634        ObjDesc->Package.AmlStart  = Op->Named.Data;
635        ObjDesc->Package.AmlLength = Op->Named.Length;
636        break;
637
638
639    case ACPI_TYPE_INTEGER:
640
641        switch (OpInfo->Type)
642        {
643        case AML_TYPE_CONSTANT:
644            /*
645             * Resolve AML Constants here - AND ONLY HERE!
646             * All constants are integers.
647             * We mark the integer with a flag that indicates that it started
648             * life as a constant -- so that stores to constants will perform
649             * as expected (noop). ZeroOp is used as a placeholder for optional
650             * target operands.
651             */
652            ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
653
654            switch (Opcode)
655            {
656            case AML_ZERO_OP:
657
658                ObjDesc->Integer.Value = 0;
659                break;
660
661            case AML_ONE_OP:
662
663                ObjDesc->Integer.Value = 1;
664                break;
665
666            case AML_ONES_OP:
667
668                ObjDesc->Integer.Value = ACPI_INTEGER_MAX;
669
670                /* Truncate value if we are executing from a 32-bit ACPI table */
671
672#ifndef ACPI_NO_METHOD_EXECUTION
673                AcpiExTruncateFor32bitTable (ObjDesc);
674#endif
675                break;
676
677            case AML_REVISION_OP:
678
679                ObjDesc->Integer.Value = ACPI_CA_VERSION;
680                break;
681
682            default:
683
684                ACPI_ERROR ((AE_INFO,
685                    "Unknown constant opcode %X", Opcode));
686                Status = AE_AML_OPERAND_TYPE;
687                break;
688            }
689            break;
690
691
692        case AML_TYPE_LITERAL:
693
694            ObjDesc->Integer.Value = Op->Common.Value.Integer;
695#ifndef ACPI_NO_METHOD_EXECUTION
696            AcpiExTruncateFor32bitTable (ObjDesc);
697#endif
698            break;
699
700
701        default:
702            ACPI_ERROR ((AE_INFO, "Unknown Integer type %X",
703                OpInfo->Type));
704            Status = AE_AML_OPERAND_TYPE;
705            break;
706        }
707        break;
708
709
710    case ACPI_TYPE_STRING:
711
712        ObjDesc->String.Pointer = Op->Common.Value.String;
713        ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String);
714
715        /*
716         * The string is contained in the ACPI table, don't ever try
717         * to delete it
718         */
719        ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
720        break;
721
722
723    case ACPI_TYPE_METHOD:
724        break;
725
726
727    case ACPI_TYPE_LOCAL_REFERENCE:
728
729        switch (OpInfo->Type)
730        {
731        case AML_TYPE_LOCAL_VARIABLE:
732
733            /* Split the opcode into a base opcode + offset */
734
735            ObjDesc->Reference.Opcode = AML_LOCAL_OP;
736            ObjDesc->Reference.Offset = Opcode - AML_LOCAL_OP;
737
738#ifndef ACPI_NO_METHOD_EXECUTION
739            Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP,
740                        ObjDesc->Reference.Offset,
741                        WalkState,
742                        (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object);
743#endif
744            break;
745
746
747        case AML_TYPE_METHOD_ARGUMENT:
748
749            /* Split the opcode into a base opcode + offset */
750
751            ObjDesc->Reference.Opcode = AML_ARG_OP;
752            ObjDesc->Reference.Offset = Opcode - AML_ARG_OP;
753
754#ifndef ACPI_NO_METHOD_EXECUTION
755            Status = AcpiDsMethodDataGetNode (AML_ARG_OP,
756                        ObjDesc->Reference.Offset,
757                        WalkState,
758                        (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object);
759#endif
760            break;
761
762        default: /* Other literals, etc.. */
763
764            if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
765            {
766                /* Node was saved in Op */
767
768                ObjDesc->Reference.Node = Op->Common.Node;
769            }
770
771            ObjDesc->Reference.Opcode = Opcode;
772            break;
773        }
774        break;
775
776
777    default:
778
779        ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X",
780            ACPI_GET_OBJECT_TYPE (ObjDesc)));
781
782        Status = AE_AML_OPERAND_TYPE;
783        break;
784    }
785
786    return_ACPI_STATUS (Status);
787}
788
789
790