366
366
acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
367
367
struct acpi_evaluate_info *info)
369
union acpi_operand_object *root_obj;
369
union acpi_operand_object *parent_obj;
370
struct acpi_namespace_node *parent_node;
371
acpi_object_type type;
370
372
acpi_status status;
372
374
ACPI_FUNCTION_TRACE(ns_exec_module_code);
377
* Get the parent node. We cheat by using the next_object field
378
* of the method object descriptor.
380
parent_node = ACPI_CAST_PTR(struct acpi_namespace_node,
381
method_obj->method.next_object);
382
type = acpi_ns_get_type(parent_node);
385
* Get the region handler and save it in the method object. We may need
386
* this if an operation region declaration causes a _REG method to be run.
388
* We can't do this in acpi_ps_link_module_code because
389
* acpi_gbl_root_node->Object is NULL at PASS1.
391
if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
392
method_obj->method.dispatch.handler =
393
parent_node->object->device.handler;
396
/* Must clear next_object (acpi_ns_attach_object needs the field) */
398
method_obj->method.next_object = NULL;
374
400
/* Initialize the evaluation information block */
376
402
ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
377
info->prefix_node = acpi_gbl_root_node;
403
info->prefix_node = parent_node;
380
* Get the currently attached root object. Add a reference, because the
406
* Get the currently attached parent object. Add a reference, because the
381
407
* ref count will be decreased when the method object is installed to
384
root_obj = acpi_ns_get_attached_object(acpi_gbl_root_node);
385
acpi_ut_add_reference(root_obj);
387
/* Install the method (module-level code) in the root node */
389
status = acpi_ns_attach_object(acpi_gbl_root_node, method_obj,
410
parent_obj = acpi_ns_get_attached_object(parent_node);
412
acpi_ut_add_reference(parent_obj);
415
/* Install the method (module-level code) in the parent node */
417
status = acpi_ns_attach_object(parent_node, method_obj,
390
418
ACPI_TYPE_METHOD);
391
419
if (ACPI_FAILURE(status)) {
395
/* Execute the root node as a control method */
423
/* Execute the parent node as a control method */
397
425
status = acpi_ns_evaluate(info);
399
427
ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
400
428
method_obj->method.aml_start));
430
/* Delete a possible implicit return value (in slack mode) */
432
if (info->return_object) {
433
acpi_ut_remove_reference(info->return_object);
402
436
/* Detach the temporary method object */
404
acpi_ns_detach_object(acpi_gbl_root_node);
406
/* Restore the original root object */
409
acpi_ns_attach_object(acpi_gbl_root_node, root_obj,
438
acpi_ns_detach_object(parent_node);
440
/* Restore the original parent object */
443
status = acpi_ns_attach_object(parent_node, parent_obj, type);
445
parent_node->type = (u8)type;
413
acpi_ut_remove_reference(root_obj);
450
acpi_ut_remove_reference(parent_obj);