Home | History | Annotate | Line # | Download | only in executer
excreate.c revision 1.1.1.2.4.2
      1  1.1.1.2.4.2  rmind /******************************************************************************
      2  1.1.1.2.4.2  rmind  *
      3  1.1.1.2.4.2  rmind  * Module Name: excreate - Named object creation
      4  1.1.1.2.4.2  rmind  *
      5  1.1.1.2.4.2  rmind  *****************************************************************************/
      6  1.1.1.2.4.2  rmind 
      7  1.1.1.2.4.2  rmind /*
      8  1.1.1.2.4.2  rmind  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.1.1.2.4.2  rmind  * All rights reserved.
     10  1.1.1.2.4.2  rmind  *
     11  1.1.1.2.4.2  rmind  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2.4.2  rmind  * modification, are permitted provided that the following conditions
     13  1.1.1.2.4.2  rmind  * are met:
     14  1.1.1.2.4.2  rmind  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2.4.2  rmind  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2.4.2  rmind  *    without modification.
     17  1.1.1.2.4.2  rmind  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2.4.2  rmind  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2.4.2  rmind  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2.4.2  rmind  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2.4.2  rmind  *    binary redistribution.
     22  1.1.1.2.4.2  rmind  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2.4.2  rmind  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2.4.2  rmind  *    from this software without specific prior written permission.
     25  1.1.1.2.4.2  rmind  *
     26  1.1.1.2.4.2  rmind  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2.4.2  rmind  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2.4.2  rmind  * Software Foundation.
     29  1.1.1.2.4.2  rmind  *
     30  1.1.1.2.4.2  rmind  * NO WARRANTY
     31  1.1.1.2.4.2  rmind  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2.4.2  rmind  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2.4.2  rmind  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2.4.2  rmind  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2.4.2  rmind  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2.4.2  rmind  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2.4.2  rmind  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2.4.2  rmind  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2.4.2  rmind  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2.4.2  rmind  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2.4.2  rmind  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2.4.2  rmind  */
     43  1.1.1.2.4.2  rmind 
     44  1.1.1.2.4.2  rmind #define __EXCREATE_C__
     45  1.1.1.2.4.2  rmind 
     46  1.1.1.2.4.2  rmind #include "acpi.h"
     47  1.1.1.2.4.2  rmind #include "accommon.h"
     48  1.1.1.2.4.2  rmind #include "acinterp.h"
     49  1.1.1.2.4.2  rmind #include "amlcode.h"
     50  1.1.1.2.4.2  rmind #include "acnamesp.h"
     51  1.1.1.2.4.2  rmind 
     52  1.1.1.2.4.2  rmind 
     53  1.1.1.2.4.2  rmind #define _COMPONENT          ACPI_EXECUTER
     54  1.1.1.2.4.2  rmind         ACPI_MODULE_NAME    ("excreate")
     55  1.1.1.2.4.2  rmind 
     56  1.1.1.2.4.2  rmind 
     57  1.1.1.2.4.2  rmind #ifndef ACPI_NO_METHOD_EXECUTION
     58  1.1.1.2.4.2  rmind /*******************************************************************************
     59  1.1.1.2.4.2  rmind  *
     60  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateAlias
     61  1.1.1.2.4.2  rmind  *
     62  1.1.1.2.4.2  rmind  * PARAMETERS:  WalkState            - Current state, contains operands
     63  1.1.1.2.4.2  rmind  *
     64  1.1.1.2.4.2  rmind  * RETURN:      Status
     65  1.1.1.2.4.2  rmind  *
     66  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new named alias
     67  1.1.1.2.4.2  rmind  *
     68  1.1.1.2.4.2  rmind  ******************************************************************************/
     69  1.1.1.2.4.2  rmind 
     70  1.1.1.2.4.2  rmind ACPI_STATUS
     71  1.1.1.2.4.2  rmind AcpiExCreateAlias (
     72  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
     73  1.1.1.2.4.2  rmind {
     74  1.1.1.2.4.2  rmind     ACPI_NAMESPACE_NODE     *TargetNode;
     75  1.1.1.2.4.2  rmind     ACPI_NAMESPACE_NODE     *AliasNode;
     76  1.1.1.2.4.2  rmind     ACPI_STATUS             Status = AE_OK;
     77  1.1.1.2.4.2  rmind 
     78  1.1.1.2.4.2  rmind 
     79  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE (ExCreateAlias);
     80  1.1.1.2.4.2  rmind 
     81  1.1.1.2.4.2  rmind 
     82  1.1.1.2.4.2  rmind     /* Get the source/alias operands (both namespace nodes) */
     83  1.1.1.2.4.2  rmind 
     84  1.1.1.2.4.2  rmind     AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
     85  1.1.1.2.4.2  rmind     TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
     86  1.1.1.2.4.2  rmind 
     87  1.1.1.2.4.2  rmind     if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
     88  1.1.1.2.4.2  rmind         (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
     89  1.1.1.2.4.2  rmind     {
     90  1.1.1.2.4.2  rmind         /*
     91  1.1.1.2.4.2  rmind          * Dereference an existing alias so that we don't create a chain
     92  1.1.1.2.4.2  rmind          * of aliases.  With this code, we guarantee that an alias is
     93  1.1.1.2.4.2  rmind          * always exactly one level of indirection away from the
     94  1.1.1.2.4.2  rmind          * actual aliased name.
     95  1.1.1.2.4.2  rmind          */
     96  1.1.1.2.4.2  rmind         TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
     97  1.1.1.2.4.2  rmind     }
     98  1.1.1.2.4.2  rmind 
     99  1.1.1.2.4.2  rmind     /*
    100  1.1.1.2.4.2  rmind      * For objects that can never change (i.e., the NS node will
    101  1.1.1.2.4.2  rmind      * permanently point to the same object), we can simply attach
    102  1.1.1.2.4.2  rmind      * the object to the new NS node.  For other objects (such as
    103  1.1.1.2.4.2  rmind      * Integers, buffers, etc.), we have to point the Alias node
    104  1.1.1.2.4.2  rmind      * to the original Node.
    105  1.1.1.2.4.2  rmind      */
    106  1.1.1.2.4.2  rmind     switch (TargetNode->Type)
    107  1.1.1.2.4.2  rmind     {
    108  1.1.1.2.4.2  rmind 
    109  1.1.1.2.4.2  rmind     /* For these types, the sub-object can change dynamically via a Store */
    110  1.1.1.2.4.2  rmind 
    111  1.1.1.2.4.2  rmind     case ACPI_TYPE_INTEGER:
    112  1.1.1.2.4.2  rmind     case ACPI_TYPE_STRING:
    113  1.1.1.2.4.2  rmind     case ACPI_TYPE_BUFFER:
    114  1.1.1.2.4.2  rmind     case ACPI_TYPE_PACKAGE:
    115  1.1.1.2.4.2  rmind     case ACPI_TYPE_BUFFER_FIELD:
    116  1.1.1.2.4.2  rmind 
    117  1.1.1.2.4.2  rmind     /*
    118  1.1.1.2.4.2  rmind      * These types open a new scope, so we need the NS node in order to access
    119  1.1.1.2.4.2  rmind      * any children.
    120  1.1.1.2.4.2  rmind      */
    121  1.1.1.2.4.2  rmind     case ACPI_TYPE_DEVICE:
    122  1.1.1.2.4.2  rmind     case ACPI_TYPE_POWER:
    123  1.1.1.2.4.2  rmind     case ACPI_TYPE_PROCESSOR:
    124  1.1.1.2.4.2  rmind     case ACPI_TYPE_THERMAL:
    125  1.1.1.2.4.2  rmind     case ACPI_TYPE_LOCAL_SCOPE:
    126  1.1.1.2.4.2  rmind 
    127  1.1.1.2.4.2  rmind         /*
    128  1.1.1.2.4.2  rmind          * The new alias has the type ALIAS and points to the original
    129  1.1.1.2.4.2  rmind          * NS node, not the object itself.
    130  1.1.1.2.4.2  rmind          */
    131  1.1.1.2.4.2  rmind         AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
    132  1.1.1.2.4.2  rmind         AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
    133  1.1.1.2.4.2  rmind         break;
    134  1.1.1.2.4.2  rmind 
    135  1.1.1.2.4.2  rmind     case ACPI_TYPE_METHOD:
    136  1.1.1.2.4.2  rmind 
    137  1.1.1.2.4.2  rmind         /*
    138  1.1.1.2.4.2  rmind          * Control method aliases need to be differentiated
    139  1.1.1.2.4.2  rmind          */
    140  1.1.1.2.4.2  rmind         AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
    141  1.1.1.2.4.2  rmind         AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
    142  1.1.1.2.4.2  rmind         break;
    143  1.1.1.2.4.2  rmind 
    144  1.1.1.2.4.2  rmind     default:
    145  1.1.1.2.4.2  rmind 
    146  1.1.1.2.4.2  rmind         /* Attach the original source object to the new Alias Node */
    147  1.1.1.2.4.2  rmind 
    148  1.1.1.2.4.2  rmind         /*
    149  1.1.1.2.4.2  rmind          * The new alias assumes the type of the target, and it points
    150  1.1.1.2.4.2  rmind          * to the same object.  The reference count of the object has an
    151  1.1.1.2.4.2  rmind          * additional reference to prevent deletion out from under either the
    152  1.1.1.2.4.2  rmind          * target node or the alias Node
    153  1.1.1.2.4.2  rmind          */
    154  1.1.1.2.4.2  rmind         Status = AcpiNsAttachObject (AliasNode,
    155  1.1.1.2.4.2  rmind                     AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
    156  1.1.1.2.4.2  rmind         break;
    157  1.1.1.2.4.2  rmind     }
    158  1.1.1.2.4.2  rmind 
    159  1.1.1.2.4.2  rmind     /* Since both operands are Nodes, we don't need to delete them */
    160  1.1.1.2.4.2  rmind 
    161  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    162  1.1.1.2.4.2  rmind }
    163  1.1.1.2.4.2  rmind 
    164  1.1.1.2.4.2  rmind 
    165  1.1.1.2.4.2  rmind /*******************************************************************************
    166  1.1.1.2.4.2  rmind  *
    167  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateEvent
    168  1.1.1.2.4.2  rmind  *
    169  1.1.1.2.4.2  rmind  * PARAMETERS:  WalkState           - Current state
    170  1.1.1.2.4.2  rmind  *
    171  1.1.1.2.4.2  rmind  * RETURN:      Status
    172  1.1.1.2.4.2  rmind  *
    173  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new event object
    174  1.1.1.2.4.2  rmind  *
    175  1.1.1.2.4.2  rmind  ******************************************************************************/
    176  1.1.1.2.4.2  rmind 
    177  1.1.1.2.4.2  rmind ACPI_STATUS
    178  1.1.1.2.4.2  rmind AcpiExCreateEvent (
    179  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    180  1.1.1.2.4.2  rmind {
    181  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    182  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    183  1.1.1.2.4.2  rmind 
    184  1.1.1.2.4.2  rmind 
    185  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE (ExCreateEvent);
    186  1.1.1.2.4.2  rmind 
    187  1.1.1.2.4.2  rmind 
    188  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
    189  1.1.1.2.4.2  rmind     if (!ObjDesc)
    190  1.1.1.2.4.2  rmind     {
    191  1.1.1.2.4.2  rmind         Status = AE_NO_MEMORY;
    192  1.1.1.2.4.2  rmind         goto Cleanup;
    193  1.1.1.2.4.2  rmind     }
    194  1.1.1.2.4.2  rmind 
    195  1.1.1.2.4.2  rmind     /*
    196  1.1.1.2.4.2  rmind      * Create the actual OS semaphore, with zero initial units -- meaning
    197  1.1.1.2.4.2  rmind      * that the event is created in an unsignalled state
    198  1.1.1.2.4.2  rmind      */
    199  1.1.1.2.4.2  rmind     Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
    200  1.1.1.2.4.2  rmind                 &ObjDesc->Event.OsSemaphore);
    201  1.1.1.2.4.2  rmind     if (ACPI_FAILURE (Status))
    202  1.1.1.2.4.2  rmind     {
    203  1.1.1.2.4.2  rmind         goto Cleanup;
    204  1.1.1.2.4.2  rmind     }
    205  1.1.1.2.4.2  rmind 
    206  1.1.1.2.4.2  rmind     /* Attach object to the Node */
    207  1.1.1.2.4.2  rmind 
    208  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
    209  1.1.1.2.4.2  rmind                 ObjDesc, ACPI_TYPE_EVENT);
    210  1.1.1.2.4.2  rmind 
    211  1.1.1.2.4.2  rmind Cleanup:
    212  1.1.1.2.4.2  rmind     /*
    213  1.1.1.2.4.2  rmind      * Remove local reference to the object (on error, will cause deletion
    214  1.1.1.2.4.2  rmind      * of both object and semaphore if present.)
    215  1.1.1.2.4.2  rmind      */
    216  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    217  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    218  1.1.1.2.4.2  rmind }
    219  1.1.1.2.4.2  rmind 
    220  1.1.1.2.4.2  rmind 
    221  1.1.1.2.4.2  rmind /*******************************************************************************
    222  1.1.1.2.4.2  rmind  *
    223  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateMutex
    224  1.1.1.2.4.2  rmind  *
    225  1.1.1.2.4.2  rmind  * PARAMETERS:  WalkState           - Current state
    226  1.1.1.2.4.2  rmind  *
    227  1.1.1.2.4.2  rmind  * RETURN:      Status
    228  1.1.1.2.4.2  rmind  *
    229  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new mutex object
    230  1.1.1.2.4.2  rmind  *
    231  1.1.1.2.4.2  rmind  *              Mutex (Name[0], SyncLevel[1])
    232  1.1.1.2.4.2  rmind  *
    233  1.1.1.2.4.2  rmind  ******************************************************************************/
    234  1.1.1.2.4.2  rmind 
    235  1.1.1.2.4.2  rmind ACPI_STATUS
    236  1.1.1.2.4.2  rmind AcpiExCreateMutex (
    237  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    238  1.1.1.2.4.2  rmind {
    239  1.1.1.2.4.2  rmind     ACPI_STATUS             Status = AE_OK;
    240  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    241  1.1.1.2.4.2  rmind 
    242  1.1.1.2.4.2  rmind 
    243  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
    244  1.1.1.2.4.2  rmind 
    245  1.1.1.2.4.2  rmind 
    246  1.1.1.2.4.2  rmind     /* Create the new mutex object */
    247  1.1.1.2.4.2  rmind 
    248  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
    249  1.1.1.2.4.2  rmind     if (!ObjDesc)
    250  1.1.1.2.4.2  rmind     {
    251  1.1.1.2.4.2  rmind         Status = AE_NO_MEMORY;
    252  1.1.1.2.4.2  rmind         goto Cleanup;
    253  1.1.1.2.4.2  rmind     }
    254  1.1.1.2.4.2  rmind 
    255  1.1.1.2.4.2  rmind     /* Create the actual OS Mutex */
    256  1.1.1.2.4.2  rmind 
    257  1.1.1.2.4.2  rmind     Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
    258  1.1.1.2.4.2  rmind     if (ACPI_FAILURE (Status))
    259  1.1.1.2.4.2  rmind     {
    260  1.1.1.2.4.2  rmind         goto Cleanup;
    261  1.1.1.2.4.2  rmind     }
    262  1.1.1.2.4.2  rmind 
    263  1.1.1.2.4.2  rmind     /* Init object and attach to NS node */
    264  1.1.1.2.4.2  rmind 
    265  1.1.1.2.4.2  rmind     ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
    266  1.1.1.2.4.2  rmind     ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
    267  1.1.1.2.4.2  rmind 
    268  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
    269  1.1.1.2.4.2  rmind 
    270  1.1.1.2.4.2  rmind 
    271  1.1.1.2.4.2  rmind Cleanup:
    272  1.1.1.2.4.2  rmind     /*
    273  1.1.1.2.4.2  rmind      * Remove local reference to the object (on error, will cause deletion
    274  1.1.1.2.4.2  rmind      * of both object and semaphore if present.)
    275  1.1.1.2.4.2  rmind      */
    276  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    277  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    278  1.1.1.2.4.2  rmind }
    279  1.1.1.2.4.2  rmind 
    280  1.1.1.2.4.2  rmind 
    281  1.1.1.2.4.2  rmind /*******************************************************************************
    282  1.1.1.2.4.2  rmind  *
    283  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateRegion
    284  1.1.1.2.4.2  rmind  *
    285  1.1.1.2.4.2  rmind  * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
    286  1.1.1.2.4.2  rmind  *              AmlLength           - Max length of the declaration AML
    287  1.1.1.2.4.2  rmind  *              RegionSpace         - SpaceID for the region
    288  1.1.1.2.4.2  rmind  *              WalkState           - Current state
    289  1.1.1.2.4.2  rmind  *
    290  1.1.1.2.4.2  rmind  * RETURN:      Status
    291  1.1.1.2.4.2  rmind  *
    292  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new operation region object
    293  1.1.1.2.4.2  rmind  *
    294  1.1.1.2.4.2  rmind  ******************************************************************************/
    295  1.1.1.2.4.2  rmind 
    296  1.1.1.2.4.2  rmind ACPI_STATUS
    297  1.1.1.2.4.2  rmind AcpiExCreateRegion (
    298  1.1.1.2.4.2  rmind     UINT8                   *AmlStart,
    299  1.1.1.2.4.2  rmind     UINT32                  AmlLength,
    300  1.1.1.2.4.2  rmind     UINT8                   RegionSpace,
    301  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    302  1.1.1.2.4.2  rmind {
    303  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    304  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    305  1.1.1.2.4.2  rmind     ACPI_NAMESPACE_NODE     *Node;
    306  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *RegionObj2;
    307  1.1.1.2.4.2  rmind 
    308  1.1.1.2.4.2  rmind 
    309  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE (ExCreateRegion);
    310  1.1.1.2.4.2  rmind 
    311  1.1.1.2.4.2  rmind 
    312  1.1.1.2.4.2  rmind     /* Get the Namespace Node */
    313  1.1.1.2.4.2  rmind 
    314  1.1.1.2.4.2  rmind     Node = WalkState->Op->Common.Node;
    315  1.1.1.2.4.2  rmind 
    316  1.1.1.2.4.2  rmind     /*
    317  1.1.1.2.4.2  rmind      * If the region object is already attached to this node,
    318  1.1.1.2.4.2  rmind      * just return
    319  1.1.1.2.4.2  rmind      */
    320  1.1.1.2.4.2  rmind     if (AcpiNsGetAttachedObject (Node))
    321  1.1.1.2.4.2  rmind     {
    322  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_OK);
    323  1.1.1.2.4.2  rmind     }
    324  1.1.1.2.4.2  rmind 
    325  1.1.1.2.4.2  rmind     /*
    326  1.1.1.2.4.2  rmind      * Space ID must be one of the predefined IDs, or in the user-defined
    327  1.1.1.2.4.2  rmind      * range
    328  1.1.1.2.4.2  rmind      */
    329  1.1.1.2.4.2  rmind     if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
    330  1.1.1.2.4.2  rmind         (RegionSpace < ACPI_USER_REGION_BEGIN))
    331  1.1.1.2.4.2  rmind     {
    332  1.1.1.2.4.2  rmind         ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type 0x%X", RegionSpace));
    333  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
    334  1.1.1.2.4.2  rmind     }
    335  1.1.1.2.4.2  rmind 
    336  1.1.1.2.4.2  rmind     ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
    337  1.1.1.2.4.2  rmind         AcpiUtGetRegionName (RegionSpace), RegionSpace));
    338  1.1.1.2.4.2  rmind 
    339  1.1.1.2.4.2  rmind     /* Create the region descriptor */
    340  1.1.1.2.4.2  rmind 
    341  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
    342  1.1.1.2.4.2  rmind     if (!ObjDesc)
    343  1.1.1.2.4.2  rmind     {
    344  1.1.1.2.4.2  rmind         Status = AE_NO_MEMORY;
    345  1.1.1.2.4.2  rmind         goto Cleanup;
    346  1.1.1.2.4.2  rmind     }
    347  1.1.1.2.4.2  rmind 
    348  1.1.1.2.4.2  rmind     /*
    349  1.1.1.2.4.2  rmind      * Remember location in AML stream of address & length
    350  1.1.1.2.4.2  rmind      * operands since they need to be evaluated at run time.
    351  1.1.1.2.4.2  rmind      */
    352  1.1.1.2.4.2  rmind     RegionObj2 = ObjDesc->Common.NextObject;
    353  1.1.1.2.4.2  rmind     RegionObj2->Extra.AmlStart = AmlStart;
    354  1.1.1.2.4.2  rmind     RegionObj2->Extra.AmlLength = AmlLength;
    355  1.1.1.2.4.2  rmind 
    356  1.1.1.2.4.2  rmind     /* Init the region from the operands */
    357  1.1.1.2.4.2  rmind 
    358  1.1.1.2.4.2  rmind     ObjDesc->Region.SpaceId = RegionSpace;
    359  1.1.1.2.4.2  rmind     ObjDesc->Region.Address = 0;
    360  1.1.1.2.4.2  rmind     ObjDesc->Region.Length = 0;
    361  1.1.1.2.4.2  rmind     ObjDesc->Region.Node = Node;
    362  1.1.1.2.4.2  rmind 
    363  1.1.1.2.4.2  rmind     /* Install the new region object in the parent Node */
    364  1.1.1.2.4.2  rmind 
    365  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
    366  1.1.1.2.4.2  rmind 
    367  1.1.1.2.4.2  rmind 
    368  1.1.1.2.4.2  rmind Cleanup:
    369  1.1.1.2.4.2  rmind 
    370  1.1.1.2.4.2  rmind     /* Remove local reference to the object */
    371  1.1.1.2.4.2  rmind 
    372  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    373  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    374  1.1.1.2.4.2  rmind }
    375  1.1.1.2.4.2  rmind 
    376  1.1.1.2.4.2  rmind 
    377  1.1.1.2.4.2  rmind /*******************************************************************************
    378  1.1.1.2.4.2  rmind  *
    379  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateProcessor
    380  1.1.1.2.4.2  rmind  *
    381  1.1.1.2.4.2  rmind  * PARAMETERS:  WalkState           - Current state
    382  1.1.1.2.4.2  rmind  *
    383  1.1.1.2.4.2  rmind  * RETURN:      Status
    384  1.1.1.2.4.2  rmind  *
    385  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new processor object and populate the fields
    386  1.1.1.2.4.2  rmind  *
    387  1.1.1.2.4.2  rmind  *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
    388  1.1.1.2.4.2  rmind  *
    389  1.1.1.2.4.2  rmind  ******************************************************************************/
    390  1.1.1.2.4.2  rmind 
    391  1.1.1.2.4.2  rmind ACPI_STATUS
    392  1.1.1.2.4.2  rmind AcpiExCreateProcessor (
    393  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    394  1.1.1.2.4.2  rmind {
    395  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
    396  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    397  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    398  1.1.1.2.4.2  rmind 
    399  1.1.1.2.4.2  rmind 
    400  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
    401  1.1.1.2.4.2  rmind 
    402  1.1.1.2.4.2  rmind 
    403  1.1.1.2.4.2  rmind     /* Create the processor object */
    404  1.1.1.2.4.2  rmind 
    405  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
    406  1.1.1.2.4.2  rmind     if (!ObjDesc)
    407  1.1.1.2.4.2  rmind     {
    408  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_NO_MEMORY);
    409  1.1.1.2.4.2  rmind     }
    410  1.1.1.2.4.2  rmind 
    411  1.1.1.2.4.2  rmind     /* Initialize the processor object from the operands */
    412  1.1.1.2.4.2  rmind 
    413  1.1.1.2.4.2  rmind     ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
    414  1.1.1.2.4.2  rmind     ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
    415  1.1.1.2.4.2  rmind     ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
    416  1.1.1.2.4.2  rmind 
    417  1.1.1.2.4.2  rmind     /* Install the processor object in the parent Node */
    418  1.1.1.2.4.2  rmind 
    419  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
    420  1.1.1.2.4.2  rmind                     ObjDesc, ACPI_TYPE_PROCESSOR);
    421  1.1.1.2.4.2  rmind 
    422  1.1.1.2.4.2  rmind     /* Remove local reference to the object */
    423  1.1.1.2.4.2  rmind 
    424  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    425  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    426  1.1.1.2.4.2  rmind }
    427  1.1.1.2.4.2  rmind 
    428  1.1.1.2.4.2  rmind 
    429  1.1.1.2.4.2  rmind /*******************************************************************************
    430  1.1.1.2.4.2  rmind  *
    431  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreatePowerResource
    432  1.1.1.2.4.2  rmind  *
    433  1.1.1.2.4.2  rmind  * PARAMETERS:  WalkState           - Current state
    434  1.1.1.2.4.2  rmind  *
    435  1.1.1.2.4.2  rmind  * RETURN:      Status
    436  1.1.1.2.4.2  rmind  *
    437  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new PowerResource object and populate the fields
    438  1.1.1.2.4.2  rmind  *
    439  1.1.1.2.4.2  rmind  *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
    440  1.1.1.2.4.2  rmind  *
    441  1.1.1.2.4.2  rmind  ******************************************************************************/
    442  1.1.1.2.4.2  rmind 
    443  1.1.1.2.4.2  rmind ACPI_STATUS
    444  1.1.1.2.4.2  rmind AcpiExCreatePowerResource (
    445  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    446  1.1.1.2.4.2  rmind {
    447  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
    448  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    449  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    450  1.1.1.2.4.2  rmind 
    451  1.1.1.2.4.2  rmind 
    452  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
    453  1.1.1.2.4.2  rmind 
    454  1.1.1.2.4.2  rmind 
    455  1.1.1.2.4.2  rmind     /* Create the power resource object */
    456  1.1.1.2.4.2  rmind 
    457  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
    458  1.1.1.2.4.2  rmind     if (!ObjDesc)
    459  1.1.1.2.4.2  rmind     {
    460  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_NO_MEMORY);
    461  1.1.1.2.4.2  rmind     }
    462  1.1.1.2.4.2  rmind 
    463  1.1.1.2.4.2  rmind     /* Initialize the power object from the operands */
    464  1.1.1.2.4.2  rmind 
    465  1.1.1.2.4.2  rmind     ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
    466  1.1.1.2.4.2  rmind     ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
    467  1.1.1.2.4.2  rmind 
    468  1.1.1.2.4.2  rmind     /* Install the  power resource object in the parent Node */
    469  1.1.1.2.4.2  rmind 
    470  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
    471  1.1.1.2.4.2  rmind                     ObjDesc, ACPI_TYPE_POWER);
    472  1.1.1.2.4.2  rmind 
    473  1.1.1.2.4.2  rmind     /* Remove local reference to the object */
    474  1.1.1.2.4.2  rmind 
    475  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    476  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    477  1.1.1.2.4.2  rmind }
    478  1.1.1.2.4.2  rmind #endif
    479  1.1.1.2.4.2  rmind 
    480  1.1.1.2.4.2  rmind 
    481  1.1.1.2.4.2  rmind /*******************************************************************************
    482  1.1.1.2.4.2  rmind  *
    483  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiExCreateMethod
    484  1.1.1.2.4.2  rmind  *
    485  1.1.1.2.4.2  rmind  * PARAMETERS:  AmlStart        - First byte of the method's AML
    486  1.1.1.2.4.2  rmind  *              AmlLength       - AML byte count for this method
    487  1.1.1.2.4.2  rmind  *              WalkState       - Current state
    488  1.1.1.2.4.2  rmind  *
    489  1.1.1.2.4.2  rmind  * RETURN:      Status
    490  1.1.1.2.4.2  rmind  *
    491  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a new method object
    492  1.1.1.2.4.2  rmind  *
    493  1.1.1.2.4.2  rmind  ******************************************************************************/
    494  1.1.1.2.4.2  rmind 
    495  1.1.1.2.4.2  rmind ACPI_STATUS
    496  1.1.1.2.4.2  rmind AcpiExCreateMethod (
    497  1.1.1.2.4.2  rmind     UINT8                   *AmlStart,
    498  1.1.1.2.4.2  rmind     UINT32                  AmlLength,
    499  1.1.1.2.4.2  rmind     ACPI_WALK_STATE         *WalkState)
    500  1.1.1.2.4.2  rmind {
    501  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
    502  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    503  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    504  1.1.1.2.4.2  rmind     UINT8                   MethodFlags;
    505  1.1.1.2.4.2  rmind 
    506  1.1.1.2.4.2  rmind 
    507  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
    508  1.1.1.2.4.2  rmind 
    509  1.1.1.2.4.2  rmind 
    510  1.1.1.2.4.2  rmind     /* Create a new method object */
    511  1.1.1.2.4.2  rmind 
    512  1.1.1.2.4.2  rmind     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
    513  1.1.1.2.4.2  rmind     if (!ObjDesc)
    514  1.1.1.2.4.2  rmind     {
    515  1.1.1.2.4.2  rmind        Status = AE_NO_MEMORY;
    516  1.1.1.2.4.2  rmind        goto Exit;
    517  1.1.1.2.4.2  rmind     }
    518  1.1.1.2.4.2  rmind 
    519  1.1.1.2.4.2  rmind     /* Save the method's AML pointer and length  */
    520  1.1.1.2.4.2  rmind 
    521  1.1.1.2.4.2  rmind     ObjDesc->Method.AmlStart = AmlStart;
    522  1.1.1.2.4.2  rmind     ObjDesc->Method.AmlLength = AmlLength;
    523  1.1.1.2.4.2  rmind 
    524  1.1.1.2.4.2  rmind     /*
    525  1.1.1.2.4.2  rmind      * Disassemble the method flags. Split off the ArgCount, Serialized
    526  1.1.1.2.4.2  rmind      * flag, and SyncLevel for efficiency.
    527  1.1.1.2.4.2  rmind      */
    528  1.1.1.2.4.2  rmind     MethodFlags = (UINT8) Operand[1]->Integer.Value;
    529  1.1.1.2.4.2  rmind     ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
    530  1.1.1.2.4.2  rmind 
    531  1.1.1.2.4.2  rmind     /*
    532  1.1.1.2.4.2  rmind      * Get the SyncLevel. If method is serialized, a mutex will be
    533  1.1.1.2.4.2  rmind      * created for this method when it is parsed.
    534  1.1.1.2.4.2  rmind      */
    535  1.1.1.2.4.2  rmind     if (MethodFlags & AML_METHOD_SERIALIZED)
    536  1.1.1.2.4.2  rmind     {
    537  1.1.1.2.4.2  rmind         ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
    538  1.1.1.2.4.2  rmind 
    539  1.1.1.2.4.2  rmind         /*
    540  1.1.1.2.4.2  rmind          * ACPI 1.0: SyncLevel = 0
    541  1.1.1.2.4.2  rmind          * ACPI 2.0: SyncLevel = SyncLevel in method declaration
    542  1.1.1.2.4.2  rmind          */
    543  1.1.1.2.4.2  rmind         ObjDesc->Method.SyncLevel = (UINT8)
    544  1.1.1.2.4.2  rmind             ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
    545  1.1.1.2.4.2  rmind     }
    546  1.1.1.2.4.2  rmind 
    547  1.1.1.2.4.2  rmind     /* Attach the new object to the method Node */
    548  1.1.1.2.4.2  rmind 
    549  1.1.1.2.4.2  rmind     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
    550  1.1.1.2.4.2  rmind                     ObjDesc, ACPI_TYPE_METHOD);
    551  1.1.1.2.4.2  rmind 
    552  1.1.1.2.4.2  rmind     /* Remove local reference to the object */
    553  1.1.1.2.4.2  rmind 
    554  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (ObjDesc);
    555  1.1.1.2.4.2  rmind 
    556  1.1.1.2.4.2  rmind Exit:
    557  1.1.1.2.4.2  rmind     /* Remove a reference to the operand */
    558  1.1.1.2.4.2  rmind 
    559  1.1.1.2.4.2  rmind     AcpiUtRemoveReference (Operand[1]);
    560  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    561  1.1.1.2.4.2  rmind }
    562  1.1.1.2.4.2  rmind 
    563  1.1.1.2.4.2  rmind 
    564