167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: excreate - Named object creation
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
7316303Sjkim/******************************************************************************
8316303Sjkim *
9316303Sjkim * 1. Copyright Notice
10316303Sjkim *
11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
1270243Smsmith * All rights reserved.
1367754Smsmith *
14316303Sjkim * 2. License
15316303Sjkim *
16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property
17316303Sjkim * rights. You may have additional license terms from the party that provided
18316303Sjkim * you this software, covering your right to use that party's intellectual
19316303Sjkim * property rights.
20316303Sjkim *
21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an
23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy,
25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered
26316303Sjkim * Code in any form, with the right to sublicense such rights; and
27316303Sjkim *
28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29316303Sjkim * license (with the right to sublicense), under only those claims of Intel
30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell,
31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof
32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright
33316303Sjkim * license, and in no event shall the patent license extend to any additions
34316303Sjkim * to or modifications of the Original Intel Code. No other license or right
35316303Sjkim * is granted directly or by implication, estoppel or otherwise;
36316303Sjkim *
37316303Sjkim * The above copyright and patent license is granted only if the following
38316303Sjkim * conditions are met:
39316303Sjkim *
40316303Sjkim * 3. Conditions
41316303Sjkim *
42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43316303Sjkim * Redistribution of source code of any substantial portion of the Covered
44316303Sjkim * Code or modification with rights to further distribute source must include
45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions,
46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition,
47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to
48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered
49316303Sjkim * Code and the date of any change. Licensee must include in that file the
50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee
51316303Sjkim * must include a prominent statement that the modification is derived,
52316303Sjkim * directly or indirectly, from Original Intel Code.
53316303Sjkim *
54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55316303Sjkim * Redistribution of source code of any substantial portion of the Covered
56316303Sjkim * Code or modification without rights to further distribute source must
57316303Sjkim * include the following Disclaimer and Export Compliance provision in the
58316303Sjkim * documentation and/or other materials provided with distribution. In
59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any
60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the
61316303Sjkim * license from Licensee to its licensee is limited to the intellectual
62316303Sjkim * property embodied in the software Licensee provides to its licensee, and
63316303Sjkim * not to intellectual property embodied in modifications its licensee may
64316303Sjkim * make.
65316303Sjkim *
66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any
67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the
68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance
69316303Sjkim * provision in the documentation and/or other materials provided with the
70316303Sjkim * distribution.
71316303Sjkim *
72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original
73316303Sjkim * Intel Code.
74316303Sjkim *
75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or
77316303Sjkim * other dealings in products derived from or relating to the Covered Code
78316303Sjkim * without prior written authorization from Intel.
79316303Sjkim *
80316303Sjkim * 4. Disclaimer and Export Compliance
81316303Sjkim *
82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86316303Sjkim
87316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89316303Sjkim * PARTICULAR PURPOSE.
90316303Sjkim *
91316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98316303Sjkim * LIMITED REMEDY.
99316303Sjkim *
100316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this
101316303Sjkim * software or system incorporating such software without first obtaining any
102316303Sjkim * required license or other approval from the U. S. Department of Commerce or
103316303Sjkim * any other agency or department of the United States Government. In the
104316303Sjkim * event Licensee exports any such software from the United States or
105316303Sjkim * re-exports any such software from a foreign destination, Licensee shall
106316303Sjkim * ensure that the distribution and export/re-export of the software is in
107316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the
108316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109316303Sjkim * any of its subsidiaries will export/re-export any technical data, process,
110316303Sjkim * software, or service, directly or indirectly, to any country for which the
111316303Sjkim * United States government or any agency thereof requires an export license,
112316303Sjkim * other governmental approval, or letter of assurance, without first obtaining
113316303Sjkim * such license, approval or letter.
114316303Sjkim *
115316303Sjkim *****************************************************************************
116316303Sjkim *
117316303Sjkim * Alternatively, you may choose to be licensed under the terms of the
118316303Sjkim * following license:
119316303Sjkim *
120217365Sjkim * Redistribution and use in source and binary forms, with or without
121217365Sjkim * modification, are permitted provided that the following conditions
122217365Sjkim * are met:
123217365Sjkim * 1. Redistributions of source code must retain the above copyright
124217365Sjkim *    notice, this list of conditions, and the following disclaimer,
125217365Sjkim *    without modification.
126217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
128217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
129217365Sjkim *    including a substantially similar Disclaimer requirement for further
130217365Sjkim *    binary redistribution.
131217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
132217365Sjkim *    of any contributors may be used to endorse or promote products derived
133217365Sjkim *    from this software without specific prior written permission.
13467754Smsmith *
135316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146316303Sjkim *
147316303Sjkim * Alternatively, you may choose to be licensed under the terms of the
148217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
149217365Sjkim * Software Foundation.
15067754Smsmith *
151316303Sjkim *****************************************************************************/
15267754Smsmith
153193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
154193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
155193341Sjkim#include <contrib/dev/acpica/include/acinterp.h>
156193341Sjkim#include <contrib/dev/acpica/include/amlcode.h>
157193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
15867754Smsmith
15967754Smsmith
16077424Smsmith#define _COMPONENT          ACPI_EXECUTER
16191116Smsmith        ACPI_MODULE_NAME    ("excreate")
16267754Smsmith
16367754Smsmith
164100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION
165151937Sjkim/*******************************************************************************
16667754Smsmith *
16777424Smsmith * FUNCTION:    AcpiExCreateAlias
16867754Smsmith *
16999679Siwasaki * PARAMETERS:  WalkState            - Current state, contains operands
17067754Smsmith *
17167754Smsmith * RETURN:      Status
17267754Smsmith *
17367754Smsmith * DESCRIPTION: Create a new named alias
17467754Smsmith *
175151937Sjkim ******************************************************************************/
17667754Smsmith
17767754SmsmithACPI_STATUS
17877424SmsmithAcpiExCreateAlias (
17967754Smsmith    ACPI_WALK_STATE         *WalkState)
18067754Smsmith{
181104470Siwasaki    ACPI_NAMESPACE_NODE     *TargetNode;
182104470Siwasaki    ACPI_NAMESPACE_NODE     *AliasNode;
183107325Siwasaki    ACPI_STATUS             Status = AE_OK;
18467754Smsmith
18567754Smsmith
186167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateAlias);
18767754Smsmith
18867754Smsmith
18977424Smsmith    /* Get the source/alias operands (both namespace nodes) */
19067754Smsmith
191104470Siwasaki    AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
192104470Siwasaki    TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
19367754Smsmith
194128212Snjl    if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
195128212Snjl        (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
196104470Siwasaki    {
197114237Snjl        /*
198104470Siwasaki         * Dereference an existing alias so that we don't create a chain
199241973Sjkim         * of aliases. With this code, we guarantee that an alias is
200114237Snjl         * always exactly one level of indirection away from the
201104470Siwasaki         * actual aliased name.
202104470Siwasaki         */
203128212Snjl        TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
204104470Siwasaki    }
20567754Smsmith
206322877Sjkim    /* Ensure that the target node is valid */
207322877Sjkim
208322877Sjkim    if (!TargetNode)
209104470Siwasaki    {
210322877Sjkim        return_ACPI_STATUS (AE_NULL_OBJECT);
211322877Sjkim    }
212193267Sjkim
213322877Sjkim    /* Construct the alias object (a namespace node) */
214193267Sjkim
215322877Sjkim    switch (TargetNode->Type)
216322877Sjkim    {
217128212Snjl    case ACPI_TYPE_METHOD:
218128212Snjl        /*
219322877Sjkim         * Control method aliases need to be differentiated with
220322877Sjkim         * a special type
221128212Snjl         */
222128212Snjl        AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
223128212Snjl        break;
224128212Snjl
225104470Siwasaki    default:
226104470Siwasaki        /*
227322877Sjkim         * All other object types.
228322877Sjkim         *
229322877Sjkim         * The new alias has the type ALIAS and points to the original
230322877Sjkim         * NS node, not the object itself.
231104470Siwasaki         */
232322877Sjkim        AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
233322877Sjkim        AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
234104470Siwasaki        break;
235104470Siwasaki    }
236104470Siwasaki
23777424Smsmith    /* Since both operands are Nodes, we don't need to delete them */
23867754Smsmith
239322877Sjkim    AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
240107325Siwasaki    return_ACPI_STATUS (Status);
24167754Smsmith}
24267754Smsmith
24367754Smsmith
244151937Sjkim/*******************************************************************************
24567754Smsmith *
24677424Smsmith * FUNCTION:    AcpiExCreateEvent
24767754Smsmith *
24884491Smsmith * PARAMETERS:  WalkState           - Current state
24967754Smsmith *
25067754Smsmith * RETURN:      Status
25167754Smsmith *
25267754Smsmith * DESCRIPTION: Create a new event object
25367754Smsmith *
254151937Sjkim ******************************************************************************/
25567754Smsmith
25667754SmsmithACPI_STATUS
25777424SmsmithAcpiExCreateEvent (
25867754Smsmith    ACPI_WALK_STATE         *WalkState)
25967754Smsmith{
26067754Smsmith    ACPI_STATUS             Status;
26167754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
26267754Smsmith
26367754Smsmith
264167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateEvent);
26567754Smsmith
26667754Smsmith
26777424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
26867754Smsmith    if (!ObjDesc)
26967754Smsmith    {
27067754Smsmith        Status = AE_NO_MEMORY;
27167754Smsmith        goto Cleanup;
27267754Smsmith    }
27367754Smsmith
27491116Smsmith    /*
27587031Smsmith     * Create the actual OS semaphore, with zero initial units -- meaning
27687031Smsmith     * that the event is created in an unsignalled state
27787031Smsmith     */
27887031Smsmith    Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
279298714Sjkim        &ObjDesc->Event.OsSemaphore);
28067754Smsmith    if (ACPI_FAILURE (Status))
28167754Smsmith    {
28267754Smsmith        goto Cleanup;
28367754Smsmith    }
28467754Smsmith
28567754Smsmith    /* Attach object to the Node */
28667754Smsmith
287298714Sjkim    Status = AcpiNsAttachObject (
288298714Sjkim        (ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
289298714Sjkim        ObjDesc, ACPI_TYPE_EVENT);
29067754Smsmith
29167754SmsmithCleanup:
29287031Smsmith    /*
29385756Smsmith     * Remove local reference to the object (on error, will cause deletion
29485756Smsmith     * of both object and semaphore if present.)
29585756Smsmith     */
29685756Smsmith    AcpiUtRemoveReference (ObjDesc);
29767754Smsmith    return_ACPI_STATUS (Status);
29867754Smsmith}
29967754Smsmith
30067754Smsmith
301151937Sjkim/*******************************************************************************
30267754Smsmith *
30377424Smsmith * FUNCTION:    AcpiExCreateMutex
30467754Smsmith *
30584491Smsmith * PARAMETERS:  WalkState           - Current state
30667754Smsmith *
30767754Smsmith * RETURN:      Status
30867754Smsmith *
30967754Smsmith * DESCRIPTION: Create a new mutex object
31067754Smsmith *
31185756Smsmith *              Mutex (Name[0], SyncLevel[1])
31285756Smsmith *
313151937Sjkim ******************************************************************************/
31467754Smsmith
31567754SmsmithACPI_STATUS
31677424SmsmithAcpiExCreateMutex (
31767754Smsmith    ACPI_WALK_STATE         *WalkState)
31867754Smsmith{
31967754Smsmith    ACPI_STATUS             Status = AE_OK;
32067754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
32167754Smsmith
32267754Smsmith
323167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
32467754Smsmith
32567754Smsmith
32685756Smsmith    /* Create the new mutex object */
32767754Smsmith
32877424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
32967754Smsmith    if (!ObjDesc)
33067754Smsmith    {
33167754Smsmith        Status = AE_NO_MEMORY;
33267754Smsmith        goto Cleanup;
33367754Smsmith    }
33467754Smsmith
335167802Sjkim    /* Create the actual OS Mutex */
336167802Sjkim
337167802Sjkim    Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
33867754Smsmith    if (ACPI_FAILURE (Status))
33967754Smsmith    {
34067754Smsmith        goto Cleanup;
34167754Smsmith    }
34267754Smsmith
34385756Smsmith    /* Init object and attach to NS node */
34467754Smsmith
34585756Smsmith    ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
346107325Siwasaki    ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
34767754Smsmith
348298714Sjkim    Status = AcpiNsAttachObject (
349298714Sjkim        ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
35067754Smsmith
35167754Smsmith
35267754SmsmithCleanup:
35387031Smsmith    /*
35485756Smsmith     * Remove local reference to the object (on error, will cause deletion
35585756Smsmith     * of both object and semaphore if present.)
35685756Smsmith     */
35785756Smsmith    AcpiUtRemoveReference (ObjDesc);
35867754Smsmith    return_ACPI_STATUS (Status);
35967754Smsmith}
36067754Smsmith
36167754Smsmith
362151937Sjkim/*******************************************************************************
36367754Smsmith *
36477424Smsmith * FUNCTION:    AcpiExCreateRegion
36567754Smsmith *
36684491Smsmith * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
36767754Smsmith *              AmlLength           - Max length of the declaration AML
368228110Sjkim *              SpaceId             - Address space ID for the region
36984491Smsmith *              WalkState           - Current state
37067754Smsmith *
37167754Smsmith * RETURN:      Status
37267754Smsmith *
37367754Smsmith * DESCRIPTION: Create a new operation region object
37467754Smsmith *
375151937Sjkim ******************************************************************************/
37667754Smsmith
37767754SmsmithACPI_STATUS
37877424SmsmithAcpiExCreateRegion (
37984491Smsmith    UINT8                   *AmlStart,
38067754Smsmith    UINT32                  AmlLength,
381228110Sjkim    UINT8                   SpaceId,
38267754Smsmith    ACPI_WALK_STATE         *WalkState)
38367754Smsmith{
38467754Smsmith    ACPI_STATUS             Status;
38567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
38667754Smsmith    ACPI_NAMESPACE_NODE     *Node;
38791116Smsmith    ACPI_OPERAND_OBJECT     *RegionObj2;
38867754Smsmith
38967754Smsmith
390167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateRegion);
39167754Smsmith
39267754Smsmith
393123315Snjl    /* Get the Namespace Node */
39485756Smsmith
39599679Siwasaki    Node = WalkState->Op->Common.Node;
39685756Smsmith
39770243Smsmith    /*
39885756Smsmith     * If the region object is already attached to this node,
39985756Smsmith     * just return
40085756Smsmith     */
40187031Smsmith    if (AcpiNsGetAttachedObject (Node))
40285756Smsmith    {
40385756Smsmith        return_ACPI_STATUS (AE_OK);
40485756Smsmith    }
40585756Smsmith
40685756Smsmith    /*
40770243Smsmith     * Space ID must be one of the predefined IDs, or in the user-defined
40869746Smsmith     * range
40969746Smsmith     */
410228110Sjkim    if (!AcpiIsValidSpaceId (SpaceId))
41167754Smsmith    {
412228110Sjkim        /*
413228110Sjkim         * Print an error message, but continue. We don't want to abort
414228110Sjkim         * a table load for this exception. Instead, if the region is
415228110Sjkim         * actually used at runtime, abort the executing method.
416228110Sjkim         */
417298714Sjkim        ACPI_ERROR ((AE_INFO,
418298714Sjkim            "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
41967754Smsmith    }
42067754Smsmith
421204773Sjkim    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
422228110Sjkim        AcpiUtGetRegionName (SpaceId), SpaceId));
42367754Smsmith
42467754Smsmith    /* Create the region descriptor */
42567754Smsmith
42677424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
42767754Smsmith    if (!ObjDesc)
42867754Smsmith    {
42967754Smsmith        Status = AE_NO_MEMORY;
43067754Smsmith        goto Cleanup;
43167754Smsmith    }
43267754Smsmith
43367754Smsmith    /*
43467754Smsmith     * Remember location in AML stream of address & length
43567754Smsmith     * operands since they need to be evaluated at run time.
43667754Smsmith     */
437298714Sjkim    RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
438167802Sjkim    RegionObj2->Extra.AmlStart = AmlStart;
43987031Smsmith    RegionObj2->Extra.AmlLength = AmlLength;
440298714Sjkim    RegionObj2->Extra.Method_REG = NULL;
441228110Sjkim    if (WalkState->ScopeInfo)
442228110Sjkim    {
443228110Sjkim        RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
444228110Sjkim    }
445228110Sjkim    else
446228110Sjkim    {
447228110Sjkim        RegionObj2->Extra.ScopeNode = Node;
448228110Sjkim    }
44967754Smsmith
45067754Smsmith    /* Init the region from the operands */
45167754Smsmith
452228110Sjkim    ObjDesc->Region.SpaceId = SpaceId;
45385756Smsmith    ObjDesc->Region.Address = 0;
454167802Sjkim    ObjDesc->Region.Length = 0;
455167802Sjkim    ObjDesc->Region.Node = Node;
456298714Sjkim    ObjDesc->Region.Handler = NULL;
457298714Sjkim    ObjDesc->Common.Flags &=
458298714Sjkim        ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
459298714Sjkim          AOPOBJ_OBJECT_INITIALIZED);
46067754Smsmith
46167754Smsmith    /* Install the new region object in the parent Node */
46267754Smsmith
46391116Smsmith    Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
46467754Smsmith
46567754Smsmith
46667754SmsmithCleanup:
46767754Smsmith
46885756Smsmith    /* Remove local reference to the object */
46967754Smsmith
47085756Smsmith    AcpiUtRemoveReference (ObjDesc);
47167754Smsmith    return_ACPI_STATUS (Status);
47267754Smsmith}
47367754Smsmith
47467754Smsmith
475151937Sjkim/*******************************************************************************
47667754Smsmith *
47777424Smsmith * FUNCTION:    AcpiExCreateProcessor
47867754Smsmith *
47999679Siwasaki * PARAMETERS:  WalkState           - Current state
48067754Smsmith *
48167754Smsmith * RETURN:      Status
48267754Smsmith *
48367754Smsmith * DESCRIPTION: Create a new processor object and populate the fields
48467754Smsmith *
48585756Smsmith *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
48685756Smsmith *
487151937Sjkim ******************************************************************************/
48867754Smsmith
48967754SmsmithACPI_STATUS
49077424SmsmithAcpiExCreateProcessor (
49185756Smsmith    ACPI_WALK_STATE         *WalkState)
49267754Smsmith{
49385756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
49485756Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
49567754Smsmith    ACPI_STATUS             Status;
49667754Smsmith
49767754Smsmith
498167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
49967754Smsmith
50067754Smsmith
50185756Smsmith    /* Create the processor object */
50285756Smsmith
50377424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
50467754Smsmith    if (!ObjDesc)
50567754Smsmith    {
50677424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
50767754Smsmith    }
50867754Smsmith
509151937Sjkim    /* Initialize the processor object from the operands */
510151937Sjkim
511167802Sjkim    ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
512167802Sjkim    ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
51385756Smsmith    ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
51467754Smsmith
51585756Smsmith    /* Install the processor object in the parent Node */
51667754Smsmith
51787031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
518298714Sjkim        ObjDesc, ACPI_TYPE_PROCESSOR);
51977424Smsmith
52085756Smsmith    /* Remove local reference to the object */
52167754Smsmith
52285756Smsmith    AcpiUtRemoveReference (ObjDesc);
52385756Smsmith    return_ACPI_STATUS (Status);
52467754Smsmith}
52567754Smsmith
52667754Smsmith
527151937Sjkim/*******************************************************************************
52867754Smsmith *
52977424Smsmith * FUNCTION:    AcpiExCreatePowerResource
53067754Smsmith *
53199679Siwasaki * PARAMETERS:  WalkState           - Current state
53267754Smsmith *
53367754Smsmith * RETURN:      Status
53467754Smsmith *
53567754Smsmith * DESCRIPTION: Create a new PowerResource object and populate the fields
53667754Smsmith *
53785756Smsmith *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
53885756Smsmith *
539151937Sjkim ******************************************************************************/
54067754Smsmith
54167754SmsmithACPI_STATUS
54277424SmsmithAcpiExCreatePowerResource (
54385756Smsmith    ACPI_WALK_STATE         *WalkState)
54467754Smsmith{
54585756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
54667754Smsmith    ACPI_STATUS             Status;
54767754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
54867754Smsmith
54967754Smsmith
550167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
55167754Smsmith
55267754Smsmith
55385756Smsmith    /* Create the power resource object */
55485756Smsmith
55577424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
55667754Smsmith    if (!ObjDesc)
55767754Smsmith    {
55877424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
55967754Smsmith    }
56067754Smsmith
56185756Smsmith    /* Initialize the power object from the operands */
56267754Smsmith
563167802Sjkim    ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
56485756Smsmith    ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
56567754Smsmith
56685756Smsmith    /* Install the  power resource object in the parent Node */
56767754Smsmith
56887031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
569298714Sjkim        ObjDesc, ACPI_TYPE_POWER);
57067754Smsmith
57185756Smsmith    /* Remove local reference to the object */
57267754Smsmith
57385756Smsmith    AcpiUtRemoveReference (ObjDesc);
57485756Smsmith    return_ACPI_STATUS (Status);
57567754Smsmith}
576100966Siwasaki#endif
57767754Smsmith
578151937Sjkim
579151937Sjkim/*******************************************************************************
58067754Smsmith *
58177424Smsmith * FUNCTION:    AcpiExCreateMethod
58267754Smsmith *
58384491Smsmith * PARAMETERS:  AmlStart        - First byte of the method's AML
58467754Smsmith *              AmlLength       - AML byte count for this method
58599679Siwasaki *              WalkState       - Current state
58667754Smsmith *
58767754Smsmith * RETURN:      Status
58867754Smsmith *
58967754Smsmith * DESCRIPTION: Create a new method object
59067754Smsmith *
591151937Sjkim ******************************************************************************/
59267754Smsmith
59367754SmsmithACPI_STATUS
59477424SmsmithAcpiExCreateMethod (
59584491Smsmith    UINT8                   *AmlStart,
59667754Smsmith    UINT32                  AmlLength,
59785756Smsmith    ACPI_WALK_STATE         *WalkState)
59867754Smsmith{
59985756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
60067754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
60167754Smsmith    ACPI_STATUS             Status;
60285756Smsmith    UINT8                   MethodFlags;
60367754Smsmith
60467754Smsmith
605167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
60667754Smsmith
60767754Smsmith
60867754Smsmith    /* Create a new method object */
60967754Smsmith
61077424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
61167754Smsmith    if (!ObjDesc)
61267754Smsmith    {
613167802Sjkim       Status = AE_NO_MEMORY;
614167802Sjkim       goto Exit;
61567754Smsmith    }
61667754Smsmith
61785756Smsmith    /* Save the method's AML pointer and length  */
61867754Smsmith
619167802Sjkim    ObjDesc->Method.AmlStart = AmlStart;
62084491Smsmith    ObjDesc->Method.AmlLength = AmlLength;
621285797Sjkim    ObjDesc->Method.Node = Operand[0];
62267754Smsmith
623127175Snjl    /*
624217365Sjkim     * Disassemble the method flags. Split off the ArgCount, Serialized
625217365Sjkim     * flag, and SyncLevel for efficiency.
626127175Snjl     */
62785756Smsmith    MethodFlags = (UINT8) Operand[1]->Integer.Value;
628298714Sjkim    ObjDesc->Method.ParamCount = (UINT8)
629298714Sjkim        (MethodFlags & AML_METHOD_ARG_COUNT);
63085756Smsmith
63167754Smsmith    /*
632167802Sjkim     * Get the SyncLevel. If method is serialized, a mutex will be
63367754Smsmith     * created for this method when it is parsed.
63467754Smsmith     */
635167802Sjkim    if (MethodFlags & AML_METHOD_SERIALIZED)
63667754Smsmith    {
637217365Sjkim        ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
638217365Sjkim
63977424Smsmith        /*
640167802Sjkim         * ACPI 1.0: SyncLevel = 0
641167802Sjkim         * ACPI 2.0: SyncLevel = SyncLevel in method declaration
64277424Smsmith         */
643167802Sjkim        ObjDesc->Method.SyncLevel = (UINT8)
644193267Sjkim            ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
64567754Smsmith    }
64667754Smsmith
64767754Smsmith    /* Attach the new object to the method Node */
64867754Smsmith
64987031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
650298714Sjkim        ObjDesc, ACPI_TYPE_METHOD);
65167754Smsmith
65285756Smsmith    /* Remove local reference to the object */
65385756Smsmith
65485756Smsmith    AcpiUtRemoveReference (ObjDesc);
65585756Smsmith
656167802SjkimExit:
65785756Smsmith    /* Remove a reference to the operand */
65885756Smsmith
65985756Smsmith    AcpiUtRemoveReference (Operand[1]);
66067754Smsmith    return_ACPI_STATUS (Status);
66167754Smsmith}
662