// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acparser.h" #include "amlcode.h" #include "acdebug.h" #define _COMPONENT … ACPI_MODULE_NAME("dsmethod") /* Local prototypes */ static acpi_status acpi_ds_detect_named_opcodes(struct acpi_walk_state *walk_state, union acpi_parse_object **out_op); static acpi_status acpi_ds_create_method_mutex(union acpi_operand_object *method_desc); /******************************************************************************* * * FUNCTION: acpi_ds_auto_serialize_method * * PARAMETERS: node - Namespace Node of the method * obj_desc - Method object attached to node * * RETURN: Status * * DESCRIPTION: Parse a control method AML to scan for control methods that * need serialization due to the creation of named objects. * * NOTE: It is a bit of overkill to mark all such methods serialized, since * there is only a problem if the method actually blocks during execution. * A blocking operation is, for example, a Sleep() operation, or any access * to an operation region. However, it is probably not possible to easily * detect whether a method will block or not, so we simply mark all suspicious * methods as serialized. * * NOTE2: This code is essentially a generic routine for parsing a single * control method. * ******************************************************************************/ acpi_status acpi_ds_auto_serialize_method(struct acpi_namespace_node *node, union acpi_operand_object *obj_desc) { … } /******************************************************************************* * * FUNCTION: acpi_ds_detect_named_opcodes * * PARAMETERS: walk_state - Current state of the parse tree walk * out_op - Unused, required for parser interface * * RETURN: Status * * DESCRIPTION: Descending callback used during the loading of ACPI tables. * Currently used to detect methods that must be marked serialized * in order to avoid problems with the creation of named objects. * ******************************************************************************/ static acpi_status acpi_ds_detect_named_opcodes(struct acpi_walk_state *walk_state, union acpi_parse_object **out_op) { … } /******************************************************************************* * * FUNCTION: acpi_ds_method_error * * PARAMETERS: status - Execution status * walk_state - Current state * * RETURN: Status * * DESCRIPTION: Called on method error. Invoke the global exception handler if * present, dump the method data if the debugger is configured * * Note: Allows the exception handler to change the status code * ******************************************************************************/ acpi_status acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) { … } /******************************************************************************* * * FUNCTION: acpi_ds_create_method_mutex * * PARAMETERS: obj_desc - The method object * * RETURN: Status * * DESCRIPTION: Create a mutex object for a serialized control method * ******************************************************************************/ static acpi_status acpi_ds_create_method_mutex(union acpi_operand_object *method_desc) { … } /******************************************************************************* * * FUNCTION: acpi_ds_begin_method_execution * * PARAMETERS: method_node - Node of the method * obj_desc - The method object * walk_state - current state, NULL if not yet executing * a method. * * RETURN: Status * * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, * increments the thread count, and waits at the method semaphore * for clearance to execute. * ******************************************************************************/ acpi_status acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, union acpi_operand_object *obj_desc, struct acpi_walk_state *walk_state) { … } /******************************************************************************* * * FUNCTION: acpi_ds_call_control_method * * PARAMETERS: thread - Info for this thread * this_walk_state - Current walk state * op - Current Op to be walked * * RETURN: Status * * DESCRIPTION: Transfer execution to a called control method * ******************************************************************************/ acpi_status acpi_ds_call_control_method(struct acpi_thread_state *thread, struct acpi_walk_state *this_walk_state, union acpi_parse_object *op) { … } /******************************************************************************* * * FUNCTION: acpi_ds_restart_control_method * * PARAMETERS: walk_state - State for preempted method (caller) * return_desc - Return value from the called method * * RETURN: Status * * DESCRIPTION: Restart a method that was preempted by another (nested) method * invocation. Handle the return value (if any) from the callee. * ******************************************************************************/ acpi_status acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, union acpi_operand_object *return_desc) { … } /******************************************************************************* * * FUNCTION: acpi_ds_terminate_control_method * * PARAMETERS: method_desc - Method object * walk_state - State associated with the method * * RETURN: None * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse * tree if requested. * * MUTEX: Interpreter is locked * ******************************************************************************/ void acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, struct acpi_walk_state *walk_state) { … }