// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acparser.h" #include "amlcode.h" #include "acnamesp.h" #include "acdispat.h" #include "acconvert.h" #define _COMPONENT … ACPI_MODULE_NAME("psargs") /* Local prototypes */ static u32 acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state); static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state *parser_state); static void acpi_ps_free_field_list(union acpi_parse_object *start); /******************************************************************************* * * FUNCTION: acpi_ps_get_next_package_length * * PARAMETERS: parser_state - Current parser state object * * RETURN: Decoded package length. On completion, the AML pointer points * past the length byte or bytes. * * DESCRIPTION: Decode and return a package length field. * Note: Largest package length is 28 bits, from ACPI specification * ******************************************************************************/ static u32 acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_package_end * * PARAMETERS: parser_state - Current parser state object * * RETURN: Pointer to end-of-package +1 * * DESCRIPTION: Get next package length and return a pointer past the end of * the package. Consumes the package length field * ******************************************************************************/ u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_namestring * * PARAMETERS: parser_state - Current parser state object * * RETURN: Pointer to the start of the name string (pointer points into * the AML. * * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name * prefix characters. Set parser state to point past the string. * (Name is consumed from the AML.) * ******************************************************************************/ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_namepath * * PARAMETERS: parser_state - Current parser state object * arg - Where the namepath will be stored * arg_count - If the namepath points to a control method * the method's argument is returned here. * possible_method_call - Whether the namepath can possibly be the * start of a method call * * RETURN: Status * * DESCRIPTION: Get next name (if method call, return # of required args). * Names are looked up in the internal namespace to determine * if the name represents a control method. If a method * is found, the number of arguments to the method is returned. * This information is critical for parsing to continue correctly. * ******************************************************************************/ acpi_status acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, struct acpi_parse_state *parser_state, union acpi_parse_object *arg, u8 possible_method_call) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_simple_arg * * PARAMETERS: parser_state - Current parser state object * arg_type - The argument type (AML_*_ARG) * arg - Where the argument is returned * * RETURN: None * * DESCRIPTION: Get the next simple argument (constant, string, or namestring) * ******************************************************************************/ void acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, u32 arg_type, union acpi_parse_object *arg) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_field * * PARAMETERS: parser_state - Current parser state object * * RETURN: A newly allocated FIELD op * * DESCRIPTION: Get next field (named_field, reserved_field, or access_field) * ******************************************************************************/ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state *parser_state) { … } /******************************************************************************* * * FUNCTION: acpi_ps_free_field_list * * PARAMETERS: start - First Op in field list * * RETURN: None. * * DESCRIPTION: Free all Op objects inside a field list. * ******************************************************************************/ static void acpi_ps_free_field_list(union acpi_parse_object *start) { … } /******************************************************************************* * * FUNCTION: acpi_ps_get_next_arg * * PARAMETERS: walk_state - Current state * parser_state - Current parser state object * arg_type - The argument type (AML_*_ARG) * return_arg - Where the next arg is returned * * RETURN: Status, and an op object containing the next argument. * * DESCRIPTION: Get next argument (including complex list arguments that require * pushing the parser stack) * ******************************************************************************/ acpi_status acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, struct acpi_parse_state *parser_state, u32 arg_type, union acpi_parse_object **return_arg) { … }