blob: cd623a39dae36d12643cafd670867e0722418a73 [file] [log] [blame]
Julian Hall0a86f762021-11-08 13:31:23 +00001/*
2 * Copyright (c) 2021, 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 <stdbool.h>
12#include <stddef.h>
13#include <stdint.h>
14#include <protocols/common/efi/efi_status.h>
15#include <protocols/service/smm_variable/smm_variable_proto.h>
16
17#ifdef __cplusplus
18extern "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 */
28struct variable_constraints
29{
30 uint16_t revision;
31 uint16_t property;
32 uint32_t attributes;
33 size_t min_size;
34 size_t max_size;
35};
36
37/**
38 * @brief Set variable check constraints
39 *
40 * @param[in] constraints Variable constraints to set
41 * @param[in] is_update True if updating previously set constraints
42 * @param[in] check_var_property The incoming check variable properties
43 *
44 * @return EFI_SUCCESS if check constraints set successfully
45 */
46efi_status_t variable_checker_set_constraints(
47 struct variable_constraints *constraints,
48 bool is_update,
49 const VAR_CHECK_VARIABLE_PROPERTY *check_var_property);
50
51/**
52 * @brief Get variable check constraints
53 *
54 * @param[in] constraints Variable constraints to get
55 * @param[out] check_var_property The result
56 */
57void variable_checker_get_constraints(
58 const struct variable_constraints *constraints,
59 VAR_CHECK_VARIABLE_PROPERTY *check_var_property);
60
61/**
62 * @brief Check if set operations is allowed
63 *
64 * @param[in] constraints Check constraints corresponding to variable
65 * @param[in] attributes The attributes to set
66 * @param[in] data_size The data size
67 *
68 * @return EFI_SUCCESS if set is allowed
69 */
70efi_status_t variable_checker_check_on_set(
71 const struct variable_constraints *constraints,
72 uint32_t attributes,
73 size_t data_size);
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* VARIABLE_CHECKER_H */