blob: 18108bc2e51cd76833c42b13d6c6e6e678bcb976 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
Bob Moore41195322006-05-26 16:36:00 -04003 * Module Name: nseval - Object evaluation, includes control method execution
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 ******************************************************************************/
6
7/*
Bob Moore25f044e2013-01-25 05:38:56 +00008 * Copyright (C) 2000 - 2013, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acparser.h"
47#include "acinterp.h"
48#include "acnamesp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040051ACPI_MODULE_NAME("nseval")
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Lin Ming7f0c8262009-08-13 14:03:15 +080053/* Local prototypes */
54static void
55acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
56 struct acpi_evaluate_info *info);
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/*******************************************************************************
59 *
Bob Moore41195322006-05-26 16:36:00 -040060 * FUNCTION: acpi_ns_evaluate
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 *
Bob Mooreba494be2012-07-12 09:40:10 +080062 * PARAMETERS: info - Evaluation info block, contains:
Bob Moore41195322006-05-26 16:36:00 -040063 * prefix_node - Prefix or Method/Object Node to execute
Bob Moore29a241c2013-05-30 10:00:01 +080064 * relative_path - Name of method to execute, If NULL, the
Bob Moore41195322006-05-26 16:36:00 -040065 * Node is the object to execute
Bob Mooreba494be2012-07-12 09:40:10 +080066 * parameters - List of parameters to pass to the method,
Robert Moore44f6c012005-04-18 22:49:35 -040067 * terminated by NULL. Params itself may be
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 * NULL if no parameters are being passed.
Robert Moore44f6c012005-04-18 22:49:35 -040069 * return_object - Where to put method's return value (if
70 * any). If NULL, no value is returned.
71 * parameter_type - Type of Parameter list
72 * return_object - Where to put method's return value (if
73 * any). If NULL, no value is returned.
Bob Mooreba494be2012-07-12 09:40:10 +080074 * flags - ACPI_IGNORE_RETURN_VALUE to delete return
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 *
76 * RETURN: Status
77 *
Bob Moore41195322006-05-26 16:36:00 -040078 * DESCRIPTION: Execute a control method or return the current value of an
79 * ACPI namespace object.
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 *
Bob Moore41195322006-05-26 16:36:00 -040081 * MUTEX: Locks interpreter
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 *
83 ******************************************************************************/
Lin Ming7f0c8262009-08-13 14:03:15 +080084
Bob Moore29a241c2013-05-30 10:00:01 +080085acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
Len Brown4be44fc2005-08-05 00:44:28 -040087 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Bob Moore41195322006-05-26 16:36:00 -040089 ACPI_FUNCTION_TRACE(ns_evaluate);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 if (!info) {
Len Brown4be44fc2005-08-05 00:44:28 -040092 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 }
94
Bob Moore29a241c2013-05-30 10:00:01 +080095 if (!info->node) {
Bob Moorec34c82b2013-04-12 00:24:22 +000096 /*
Bob Moore29a241c2013-05-30 10:00:01 +080097 * Get the actual namespace node for the target object if we
98 * need to. Handles these cases:
Bob Moorec34c82b2013-04-12 00:24:22 +000099 *
Bob Moore29a241c2013-05-30 10:00:01 +0800100 * 1) Null node, valid pathname from root (absolute path)
101 * 2) Node and valid pathname (path relative to Node)
102 * 3) Node, Null pathname
Bob Moorec34c82b2013-04-12 00:24:22 +0000103 */
Bob Moore29a241c2013-05-30 10:00:01 +0800104 status =
105 acpi_ns_get_node(info->prefix_node, info->relative_pathname,
106 ACPI_NS_NO_UPSEARCH, &info->node);
Bob Moorec34c82b2013-04-12 00:24:22 +0000107 if (ACPI_FAILURE(status)) {
108 return_ACPI_STATUS(status);
109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 }
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800113 * For a method alias, we must grab the actual method node so that
114 * proper scoping context will be established before execution.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 */
Bob Moore29a241c2013-05-30 10:00:01 +0800116 if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
117 info->node =
Len Brown4be44fc2005-08-05 00:44:28 -0400118 ACPI_CAST_PTR(struct acpi_namespace_node,
Bob Moore29a241c2013-05-30 10:00:01 +0800119 info->node->object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 }
121
Bob Moore29a241c2013-05-30 10:00:01 +0800122 /* Complete the info block initialization */
Bob Moore41195322006-05-26 16:36:00 -0400123
Bob Moore29a241c2013-05-30 10:00:01 +0800124 info->return_object = NULL;
125 info->node_flags = info->node->flags;
126 info->obj_desc = acpi_ns_get_attached_object(info->node);
127
128 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
129 info->relative_pathname, info->node,
130 acpi_ns_get_attached_object(info->node)));
131
132 /* Get info if we have a predefined name (_HID, etc.) */
133
134 info->predefined =
135 acpi_ut_match_predefined_method(info->node->name.ascii);
136
137 /* Get the full pathname to the object, for use in warning messages */
138
139 info->full_pathname = acpi_ns_get_external_pathname(info->node);
140 if (!info->full_pathname) {
141 return_ACPI_STATUS(AE_NO_MEMORY);
142 }
143
144 /* Count the number of arguments being passed in */
145
146 info->param_count = 0;
147 if (info->parameters) {
148 while (info->parameters[info->param_count]) {
149 info->param_count++;
150 }
151
152 /* Warn on impossible argument count */
153
154 if (info->param_count > ACPI_METHOD_NUM_ARGS) {
155 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
156 ACPI_WARN_ALWAYS,
157 "Excess arguments (%u) - using only %u",
158 info->param_count,
159 ACPI_METHOD_NUM_ARGS));
160
161 info->param_count = ACPI_METHOD_NUM_ARGS;
162 }
163 }
Bob Mooree8707b32008-09-28 15:26:17 +0800164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800166 * For predefined names: Check that the declared argument count
167 * matches the ACPI spec -- otherwise this is a BIOS error.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 */
Bob Moore29a241c2013-05-30 10:00:01 +0800169 acpi_ns_check_acpi_compliance(info->full_pathname, info->node,
170 info->predefined);
171
172 /*
173 * For all names: Check that the incoming argument count for
174 * this method/object matches the actual ASL/AML definition.
175 */
176 acpi_ns_check_argument_count(info->full_pathname, info->node,
177 info->param_count, info->predefined);
178
179 /* For predefined names: Typecheck all incoming arguments */
180
181 acpi_ns_check_argument_types(info);
182
183 /*
184 * Three major evaluation cases:
185 *
186 * 1) Object types that cannot be evaluated by definition
187 * 2) The object is a control method -- execute it
188 * 3) The object is not a method -- just return it's current value
189 */
190 switch (acpi_ns_get_type(info->node)) {
191 case ACPI_TYPE_DEVICE:
192 case ACPI_TYPE_EVENT:
193 case ACPI_TYPE_MUTEX:
194 case ACPI_TYPE_REGION:
195 case ACPI_TYPE_THERMAL:
196 case ACPI_TYPE_LOCAL_SCOPE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800198 * 1) Disallow evaluation of certain object types. For these,
199 * object evaluation is undefined and not supported.
200 */
201 ACPI_ERROR((AE_INFO,
202 "%s: Evaluation of object type [%s] is not supported",
203 info->full_pathname,
204 acpi_ut_get_type_name(info->node->type)));
205
206 status = AE_TYPE;
207 goto cleanup;
208
209 case ACPI_TYPE_METHOD:
210 /*
211 * 2) Object is a control method - execute it
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 */
Bob Moore41195322006-05-26 16:36:00 -0400213
214 /* Verify that there is a method object associated with this node */
215
Bob Moore41195322006-05-26 16:36:00 -0400216 if (!info->obj_desc) {
217 ACPI_ERROR((AE_INFO,
Bob Moore29a241c2013-05-30 10:00:01 +0800218 "%s: Method has no attached sub-object",
219 info->full_pathname));
220 status = AE_NULL_OBJECT;
221 goto cleanup;
Bob Moore41195322006-05-26 16:36:00 -0400222 }
223
Bob Moore41195322006-05-26 16:36:00 -0400224 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
Bob Moore29a241c2013-05-30 10:00:01 +0800225 "**** Execute method [%s] at AML address %p length %X\n",
226 info->full_pathname,
Bob Moore41195322006-05-26 16:36:00 -0400227 info->obj_desc->method.aml_start + 1,
228 info->obj_desc->method.aml_length - 1));
229
230 /*
231 * Any namespace deletion must acquire both the namespace and
232 * interpreter locks to ensure that no thread is using the portion of
233 * the namespace that is being deleted.
234 *
235 * Execute the method via the interpreter. The interpreter is locked
236 * here before calling into the AML parser
237 */
Len Brown4d2acd92007-05-09 22:56:38 -0400238 acpi_ex_enter_interpreter();
Bob Moore41195322006-05-26 16:36:00 -0400239 status = acpi_ps_execute_method(info);
240 acpi_ex_exit_interpreter();
Bob Moore29a241c2013-05-30 10:00:01 +0800241 break;
242
243 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800245 * 3) All other non-method objects -- get the current object value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Bob Moore41195322006-05-26 16:36:00 -0400248 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800249 * Some objects require additional resolution steps (e.g., the Node
250 * may be a field that must be read, etc.) -- we can't just grab
251 * the object out of the node.
Bob Moore41195322006-05-26 16:36:00 -0400252 *
253 * Use resolve_node_to_value() to get the associated value.
254 *
255 * NOTE: we can get away with passing in NULL for a walk state because
Bob Moore29a241c2013-05-30 10:00:01 +0800256 * the Node is guaranteed to not be a reference to either a method
Bob Moore41195322006-05-26 16:36:00 -0400257 * local or a method argument (because this interface is never called
258 * from a running method.)
259 *
260 * Even though we do not directly invoke the interpreter for object
Bob Moore29a241c2013-05-30 10:00:01 +0800261 * resolution, we must lock it because we could access an op_region.
262 * The op_region access code assumes that the interpreter is locked.
Bob Moore41195322006-05-26 16:36:00 -0400263 */
Len Brown4d2acd92007-05-09 22:56:38 -0400264 acpi_ex_enter_interpreter();
Bob Moore52fc0b02006-10-02 00:00:00 -0400265
Bob Moore29a241c2013-05-30 10:00:01 +0800266 /* TBD: resolve_node_to_value has a strange interface, fix */
267
268 info->return_object =
269 ACPI_CAST_PTR(union acpi_operand_object, info->node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Bob Moore41195322006-05-26 16:36:00 -0400271 status =
Bob Moore29a241c2013-05-30 10:00:01 +0800272 acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
273 (struct acpi_namespace_node,
274 &info->return_object), NULL);
Bob Moore41195322006-05-26 16:36:00 -0400275 acpi_ex_exit_interpreter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Bob Moore29a241c2013-05-30 10:00:01 +0800277 if (ACPI_FAILURE(status)) {
278 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 }
Bob Moore29a241c2013-05-30 10:00:01 +0800280
281 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Returned object %p [%s]\n",
282 info->return_object,
283 acpi_ut_get_object_type_name(info->
284 return_object)));
285
286 status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */
287 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 }
289
Bob Mooreeeb44372008-11-13 11:19:24 +0800290 /*
Bob Moore29a241c2013-05-30 10:00:01 +0800291 * For predefined names, check the return value against the ACPI
292 * specification. Some incorrect return value types are repaired.
Bob Mooreeeb44372008-11-13 11:19:24 +0800293 */
Bob Moore29a241c2013-05-30 10:00:01 +0800294 (void)acpi_ns_check_return_value(info->node, info, info->param_count,
295 status, &info->return_object);
Bob Mooree8707b32008-09-28 15:26:17 +0800296
297 /* Check if there is a return value that must be dealt with */
298
Bob Moore41195322006-05-26 16:36:00 -0400299 if (status == AE_CTRL_RETURN_VALUE) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Bob Moore41195322006-05-26 16:36:00 -0400301 /* If caller does not want the return value, delete it */
302
303 if (info->flags & ACPI_IGNORE_RETURN_VALUE) {
304 acpi_ut_remove_reference(info->return_object);
305 info->return_object = NULL;
306 }
307
308 /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
309
310 status = AE_OK;
311 }
312
313 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
314 "*** Completed evaluation of object %s ***\n",
Bob Moore29a241c2013-05-30 10:00:01 +0800315 info->relative_pathname));
Bob Moore41195322006-05-26 16:36:00 -0400316
Bob Moore29a241c2013-05-30 10:00:01 +0800317 cleanup:
Bob Moore41195322006-05-26 16:36:00 -0400318 /*
319 * Namespace was unlocked by the handling acpi_ns* function, so we
Bob Moore29a241c2013-05-30 10:00:01 +0800320 * just free the pathname and return
Bob Moore41195322006-05-26 16:36:00 -0400321 */
Bob Moore29a241c2013-05-30 10:00:01 +0800322 ACPI_FREE(info->full_pathname);
323 info->full_pathname = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400324 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325}
Lin Ming7f0c8262009-08-13 14:03:15 +0800326
327/*******************************************************************************
328 *
329 * FUNCTION: acpi_ns_exec_module_code_list
330 *
331 * PARAMETERS: None
332 *
333 * RETURN: None. Exceptions during method execution are ignored, since
334 * we cannot abort a table load.
335 *
336 * DESCRIPTION: Execute all elements of the global module-level code list.
337 * Each element is executed as a single control method.
338 *
339 ******************************************************************************/
340
341void acpi_ns_exec_module_code_list(void)
342{
343 union acpi_operand_object *prev;
344 union acpi_operand_object *next;
345 struct acpi_evaluate_info *info;
346 u32 method_count = 0;
347
348 ACPI_FUNCTION_TRACE(ns_exec_module_code_list);
349
350 /* Exit now if the list is empty */
351
352 next = acpi_gbl_module_code_list;
353 if (!next) {
354 return_VOID;
355 }
356
357 /* Allocate the evaluation information block */
358
359 info = ACPI_ALLOCATE(sizeof(struct acpi_evaluate_info));
360 if (!info) {
361 return_VOID;
362 }
363
364 /* Walk the list, executing each "method" */
365
366 while (next) {
367 prev = next;
368 next = next->method.mutex;
369
370 /* Clear the link field and execute the method */
371
372 prev->method.mutex = NULL;
373 acpi_ns_exec_module_code(prev, info);
374 method_count++;
375
376 /* Delete the (temporary) method object */
377
378 acpi_ut_remove_reference(prev);
379 }
380
381 ACPI_INFO((AE_INFO,
382 "Executed %u blocks of module-level executable AML code",
383 method_count));
384
385 ACPI_FREE(info);
386 acpi_gbl_module_code_list = NULL;
387 return_VOID;
388}
389
390/*******************************************************************************
391 *
392 * FUNCTION: acpi_ns_exec_module_code
393 *
394 * PARAMETERS: method_obj - Object container for the module-level code
Bob Mooreba494be2012-07-12 09:40:10 +0800395 * info - Info block for method evaluation
Lin Ming7f0c8262009-08-13 14:03:15 +0800396 *
397 * RETURN: None. Exceptions during method execution are ignored, since
398 * we cannot abort a table load.
399 *
400 * DESCRIPTION: Execute a control method containing a block of module-level
401 * executable AML code. The control method is temporarily
402 * installed to the root node, then evaluated.
403 *
404 ******************************************************************************/
405
406static void
407acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
408 struct acpi_evaluate_info *info)
409{
Lin Ming9a884ab2009-11-12 09:57:53 +0800410 union acpi_operand_object *parent_obj;
411 struct acpi_namespace_node *parent_node;
412 acpi_object_type type;
Lin Ming7f0c8262009-08-13 14:03:15 +0800413 acpi_status status;
414
415 ACPI_FUNCTION_TRACE(ns_exec_module_code);
416
Lin Ming9a884ab2009-11-12 09:57:53 +0800417 /*
418 * Get the parent node. We cheat by using the next_object field
419 * of the method object descriptor.
420 */
421 parent_node = ACPI_CAST_PTR(struct acpi_namespace_node,
422 method_obj->method.next_object);
423 type = acpi_ns_get_type(parent_node);
424
Lin Minge31c32c2009-12-11 15:28:27 +0800425 /*
426 * Get the region handler and save it in the method object. We may need
427 * this if an operation region declaration causes a _REG method to be run.
428 *
429 * We can't do this in acpi_ps_link_module_code because
430 * acpi_gbl_root_node->Object is NULL at PASS1.
431 */
432 if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
Lin Ming26294842011-01-12 09:19:43 +0800433 method_obj->method.dispatch.handler =
Lin Minge31c32c2009-12-11 15:28:27 +0800434 parent_node->object->device.handler;
435 }
436
Lin Ming9a884ab2009-11-12 09:57:53 +0800437 /* Must clear next_object (acpi_ns_attach_object needs the field) */
438
439 method_obj->method.next_object = NULL;
440
Lin Ming7f0c8262009-08-13 14:03:15 +0800441 /* Initialize the evaluation information block */
442
443 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
Lin Ming9a884ab2009-11-12 09:57:53 +0800444 info->prefix_node = parent_node;
Lin Ming7f0c8262009-08-13 14:03:15 +0800445
446 /*
Lin Ming9a884ab2009-11-12 09:57:53 +0800447 * Get the currently attached parent object. Add a reference, because the
Lin Ming7f0c8262009-08-13 14:03:15 +0800448 * ref count will be decreased when the method object is installed to
Lin Ming9a884ab2009-11-12 09:57:53 +0800449 * the parent node.
Lin Ming7f0c8262009-08-13 14:03:15 +0800450 */
Lin Ming9a884ab2009-11-12 09:57:53 +0800451 parent_obj = acpi_ns_get_attached_object(parent_node);
452 if (parent_obj) {
453 acpi_ut_add_reference(parent_obj);
454 }
Lin Ming7f0c8262009-08-13 14:03:15 +0800455
Lin Ming9a884ab2009-11-12 09:57:53 +0800456 /* Install the method (module-level code) in the parent node */
Lin Ming7f0c8262009-08-13 14:03:15 +0800457
Lin Ming9a884ab2009-11-12 09:57:53 +0800458 status = acpi_ns_attach_object(parent_node, method_obj,
Lin Ming7f0c8262009-08-13 14:03:15 +0800459 ACPI_TYPE_METHOD);
460 if (ACPI_FAILURE(status)) {
461 goto exit;
462 }
463
Lin Ming9a884ab2009-11-12 09:57:53 +0800464 /* Execute the parent node as a control method */
Lin Ming7f0c8262009-08-13 14:03:15 +0800465
466 status = acpi_ns_evaluate(info);
467
468 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
469 method_obj->method.aml_start));
470
Lin Ming583061c2009-12-11 14:36:47 +0800471 /* Delete a possible implicit return value (in slack mode) */
472
473 if (info->return_object) {
474 acpi_ut_remove_reference(info->return_object);
475 }
476
Lin Ming7f0c8262009-08-13 14:03:15 +0800477 /* Detach the temporary method object */
478
Lin Ming9a884ab2009-11-12 09:57:53 +0800479 acpi_ns_detach_object(parent_node);
Lin Ming7f0c8262009-08-13 14:03:15 +0800480
Lin Ming9a884ab2009-11-12 09:57:53 +0800481 /* Restore the original parent object */
Lin Ming7f0c8262009-08-13 14:03:15 +0800482
Lin Ming9a884ab2009-11-12 09:57:53 +0800483 if (parent_obj) {
484 status = acpi_ns_attach_object(parent_node, parent_obj, type);
485 } else {
486 parent_node->type = (u8)type;
487 }
Lin Ming7f0c8262009-08-13 14:03:15 +0800488
489 exit:
Lin Ming9a884ab2009-11-12 09:57:53 +0800490 if (parent_obj) {
491 acpi_ut_remove_reference(parent_obj);
492 }
Lin Ming7f0c8262009-08-13 14:03:15 +0800493 return_VOID;
494}