// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: nspredef - Validation of ACPI predefined methods and objects * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #define ACPI_CREATE_PREDEFINED_TABLE #include <acpi/acpi.h> #include "accommon.h" #include "acnamesp.h" #include "acpredef.h" #define _COMPONENT … ACPI_MODULE_NAME("nspredef") /******************************************************************************* * * This module validates predefined ACPI objects that appear in the namespace, * at the time they are evaluated (via acpi_evaluate_object). The purpose of this * validation is to detect problems with BIOS-exposed predefined ACPI objects * before the results are returned to the ACPI-related drivers. * * There are several areas that are validated: * * 1) The number of input arguments as defined by the method/object in the * ASL is validated against the ACPI specification. * 2) The type of the return object (if any) is validated against the ACPI * specification. * 3) For returned package objects, the count of package elements is * validated, as well as the type of each package element. Nested * packages are supported. * * For any problems found, a warning message is issued. * ******************************************************************************/ /* Local prototypes */ static acpi_status acpi_ns_check_reference(struct acpi_evaluate_info *info, union acpi_operand_object *return_object); static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); /******************************************************************************* * * FUNCTION: acpi_ns_check_return_value * * PARAMETERS: node - Namespace node for the method/object * info - Method execution information block * user_param_count - Number of parameters actually passed * return_status - Status from the object evaluation * return_object_ptr - Pointer to the object returned from the * evaluation of a method or object * * RETURN: Status * * DESCRIPTION: Check the value returned from a predefined name. * ******************************************************************************/ acpi_status acpi_ns_check_return_value(struct acpi_namespace_node *node, struct acpi_evaluate_info *info, u32 user_param_count, acpi_status return_status, union acpi_operand_object **return_object_ptr) { … } /******************************************************************************* * * FUNCTION: acpi_ns_check_object_type * * PARAMETERS: info - Method execution information block * return_object_ptr - Pointer to the object returned from the * evaluation of a method or object * expected_btypes - Bitmap of expected return type(s) * package_index - Index of object within parent package (if * applicable - ACPI_NOT_PACKAGE_ELEMENT * otherwise) * * RETURN: Status * * DESCRIPTION: Check the type of the return object against the expected object * type(s). Use of Btype allows multiple expected object types. * ******************************************************************************/ acpi_status acpi_ns_check_object_type(struct acpi_evaluate_info *info, union acpi_operand_object **return_object_ptr, u32 expected_btypes, u32 package_index) { … } /******************************************************************************* * * FUNCTION: acpi_ns_check_reference * * PARAMETERS: info - Method execution information block * return_object - Object returned from the evaluation of a * method or object * * RETURN: Status * * DESCRIPTION: Check a returned reference object for the correct reference * type. The only reference type that can be returned from a * predefined method is a named reference. All others are invalid. * ******************************************************************************/ static acpi_status acpi_ns_check_reference(struct acpi_evaluate_info *info, union acpi_operand_object *return_object) { … } /******************************************************************************* * * FUNCTION: acpi_ns_get_bitmapped_type * * PARAMETERS: return_object - Object returned from method/obj evaluation * * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object * type is not supported. ACPI_RTYPE_NONE indicates that no * object was returned (return_object is NULL). * * DESCRIPTION: Convert object type into a bitmapped object return type. * ******************************************************************************/ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) { … }