// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /******************************************************************************* * * Module Name: utresrc - Resource management utilities * ******************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acresrc.h" #define _COMPONENT … ACPI_MODULE_NAME("utresrc") /* * Base sizes of the raw AML resource descriptors, indexed by resource type. * Zero indicates a reserved (and therefore invalid) resource type. */ const u8 acpi_gbl_resource_aml_sizes[] = …; const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = …; /* * Resource types, used to validate the resource length field. * The length of fixed-length types must match exactly, variable * lengths must meet the minimum required length, etc. * Zero indicates a reserved (and therefore invalid) resource type. */ static const u8 acpi_gbl_resource_types[] = …; /******************************************************************************* * * FUNCTION: acpi_ut_walk_aml_resources * * PARAMETERS: walk_state - Current walk info * PARAMETERS: aml - Pointer to the raw AML resource template * aml_length - Length of the entire template * user_function - Called once for each descriptor found. If * NULL, a pointer to the end_tag is returned * context - Passed to user_function * * RETURN: Status * * DESCRIPTION: Walk a raw AML resource list(buffer). User function called * once for each resource found. * ******************************************************************************/ acpi_status acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, u8 *aml, acpi_size aml_length, acpi_walk_aml_callback user_function, void **context) { … } /******************************************************************************* * * FUNCTION: acpi_ut_validate_resource * * PARAMETERS: walk_state - Current walk info * aml - Pointer to the raw AML resource descriptor * return_index - Where the resource index is returned. NULL * if the index is not required. * * RETURN: Status, and optionally the Index into the global resource tables * * DESCRIPTION: Validate an AML resource descriptor by checking the Resource * Type and Resource Length. Returns an index into the global * resource information/dispatch tables for later use. * ******************************************************************************/ acpi_status acpi_ut_validate_resource(struct acpi_walk_state *walk_state, void *aml, u8 *return_index) { … } /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_type * * PARAMETERS: aml - Pointer to the raw AML resource descriptor * * RETURN: The Resource Type with no extraneous bits (except the * Large/Small descriptor bit -- this is left alone) * * DESCRIPTION: Extract the Resource Type/Name from the first byte of * a resource descriptor. * ******************************************************************************/ u8 acpi_ut_get_resource_type(void *aml) { … } /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_length * * PARAMETERS: aml - Pointer to the raw AML resource descriptor * * RETURN: Byte Length * * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By * definition, this does not include the size of the descriptor * header or the length field itself. * ******************************************************************************/ u16 acpi_ut_get_resource_length(void *aml) { … } /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_header_length * * PARAMETERS: aml - Pointer to the raw AML resource descriptor * * RETURN: Length of the AML header (depends on large/small descriptor) * * DESCRIPTION: Get the length of the header for this resource. * ******************************************************************************/ u8 acpi_ut_get_resource_header_length(void *aml) { … } /******************************************************************************* * * FUNCTION: acpi_ut_get_descriptor_length * * PARAMETERS: aml - Pointer to the raw AML resource descriptor * * RETURN: Byte length * * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the * length of the descriptor header and the length field itself. * Used to walk descriptor lists. * ******************************************************************************/ u32 acpi_ut_get_descriptor_length(void *aml) { … } /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_end_tag * * PARAMETERS: obj_desc - The resource template buffer object * end_tag - Where the pointer to the end_tag is returned * * RETURN: Status, pointer to the end tag * * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template * Note: allows a buffer length of zero. * ******************************************************************************/ acpi_status acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag) { … }