Home | History | Annotate | Line # | Download | only in namespace
nseval.c revision 1.3
      1  1.1  jruoho /*******************************************************************************
      2  1.1  jruoho  *
      3  1.1  jruoho  * Module Name: nseval - Object evaluation, includes control method execution
      4  1.1  jruoho  *
      5  1.1  jruoho  ******************************************************************************/
      6  1.1  jruoho 
      7  1.3  jruoho /*
      8  1.3  jruoho  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.1  jruoho  * All rights reserved.
     10  1.1  jruoho  *
     11  1.3  jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.3  jruoho  * modification, are permitted provided that the following conditions
     13  1.3  jruoho  * are met:
     14  1.3  jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.3  jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.3  jruoho  *    without modification.
     17  1.3  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.3  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.3  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.3  jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.3  jruoho  *    binary redistribution.
     22  1.3  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.3  jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.3  jruoho  *    from this software without specific prior written permission.
     25  1.3  jruoho  *
     26  1.3  jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.3  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.3  jruoho  * Software Foundation.
     29  1.3  jruoho  *
     30  1.3  jruoho  * NO WARRANTY
     31  1.3  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.3  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.3  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.3  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.3  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.3  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.3  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.3  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.3  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.3  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.3  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.3  jruoho  */
     43  1.1  jruoho 
     44  1.1  jruoho #define __NSEVAL_C__
     45  1.1  jruoho 
     46  1.1  jruoho #include "acpi.h"
     47  1.1  jruoho #include "accommon.h"
     48  1.1  jruoho #include "acparser.h"
     49  1.1  jruoho #include "acinterp.h"
     50  1.1  jruoho #include "acnamesp.h"
     51  1.1  jruoho 
     52  1.1  jruoho 
     53  1.1  jruoho #define _COMPONENT          ACPI_NAMESPACE
     54  1.1  jruoho         ACPI_MODULE_NAME    ("nseval")
     55  1.1  jruoho 
     56  1.1  jruoho /* Local prototypes */
     57  1.1  jruoho 
     58  1.1  jruoho static void
     59  1.1  jruoho AcpiNsExecModuleCode (
     60  1.1  jruoho     ACPI_OPERAND_OBJECT     *MethodObj,
     61  1.1  jruoho     ACPI_EVALUATE_INFO      *Info);
     62  1.1  jruoho 
     63  1.1  jruoho 
     64  1.1  jruoho /*******************************************************************************
     65  1.1  jruoho  *
     66  1.1  jruoho  * FUNCTION:    AcpiNsEvaluate
     67  1.1  jruoho  *
     68  1.1  jruoho  * PARAMETERS:  Info            - Evaluation info block, contains:
     69  1.1  jruoho  *                  PrefixNode      - Prefix or Method/Object Node to execute
     70  1.1  jruoho  *                  Pathname        - Name of method to execute, If NULL, the
     71  1.1  jruoho  *                                    Node is the object to execute
     72  1.1  jruoho  *                  Parameters      - List of parameters to pass to the method,
     73  1.1  jruoho  *                                    terminated by NULL. Params itself may be
     74  1.1  jruoho  *                                    NULL if no parameters are being passed.
     75  1.1  jruoho  *                  ReturnObject    - Where to put method's return value (if
     76  1.1  jruoho  *                                    any). If NULL, no value is returned.
     77  1.1  jruoho  *                  ParameterType   - Type of Parameter list
     78  1.1  jruoho  *                  ReturnObject    - Where to put method's return value (if
     79  1.1  jruoho  *                                    any). If NULL, no value is returned.
     80  1.1  jruoho  *                  Flags           - ACPI_IGNORE_RETURN_VALUE to delete return
     81  1.1  jruoho  *
     82  1.1  jruoho  * RETURN:      Status
     83  1.1  jruoho  *
     84  1.1  jruoho  * DESCRIPTION: Execute a control method or return the current value of an
     85  1.1  jruoho  *              ACPI namespace object.
     86  1.1  jruoho  *
     87  1.1  jruoho  * MUTEX:       Locks interpreter
     88  1.1  jruoho  *
     89  1.1  jruoho  ******************************************************************************/
     90  1.1  jruoho 
     91  1.1  jruoho ACPI_STATUS
     92  1.1  jruoho AcpiNsEvaluate (
     93  1.1  jruoho     ACPI_EVALUATE_INFO      *Info)
     94  1.1  jruoho {
     95  1.1  jruoho     ACPI_STATUS             Status;
     96  1.1  jruoho     ACPI_NAMESPACE_NODE     *Node;
     97  1.1  jruoho 
     98  1.1  jruoho 
     99  1.1  jruoho     ACPI_FUNCTION_TRACE (NsEvaluate);
    100  1.1  jruoho 
    101  1.1  jruoho 
    102  1.1  jruoho     if (!Info)
    103  1.1  jruoho     {
    104  1.1  jruoho         return_ACPI_STATUS (AE_BAD_PARAMETER);
    105  1.1  jruoho     }
    106  1.1  jruoho 
    107  1.1  jruoho     /* Initialize the return value to an invalid object */
    108  1.1  jruoho 
    109  1.1  jruoho     Info->ReturnObject = NULL;
    110  1.1  jruoho     Info->ParamCount = 0;
    111  1.1  jruoho 
    112  1.1  jruoho     /*
    113  1.1  jruoho      * Get the actual namespace node for the target object. Handles these cases:
    114  1.1  jruoho      *
    115  1.1  jruoho      * 1) Null node, Pathname (absolute path)
    116  1.1  jruoho      * 2) Node, Pathname (path relative to Node)
    117  1.1  jruoho      * 3) Node, Null Pathname
    118  1.1  jruoho      */
    119  1.1  jruoho     Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname,
    120  1.1  jruoho                 ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode);
    121  1.1  jruoho     if (ACPI_FAILURE (Status))
    122  1.1  jruoho     {
    123  1.1  jruoho         return_ACPI_STATUS (Status);
    124  1.1  jruoho     }
    125  1.1  jruoho 
    126  1.1  jruoho     /*
    127  1.1  jruoho      * For a method alias, we must grab the actual method node so that proper
    128  1.1  jruoho      * scoping context will be established before execution.
    129  1.1  jruoho      */
    130  1.1  jruoho     if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
    131  1.1  jruoho     {
    132  1.1  jruoho         Info->ResolvedNode =
    133  1.1  jruoho             ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object);
    134  1.1  jruoho     }
    135  1.1  jruoho 
    136  1.1  jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname,
    137  1.1  jruoho         Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode)));
    138  1.1  jruoho 
    139  1.1  jruoho     Node = Info->ResolvedNode;
    140  1.1  jruoho 
    141  1.1  jruoho     /*
    142  1.1  jruoho      * Two major cases here:
    143  1.1  jruoho      *
    144  1.1  jruoho      * 1) The object is a control method -- execute it
    145  1.1  jruoho      * 2) The object is not a method -- just return it's current value
    146  1.1  jruoho      */
    147  1.1  jruoho     if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD)
    148  1.1  jruoho     {
    149  1.1  jruoho         /*
    150  1.1  jruoho          * 1) Object is a control method - execute it
    151  1.1  jruoho          */
    152  1.1  jruoho 
    153  1.1  jruoho         /* Verify that there is a method object associated with this node */
    154  1.1  jruoho 
    155  1.1  jruoho         Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode);
    156  1.1  jruoho         if (!Info->ObjDesc)
    157  1.1  jruoho         {
    158  1.1  jruoho             ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object"));
    159  1.1  jruoho             return_ACPI_STATUS (AE_NULL_OBJECT);
    160  1.1  jruoho         }
    161  1.1  jruoho 
    162  1.1  jruoho         /* Count the number of arguments being passed to the method */
    163  1.1  jruoho 
    164  1.1  jruoho         if (Info->Parameters)
    165  1.1  jruoho         {
    166  1.1  jruoho             while (Info->Parameters[Info->ParamCount])
    167  1.1  jruoho             {
    168  1.1  jruoho                 if (Info->ParamCount > ACPI_METHOD_MAX_ARG)
    169  1.1  jruoho                 {
    170  1.1  jruoho                     return_ACPI_STATUS (AE_LIMIT);
    171  1.1  jruoho                 }
    172  1.1  jruoho                 Info->ParamCount++;
    173  1.1  jruoho             }
    174  1.1  jruoho         }
    175  1.1  jruoho 
    176  1.1  jruoho         ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method",
    177  1.1  jruoho             ACPI_LV_INFO, _COMPONENT);
    178  1.1  jruoho 
    179  1.1  jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    180  1.1  jruoho             "Method at AML address %p Length %X\n",
    181  1.1  jruoho             Info->ObjDesc->Method.AmlStart + 1,
    182  1.1  jruoho             Info->ObjDesc->Method.AmlLength - 1));
    183  1.1  jruoho 
    184  1.1  jruoho         /*
    185  1.1  jruoho          * Any namespace deletion must acquire both the namespace and
    186  1.1  jruoho          * interpreter locks to ensure that no thread is using the portion of
    187  1.1  jruoho          * the namespace that is being deleted.
    188  1.1  jruoho          *
    189  1.1  jruoho          * Execute the method via the interpreter. The interpreter is locked
    190  1.1  jruoho          * here before calling into the AML parser
    191  1.1  jruoho          */
    192  1.1  jruoho         AcpiExEnterInterpreter ();
    193  1.1  jruoho         Status = AcpiPsExecuteMethod (Info);
    194  1.1  jruoho         AcpiExExitInterpreter ();
    195  1.1  jruoho     }
    196  1.1  jruoho     else
    197  1.1  jruoho     {
    198  1.1  jruoho         /*
    199  1.1  jruoho          * 2) Object is not a method, return its current value
    200  1.1  jruoho          *
    201  1.1  jruoho          * Disallow certain object types. For these, "evaluation" is undefined.
    202  1.1  jruoho          */
    203  1.1  jruoho         switch (Info->ResolvedNode->Type)
    204  1.1  jruoho         {
    205  1.1  jruoho         case ACPI_TYPE_DEVICE:
    206  1.1  jruoho         case ACPI_TYPE_EVENT:
    207  1.1  jruoho         case ACPI_TYPE_MUTEX:
    208  1.1  jruoho         case ACPI_TYPE_REGION:
    209  1.1  jruoho         case ACPI_TYPE_THERMAL:
    210  1.1  jruoho         case ACPI_TYPE_LOCAL_SCOPE:
    211  1.1  jruoho 
    212  1.1  jruoho             ACPI_ERROR ((AE_INFO,
    213  1.1  jruoho                 "[%4.4s] Evaluation of object type [%s] is not supported",
    214  1.1  jruoho                 Info->ResolvedNode->Name.Ascii,
    215  1.1  jruoho                 AcpiUtGetTypeName (Info->ResolvedNode->Type)));
    216  1.1  jruoho 
    217  1.1  jruoho             return_ACPI_STATUS (AE_TYPE);
    218  1.1  jruoho 
    219  1.1  jruoho         default:
    220  1.1  jruoho             break;
    221  1.1  jruoho         }
    222  1.1  jruoho 
    223  1.1  jruoho         /*
    224  1.1  jruoho          * Objects require additional resolution steps (e.g., the Node may be
    225  1.1  jruoho          * a field that must be read, etc.) -- we can't just grab the object
    226  1.1  jruoho          * out of the node.
    227  1.1  jruoho          *
    228  1.1  jruoho          * Use ResolveNodeToValue() to get the associated value.
    229  1.1  jruoho          *
    230  1.1  jruoho          * NOTE: we can get away with passing in NULL for a walk state because
    231  1.1  jruoho          * ResolvedNode is guaranteed to not be a reference to either a method
    232  1.1  jruoho          * local or a method argument (because this interface is never called
    233  1.1  jruoho          * from a running method.)
    234  1.1  jruoho          *
    235  1.1  jruoho          * Even though we do not directly invoke the interpreter for object
    236  1.1  jruoho          * resolution, we must lock it because we could access an opregion.
    237  1.1  jruoho          * The opregion access code assumes that the interpreter is locked.
    238  1.1  jruoho          */
    239  1.1  jruoho         AcpiExEnterInterpreter ();
    240  1.1  jruoho 
    241  1.1  jruoho         /* Function has a strange interface */
    242  1.1  jruoho 
    243  1.1  jruoho         Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL);
    244  1.1  jruoho         AcpiExExitInterpreter ();
    245  1.1  jruoho 
    246  1.1  jruoho         /*
    247  1.1  jruoho          * If AcpiExResolveNodeToValue() succeeded, the return value was placed
    248  1.1  jruoho          * in ResolvedNode.
    249  1.1  jruoho          */
    250  1.1  jruoho         if (ACPI_SUCCESS (Status))
    251  1.1  jruoho         {
    252  1.1  jruoho             Status = AE_CTRL_RETURN_VALUE;
    253  1.1  jruoho             Info->ReturnObject =
    254  1.1  jruoho                 ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode);
    255  1.1  jruoho 
    256  1.1  jruoho             ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
    257  1.1  jruoho                 Info->ReturnObject,
    258  1.1  jruoho                 AcpiUtGetObjectTypeName (Info->ReturnObject)));
    259  1.1  jruoho         }
    260  1.1  jruoho     }
    261  1.1  jruoho 
    262  1.1  jruoho     /*
    263  1.1  jruoho      * Check input argument count against the ASL-defined count for a method.
    264  1.1  jruoho      * Also check predefined names: argument count and return value against
    265  1.1  jruoho      * the ACPI specification. Some incorrect return value types are repaired.
    266  1.1  jruoho      */
    267  1.1  jruoho     (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount,
    268  1.1  jruoho                 Status, &Info->ReturnObject);
    269  1.1  jruoho 
    270  1.1  jruoho     /* Check if there is a return value that must be dealt with */
    271  1.1  jruoho 
    272  1.1  jruoho     if (Status == AE_CTRL_RETURN_VALUE)
    273  1.1  jruoho     {
    274  1.1  jruoho         /* If caller does not want the return value, delete it */
    275  1.1  jruoho 
    276  1.1  jruoho         if (Info->Flags & ACPI_IGNORE_RETURN_VALUE)
    277  1.1  jruoho         {
    278  1.1  jruoho             AcpiUtRemoveReference (Info->ReturnObject);
    279  1.1  jruoho             Info->ReturnObject = NULL;
    280  1.1  jruoho         }
    281  1.1  jruoho 
    282  1.1  jruoho         /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
    283  1.1  jruoho 
    284  1.1  jruoho         Status = AE_OK;
    285  1.1  jruoho     }
    286  1.1  jruoho 
    287  1.1  jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
    288  1.1  jruoho         "*** Completed evaluation of object %s ***\n", Info->Pathname));
    289  1.1  jruoho 
    290  1.1  jruoho     /*
    291  1.1  jruoho      * Namespace was unlocked by the handling AcpiNs* function, so we
    292  1.1  jruoho      * just return
    293  1.1  jruoho      */
    294  1.1  jruoho     return_ACPI_STATUS (Status);
    295  1.1  jruoho }
    296  1.1  jruoho 
    297  1.1  jruoho 
    298  1.1  jruoho /*******************************************************************************
    299  1.1  jruoho  *
    300  1.1  jruoho  * FUNCTION:    AcpiNsExecModuleCodeList
    301  1.1  jruoho  *
    302  1.1  jruoho  * PARAMETERS:  None
    303  1.1  jruoho  *
    304  1.1  jruoho  * RETURN:      None. Exceptions during method execution are ignored, since
    305  1.1  jruoho  *              we cannot abort a table load.
    306  1.1  jruoho  *
    307  1.1  jruoho  * DESCRIPTION: Execute all elements of the global module-level code list.
    308  1.1  jruoho  *              Each element is executed as a single control method.
    309  1.1  jruoho  *
    310  1.1  jruoho  ******************************************************************************/
    311  1.1  jruoho 
    312  1.1  jruoho void
    313  1.1  jruoho AcpiNsExecModuleCodeList (
    314  1.1  jruoho     void)
    315  1.1  jruoho {
    316  1.1  jruoho     ACPI_OPERAND_OBJECT     *Prev;
    317  1.1  jruoho     ACPI_OPERAND_OBJECT     *Next;
    318  1.1  jruoho     ACPI_EVALUATE_INFO      *Info;
    319  1.1  jruoho     UINT32                  MethodCount = 0;
    320  1.1  jruoho 
    321  1.1  jruoho 
    322  1.1  jruoho     ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
    323  1.1  jruoho 
    324  1.1  jruoho 
    325  1.1  jruoho     /* Exit now if the list is empty */
    326  1.1  jruoho 
    327  1.1  jruoho     Next = AcpiGbl_ModuleCodeList;
    328  1.1  jruoho     if (!Next)
    329  1.1  jruoho     {
    330  1.1  jruoho         return_VOID;
    331  1.1  jruoho     }
    332  1.1  jruoho 
    333  1.1  jruoho     /* Allocate the evaluation information block */
    334  1.1  jruoho 
    335  1.1  jruoho     Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
    336  1.1  jruoho     if (!Info)
    337  1.1  jruoho     {
    338  1.1  jruoho         return_VOID;
    339  1.1  jruoho     }
    340  1.1  jruoho 
    341  1.1  jruoho     /* Walk the list, executing each "method" */
    342  1.1  jruoho 
    343  1.1  jruoho     while (Next)
    344  1.1  jruoho     {
    345  1.1  jruoho         Prev = Next;
    346  1.1  jruoho         Next = Next->Method.Mutex;
    347  1.1  jruoho 
    348  1.1  jruoho         /* Clear the link field and execute the method */
    349  1.1  jruoho 
    350  1.1  jruoho         Prev->Method.Mutex = NULL;
    351  1.1  jruoho         AcpiNsExecModuleCode (Prev, Info);
    352  1.1  jruoho         MethodCount++;
    353  1.1  jruoho 
    354  1.1  jruoho         /* Delete the (temporary) method object */
    355  1.1  jruoho 
    356  1.1  jruoho         AcpiUtRemoveReference (Prev);
    357  1.1  jruoho     }
    358  1.1  jruoho 
    359  1.2  jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    360  1.1  jruoho         "Executed %u blocks of module-level executable AML code",
    361  1.1  jruoho         MethodCount));
    362  1.1  jruoho 
    363  1.1  jruoho     ACPI_FREE (Info);
    364  1.1  jruoho     AcpiGbl_ModuleCodeList = NULL;
    365  1.1  jruoho     return_VOID;
    366  1.1  jruoho }
    367  1.1  jruoho 
    368  1.1  jruoho 
    369  1.1  jruoho /*******************************************************************************
    370  1.1  jruoho  *
    371  1.1  jruoho  * FUNCTION:    AcpiNsExecModuleCode
    372  1.1  jruoho  *
    373  1.1  jruoho  * PARAMETERS:  MethodObj           - Object container for the module-level code
    374  1.1  jruoho  *              Info                - Info block for method evaluation
    375  1.1  jruoho  *
    376  1.1  jruoho  * RETURN:      None. Exceptions during method execution are ignored, since
    377  1.1  jruoho  *              we cannot abort a table load.
    378  1.1  jruoho  *
    379  1.1  jruoho  * DESCRIPTION: Execute a control method containing a block of module-level
    380  1.1  jruoho  *              executable AML code. The control method is temporarily
    381  1.1  jruoho  *              installed to the root node, then evaluated.
    382  1.1  jruoho  *
    383  1.1  jruoho  ******************************************************************************/
    384  1.1  jruoho 
    385  1.1  jruoho static void
    386  1.1  jruoho AcpiNsExecModuleCode (
    387  1.1  jruoho     ACPI_OPERAND_OBJECT     *MethodObj,
    388  1.1  jruoho     ACPI_EVALUATE_INFO      *Info)
    389  1.1  jruoho {
    390  1.1  jruoho     ACPI_OPERAND_OBJECT     *ParentObj;
    391  1.1  jruoho     ACPI_NAMESPACE_NODE     *ParentNode;
    392  1.1  jruoho     ACPI_OBJECT_TYPE        Type;
    393  1.1  jruoho     ACPI_STATUS             Status;
    394  1.1  jruoho 
    395  1.1  jruoho 
    396  1.1  jruoho     ACPI_FUNCTION_TRACE (NsExecModuleCode);
    397  1.1  jruoho 
    398  1.1  jruoho 
    399  1.1  jruoho     /*
    400  1.1  jruoho      * Get the parent node. We cheat by using the NextObject field
    401  1.1  jruoho      * of the method object descriptor.
    402  1.1  jruoho      */
    403  1.1  jruoho     ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
    404  1.1  jruoho                     MethodObj->Method.NextObject);
    405  1.1  jruoho     Type = AcpiNsGetType (ParentNode);
    406  1.1  jruoho 
    407  1.1  jruoho     /*
    408  1.1  jruoho      * Get the region handler and save it in the method object. We may need
    409  1.1  jruoho      * this if an operation region declaration causes a _REG method to be run.
    410  1.1  jruoho      *
    411  1.1  jruoho      * We can't do this in AcpiPsLinkModuleCode because
    412  1.1  jruoho      * AcpiGbl_RootNode->Object is NULL at PASS1.
    413  1.1  jruoho      */
    414  1.1  jruoho     if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
    415  1.1  jruoho     {
    416  1.3  jruoho         MethodObj->Method.Dispatch.Handler =
    417  1.1  jruoho             ParentNode->Object->Device.Handler;
    418  1.1  jruoho     }
    419  1.1  jruoho 
    420  1.1  jruoho     /* Must clear NextObject (AcpiNsAttachObject needs the field) */
    421  1.1  jruoho 
    422  1.1  jruoho     MethodObj->Method.NextObject = NULL;
    423  1.1  jruoho 
    424  1.1  jruoho     /* Initialize the evaluation information block */
    425  1.1  jruoho 
    426  1.1  jruoho     ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
    427  1.1  jruoho     Info->PrefixNode = ParentNode;
    428  1.1  jruoho 
    429  1.1  jruoho     /*
    430  1.1  jruoho      * Get the currently attached parent object. Add a reference, because the
    431  1.1  jruoho      * ref count will be decreased when the method object is installed to
    432  1.1  jruoho      * the parent node.
    433  1.1  jruoho      */
    434  1.1  jruoho     ParentObj = AcpiNsGetAttachedObject (ParentNode);
    435  1.1  jruoho     if (ParentObj)
    436  1.1  jruoho     {
    437  1.1  jruoho         AcpiUtAddReference (ParentObj);
    438  1.1  jruoho     }
    439  1.1  jruoho 
    440  1.1  jruoho     /* Install the method (module-level code) in the parent node */
    441  1.1  jruoho 
    442  1.1  jruoho     Status = AcpiNsAttachObject (ParentNode, MethodObj,
    443  1.1  jruoho                 ACPI_TYPE_METHOD);
    444  1.1  jruoho     if (ACPI_FAILURE (Status))
    445  1.1  jruoho     {
    446  1.1  jruoho         goto Exit;
    447  1.1  jruoho     }
    448  1.1  jruoho 
    449  1.1  jruoho     /* Execute the parent node as a control method */
    450  1.1  jruoho 
    451  1.1  jruoho     Status = AcpiNsEvaluate (Info);
    452  1.1  jruoho 
    453  1.1  jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n",
    454  1.1  jruoho         MethodObj->Method.AmlStart));
    455  1.1  jruoho 
    456  1.1  jruoho     /* Delete a possible implicit return value (in slack mode) */
    457  1.1  jruoho 
    458  1.1  jruoho     if (Info->ReturnObject)
    459  1.1  jruoho     {
    460  1.1  jruoho         AcpiUtRemoveReference (Info->ReturnObject);
    461  1.1  jruoho     }
    462  1.1  jruoho 
    463  1.1  jruoho     /* Detach the temporary method object */
    464  1.1  jruoho 
    465  1.1  jruoho     AcpiNsDetachObject (ParentNode);
    466  1.1  jruoho 
    467  1.1  jruoho     /* Restore the original parent object */
    468  1.1  jruoho 
    469  1.1  jruoho     if (ParentObj)
    470  1.1  jruoho     {
    471  1.1  jruoho         Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
    472  1.1  jruoho     }
    473  1.1  jruoho     else
    474  1.1  jruoho     {
    475  1.1  jruoho         ParentNode->Type = (UINT8) Type;
    476  1.1  jruoho     }
    477  1.1  jruoho 
    478  1.1  jruoho Exit:
    479  1.1  jruoho     if (ParentObj)
    480  1.1  jruoho     {
    481  1.1  jruoho         AcpiUtRemoveReference (ParentObj);
    482  1.1  jruoho     }
    483  1.1  jruoho     return_VOID;
    484  1.1  jruoho }
    485  1.1  jruoho 
    486