excreate.c revision 193341
167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: excreate - Named object creation
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
767754Smsmith/******************************************************************************
867754Smsmith *
967754Smsmith * 1. Copyright Notice
1067754Smsmith *
11193267Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
1270243Smsmith * All rights reserved.
1367754Smsmith *
1467754Smsmith * 2. License
1567754Smsmith *
1667754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1767754Smsmith * rights.  You may have additional license terms from the party that provided
1867754Smsmith * you this software, covering your right to use that party's intellectual
1967754Smsmith * property rights.
2067754Smsmith *
2167754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2267754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2367754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2467754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2567754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2667754Smsmith * Code in any form, with the right to sublicense such rights; and
2767754Smsmith *
2867754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
2967754Smsmith * license (with the right to sublicense), under only those claims of Intel
3067754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3167754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3267754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3367754Smsmith * license, and in no event shall the patent license extend to any additions
3467754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3567754Smsmith * is granted directly or by implication, estoppel or otherwise;
3667754Smsmith *
3767754Smsmith * The above copyright and patent license is granted only if the following
3867754Smsmith * conditions are met:
3967754Smsmith *
4067754Smsmith * 3. Conditions
4167754Smsmith *
4267754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4367754Smsmith * Redistribution of source code of any substantial portion of the Covered
4467754Smsmith * Code or modification with rights to further distribute source must include
4567754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4667754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4767754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4867754Smsmith * contain a file documenting the changes Licensee made to create that Covered
4967754Smsmith * Code and the date of any change.  Licensee must include in that file the
5067754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5167754Smsmith * must include a prominent statement that the modification is derived,
5267754Smsmith * directly or indirectly, from Original Intel Code.
5367754Smsmith *
5467754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5567754Smsmith * Redistribution of source code of any substantial portion of the Covered
5667754Smsmith * Code or modification without rights to further distribute source must
5767754Smsmith * include the following Disclaimer and Export Compliance provision in the
5867754Smsmith * documentation and/or other materials provided with distribution.  In
5967754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6067754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6167754Smsmith * license from Licensee to its licensee is limited to the intellectual
6267754Smsmith * property embodied in the software Licensee provides to its licensee, and
6367754Smsmith * not to intellectual property embodied in modifications its licensee may
6467754Smsmith * make.
6567754Smsmith *
6667754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6767754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6867754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
6967754Smsmith * provision in the documentation and/or other materials provided with the
7067754Smsmith * distribution.
7167754Smsmith *
7267754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7367754Smsmith * Intel Code.
7467754Smsmith *
7567754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7667754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7767754Smsmith * other dealings in products derived from or relating to the Covered Code
7867754Smsmith * without prior written authorization from Intel.
7967754Smsmith *
8067754Smsmith * 4. Disclaimer and Export Compliance
8167754Smsmith *
8267754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8367754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8467754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8567754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8667754Smsmith
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11667754Smsmith
11777424Smsmith#define __EXCREATE_C__
11867754Smsmith
119193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
120193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
121193341Sjkim#include <contrib/dev/acpica/include/acinterp.h>
122193341Sjkim#include <contrib/dev/acpica/include/amlcode.h>
123193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
12467754Smsmith
12567754Smsmith
12677424Smsmith#define _COMPONENT          ACPI_EXECUTER
12791116Smsmith        ACPI_MODULE_NAME    ("excreate")
12867754Smsmith
12967754Smsmith
130100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION
131151937Sjkim/*******************************************************************************
13267754Smsmith *
13377424Smsmith * FUNCTION:    AcpiExCreateAlias
13467754Smsmith *
13599679Siwasaki * PARAMETERS:  WalkState            - Current state, contains operands
13667754Smsmith *
13767754Smsmith * RETURN:      Status
13867754Smsmith *
13967754Smsmith * DESCRIPTION: Create a new named alias
14067754Smsmith *
141151937Sjkim ******************************************************************************/
14267754Smsmith
14367754SmsmithACPI_STATUS
14477424SmsmithAcpiExCreateAlias (
14567754Smsmith    ACPI_WALK_STATE         *WalkState)
14667754Smsmith{
147104470Siwasaki    ACPI_NAMESPACE_NODE     *TargetNode;
148104470Siwasaki    ACPI_NAMESPACE_NODE     *AliasNode;
149107325Siwasaki    ACPI_STATUS             Status = AE_OK;
15067754Smsmith
15167754Smsmith
152167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateAlias);
15367754Smsmith
15467754Smsmith
15577424Smsmith    /* Get the source/alias operands (both namespace nodes) */
15667754Smsmith
157104470Siwasaki    AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
158104470Siwasaki    TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
15967754Smsmith
160128212Snjl    if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
161128212Snjl        (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
162104470Siwasaki    {
163114237Snjl        /*
164104470Siwasaki         * Dereference an existing alias so that we don't create a chain
165104470Siwasaki         * of aliases.  With this code, we guarantee that an alias is
166114237Snjl         * always exactly one level of indirection away from the
167104470Siwasaki         * actual aliased name.
168104470Siwasaki         */
169128212Snjl        TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
170104470Siwasaki    }
17167754Smsmith
17267754Smsmith    /*
173104470Siwasaki     * For objects that can never change (i.e., the NS node will
174104470Siwasaki     * permanently point to the same object), we can simply attach
175104470Siwasaki     * the object to the new NS node.  For other objects (such as
176104470Siwasaki     * Integers, buffers, etc.), we have to point the Alias node
177104470Siwasaki     * to the original Node.
17867754Smsmith     */
179104470Siwasaki    switch (TargetNode->Type)
180104470Siwasaki    {
181193267Sjkim
182193267Sjkim    /* For these types, the sub-object can change dynamically via a Store */
183193267Sjkim
184104470Siwasaki    case ACPI_TYPE_INTEGER:
185104470Siwasaki    case ACPI_TYPE_STRING:
186104470Siwasaki    case ACPI_TYPE_BUFFER:
187104470Siwasaki    case ACPI_TYPE_PACKAGE:
188104470Siwasaki    case ACPI_TYPE_BUFFER_FIELD:
18967754Smsmith
190193267Sjkim    /*
191193267Sjkim     * These types open a new scope, so we need the NS node in order to access
192193267Sjkim     * any children.
193193267Sjkim     */
194193267Sjkim    case ACPI_TYPE_DEVICE:
195193267Sjkim    case ACPI_TYPE_POWER:
196193267Sjkim    case ACPI_TYPE_PROCESSOR:
197193267Sjkim    case ACPI_TYPE_THERMAL:
198193267Sjkim    case ACPI_TYPE_LOCAL_SCOPE:
199193267Sjkim
200104470Siwasaki        /*
201104470Siwasaki         * The new alias has the type ALIAS and points to the original
202193267Sjkim         * NS node, not the object itself.
203104470Siwasaki         */
204107325Siwasaki        AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
205107325Siwasaki        AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
206104470Siwasaki        break;
207104470Siwasaki
208128212Snjl    case ACPI_TYPE_METHOD:
209128212Snjl
210128212Snjl        /*
211193267Sjkim         * Control method aliases need to be differentiated
212128212Snjl         */
213128212Snjl        AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
214128212Snjl        AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
215128212Snjl        break;
216128212Snjl
217104470Siwasaki    default:
218104470Siwasaki
219104470Siwasaki        /* Attach the original source object to the new Alias Node */
220104470Siwasaki
221104470Siwasaki        /*
222104470Siwasaki         * The new alias assumes the type of the target, and it points
223104470Siwasaki         * to the same object.  The reference count of the object has an
224104470Siwasaki         * additional reference to prevent deletion out from under either the
225104470Siwasaki         * target node or the alias Node
226104470Siwasaki         */
227104470Siwasaki        Status = AcpiNsAttachObject (AliasNode,
228151937Sjkim                    AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
229104470Siwasaki        break;
230104470Siwasaki    }
231104470Siwasaki
23277424Smsmith    /* Since both operands are Nodes, we don't need to delete them */
23367754Smsmith
234107325Siwasaki    return_ACPI_STATUS (Status);
23567754Smsmith}
23667754Smsmith
23767754Smsmith
238151937Sjkim/*******************************************************************************
23967754Smsmith *
24077424Smsmith * FUNCTION:    AcpiExCreateEvent
24167754Smsmith *
24284491Smsmith * PARAMETERS:  WalkState           - Current state
24367754Smsmith *
24467754Smsmith * RETURN:      Status
24567754Smsmith *
24667754Smsmith * DESCRIPTION: Create a new event object
24767754Smsmith *
248151937Sjkim ******************************************************************************/
24967754Smsmith
25067754SmsmithACPI_STATUS
25177424SmsmithAcpiExCreateEvent (
25267754Smsmith    ACPI_WALK_STATE         *WalkState)
25367754Smsmith{
25467754Smsmith    ACPI_STATUS             Status;
25567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
25667754Smsmith
25767754Smsmith
258167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateEvent);
25967754Smsmith
26067754Smsmith
26177424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
26267754Smsmith    if (!ObjDesc)
26367754Smsmith    {
26467754Smsmith        Status = AE_NO_MEMORY;
26567754Smsmith        goto Cleanup;
26667754Smsmith    }
26767754Smsmith
26891116Smsmith    /*
26987031Smsmith     * Create the actual OS semaphore, with zero initial units -- meaning
27087031Smsmith     * that the event is created in an unsignalled state
27187031Smsmith     */
27287031Smsmith    Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
273167802Sjkim                &ObjDesc->Event.OsSemaphore);
27467754Smsmith    if (ACPI_FAILURE (Status))
27567754Smsmith    {
27667754Smsmith        goto Cleanup;
27767754Smsmith    }
27867754Smsmith
27967754Smsmith    /* Attach object to the Node */
28067754Smsmith
28185756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
282151937Sjkim                ObjDesc, ACPI_TYPE_EVENT);
28367754Smsmith
28467754SmsmithCleanup:
28587031Smsmith    /*
28685756Smsmith     * Remove local reference to the object (on error, will cause deletion
28785756Smsmith     * of both object and semaphore if present.)
28885756Smsmith     */
28985756Smsmith    AcpiUtRemoveReference (ObjDesc);
29067754Smsmith    return_ACPI_STATUS (Status);
29167754Smsmith}
29267754Smsmith
29367754Smsmith
294151937Sjkim/*******************************************************************************
29567754Smsmith *
29677424Smsmith * FUNCTION:    AcpiExCreateMutex
29767754Smsmith *
29884491Smsmith * PARAMETERS:  WalkState           - Current state
29967754Smsmith *
30067754Smsmith * RETURN:      Status
30167754Smsmith *
30267754Smsmith * DESCRIPTION: Create a new mutex object
30367754Smsmith *
30485756Smsmith *              Mutex (Name[0], SyncLevel[1])
30585756Smsmith *
306151937Sjkim ******************************************************************************/
30767754Smsmith
30867754SmsmithACPI_STATUS
30977424SmsmithAcpiExCreateMutex (
31067754Smsmith    ACPI_WALK_STATE         *WalkState)
31167754Smsmith{
31267754Smsmith    ACPI_STATUS             Status = AE_OK;
31367754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
31467754Smsmith
31567754Smsmith
316167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
31767754Smsmith
31867754Smsmith
31985756Smsmith    /* Create the new mutex object */
32067754Smsmith
32177424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
32267754Smsmith    if (!ObjDesc)
32367754Smsmith    {
32467754Smsmith        Status = AE_NO_MEMORY;
32567754Smsmith        goto Cleanup;
32667754Smsmith    }
32767754Smsmith
328167802Sjkim    /* Create the actual OS Mutex */
329167802Sjkim
330167802Sjkim    Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
33167754Smsmith    if (ACPI_FAILURE (Status))
33267754Smsmith    {
33367754Smsmith        goto Cleanup;
33467754Smsmith    }
33567754Smsmith
33685756Smsmith    /* Init object and attach to NS node */
33767754Smsmith
33885756Smsmith    ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
339107325Siwasaki    ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
34067754Smsmith
341167802Sjkim    Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
34267754Smsmith
34367754Smsmith
34467754SmsmithCleanup:
34587031Smsmith    /*
34685756Smsmith     * Remove local reference to the object (on error, will cause deletion
34785756Smsmith     * of both object and semaphore if present.)
34885756Smsmith     */
34985756Smsmith    AcpiUtRemoveReference (ObjDesc);
35067754Smsmith    return_ACPI_STATUS (Status);
35167754Smsmith}
35267754Smsmith
35367754Smsmith
354151937Sjkim/*******************************************************************************
35567754Smsmith *
35677424Smsmith * FUNCTION:    AcpiExCreateRegion
35767754Smsmith *
35884491Smsmith * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
35967754Smsmith *              AmlLength           - Max length of the declaration AML
360151937Sjkim *              RegionSpace         - SpaceID for the region
36184491Smsmith *              WalkState           - Current state
36267754Smsmith *
36367754Smsmith * RETURN:      Status
36467754Smsmith *
36567754Smsmith * DESCRIPTION: Create a new operation region object
36667754Smsmith *
367151937Sjkim ******************************************************************************/
36867754Smsmith
36967754SmsmithACPI_STATUS
37077424SmsmithAcpiExCreateRegion (
37184491Smsmith    UINT8                   *AmlStart,
37267754Smsmith    UINT32                  AmlLength,
37369746Smsmith    UINT8                   RegionSpace,
37467754Smsmith    ACPI_WALK_STATE         *WalkState)
37567754Smsmith{
37667754Smsmith    ACPI_STATUS             Status;
37767754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
37867754Smsmith    ACPI_NAMESPACE_NODE     *Node;
37991116Smsmith    ACPI_OPERAND_OBJECT     *RegionObj2;
38067754Smsmith
38167754Smsmith
382167802Sjkim    ACPI_FUNCTION_TRACE (ExCreateRegion);
38367754Smsmith
38467754Smsmith
385123315Snjl    /* Get the Namespace Node */
38685756Smsmith
38799679Siwasaki    Node = WalkState->Op->Common.Node;
38885756Smsmith
38970243Smsmith    /*
39085756Smsmith     * If the region object is already attached to this node,
39185756Smsmith     * just return
39285756Smsmith     */
39387031Smsmith    if (AcpiNsGetAttachedObject (Node))
39485756Smsmith    {
39585756Smsmith        return_ACPI_STATUS (AE_OK);
39685756Smsmith    }
39785756Smsmith
39885756Smsmith    /*
39970243Smsmith     * Space ID must be one of the predefined IDs, or in the user-defined
40069746Smsmith     * range
40169746Smsmith     */
40287031Smsmith    if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
40387031Smsmith        (RegionSpace < ACPI_USER_REGION_BEGIN))
40467754Smsmith    {
405167802Sjkim        ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace));
40669746Smsmith        return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
40767754Smsmith    }
40867754Smsmith
40982367Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
410151937Sjkim        AcpiUtGetRegionName (RegionSpace), RegionSpace));
41167754Smsmith
41267754Smsmith    /* Create the region descriptor */
41367754Smsmith
41477424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
41567754Smsmith    if (!ObjDesc)
41667754Smsmith    {
41767754Smsmith        Status = AE_NO_MEMORY;
41867754Smsmith        goto Cleanup;
41967754Smsmith    }
42067754Smsmith
42167754Smsmith    /*
42267754Smsmith     * Remember location in AML stream of address & length
42367754Smsmith     * operands since they need to be evaluated at run time.
42467754Smsmith     */
425167802Sjkim    RegionObj2 = ObjDesc->Common.NextObject;
426167802Sjkim    RegionObj2->Extra.AmlStart = AmlStart;
42787031Smsmith    RegionObj2->Extra.AmlLength = AmlLength;
42867754Smsmith
42967754Smsmith    /* Init the region from the operands */
43067754Smsmith
43185756Smsmith    ObjDesc->Region.SpaceId = RegionSpace;
43285756Smsmith    ObjDesc->Region.Address = 0;
433167802Sjkim    ObjDesc->Region.Length = 0;
434167802Sjkim    ObjDesc->Region.Node = Node;
43567754Smsmith
43667754Smsmith    /* Install the new region object in the parent Node */
43767754Smsmith
43891116Smsmith    Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
43967754Smsmith
44067754Smsmith
44167754SmsmithCleanup:
44267754Smsmith
44385756Smsmith    /* Remove local reference to the object */
44467754Smsmith
44585756Smsmith    AcpiUtRemoveReference (ObjDesc);
44667754Smsmith    return_ACPI_STATUS (Status);
44767754Smsmith}
44867754Smsmith
44967754Smsmith
450151937Sjkim/*******************************************************************************
45167754Smsmith *
45277424Smsmith * FUNCTION:    AcpiExCreateProcessor
45367754Smsmith *
45499679Siwasaki * PARAMETERS:  WalkState           - Current state
45567754Smsmith *
45667754Smsmith * RETURN:      Status
45767754Smsmith *
45867754Smsmith * DESCRIPTION: Create a new processor object and populate the fields
45967754Smsmith *
46085756Smsmith *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
46185756Smsmith *
462151937Sjkim ******************************************************************************/
46367754Smsmith
46467754SmsmithACPI_STATUS
46577424SmsmithAcpiExCreateProcessor (
46685756Smsmith    ACPI_WALK_STATE         *WalkState)
46767754Smsmith{
46885756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
46985756Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
47067754Smsmith    ACPI_STATUS             Status;
47167754Smsmith
47267754Smsmith
473167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
47467754Smsmith
47567754Smsmith
47685756Smsmith    /* Create the processor object */
47785756Smsmith
47877424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
47967754Smsmith    if (!ObjDesc)
48067754Smsmith    {
48177424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
48267754Smsmith    }
48367754Smsmith
484151937Sjkim    /* Initialize the processor object from the operands */
485151937Sjkim
486167802Sjkim    ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
487167802Sjkim    ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
48885756Smsmith    ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
48967754Smsmith
49085756Smsmith    /* Install the processor object in the parent Node */
49167754Smsmith
49287031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
49391116Smsmith                    ObjDesc, ACPI_TYPE_PROCESSOR);
49477424Smsmith
49585756Smsmith    /* Remove local reference to the object */
49667754Smsmith
49785756Smsmith    AcpiUtRemoveReference (ObjDesc);
49885756Smsmith    return_ACPI_STATUS (Status);
49967754Smsmith}
50067754Smsmith
50167754Smsmith
502151937Sjkim/*******************************************************************************
50367754Smsmith *
50477424Smsmith * FUNCTION:    AcpiExCreatePowerResource
50567754Smsmith *
50699679Siwasaki * PARAMETERS:  WalkState           - Current state
50767754Smsmith *
50867754Smsmith * RETURN:      Status
50967754Smsmith *
51067754Smsmith * DESCRIPTION: Create a new PowerResource object and populate the fields
51167754Smsmith *
51285756Smsmith *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
51385756Smsmith *
514151937Sjkim ******************************************************************************/
51567754Smsmith
51667754SmsmithACPI_STATUS
51777424SmsmithAcpiExCreatePowerResource (
51885756Smsmith    ACPI_WALK_STATE         *WalkState)
51967754Smsmith{
52085756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
52167754Smsmith    ACPI_STATUS             Status;
52267754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
52367754Smsmith
52467754Smsmith
525167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
52667754Smsmith
52767754Smsmith
52885756Smsmith    /* Create the power resource object */
52985756Smsmith
53077424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
53167754Smsmith    if (!ObjDesc)
53267754Smsmith    {
53377424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
53467754Smsmith    }
53567754Smsmith
53685756Smsmith    /* Initialize the power object from the operands */
53767754Smsmith
538167802Sjkim    ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
53985756Smsmith    ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
54067754Smsmith
54185756Smsmith    /* Install the  power resource object in the parent Node */
54267754Smsmith
54387031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
54491116Smsmith                    ObjDesc, ACPI_TYPE_POWER);
54567754Smsmith
54685756Smsmith    /* Remove local reference to the object */
54767754Smsmith
54885756Smsmith    AcpiUtRemoveReference (ObjDesc);
54985756Smsmith    return_ACPI_STATUS (Status);
55067754Smsmith}
551100966Siwasaki#endif
55267754Smsmith
553151937Sjkim
554151937Sjkim/*******************************************************************************
55567754Smsmith *
55677424Smsmith * FUNCTION:    AcpiExCreateMethod
55767754Smsmith *
55884491Smsmith * PARAMETERS:  AmlStart        - First byte of the method's AML
55967754Smsmith *              AmlLength       - AML byte count for this method
56099679Siwasaki *              WalkState       - Current state
56167754Smsmith *
56267754Smsmith * RETURN:      Status
56367754Smsmith *
56467754Smsmith * DESCRIPTION: Create a new method object
56567754Smsmith *
566151937Sjkim ******************************************************************************/
56767754Smsmith
56867754SmsmithACPI_STATUS
56977424SmsmithAcpiExCreateMethod (
57084491Smsmith    UINT8                   *AmlStart,
57167754Smsmith    UINT32                  AmlLength,
57285756Smsmith    ACPI_WALK_STATE         *WalkState)
57367754Smsmith{
57485756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
57567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
57667754Smsmith    ACPI_STATUS             Status;
57785756Smsmith    UINT8                   MethodFlags;
57867754Smsmith
57967754Smsmith
580167802Sjkim    ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
58167754Smsmith
58267754Smsmith
58367754Smsmith    /* Create a new method object */
58467754Smsmith
58577424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
58667754Smsmith    if (!ObjDesc)
58767754Smsmith    {
588167802Sjkim       Status = AE_NO_MEMORY;
589167802Sjkim       goto Exit;
59067754Smsmith    }
59167754Smsmith
59285756Smsmith    /* Save the method's AML pointer and length  */
59367754Smsmith
594167802Sjkim    ObjDesc->Method.AmlStart = AmlStart;
59584491Smsmith    ObjDesc->Method.AmlLength = AmlLength;
59667754Smsmith
597127175Snjl    /*
598167802Sjkim     * Disassemble the method flags. Split off the Arg Count
599127175Snjl     * for efficiency
600127175Snjl     */
60185756Smsmith    MethodFlags = (UINT8) Operand[1]->Integer.Value;
60285756Smsmith
603127175Snjl    ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT);
604167802Sjkim    ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
60585756Smsmith
60667754Smsmith    /*
607167802Sjkim     * Get the SyncLevel. If method is serialized, a mutex will be
60867754Smsmith     * created for this method when it is parsed.
60967754Smsmith     */
610167802Sjkim    if (MethodFlags & AML_METHOD_SERIALIZED)
61167754Smsmith    {
61277424Smsmith        /*
613167802Sjkim         * ACPI 1.0: SyncLevel = 0
614167802Sjkim         * ACPI 2.0: SyncLevel = SyncLevel in method declaration
61577424Smsmith         */
616167802Sjkim        ObjDesc->Method.SyncLevel = (UINT8)
617193267Sjkim            ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
61867754Smsmith    }
61967754Smsmith
62067754Smsmith    /* Attach the new object to the method Node */
62167754Smsmith
62287031Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
62391116Smsmith                    ObjDesc, ACPI_TYPE_METHOD);
62467754Smsmith
62585756Smsmith    /* Remove local reference to the object */
62685756Smsmith
62785756Smsmith    AcpiUtRemoveReference (ObjDesc);
62885756Smsmith
629167802SjkimExit:
63085756Smsmith    /* Remove a reference to the operand */
63185756Smsmith
63285756Smsmith    AcpiUtRemoveReference (Operand[1]);
63367754Smsmith    return_ACPI_STATUS (Status);
63467754Smsmith}
63567754Smsmith
63667754Smsmith
637