// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager * ******************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acnamesp.h" #include "acresrc.h" #define _COMPONENT … ACPI_MODULE_NAME("rsutils") /******************************************************************************* * * FUNCTION: acpi_rs_decode_bitmask * * PARAMETERS: mask - Bitmask to decode * list - Where the converted list is returned * * RETURN: Count of bits set (length of list) * * DESCRIPTION: Convert a bit mask into a list of values * ******************************************************************************/ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list) { … } /******************************************************************************* * * FUNCTION: acpi_rs_encode_bitmask * * PARAMETERS: list - List of values to encode * count - Length of list * * RETURN: Encoded bitmask * * DESCRIPTION: Convert a list of values to an encoded bitmask * ******************************************************************************/ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) { … } /******************************************************************************* * * FUNCTION: acpi_rs_move_data * * PARAMETERS: destination - Pointer to the destination descriptor * source - Pointer to the source descriptor * item_count - How many items to move * move_type - Byte width * * RETURN: None * * DESCRIPTION: Move multiple data items from one descriptor to another. Handles * alignment issues and endian issues if necessary, as configured * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) * ******************************************************************************/ void acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) { … } /******************************************************************************* * * FUNCTION: acpi_rs_set_resource_length * * PARAMETERS: total_length - Length of the AML descriptor, including * the header and length fields. * aml - Pointer to the raw AML descriptor * * RETURN: None * * DESCRIPTION: Set the resource_length field of an AML * resource descriptor, both Large and Small descriptors are * supported automatically. Note: Descriptor Type field must * be valid. * ******************************************************************************/ void acpi_rs_set_resource_length(acpi_rsdesc_size total_length, union aml_resource *aml) { … } /******************************************************************************* * * FUNCTION: acpi_rs_set_resource_header * * PARAMETERS: descriptor_type - Byte to be inserted as the type * total_length - Length of the AML descriptor, including * the header and length fields. * aml - Pointer to the raw AML descriptor * * RETURN: None * * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML * resource descriptor, both Large and Small descriptors are * supported automatically * ******************************************************************************/ void acpi_rs_set_resource_header(u8 descriptor_type, acpi_rsdesc_size total_length, union aml_resource *aml) { … } /******************************************************************************* * * FUNCTION: acpi_rs_strcpy * * PARAMETERS: destination - Pointer to the destination string * source - Pointer to the source string * * RETURN: String length, including NULL terminator * * DESCRIPTION: Local string copy that returns the string length, saving a * strcpy followed by a strlen. * ******************************************************************************/ static u16 acpi_rs_strcpy(char *destination, char *source) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_resource_source * * PARAMETERS: resource_length - Length field of the descriptor * minimum_length - Minimum length of the descriptor (minus * any optional fields) * resource_source - Where the resource_source is returned * aml - Pointer to the raw AML descriptor * string_ptr - (optional) where to store the actual * resource_source string * * RETURN: Length of the string plus NULL terminator, rounded up to native * word boundary * * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor * to an internal resource descriptor * ******************************************************************************/ acpi_rs_length acpi_rs_get_resource_source(acpi_rs_length resource_length, acpi_rs_length minimum_length, struct acpi_resource_source * resource_source, union aml_resource * aml, char *string_ptr) { … } /******************************************************************************* * * FUNCTION: acpi_rs_set_resource_source * * PARAMETERS: aml - Pointer to the raw AML descriptor * minimum_length - Minimum length of the descriptor (minus * any optional fields) * resource_source - Internal resource_source * * RETURN: Total length of the AML descriptor * * DESCRIPTION: Convert an optional resource_source from internal format to a * raw AML resource descriptor * ******************************************************************************/ acpi_rsdesc_size acpi_rs_set_resource_source(union aml_resource *aml, acpi_rs_length minimum_length, struct acpi_resource_source *resource_source) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_prt_method_data * * PARAMETERS: node - Device node * ret_buffer - Pointer to a buffer structure for the * results * * RETURN: Status * * DESCRIPTION: This function is called to get the _PRT value of an object * contained in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * ******************************************************************************/ acpi_status acpi_rs_get_prt_method_data(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_crs_method_data * * PARAMETERS: node - Device node * ret_buffer - Pointer to a buffer structure for the * results * * RETURN: Status * * DESCRIPTION: This function is called to get the _CRS value of an object * contained in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * ******************************************************************************/ acpi_status acpi_rs_get_crs_method_data(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_prs_method_data * * PARAMETERS: node - Device node * ret_buffer - Pointer to a buffer structure for the * results * * RETURN: Status * * DESCRIPTION: This function is called to get the _PRS value of an object * contained in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * ******************************************************************************/ acpi_status acpi_rs_get_prs_method_data(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_aei_method_data * * PARAMETERS: node - Device node * ret_buffer - Pointer to a buffer structure for the * results * * RETURN: Status * * DESCRIPTION: This function is called to get the _AEI value of an object * contained in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * ******************************************************************************/ acpi_status acpi_rs_get_aei_method_data(struct acpi_namespace_node *node, struct acpi_buffer *ret_buffer) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_method_data * * PARAMETERS: handle - Handle to the containing object * path - Path to method, relative to Handle * ret_buffer - Pointer to a buffer structure for the * results * * RETURN: Status * * DESCRIPTION: This function is called to get the _CRS or _PRS value of an * object contained in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * ******************************************************************************/ acpi_status acpi_rs_get_method_data(acpi_handle handle, const char *path, struct acpi_buffer *ret_buffer) { … } /******************************************************************************* * * FUNCTION: acpi_rs_set_srs_method_data * * PARAMETERS: node - Device node * in_buffer - Pointer to a buffer structure of the * parameter * * RETURN: Status * * DESCRIPTION: This function is called to set the _SRS of an object contained * in an object specified by the handle passed in * * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * * Note: Parameters guaranteed valid by caller * ******************************************************************************/ acpi_status acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, struct acpi_buffer *in_buffer) { … }