dsobject.c revision 71867
1/******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 *              $Revision: 56 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 "acinterp.h"
124#include "acnamesp.h"
125
126#define _COMPONENT          DISPATCHER
127        MODULE_NAME         ("dsobject")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION:    AcpiDsInitOneObject
133 *
134 * PARAMETERS:  ObjHandle       - Node
135 *              Level           - Current nesting level
136 *              Context         - Points to a init info struct
137 *              ReturnValue     - Not used
138 *
139 * RETURN:      Status
140 *
141 * DESCRIPTION: Callback from AcpiWalkNamespace.  Invoked for every object
142 *              within the  namespace.
143 *
144 *              Currently, the only objects that require initialization are:
145 *              1) Methods
146 *              2) Op Regions
147 *
148 ******************************************************************************/
149
150ACPI_STATUS
151AcpiDsInitOneObject (
152    ACPI_HANDLE             ObjHandle,
153    UINT32                  Level,
154    void                    *Context,
155    void                    **ReturnValue)
156{
157    OBJECT_TYPE_INTERNAL    Type;
158    ACPI_STATUS             Status;
159    ACPI_INIT_WALK_INFO     *Info = (ACPI_INIT_WALK_INFO *) Context;
160    UINT8                   TableRevision;
161
162
163    Info->ObjectCount++;
164    TableRevision = Info->TableDesc->Pointer->Revision;
165
166    /*
167     * We are only interested in objects owned by the table that
168     * was just loaded
169     */
170
171    if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId !=
172            Info->TableDesc->TableId)
173    {
174        return (AE_OK);
175    }
176
177
178    /* And even then, we are only interested in a few object types */
179
180    Type = AcpiNsGetType (ObjHandle);
181
182    switch (Type)
183    {
184
185    case ACPI_TYPE_REGION:
186
187        AcpiDsInitializeRegion (ObjHandle);
188
189        Info->OpRegionCount++;
190        break;
191
192
193    case ACPI_TYPE_METHOD:
194
195        Info->MethodCount++;
196
197        DEBUG_PRINT_RAW (ACPI_OK, ("."));
198
199        /*
200         * Set the execution data width (32 or 64) based upon the
201         * revision number of the parent ACPI table.
202         */
203
204        if (TableRevision == 1)
205        {
206            ((ACPI_NAMESPACE_NODE *)ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32;
207        }
208
209        /*
210         * Always parse methods to detect errors, we may delete
211         * the parse tree below
212         */
213
214        Status = AcpiDsParseMethod (ObjHandle);
215
216        /* TBD: [Errors] what do we do with an error? */
217
218        if (ACPI_FAILURE (Status))
219        {
220            DEBUG_PRINT (ACPI_ERROR,
221                ("DsInitOneObject: Method %p [%4.4s] parse failed! %s\n",
222                ObjHandle, &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name,
223                AcpiCmFormatException (Status)));
224            break;
225        }
226
227        /*
228         * Delete the parse tree.  We simple re-parse the method
229         * for every execution since there isn't much overhead
230         */
231        AcpiNsDeleteNamespaceSubtree (ObjHandle);
232        break;
233
234    default:
235        break;
236    }
237
238    /*
239     * We ignore errors from above, and always return OK, since
240     * we don't want to abort the walk on a single error.
241     */
242    return (AE_OK);
243}
244
245
246/*******************************************************************************
247 *
248 * FUNCTION:    AcpiDsInitializeObjects
249 *
250 * PARAMETERS:  None
251 *
252 * RETURN:      Status
253 *
254 * DESCRIPTION: Walk the entire namespace and perform any necessary
255 *              initialization on the objects found therein
256 *
257 ******************************************************************************/
258
259ACPI_STATUS
260AcpiDsInitializeObjects (
261    ACPI_TABLE_DESC         *TableDesc,
262    ACPI_NAMESPACE_NODE     *StartNode)
263{
264    ACPI_STATUS             Status;
265    ACPI_INIT_WALK_INFO     Info;
266
267
268    FUNCTION_TRACE ("DsInitializeObjects");
269
270
271    DEBUG_PRINT (TRACE_DISPATCH,
272        ("DsInitializeObjects: **** Starting initialization of namespace objects ****\n"));
273    DEBUG_PRINT_RAW (ACPI_OK, ("Parsing Methods:"));
274
275
276    Info.MethodCount    = 0;
277    Info.OpRegionCount  = 0;
278    Info.ObjectCount    = 0;
279    Info.TableDesc      = TableDesc;
280
281
282    /* Walk entire namespace from the supplied root */
283
284    Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode,
285                                ACPI_UINT32_MAX, AcpiDsInitOneObject,
286                                &Info, NULL);
287    if (ACPI_FAILURE (Status))
288    {
289        DEBUG_PRINT (ACPI_ERROR,
290            ("DsInitializeObjects: WalkNamespace failed! %x\n", Status));
291    }
292
293    DEBUG_PRINT_RAW (ACPI_OK,
294        ("\n%d Control Methods found and parsed (%d nodes total)\n",
295        Info.MethodCount, Info.ObjectCount));
296    DEBUG_PRINT (TRACE_DISPATCH,
297        ("DsInitializeObjects: %d Control Methods found\n", Info.MethodCount));
298    DEBUG_PRINT (TRACE_DISPATCH,
299        ("DsInitializeObjects: %d Op Regions found\n", Info.OpRegionCount));
300
301    return_ACPI_STATUS (AE_OK);
302}
303
304
305/*****************************************************************************
306 *
307 * FUNCTION:    AcpiDsInitObjectFromOp
308 *
309 * PARAMETERS:  Op              - Parser op used to init the internal object
310 *              Opcode          - AML opcode associated with the object
311 *              ObjDesc         - Namespace object to be initialized
312 *
313 * RETURN:      Status
314 *
315 * DESCRIPTION: Initialize a namespace object from a parser Op and its
316 *              associated arguments.  The namespace object is a more compact
317 *              representation of the Op and its arguments.
318 *
319 ****************************************************************************/
320
321ACPI_STATUS
322AcpiDsInitObjectFromOp (
323    ACPI_WALK_STATE         *WalkState,
324    ACPI_PARSE_OBJECT       *Op,
325    UINT16                  Opcode,
326    ACPI_OPERAND_OBJECT     **ObjDesc)
327{
328    ACPI_STATUS             Status;
329    ACPI_PARSE_OBJECT       *Arg;
330    ACPI_PARSE2_OBJECT      *ByteList;
331    ACPI_OPERAND_OBJECT     *ArgDesc;
332    ACPI_OPCODE_INFO        *OpInfo;
333
334
335    OpInfo = AcpiPsGetOpcodeInfo (Opcode);
336    if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
337    {
338        /* Unknown opcode */
339
340        return (AE_TYPE);
341    }
342
343
344    /* Get and prepare the first argument */
345
346    switch ((*ObjDesc)->Common.Type)
347    {
348    case ACPI_TYPE_BUFFER:
349
350        /* First arg is a number */
351
352        AcpiDsCreateOperand (WalkState, Op->Value.Arg, 0);
353        ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
354        AcpiDsObjStackPop (1, WalkState);
355
356        /* Resolve the object (could be an arg or local) */
357
358        Status = AcpiAmlResolveToValue (&ArgDesc, WalkState);
359        if (ACPI_FAILURE (Status))
360        {
361            AcpiCmRemoveReference (ArgDesc);
362            return (Status);
363        }
364
365        /* We are expecting a number */
366
367        if (ArgDesc->Common.Type != ACPI_TYPE_INTEGER)
368        {
369            DEBUG_PRINT (ACPI_ERROR,
370                ("InitObject: Expecting number, got obj: %p type %X\n",
371                ArgDesc, ArgDesc->Common.Type));
372            AcpiCmRemoveReference (ArgDesc);
373            return (AE_TYPE);
374        }
375
376        /* Get the value, delete the internal object */
377
378        (*ObjDesc)->Buffer.Length = (UINT32) ArgDesc->Integer.Value;
379        AcpiCmRemoveReference (ArgDesc);
380
381        /* Allocate the buffer */
382
383        if ((*ObjDesc)->Buffer.Length == 0)
384        {
385            (*ObjDesc)->Buffer.Pointer = NULL;
386            REPORT_WARNING (("Buffer created with zero length in AML\n"));
387            break;
388        }
389
390        else
391        {
392            (*ObjDesc)->Buffer.Pointer =
393                            AcpiCmCallocate ((*ObjDesc)->Buffer.Length);
394
395            if (!(*ObjDesc)->Buffer.Pointer)
396            {
397                return (AE_NO_MEMORY);
398            }
399        }
400
401        /*
402         * Second arg is the buffer data (optional)
403         * ByteList can be either individual bytes or a
404         * string initializer!
405         */
406
407        /* skip first arg */
408        Arg = Op->Value.Arg;
409        ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next;
410        if (ByteList)
411        {
412            if (ByteList->Opcode != AML_BYTELIST_OP)
413            {
414                DEBUG_PRINT (ACPI_ERROR,
415                    ("InitObject: Expecting bytelist, got: %x\n",
416                    ByteList));
417                return (AE_TYPE);
418            }
419
420            MEMCPY ((*ObjDesc)->Buffer.Pointer, ByteList->Data,
421                    (*ObjDesc)->Buffer.Length);
422        }
423
424        break;
425
426
427    case ACPI_TYPE_PACKAGE:
428
429        /*
430         * When called, an internal package object has already
431         *  been built and is pointed to by *ObjDesc.
432         *  AcpiDsBuildInternalObject build another internal
433         *  package object, so remove reference to the original
434         *  so that it is deleted.  Error checking is done
435         *  within the remove reference function.
436         */
437        AcpiCmRemoveReference(*ObjDesc);
438
439        Status = AcpiDsBuildInternalObject (WalkState, Op, ObjDesc);
440        break;
441
442    case ACPI_TYPE_INTEGER:
443        (*ObjDesc)->Integer.Value = Op->Value.Integer;
444        break;
445
446
447    case ACPI_TYPE_STRING:
448        (*ObjDesc)->String.Pointer = Op->Value.String;
449        (*ObjDesc)->String.Length = STRLEN (Op->Value.String);
450        break;
451
452
453    case ACPI_TYPE_METHOD:
454        break;
455
456
457    case INTERNAL_TYPE_REFERENCE:
458
459        switch (ACPI_GET_OP_CLASS (OpInfo))
460        {
461        case OPTYPE_LOCAL_VARIABLE:
462
463            /* Split the opcode into a base opcode + offset */
464
465            (*ObjDesc)->Reference.OpCode = AML_LOCAL_OP;
466            (*ObjDesc)->Reference.Offset = Opcode - AML_LOCAL_OP;
467            break;
468
469        case OPTYPE_METHOD_ARGUMENT:
470
471            /* Split the opcode into a base opcode + offset */
472
473            (*ObjDesc)->Reference.OpCode = AML_ARG_OP;
474            (*ObjDesc)->Reference.Offset = Opcode - AML_ARG_OP;
475            break;
476
477        default: /* Constants, Literals, etc.. */
478
479            if (Op->Opcode == AML_NAMEPATH_OP)
480            {
481                /* Node was saved in Op */
482
483                (*ObjDesc)->Reference.Node = Op->Node;
484            }
485
486            (*ObjDesc)->Reference.OpCode = Opcode;
487            break;
488        }
489
490        break;
491
492
493    default:
494
495        DEBUG_PRINT (ACPI_ERROR,
496            ("InitObject: Unimplemented data type: %x\n",
497            (*ObjDesc)->Common.Type));
498
499        break;
500    }
501
502    return (AE_OK);
503}
504
505
506/*****************************************************************************
507 *
508 * FUNCTION:    AcpiDsBuildInternalSimpleObj
509 *
510 * PARAMETERS:  Op              - Parser object to be translated
511 *              ObjDescPtr      - Where the ACPI internal object is returned
512 *
513 * RETURN:      Status
514 *
515 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
516 *              Simple objects are any objects other than a package object!
517 *
518 ****************************************************************************/
519
520static ACPI_STATUS
521AcpiDsBuildInternalSimpleObj (
522    ACPI_WALK_STATE         *WalkState,
523    ACPI_PARSE_OBJECT       *Op,
524    ACPI_OPERAND_OBJECT     **ObjDescPtr)
525{
526    ACPI_OPERAND_OBJECT     *ObjDesc;
527    OBJECT_TYPE_INTERNAL    Type;
528    ACPI_STATUS             Status;
529    UINT32                  Length;
530    char                    *Name;
531
532
533    FUNCTION_TRACE ("DsBuildInternalSimpleObj");
534
535
536    if (Op->Opcode == AML_NAMEPATH_OP)
537    {
538        /*
539         * This is an object reference.  If The name was
540         * previously looked up in the NS, it is stored in this op.
541         * Otherwise, go ahead and look it up now
542         */
543
544        if (!Op->Node)
545        {
546            Status = AcpiNsLookup (WalkState->ScopeInfo,
547                            Op->Value.String, ACPI_TYPE_ANY,
548                            IMODE_EXECUTE,
549                            NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
550                            NULL,
551                            (ACPI_NAMESPACE_NODE **)&(Op->Node));
552
553            if (ACPI_FAILURE (Status))
554            {
555                if (Status == AE_NOT_FOUND)
556                {
557                    Name = NULL;
558                    AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, &Length, &Name);
559
560                    if (Name)
561                    {
562                        REPORT_WARNING (("Reference %s at AML %X not found\n",
563                                    Name, Op->AmlOffset));
564                        AcpiCmFree (Name);
565                    }
566                    else
567                    {
568                        REPORT_WARNING (("Reference %s at AML %X not found\n",
569                                   Op->Value.String, Op->AmlOffset));
570                    }
571                    *ObjDescPtr = NULL;
572                }
573
574                else
575                {
576                    return_ACPI_STATUS (Status);
577                }
578            }
579        }
580
581        /*
582         * The reference will be a Reference
583         * TBD: [Restructure] unless we really need a separate
584         *  type of INTERNAL_TYPE_REFERENCE change
585         *  AcpiDsMapOpcodeToDataType to handle this case
586         */
587        Type = INTERNAL_TYPE_REFERENCE;
588    }
589    else
590    {
591        Type = AcpiDsMapOpcodeToDataType (Op->Opcode, NULL);
592    }
593
594
595    /* Create and init the internal ACPI object */
596
597    ObjDesc = AcpiCmCreateInternalObject (Type);
598    if (!ObjDesc)
599    {
600        return_ACPI_STATUS (AE_NO_MEMORY);
601    }
602
603    Status = AcpiDsInitObjectFromOp (WalkState, Op,
604                                        Op->Opcode, &ObjDesc);
605
606    if (ACPI_FAILURE (Status))
607    {
608        AcpiCmRemoveReference (ObjDesc);
609        return_ACPI_STATUS (Status);
610    }
611
612    *ObjDescPtr = ObjDesc;
613
614    return_ACPI_STATUS (AE_OK);
615}
616
617
618/*****************************************************************************
619 *
620 * FUNCTION:    AcpiDsBuildInternalPackageObj
621 *
622 * PARAMETERS:  Op              - Parser object to be translated
623 *              ObjDescPtr      - Where the ACPI internal object is returned
624 *
625 * RETURN:      Status
626 *
627 * DESCRIPTION: Translate a parser Op package object to the equivalent
628 *              namespace object
629 *
630 ****************************************************************************/
631
632ACPI_STATUS
633AcpiDsBuildInternalPackageObj (
634    ACPI_WALK_STATE         *WalkState,
635    ACPI_PARSE_OBJECT       *Op,
636    ACPI_OPERAND_OBJECT     **ObjDescPtr)
637{
638    ACPI_PARSE_OBJECT       *Arg;
639    ACPI_OPERAND_OBJECT     *ObjDesc;
640    ACPI_STATUS             Status = AE_OK;
641
642
643    FUNCTION_TRACE ("DsBuildInternalPackageObj");
644
645
646    ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE);
647    if (!ObjDesc)
648    {
649        return_ACPI_STATUS (AE_NO_MEMORY);
650    }
651
652    /* The first argument must be the package length */
653
654    Arg = Op->Value.Arg;
655    ObjDesc->Package.Count = Arg->Value.Integer;
656
657    /*
658     * Allocate the array of pointers (ptrs to the
659     * individual objects) Add an extra pointer slot so
660     * that the list is always null terminated.
661     */
662
663    ObjDesc->Package.Elements =
664                AcpiCmCallocate ((ObjDesc->Package.Count + 1) *
665                sizeof (void *));
666
667    if (!ObjDesc->Package.Elements)
668    {
669        /* Package vector allocation failure   */
670
671        REPORT_ERROR (("DsBuildInternalPackageObj: Package vector allocation failure\n"));
672
673        AcpiCmDeleteObjectDesc (ObjDesc);
674        return_ACPI_STATUS (AE_NO_MEMORY);
675    }
676
677    ObjDesc->Package.NextElement = ObjDesc->Package.Elements;
678
679    /*
680     * Now init the elements of the package
681     */
682
683    Arg = Arg->Next;
684    while (Arg)
685    {
686        if (Arg->Opcode == AML_PACKAGE_OP)
687        {
688            Status = AcpiDsBuildInternalPackageObj (WalkState, Arg,
689                                        ObjDesc->Package.NextElement);
690        }
691
692        else
693        {
694            Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg,
695                                        ObjDesc->Package.NextElement);
696        }
697
698        ObjDesc->Package.NextElement++;
699        Arg = Arg->Next;
700    }
701
702    *ObjDescPtr = ObjDesc;
703    return_ACPI_STATUS (Status);
704}
705
706
707/*****************************************************************************
708 *
709 * FUNCTION:    AcpiDsBuildInternalObject
710 *
711 * PARAMETERS:  Op              - Parser object to be translated
712 *              ObjDescPtr      - Where the ACPI internal object is returned
713 *
714 * RETURN:      Status
715 *
716 * DESCRIPTION: Translate a parser Op object to the equivalent namespace
717 *              object
718 *
719 ****************************************************************************/
720
721ACPI_STATUS
722AcpiDsBuildInternalObject (
723    ACPI_WALK_STATE         *WalkState,
724    ACPI_PARSE_OBJECT       *Op,
725    ACPI_OPERAND_OBJECT     **ObjDescPtr)
726{
727    ACPI_STATUS             Status;
728
729
730    if (Op->Opcode == AML_PACKAGE_OP)
731    {
732        Status = AcpiDsBuildInternalPackageObj (WalkState, Op,
733                                                ObjDescPtr);
734    }
735
736    else
737    {
738        Status = AcpiDsBuildInternalSimpleObj (WalkState, Op,
739                                                ObjDescPtr);
740    }
741
742    return (Status);
743}
744
745
746/*****************************************************************************
747 *
748 * FUNCTION:    AcpiDsCreateNode
749 *
750 * PARAMETERS:  Op              - Parser object to be translated
751 *              ObjDescPtr      - Where the ACPI internal object is returned
752 *
753 * RETURN:      Status
754 *
755 * DESCRIPTION:
756 *
757 ****************************************************************************/
758
759ACPI_STATUS
760AcpiDsCreateNode (
761    ACPI_WALK_STATE         *WalkState,
762    ACPI_NAMESPACE_NODE     *Node,
763    ACPI_PARSE_OBJECT       *Op)
764{
765    ACPI_STATUS             Status;
766    ACPI_OPERAND_OBJECT     *ObjDesc;
767
768
769    FUNCTION_TRACE_PTR ("DsCreateNode", Op);
770
771
772    if (!Op->Value.Arg)
773    {
774        /* No arguments, there is nothing to do */
775
776        return_ACPI_STATUS (AE_OK);
777    }
778
779
780    /* Build an internal object for the argument(s) */
781
782    Status = AcpiDsBuildInternalObject (WalkState,
783                                        Op->Value.Arg, &ObjDesc);
784    if (ACPI_FAILURE (Status))
785    {
786        return_ACPI_STATUS (Status);
787    }
788
789
790    /* Re-type the object according to it's argument */
791
792    Node->Type = ObjDesc->Common.Type;
793
794    /* Init obj */
795
796    Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
797                                    (UINT8) Node->Type);
798    if (ACPI_FAILURE (Status))
799    {
800        goto Cleanup;
801    }
802
803    return_ACPI_STATUS (Status);
804
805
806Cleanup:
807
808    AcpiCmRemoveReference (ObjDesc);
809
810    return_ACPI_STATUS (Status);
811}
812
813
814