1 /*******************************************************************************
2  *
3  * Module Name: nseval - Object evaluation, includes control method execution
4  *
5  ******************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65 
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government. In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************
116  *
117  * Alternatively, you may choose to be licensed under the terms of the
118  * following license:
119  *
120  * Redistribution and use in source and binary forms, with or without
121  * modification, are permitted provided that the following conditions
122  * are met:
123  * 1. Redistributions of source code must retain the above copyright
124  *    notice, this list of conditions, and the following disclaimer,
125  *    without modification.
126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127  *    substantially similar to the "NO WARRANTY" disclaimer below
128  *    ("Disclaimer") and any redistribution must be conditioned upon
129  *    including a substantially similar Disclaimer requirement for further
130  *    binary redistribution.
131  * 3. Neither the names of the above-listed copyright holders nor the names
132  *    of any contributors may be used to endorse or promote products derived
133  *    from this software without specific prior written permission.
134  *
135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146  *
147  * Alternatively, you may choose to be licensed under the terms of the
148  * GNU General Public License ("GPL") version 2 as published by the Free
149  * Software Foundation.
150  *
151  *****************************************************************************/
152 
153 #include "acpi.h"
154 #include "accommon.h"
155 #include "acparser.h"
156 #include "acinterp.h"
157 #include "acnamesp.h"
158 
159 
160 #define _COMPONENT          ACPI_NAMESPACE
161         ACPI_MODULE_NAME    ("nseval")
162 
163 /* Local prototypes */
164 
165 static void
166 AcpiNsExecModuleCode (
167     ACPI_OPERAND_OBJECT     *MethodObj,
168     ACPI_EVALUATE_INFO      *Info);
169 
170 
171 /*******************************************************************************
172  *
173  * FUNCTION:    AcpiNsEvaluate
174  *
175  * PARAMETERS:  Info            - Evaluation info block, contains these fields
176  *                                and more:
177  *                  PrefixNode      - Prefix or Method/Object Node to execute
178  *                  RelativePath    - Name of method to execute, If NULL, the
179  *                                    Node is the object to execute
180  *                  Parameters      - List of parameters to pass to the method,
181  *                                    terminated by NULL. Params itself may be
182  *                                    NULL if no parameters are being passed.
183  *                  ParameterType   - Type of Parameter list
184  *                  ReturnObject    - Where to put method's return value (if
185  *                                    any). If NULL, no value is returned.
186  *                  Flags           - ACPI_IGNORE_RETURN_VALUE to delete return
187  *
188  * RETURN:      Status
189  *
190  * DESCRIPTION: Execute a control method or return the current value of an
191  *              ACPI namespace object.
192  *
193  * MUTEX:       Locks interpreter
194  *
195  ******************************************************************************/
196 
197 ACPI_STATUS
198 AcpiNsEvaluate (
199     ACPI_EVALUATE_INFO      *Info)
200 {
201     ACPI_STATUS             Status;
202 
203 
204     ACPI_FUNCTION_TRACE (NsEvaluate);
205 
206 
207     if (!Info)
208     {
209         return_ACPI_STATUS (AE_BAD_PARAMETER);
210     }
211 
212     if (!Info->Node)
213     {
214         /*
215          * Get the actual namespace node for the target object if we
216          * need to. Handles these cases:
217          *
218          * 1) Null node, valid pathname from root (absolute path)
219          * 2) Node and valid pathname (path relative to Node)
220          * 3) Node, Null pathname
221          */
222         Status = AcpiNsGetNode (Info->PrefixNode, Info->RelativePathname,
223             ACPI_NS_NO_UPSEARCH, &Info->Node);
224         if (ACPI_FAILURE (Status))
225         {
226             return_ACPI_STATUS (Status);
227         }
228     }
229 
230     /*
231      * For a method alias, we must grab the actual method node so that
232      * proper scoping context will be established before execution.
233      */
234     if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
235     {
236         Info->Node = ACPI_CAST_PTR (
237             ACPI_NAMESPACE_NODE, Info->Node->Object);
238     }
239 
240     /* Complete the info block initialization */
241 
242     Info->ReturnObject = NULL;
243     Info->NodeFlags = Info->Node->Flags;
244     Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node);
245 
246     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
247         Info->RelativePathname, Info->Node,
248         AcpiNsGetAttachedObject (Info->Node)));
249 
250     /* Get info if we have a predefined name (_HID, etc.) */
251 
252     Info->Predefined = AcpiUtMatchPredefinedMethod (Info->Node->Name.Ascii);
253 
254     /* Get the full pathname to the object, for use in warning messages */
255 
256     Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE);
257     if (!Info->FullPathname)
258     {
259         return_ACPI_STATUS (AE_NO_MEMORY);
260     }
261 
262     /* Optional object evaluation log */
263 
264     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EVALUATION,
265         "%-26s:  %s (%s)\n", "   Enter evaluation",
266         &Info->FullPathname[1], AcpiUtGetTypeName (Info->Node->Type)));
267 
268     /* Count the number of arguments being passed in */
269 
270     Info->ParamCount = 0;
271     if (Info->Parameters)
272     {
273         while (Info->Parameters[Info->ParamCount])
274         {
275             Info->ParamCount++;
276         }
277 
278         /* Warn on impossible argument count */
279 
280         if (Info->ParamCount > ACPI_METHOD_NUM_ARGS)
281         {
282             ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS,
283                 "Excess arguments (%u) - using only %u",
284                 Info->ParamCount, ACPI_METHOD_NUM_ARGS));
285 
286             Info->ParamCount = ACPI_METHOD_NUM_ARGS;
287         }
288     }
289 
290     /*
291      * For predefined names: Check that the declared argument count
292      * matches the ACPI spec -- otherwise this is a BIOS error.
293      */
294     AcpiNsCheckAcpiCompliance (Info->FullPathname, Info->Node,
295         Info->Predefined);
296 
297     /*
298      * For all names: Check that the incoming argument count for
299      * this method/object matches the actual ASL/AML definition.
300      */
301     AcpiNsCheckArgumentCount (Info->FullPathname, Info->Node,
302         Info->ParamCount, Info->Predefined);
303 
304     /* For predefined names: Typecheck all incoming arguments */
305 
306     AcpiNsCheckArgumentTypes (Info);
307 
308     /*
309      * Three major evaluation cases:
310      *
311      * 1) Object types that cannot be evaluated by definition
312      * 2) The object is a control method -- execute it
313      * 3) The object is not a method -- just return it's current value
314      */
315     switch (AcpiNsGetType (Info->Node))
316     {
317     case ACPI_TYPE_ANY:
318     case ACPI_TYPE_DEVICE:
319     case ACPI_TYPE_EVENT:
320     case ACPI_TYPE_MUTEX:
321     case ACPI_TYPE_REGION:
322     case ACPI_TYPE_THERMAL:
323     case ACPI_TYPE_LOCAL_SCOPE:
324         /*
325          * 1) Disallow evaluation of these object types. For these,
326          *    object evaluation is undefined.
327          */
328         ACPI_ERROR ((AE_INFO,
329             "%s: This object type [%s] "
330             "never contains data and cannot be evaluated",
331             Info->FullPathname, AcpiUtGetTypeName (Info->Node->Type)));
332 
333         Status = AE_TYPE;
334         goto Cleanup;
335 
336     case ACPI_TYPE_METHOD:
337         /*
338          * 2) Object is a control method - execute it
339          */
340 
341         /* Verify that there is a method object associated with this node */
342 
343         if (!Info->ObjDesc)
344         {
345             ACPI_ERROR ((AE_INFO, "%s: Method has no attached sub-object",
346                 Info->FullPathname));
347             Status = AE_NULL_OBJECT;
348             goto Cleanup;
349         }
350 
351         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
352             "**** Execute method [%s] at AML address %p length %X\n",
353             Info->FullPathname,
354             Info->ObjDesc->Method.AmlStart + 1,
355             Info->ObjDesc->Method.AmlLength - 1));
356 
357         /*
358          * Any namespace deletion must acquire both the namespace and
359          * interpreter locks to ensure that no thread is using the portion of
360          * the namespace that is being deleted.
361          *
362          * Execute the method via the interpreter. The interpreter is locked
363          * here before calling into the AML parser
364          */
365         AcpiExEnterInterpreter ();
366         Status = AcpiPsExecuteMethod (Info);
367         AcpiExExitInterpreter ();
368         break;
369 
370     default:
371         /*
372          * 3) All other non-method objects -- get the current object value
373          */
374 
375         /*
376          * Some objects require additional resolution steps (e.g., the Node
377          * may be a field that must be read, etc.) -- we can't just grab
378          * the object out of the node.
379          *
380          * Use ResolveNodeToValue() to get the associated value.
381          *
382          * NOTE: we can get away with passing in NULL for a walk state because
383          * the Node is guaranteed to not be a reference to either a method
384          * local or a method argument (because this interface is never called
385          * from a running method.)
386          *
387          * Even though we do not directly invoke the interpreter for object
388          * resolution, we must lock it because we could access an OpRegion.
389          * The OpRegion access code assumes that the interpreter is locked.
390          */
391         AcpiExEnterInterpreter ();
392 
393         /* TBD: ResolveNodeToValue has a strange interface, fix */
394 
395         Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->Node);
396 
397         Status = AcpiExResolveNodeToValue (ACPI_CAST_INDIRECT_PTR (
398             ACPI_NAMESPACE_NODE, &Info->ReturnObject), NULL);
399         AcpiExExitInterpreter ();
400 
401         if (ACPI_FAILURE (Status))
402         {
403             Info->ReturnObject = NULL;
404             goto Cleanup;
405         }
406 
407         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returned object %p [%s]\n",
408             Info->ReturnObject,
409             AcpiUtGetObjectTypeName (Info->ReturnObject)));
410 
411         Status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */
412         break;
413     }
414 
415     /*
416      * For predefined names, check the return value against the ACPI
417      * specification. Some incorrect return value types are repaired.
418      */
419     (void) AcpiNsCheckReturnValue (Info->Node, Info, Info->ParamCount,
420         Status, &Info->ReturnObject);
421 
422     /* Check if there is a return value that must be dealt with */
423 
424     if (Status == AE_CTRL_RETURN_VALUE)
425     {
426         /* If caller does not want the return value, delete it */
427 
428         if (Info->Flags & ACPI_IGNORE_RETURN_VALUE)
429         {
430             AcpiUtRemoveReference (Info->ReturnObject);
431             Info->ReturnObject = NULL;
432         }
433 
434         /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
435 
436         Status = AE_OK;
437     }
438     else if (ACPI_FAILURE(Status))
439     {
440         /* If ReturnObject exists, delete it */
441 
442         if (Info->ReturnObject)
443         {
444             AcpiUtRemoveReference (Info->ReturnObject);
445             Info->ReturnObject = NULL;
446         }
447     }
448 
449     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
450         "*** Completed evaluation of object %s ***\n",
451         Info->RelativePathname));
452 
453 Cleanup:
454     /* Optional object evaluation log */
455 
456     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EVALUATION,
457         "%-26s:  %s\n", "   Exit evaluation",
458         &Info->FullPathname[1]));
459 
460     /*
461      * Namespace was unlocked by the handling AcpiNs* function, so we
462      * just free the pathname and return
463      */
464     ACPI_FREE (Info->FullPathname);
465     Info->FullPathname = NULL;
466     return_ACPI_STATUS (Status);
467 }
468 
469 
470 /*******************************************************************************
471  *
472  * FUNCTION:    AcpiNsExecModuleCodeList
473  *
474  * PARAMETERS:  None
475  *
476  * RETURN:      None. Exceptions during method execution are ignored, since
477  *              we cannot abort a table load.
478  *
479  * DESCRIPTION: Execute all elements of the global module-level code list.
480  *              Each element is executed as a single control method.
481  *
482  * NOTE: With this option enabled, each block of detected executable AML
483  * code that is outside of any control method is wrapped with a temporary
484  * control method object and placed on a global list. The methods on this
485  * list are executed below.
486  *
487  * This function executes the module-level code for all tables only after
488  * all of the tables have been loaded. It is a legacy option and is
489  * not compatible with other ACPI implementations. See AcpiNsLoadTable.
490  *
491  * This function will be removed when the legacy option is removed.
492  *
493  ******************************************************************************/
494 
495 void
496 AcpiNsExecModuleCodeList (
497     void)
498 {
499     ACPI_OPERAND_OBJECT     *Prev;
500     ACPI_OPERAND_OBJECT     *Next;
501     ACPI_EVALUATE_INFO      *Info;
502     UINT32                  MethodCount = 0;
503 
504 
505     ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
506 
507 
508     /* Exit now if the list is empty */
509 
510     Next = AcpiGbl_ModuleCodeList;
511     if (!Next)
512     {
513         ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES,
514             "Legacy MLC block list is empty\n"));
515 
516         return_VOID;
517     }
518 
519     /* Allocate the evaluation information block */
520 
521     Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
522     if (!Info)
523     {
524         return_VOID;
525     }
526 
527     /* Walk the list, executing each "method" */
528 
529     while (Next)
530     {
531         Prev = Next;
532         Next = Next->Method.Mutex;
533 
534         /* Clear the link field and execute the method */
535 
536         Prev->Method.Mutex = NULL;
537         AcpiNsExecModuleCode (Prev, Info);
538         MethodCount++;
539 
540         /* Delete the (temporary) method object */
541 
542         AcpiUtRemoveReference (Prev);
543     }
544 
545     ACPI_INFO ((
546         "Executed %u blocks of module-level executable AML code",
547         MethodCount));
548 
549     ACPI_FREE (Info);
550     AcpiGbl_ModuleCodeList = NULL;
551     return_VOID;
552 }
553 
554 
555 /*******************************************************************************
556  *
557  * FUNCTION:    AcpiNsExecModuleCode
558  *
559  * PARAMETERS:  MethodObj           - Object container for the module-level code
560  *              Info                - Info block for method evaluation
561  *
562  * RETURN:      None. Exceptions during method execution are ignored, since
563  *              we cannot abort a table load.
564  *
565  * DESCRIPTION: Execute a control method containing a block of module-level
566  *              executable AML code. The control method is temporarily
567  *              installed to the root node, then evaluated.
568  *
569  ******************************************************************************/
570 
571 static void
572 AcpiNsExecModuleCode (
573     ACPI_OPERAND_OBJECT     *MethodObj,
574     ACPI_EVALUATE_INFO      *Info)
575 {
576     ACPI_OPERAND_OBJECT     *ParentObj;
577     ACPI_NAMESPACE_NODE     *ParentNode;
578     ACPI_OBJECT_TYPE        Type;
579     ACPI_STATUS             Status;
580 
581 
582     ACPI_FUNCTION_TRACE (NsExecModuleCode);
583 
584 
585     /*
586      * Get the parent node. We cheat by using the NextObject field
587      * of the method object descriptor.
588      */
589     ParentNode = ACPI_CAST_PTR (
590         ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject);
591     Type = AcpiNsGetType (ParentNode);
592 
593     /*
594      * Get the region handler and save it in the method object. We may need
595      * this if an operation region declaration causes a _REG method to be run.
596      *
597      * We can't do this in AcpiPsLinkModuleCode because
598      * AcpiGbl_RootNode->Object is NULL at PASS1.
599      */
600     if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
601     {
602         MethodObj->Method.Dispatch.Handler =
603             ParentNode->Object->Device.Handler;
604     }
605 
606     /* Must clear NextObject (AcpiNsAttachObject needs the field) */
607 
608     MethodObj->Method.NextObject = NULL;
609 
610     /* Initialize the evaluation information block */
611 
612     memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
613     Info->PrefixNode = ParentNode;
614 
615     /*
616      * Get the currently attached parent object. Add a reference,
617      * because the ref count will be decreased when the method object
618      * is installed to the parent node.
619      */
620     ParentObj = AcpiNsGetAttachedObject (ParentNode);
621     if (ParentObj)
622     {
623         AcpiUtAddReference (ParentObj);
624     }
625 
626     /* Install the method (module-level code) in the parent node */
627 
628     Status = AcpiNsAttachObject (ParentNode, MethodObj, ACPI_TYPE_METHOD);
629     if (ACPI_FAILURE (Status))
630     {
631         goto Exit;
632     }
633 
634     /* Execute the parent node as a control method */
635 
636     Status = AcpiNsEvaluate (Info);
637 
638     ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES,
639         "Executed module-level code at %p\n",
640         MethodObj->Method.AmlStart));
641 
642     /* Delete a possible implicit return value (in slack mode) */
643 
644     if (Info->ReturnObject)
645     {
646         AcpiUtRemoveReference (Info->ReturnObject);
647     }
648 
649     /* Detach the temporary method object */
650 
651     AcpiNsDetachObject (ParentNode);
652 
653     /* Restore the original parent object */
654 
655     if (ParentObj)
656     {
657         Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
658     }
659     else
660     {
661         ParentNode->Type = (UINT8) Type;
662     }
663 
664 Exit:
665     if (ParentObj)
666     {
667         AcpiUtRemoveReference (ParentObj);
668     }
669     return_VOID;
670 }
671