// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /******************************************************************************* * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces * ******************************************************************************/ #define EXPORT_ACPI_INTERFACES #include <acpi/acpi.h> #include "accommon.h" #include "acnamesp.h" #include "acinterp.h" #define _COMPONENT … ACPI_MODULE_NAME("nsxfeval") /* Local prototypes */ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info); /******************************************************************************* * * FUNCTION: acpi_evaluate_object_typed * * PARAMETERS: handle - Object handle (optional) * pathname - Object pathname (optional) * external_params - List of parameters to pass to a method, * terminated by NULL. May be NULL * if no parameters are being passed. * return_buffer - Where to put the object's return value (if * any). If NULL, no value is returned. * return_type - Expected type of return object * * RETURN: Status * * DESCRIPTION: Find and evaluate the given object, passing the given * parameters if necessary. One of "Handle" or "Pathname" must * be valid (non-null) * ******************************************************************************/ acpi_status acpi_evaluate_object_typed(acpi_handle handle, acpi_string pathname, struct acpi_object_list *external_params, struct acpi_buffer *return_buffer, acpi_object_type return_type) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_evaluate_object * * PARAMETERS: handle - Object handle (optional) * pathname - Object pathname (optional) * external_params - List of parameters to pass to method, * terminated by NULL. May be NULL * if no parameters are being passed. * return_buffer - Where to put method's return value (if * any). If NULL, no value is returned. * * RETURN: Status * * DESCRIPTION: Find and evaluate the given object, passing the given * parameters if necessary. One of "Handle" or "Pathname" must * be valid (non-null) * ******************************************************************************/ acpi_status acpi_evaluate_object(acpi_handle handle, acpi_string pathname, struct acpi_object_list *external_params, struct acpi_buffer *return_buffer) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_ns_resolve_references * * PARAMETERS: info - Evaluation info block * * RETURN: Info->return_object is replaced with the dereferenced object * * DESCRIPTION: Dereference certain reference objects. Called before an * internal return object is converted to an external union acpi_object. * * Performs an automatic dereference of Index and ref_of reference objects. * These reference objects are not supported by the union acpi_object, so this is a * last resort effort to return something useful. Also, provides compatibility * with other ACPI implementations. * * NOTE: does not handle references within returned package objects or nested * references, but this support could be added later if found to be necessary. * ******************************************************************************/ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info) { … } /******************************************************************************* * * FUNCTION: acpi_walk_namespace * * PARAMETERS: type - acpi_object_type to search for * start_object - Handle in namespace where search begins * max_depth - Depth to which search is to reach * descending_callback - Called during tree descent * when an object of "Type" is found * ascending_callback - Called during tree ascent * when an object of "Type" is found * context - Passed to user function(s) above * return_value - Location where return value of * user_function is put if terminated early * * RETURNS Return value from the user_function if terminated early. * Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, * starting (and ending) at the object specified by start_handle. * The callback function is called whenever an object that matches * the type parameter is found. If the callback function returns * a non-zero value, the search is terminated immediately and this * value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to * provide multiple services; the callback function(s) can be * tailored to each task, whether it is a print function, * a compare function, etc. * ******************************************************************************/ acpi_status acpi_walk_namespace(acpi_object_type type, acpi_handle start_object, u32 max_depth, acpi_walk_callback descending_callback, acpi_walk_callback ascending_callback, void *context, void **return_value) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_ns_get_device_callback * * PARAMETERS: Callback from acpi_get_device * * RETURN: Status * * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non- * present devices, or if they specified a HID, it filters based * on that. * ******************************************************************************/ static acpi_status acpi_ns_get_device_callback(acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { … } /******************************************************************************* * * FUNCTION: acpi_get_devices * * PARAMETERS: HID - HID to search for. Can be NULL. * user_function - Called when a matching object is found * context - Passed to user function * return_value - Location where return value of * user_function is put if terminated early * * RETURNS Return value from the user_function if terminated early. * Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, * starting (and ending) at the object specified by start_handle. * The user_function is called whenever an object of type * Device is found. If the user function returns * a non-zero value, the search is terminated immediately and this * value is returned to the caller. * * This is a wrapper for walk_namespace, but the callback performs * additional filtering. Please see acpi_ns_get_device_callback. * ******************************************************************************/ acpi_status acpi_get_devices(const char *HID, acpi_walk_callback user_function, void *context, void **return_value) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_attach_data * * PARAMETERS: obj_handle - Namespace node * handler - Handler for this attachment * data - Pointer to data to be attached * * RETURN: Status * * DESCRIPTION: Attach arbitrary data and handler to a namespace node. * ******************************************************************************/ acpi_status acpi_attach_data(acpi_handle obj_handle, acpi_object_handler handler, void *data) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_detach_data * * PARAMETERS: obj_handle - Namespace node handle * handler - Handler used in call to acpi_attach_data * * RETURN: Status * * DESCRIPTION: Remove data that was previously attached to a node. * ******************************************************************************/ acpi_status acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_get_data_full * * PARAMETERS: obj_handle - Namespace node * handler - Handler used in call to attach_data * data - Where the data is returned * callback - function to execute before returning * * RETURN: Status * * DESCRIPTION: Retrieve data that was previously attached to a namespace node * and execute a callback before returning. * ******************************************************************************/ acpi_status acpi_get_data_full(acpi_handle obj_handle, acpi_object_handler handler, void **data, void (*callback)(void *)) { … } ACPI_EXPORT_SYMBOL(…) /******************************************************************************* * * FUNCTION: acpi_get_data * * PARAMETERS: obj_handle - Namespace node * handler - Handler used in call to attach_data * data - Where the data is returned * * RETURN: Status * * DESCRIPTION: Retrieve data that was previously attached to a namespace node. * ******************************************************************************/ acpi_status acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) { … } ACPI_EXPORT_SYMBOL(…)