1 /* 2 * Copyright (c) 2021-2023, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef VARIABLE_CHECKER_H 9 #define VARIABLE_CHECKER_H 10 11 #include <protocols/common/efi/efi_status.h> 12 #include <protocols/service/smm_variable/smm_variable_proto.h> 13 #include <stdbool.h> 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * \brief variable_constraints structure definition 23 * 24 * Defines constraints used for checking variable set operations 25 * based on policy driven constraints, set using: 26 * SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET. 27 */ 28 struct variable_constraints { 29 uint16_t revision; 30 uint16_t property; 31 uint32_t attributes; 32 size_t min_size; 33 size_t max_size; 34 }; 35 36 /** 37 * @brief Set variable check constraints 38 * 39 * @param[in] constraints Variable constraints to set 40 * @param[in] is_update True if updating previously set constraints 41 * @param[in] check_var_property The incoming check variable properties 42 * 43 * @return EFI_SUCCESS if check constraints set successfully 44 */ 45 efi_status_t 46 variable_checker_set_constraints(struct variable_constraints *constraints, bool is_update, 47 const VAR_CHECK_VARIABLE_PROPERTY *check_var_property); 48 49 /** 50 * @brief Get variable check constraints 51 * 52 * @param[in] constraints Variable constraints to get 53 * @param[out] check_var_property The result 54 */ 55 void variable_checker_get_constraints(const struct variable_constraints *constraints, 56 VAR_CHECK_VARIABLE_PROPERTY *check_var_property); 57 58 /** 59 * @brief Check if set operations is allowed 60 * 61 * @param[in] constraints Check constraints corresponding to variable 62 * @param[in] attributes The attributes to set 63 * @param[in] data_size The data size 64 * 65 * @return EFI_SUCCESS if set is allowed 66 */ 67 efi_status_t variable_checker_check_on_set(const struct variable_constraints *constraints, 68 uint32_t attributes, size_t data_size); 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #endif /* VARIABLE_CHECKER_H */ 75