excreate.c revision 85756
167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: excreate - Named object creation
485756Smsmith *              $Revision: 71 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
1271867Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
1370243Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial portion of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith
8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9067754Smsmith * PARTICULAR PURPOSE.
9167754Smsmith *
9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9967754Smsmith * LIMITED REMEDY.
10067754Smsmith *
10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10267754Smsmith * software or system incorporating such software without first obtaining any
10367754Smsmith * required license or other approval from the U. S. Department of Commerce or
10467754Smsmith * any other agency or department of the United States Government.  In the
10567754Smsmith * event Licensee exports any such software from the United States or
10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10767754Smsmith * ensure that the distribution and export/re-export of the software is in
10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11167754Smsmith * software, or service, directly or indirectly, to any country for which the
11267754Smsmith * United States government or any agency thereof requires an export license,
11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11467754Smsmith * such license, approval or letter.
11567754Smsmith *
11667754Smsmith *****************************************************************************/
11767754Smsmith
11877424Smsmith#define __EXCREATE_C__
11967754Smsmith
12067754Smsmith#include "acpi.h"
12167754Smsmith#include "acparser.h"
12267754Smsmith#include "acinterp.h"
12367754Smsmith#include "amlcode.h"
12467754Smsmith#include "acnamesp.h"
12567754Smsmith#include "acevents.h"
12667754Smsmith#include "acdispat.h"
12767754Smsmith
12867754Smsmith
12977424Smsmith#define _COMPONENT          ACPI_EXECUTER
13077424Smsmith        MODULE_NAME         ("excreate")
13167754Smsmith
13267754Smsmith
13367754Smsmith
13467754Smsmith/*****************************************************************************
13567754Smsmith *
13677424Smsmith * FUNCTION:    AcpiExCreateAlias
13767754Smsmith *
13877424Smsmith * PARAMETERS:  WalkState            - Current state, contains List of
13977424Smsmith *                                      operands for the opcode
14067754Smsmith *
14167754Smsmith * RETURN:      Status
14267754Smsmith *
14367754Smsmith * DESCRIPTION: Create a new named alias
14467754Smsmith *
14567754Smsmith ****************************************************************************/
14667754Smsmith
14767754SmsmithACPI_STATUS
14877424SmsmithAcpiExCreateAlias (
14967754Smsmith    ACPI_WALK_STATE         *WalkState)
15067754Smsmith{
15167754Smsmith    ACPI_NAMESPACE_NODE     *SourceNode;
15267754Smsmith    ACPI_STATUS             Status;
15367754Smsmith
15467754Smsmith
15577424Smsmith    FUNCTION_TRACE ("ExCreateAlias");
15667754Smsmith
15767754Smsmith
15877424Smsmith    /* Get the source/alias operands (both namespace nodes) */
15967754Smsmith
16085756Smsmith    SourceNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
16167754Smsmith
16267754Smsmith
16385756Smsmith    /* Attach the original source object to the new Alias Node */
16467754Smsmith
16585756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
16685756Smsmith                                    SourceNode->Object,
16767754Smsmith                                    SourceNode->Type);
16867754Smsmith
16967754Smsmith    /*
17067754Smsmith     * The new alias assumes the type of the source, but it points
17185756Smsmith     * to the same object.  The reference count of the object has an
17285756Smsmith     * additional reference to prevent deletion out from under either the
17367754Smsmith     * source or the alias Node
17467754Smsmith     */
17567754Smsmith
17677424Smsmith    /* Since both operands are Nodes, we don't need to delete them */
17767754Smsmith
17867754Smsmith    return_ACPI_STATUS (Status);
17967754Smsmith}
18067754Smsmith
18167754Smsmith
18267754Smsmith/*****************************************************************************
18367754Smsmith *
18477424Smsmith * FUNCTION:    AcpiExCreateEvent
18567754Smsmith *
18684491Smsmith * PARAMETERS:  WalkState           - Current state
18767754Smsmith *
18867754Smsmith * RETURN:      Status
18967754Smsmith *
19067754Smsmith * DESCRIPTION: Create a new event object
19167754Smsmith *
19267754Smsmith ****************************************************************************/
19367754Smsmith
19467754SmsmithACPI_STATUS
19577424SmsmithAcpiExCreateEvent (
19667754Smsmith    ACPI_WALK_STATE         *WalkState)
19767754Smsmith{
19867754Smsmith    ACPI_STATUS             Status;
19967754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
20067754Smsmith
20167754Smsmith
20277424Smsmith    FUNCTION_TRACE ("ExCreateEvent");
20367754Smsmith
20467754Smsmith
20577424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
20667754Smsmith    if (!ObjDesc)
20767754Smsmith    {
20867754Smsmith        Status = AE_NO_MEMORY;
20967754Smsmith        goto Cleanup;
21067754Smsmith    }
21167754Smsmith
21267754Smsmith    /* Create the actual OS semaphore */
21367754Smsmith
21467754Smsmith    /* TBD: [Investigate] should be created with 0 or 1 units? */
21567754Smsmith
21667754Smsmith    Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1,
21767754Smsmith                                    &ObjDesc->Event.Semaphore);
21867754Smsmith    if (ACPI_FAILURE (Status))
21967754Smsmith    {
22067754Smsmith        goto Cleanup;
22167754Smsmith    }
22267754Smsmith
22367754Smsmith    /* Attach object to the Node */
22467754Smsmith
22585756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
22667754Smsmith                                    ObjDesc, (UINT8) ACPI_TYPE_EVENT);
22767754Smsmith
22867754SmsmithCleanup:
22985756Smsmith    /*
23085756Smsmith     * Remove local reference to the object (on error, will cause deletion
23185756Smsmith     * of both object and semaphore if present.)
23285756Smsmith     */
23385756Smsmith    AcpiUtRemoveReference (ObjDesc);
23467754Smsmith    return_ACPI_STATUS (Status);
23567754Smsmith}
23667754Smsmith
23767754Smsmith
23867754Smsmith/*****************************************************************************
23967754Smsmith *
24077424Smsmith * FUNCTION:    AcpiExCreateMutex
24167754Smsmith *
24284491Smsmith * PARAMETERS:  WalkState           - Current state
24367754Smsmith *
24467754Smsmith * RETURN:      Status
24567754Smsmith *
24667754Smsmith * DESCRIPTION: Create a new mutex object
24767754Smsmith *
24885756Smsmith *              Mutex (Name[0], SyncLevel[1])
24985756Smsmith *
25067754Smsmith ****************************************************************************/
25167754Smsmith
25267754SmsmithACPI_STATUS
25377424SmsmithAcpiExCreateMutex (
25467754Smsmith    ACPI_WALK_STATE         *WalkState)
25567754Smsmith{
25667754Smsmith    ACPI_STATUS             Status = AE_OK;
25767754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
25867754Smsmith
25967754Smsmith
26077424Smsmith    FUNCTION_TRACE_PTR ("ExCreateMutex", WALK_OPERANDS);
26167754Smsmith
26267754Smsmith
26385756Smsmith    /* Create the new mutex object */
26467754Smsmith
26577424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
26667754Smsmith    if (!ObjDesc)
26767754Smsmith    {
26867754Smsmith        Status = AE_NO_MEMORY;
26967754Smsmith        goto Cleanup;
27067754Smsmith    }
27167754Smsmith
27267754Smsmith    /* Create the actual OS semaphore */
27367754Smsmith
27467754Smsmith    Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore);
27567754Smsmith    if (ACPI_FAILURE (Status))
27667754Smsmith    {
27767754Smsmith        goto Cleanup;
27867754Smsmith    }
27967754Smsmith
28085756Smsmith    /* Init object and attach to NS node */
28167754Smsmith
28285756Smsmith    ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
28367754Smsmith
28485756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
28567754Smsmith                                ObjDesc, (UINT8) ACPI_TYPE_MUTEX);
28667754Smsmith
28767754Smsmith
28867754SmsmithCleanup:
28985756Smsmith    /*
29085756Smsmith     * Remove local reference to the object (on error, will cause deletion
29185756Smsmith     * of both object and semaphore if present.)
29285756Smsmith     */
29385756Smsmith    AcpiUtRemoveReference (ObjDesc);
29467754Smsmith    return_ACPI_STATUS (Status);
29567754Smsmith}
29667754Smsmith
29767754Smsmith
29867754Smsmith/*****************************************************************************
29967754Smsmith *
30077424Smsmith * FUNCTION:    AcpiExCreateRegion
30167754Smsmith *
30284491Smsmith * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
30367754Smsmith *              AmlLength           - Max length of the declaration AML
30467754Smsmith *              Operands            - List of operands for the opcode
30584491Smsmith *              WalkState           - Current state
30667754Smsmith *
30767754Smsmith * RETURN:      Status
30867754Smsmith *
30967754Smsmith * DESCRIPTION: Create a new operation region object
31067754Smsmith *
31167754Smsmith ****************************************************************************/
31267754Smsmith
31367754SmsmithACPI_STATUS
31477424SmsmithAcpiExCreateRegion (
31584491Smsmith    UINT8                   *AmlStart,
31667754Smsmith    UINT32                  AmlLength,
31769746Smsmith    UINT8                   RegionSpace,
31867754Smsmith    ACPI_WALK_STATE         *WalkState)
31967754Smsmith{
32067754Smsmith    ACPI_STATUS             Status;
32167754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
32267754Smsmith    ACPI_NAMESPACE_NODE     *Node;
32367754Smsmith
32467754Smsmith
32577424Smsmith    FUNCTION_TRACE ("ExCreateRegion");
32667754Smsmith
32767754Smsmith
32885756Smsmith    /* Get the Node from the object stack  */
32985756Smsmith
33085756Smsmith    Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
33185756Smsmith
33270243Smsmith    /*
33385756Smsmith     * If the region object is already attached to this node,
33485756Smsmith     * just return
33585756Smsmith     */
33685756Smsmith    if (Node->Object)
33785756Smsmith    {
33885756Smsmith        return_ACPI_STATUS (AE_OK);
33985756Smsmith    }
34085756Smsmith
34185756Smsmith    /*
34270243Smsmith     * Space ID must be one of the predefined IDs, or in the user-defined
34369746Smsmith     * range
34469746Smsmith     */
34569746Smsmith    if ((RegionSpace >= NUM_REGION_TYPES) &&
34669746Smsmith        (RegionSpace < USER_REGION_BEGIN))
34767754Smsmith    {
34869746Smsmith        REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace));
34969746Smsmith        return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
35067754Smsmith    }
35167754Smsmith
35282367Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
35377424Smsmith                    AcpiUtGetRegionName (RegionSpace), RegionSpace));
35467754Smsmith
35567754Smsmith
35667754Smsmith    /* Create the region descriptor */
35767754Smsmith
35877424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
35967754Smsmith    if (!ObjDesc)
36067754Smsmith    {
36167754Smsmith        Status = AE_NO_MEMORY;
36267754Smsmith        goto Cleanup;
36367754Smsmith    }
36467754Smsmith
36585756Smsmith    /* Allocate a method object for this region */
36685756Smsmith
36777424Smsmith    ObjDesc->Region.Extra =  AcpiUtCreateInternalObject (
36867754Smsmith                                        INTERNAL_TYPE_EXTRA);
36967754Smsmith    if (!ObjDesc->Region.Extra)
37067754Smsmith    {
37167754Smsmith        Status = AE_NO_MEMORY;
37267754Smsmith        goto Cleanup;
37367754Smsmith    }
37467754Smsmith
37567754Smsmith    /*
37667754Smsmith     * Remember location in AML stream of address & length
37767754Smsmith     * operands since they need to be evaluated at run time.
37867754Smsmith     */
37984491Smsmith    ObjDesc->Region.Extra->Extra.AmlStart  = AmlStart;
38084491Smsmith    ObjDesc->Region.Extra->Extra.AmlLength = AmlLength;
38167754Smsmith
38267754Smsmith    /* Init the region from the operands */
38367754Smsmith
38485756Smsmith    ObjDesc->Region.SpaceId = RegionSpace;
38585756Smsmith    ObjDesc->Region.Address = 0;
38685756Smsmith    ObjDesc->Region.Length  = 0;
38785756Smsmith    ObjDesc->Region.Node    = Node;
38867754Smsmith
38967754Smsmith    /* Install the new region object in the parent Node */
39067754Smsmith
39167754Smsmith    Status = AcpiNsAttachObject (Node, ObjDesc,
39267754Smsmith                                (UINT8) ACPI_TYPE_REGION);
39367754Smsmith    if (ACPI_FAILURE (Status))
39467754Smsmith    {
39567754Smsmith        goto Cleanup;
39667754Smsmith    }
39767754Smsmith
39867754Smsmith    /*
39967754Smsmith     * If we have a valid region, initialize it
40067754Smsmith     * Namespace is NOT locked at this point.
40167754Smsmith     */
40267754Smsmith    Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
40367754Smsmith    if (ACPI_FAILURE (Status))
40467754Smsmith    {
40567754Smsmith        /*
40667754Smsmith         *  If AE_NOT_EXIST is returned, it is not fatal
40767754Smsmith         *  because many regions get created before a handler
40867754Smsmith         *  is installed for said region.
40967754Smsmith         */
41067754Smsmith        if (AE_NOT_EXIST == Status)
41167754Smsmith        {
41267754Smsmith            Status = AE_OK;
41367754Smsmith        }
41467754Smsmith    }
41567754Smsmith
41667754SmsmithCleanup:
41767754Smsmith
41885756Smsmith    /* Remove local reference to the object */
41967754Smsmith
42085756Smsmith    AcpiUtRemoveReference (ObjDesc);
42167754Smsmith
42267754Smsmith    return_ACPI_STATUS (Status);
42367754Smsmith}
42467754Smsmith
42567754Smsmith
42667754Smsmith/*****************************************************************************
42767754Smsmith *
42884491Smsmith * FUNCTION:    AcpiExCreateTableRegion
42984491Smsmith *
43084491Smsmith * PARAMETERS:  WalkState           - Current state
43184491Smsmith *
43284491Smsmith * RETURN:      Status
43384491Smsmith *
43484491Smsmith * DESCRIPTION: Create a new DataTableRegion object
43584491Smsmith *
43684491Smsmith ****************************************************************************/
43784491Smsmith
43884491SmsmithACPI_STATUS
43984491SmsmithAcpiExCreateTableRegion (
44084491Smsmith    ACPI_WALK_STATE         *WalkState)
44184491Smsmith{
44284491Smsmith    ACPI_STATUS             Status = AE_OK;
44384491Smsmith
44484491Smsmith
44584491Smsmith    FUNCTION_TRACE ("ExCreateTableRegion");
44684491Smsmith
44784491Smsmith/*
44884491Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
44984491Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
45084491Smsmith    if (!ObjDesc)
45184491Smsmith    {
45284491Smsmith        Status = AE_NO_MEMORY;
45384491Smsmith        goto Cleanup;
45484491Smsmith    }
45584491Smsmith
45684491Smsmith
45784491SmsmithCleanup:
45884491Smsmith*/
45984491Smsmith
46084491Smsmith    return_ACPI_STATUS (Status);
46184491Smsmith}
46284491Smsmith
46384491Smsmith
46484491Smsmith/*****************************************************************************
46584491Smsmith *
46677424Smsmith * FUNCTION:    AcpiExCreateProcessor
46767754Smsmith *
46867754Smsmith * PARAMETERS:  Op              - Op containing the Processor definition and
46967754Smsmith *                                args
47077424Smsmith *              ProcessorNode   - Parent Node for the processor object
47167754Smsmith *
47267754Smsmith * RETURN:      Status
47367754Smsmith *
47467754Smsmith * DESCRIPTION: Create a new processor object and populate the fields
47567754Smsmith *
47685756Smsmith *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
47785756Smsmith *
47867754Smsmith ****************************************************************************/
47967754Smsmith
48067754SmsmithACPI_STATUS
48177424SmsmithAcpiExCreateProcessor (
48285756Smsmith    ACPI_WALK_STATE         *WalkState)
48367754Smsmith{
48485756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
48585756Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
48667754Smsmith    ACPI_STATUS             Status;
48767754Smsmith
48867754Smsmith
48985756Smsmith    FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState);
49067754Smsmith
49167754Smsmith
49285756Smsmith    /* Create the processor object */
49385756Smsmith
49477424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
49567754Smsmith    if (!ObjDesc)
49667754Smsmith    {
49777424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
49867754Smsmith    }
49967754Smsmith
50085756Smsmith    /*
50185756Smsmith     * Initialize the processor object from the operands
50285756Smsmith     */
50385756Smsmith    ObjDesc->Processor.ProcId  = (UINT8)           Operand[1]->Integer.Value;
50485756Smsmith    ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
50585756Smsmith    ObjDesc->Processor.Length  = (UINT8)           Operand[3]->Integer.Value;
50667754Smsmith
50785756Smsmith    /* Install the processor object in the parent Node */
50867754Smsmith
50985756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
51085756Smsmith                    ObjDesc, (UINT8) ACPI_TYPE_PROCESSOR);
51177424Smsmith
51267754Smsmith
51385756Smsmith    /* Remove local reference to the object */
51467754Smsmith
51585756Smsmith    AcpiUtRemoveReference (ObjDesc);
51685756Smsmith    return_ACPI_STATUS (Status);
51767754Smsmith}
51867754Smsmith
51967754Smsmith
52067754Smsmith/*****************************************************************************
52167754Smsmith *
52277424Smsmith * FUNCTION:    AcpiExCreatePowerResource
52367754Smsmith *
52467754Smsmith * PARAMETERS:  Op              - Op containing the PowerResource definition
52567754Smsmith *                                and args
52677424Smsmith *              PowerNode       - Parent Node for the power object
52767754Smsmith *
52867754Smsmith * RETURN:      Status
52967754Smsmith *
53067754Smsmith * DESCRIPTION: Create a new PowerResource object and populate the fields
53167754Smsmith *
53285756Smsmith *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
53385756Smsmith *
53467754Smsmith ****************************************************************************/
53567754Smsmith
53667754SmsmithACPI_STATUS
53777424SmsmithAcpiExCreatePowerResource (
53885756Smsmith    ACPI_WALK_STATE         *WalkState)
53967754Smsmith{
54085756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
54167754Smsmith    ACPI_STATUS             Status;
54267754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
54367754Smsmith
54467754Smsmith
54585756Smsmith    FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState);
54667754Smsmith
54767754Smsmith
54885756Smsmith    /* Create the power resource object */
54985756Smsmith
55077424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
55167754Smsmith    if (!ObjDesc)
55267754Smsmith    {
55377424Smsmith        return_ACPI_STATUS (AE_NO_MEMORY);
55467754Smsmith    }
55567754Smsmith
55685756Smsmith    /* Initialize the power object from the operands */
55767754Smsmith
55885756Smsmith    ObjDesc->PowerResource.SystemLevel   = (UINT8)  Operand[1]->Integer.Value;
55985756Smsmith    ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
56067754Smsmith
56185756Smsmith    /* Install the  power resource object in the parent Node */
56267754Smsmith
56385756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
56485756Smsmith                    ObjDesc, (UINT8) ACPI_TYPE_POWER);
56567754Smsmith
56667754Smsmith
56785756Smsmith    /* Remove local reference to the object */
56867754Smsmith
56985756Smsmith    AcpiUtRemoveReference (ObjDesc);
57085756Smsmith    return_ACPI_STATUS (Status);
57167754Smsmith}
57267754Smsmith
57367754Smsmith
57467754Smsmith/*****************************************************************************
57567754Smsmith *
57677424Smsmith * FUNCTION:    AcpiExCreateMethod
57767754Smsmith *
57884491Smsmith * PARAMETERS:  AmlStart        - First byte of the method's AML
57967754Smsmith *              AmlLength       - AML byte count for this method
58067754Smsmith *              MethodFlags     - AML method flag byte
58167754Smsmith *              Method          - Method Node
58267754Smsmith *
58367754Smsmith * RETURN:      Status
58467754Smsmith *
58567754Smsmith * DESCRIPTION: Create a new method object
58667754Smsmith *
58767754Smsmith ****************************************************************************/
58867754Smsmith
58967754SmsmithACPI_STATUS
59077424SmsmithAcpiExCreateMethod (
59184491Smsmith    UINT8                   *AmlStart,
59267754Smsmith    UINT32                  AmlLength,
59385756Smsmith    ACPI_WALK_STATE         *WalkState)
59467754Smsmith{
59585756Smsmith    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
59667754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
59767754Smsmith    ACPI_STATUS             Status;
59885756Smsmith    UINT8                   MethodFlags;
59967754Smsmith
60067754Smsmith
60185756Smsmith    FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState);
60267754Smsmith
60367754Smsmith
60467754Smsmith    /* Create a new method object */
60567754Smsmith
60677424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
60767754Smsmith    if (!ObjDesc)
60867754Smsmith    {
60967754Smsmith       return_ACPI_STATUS (AE_NO_MEMORY);
61067754Smsmith    }
61167754Smsmith
61285756Smsmith    /* Save the method's AML pointer and length  */
61367754Smsmith
61484491Smsmith    ObjDesc->Method.AmlStart  = AmlStart;
61584491Smsmith    ObjDesc->Method.AmlLength = AmlLength;
61667754Smsmith
61785756Smsmith    /* disassemble the method flags */
61867754Smsmith
61985756Smsmith    MethodFlags = (UINT8) Operand[1]->Integer.Value;
62085756Smsmith
62185756Smsmith    ObjDesc->Method.MethodFlags = MethodFlags;
62285756Smsmith    ObjDesc->Method.ParamCount  = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT);
62385756Smsmith
62467754Smsmith    /*
62567754Smsmith     * Get the concurrency count.  If required, a semaphore will be
62667754Smsmith     * created for this method when it is parsed.
62767754Smsmith     */
62867754Smsmith    if (MethodFlags & METHOD_FLAGS_SERIALIZED)
62967754Smsmith    {
63077424Smsmith        /*
63177424Smsmith         * ACPI 1.0: Concurrency = 1
63277424Smsmith         * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1)
63377424Smsmith         */
63477424Smsmith        ObjDesc->Method.Concurrency = (UINT8)
63577424Smsmith                        (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1);
63667754Smsmith    }
63767754Smsmith
63867754Smsmith    else
63967754Smsmith    {
64067754Smsmith        ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY;
64167754Smsmith    }
64267754Smsmith
64367754Smsmith    /* Attach the new object to the method Node */
64467754Smsmith
64585756Smsmith    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
64685756Smsmith                    ObjDesc, (UINT8) ACPI_TYPE_METHOD);
64767754Smsmith
64885756Smsmith    /* Remove local reference to the object */
64985756Smsmith
65085756Smsmith    AcpiUtRemoveReference (ObjDesc);
65185756Smsmith
65285756Smsmith    /* Remove a reference to the operand */
65385756Smsmith
65485756Smsmith    AcpiUtRemoveReference (Operand[1]);
65567754Smsmith    return_ACPI_STATUS (Status);
65667754Smsmith}
65767754Smsmith
65867754Smsmith
659