// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths * ******************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acresrc.h" #include "acnamesp.h" #define _COMPONENT … ACPI_MODULE_NAME("rscalc") /* Local prototypes */ static u8 acpi_rs_count_set_bits(u16 bit_field); static acpi_rs_length acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); static u32 acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length); /******************************************************************************* * * FUNCTION: acpi_rs_count_set_bits * * PARAMETERS: bit_field - Field in which to count bits * * RETURN: Number of bits set within the field * * DESCRIPTION: Count the number of bits set in a resource field. Used for * (Short descriptor) interrupt and DMA lists. * ******************************************************************************/ static u8 acpi_rs_count_set_bits(u16 bit_field) { … } /******************************************************************************* * * FUNCTION: acpi_rs_struct_option_length * * PARAMETERS: resource_source - Pointer to optional descriptor field * * RETURN: Status * * DESCRIPTION: Common code to handle optional resource_source_index and * resource_source fields in some Large descriptors. Used during * list-to-stream conversion * ******************************************************************************/ static acpi_rs_length acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) { … } /******************************************************************************* * * FUNCTION: acpi_rs_stream_option_length * * PARAMETERS: resource_length - Length from the resource header * minimum_total_length - Minimum length of this resource, before * any optional fields. Includes header size * * RETURN: Length of optional string (0 if no string present) * * DESCRIPTION: Common code to handle optional resource_source_index and * resource_source fields in some Large descriptors. Used during * stream-to-list conversion * ******************************************************************************/ static u32 acpi_rs_stream_option_length(u32 resource_length, u32 minimum_aml_resource_length) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_aml_length * * PARAMETERS: resource - Pointer to the resource linked list * resource_list_size - Size of the resource linked list * size_needed - Where the required size is returned * * RETURN: Status * * DESCRIPTION: Takes a linked list of internal resource descriptors and * calculates the size buffer needed to hold the corresponding * external resource byte stream. * ******************************************************************************/ acpi_status acpi_rs_get_aml_length(struct acpi_resource *resource, acpi_size resource_list_size, acpi_size *size_needed) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_list_length * * PARAMETERS: aml_buffer - Pointer to the resource byte stream * aml_buffer_length - Size of aml_buffer * size_needed - Where the size needed is returned * * RETURN: Status * * DESCRIPTION: Takes an external resource byte stream and calculates the size * buffer needed to hold the corresponding internal resource * descriptor linked list. * ******************************************************************************/ acpi_status acpi_rs_get_list_length(u8 *aml_buffer, u32 aml_buffer_length, acpi_size *size_needed) { … } /******************************************************************************* * * FUNCTION: acpi_rs_get_pci_routing_table_length * * PARAMETERS: package_object - Pointer to the package object * buffer_size_needed - u32 pointer of the size buffer * needed to properly return the * parsed data * * RETURN: Status * * DESCRIPTION: Given a package representing a PCI routing table, this * calculates the size of the corresponding linked list of * descriptions. * ******************************************************************************/ acpi_status acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, acpi_size *buffer_size_needed) { … }