1 /** @file -- VariablePolicyLib.h
2 Business logic for Variable Policy enforcement.
4 Copyright (c) Microsoft Corporation.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _VARIABLE_POLICY_LIB_H_
10 #define _VARIABLE_POLICY_LIB_H_
12 #include <Protocol/VariablePolicy.h>
15 This API function validates and registers a new policy with
16 the policy enforcement engine.
18 @param[in] NewPolicy Pointer to the incoming policy structure.
21 @retval EFI_INVALID_PARAMETER NewPolicy is NULL or is internally inconsistent.
22 @retval EFI_ALREADY_STARTED An identical matching policy already exists.
23 @retval EFI_WRITE_PROTECTED The interface has been locked until the next reboot.
24 @retval EFI_UNSUPPORTED Policy enforcement has been disabled. No reason to add more policies.
25 @retval EFI_ABORTED A calculation error has prevented this function from completing.
26 @retval EFI_OUT_OF_RESOURCES Cannot grow the table to hold any more policies.
27 @retval EFI_NOT_READY Library has not yet been initialized.
32 RegisterVariablePolicy (
33 IN CONST VARIABLE_POLICY_ENTRY
*NewPolicy
38 This API function checks to see whether the parameters to SetVariable would
39 be allowed according to the current variable policies.
41 @param[in] VariableName Same as EFI_SET_VARIABLE.
42 @param[in] VendorGuid Same as EFI_SET_VARIABLE.
43 @param[in] Attributes Same as EFI_SET_VARIABLE.
44 @param[in] DataSize Same as EFI_SET_VARIABLE.
45 @param[in] Data Same as EFI_SET_VARIABLE.
47 @retval EFI_SUCCESS A matching policy allows this update.
48 @retval EFI_SUCCESS There are currently no policies that restrict this update.
49 @retval EFI_SUCCESS The protections have been disable until the next reboot.
50 @retval EFI_WRITE_PROTECTED Variable is currently locked.
51 @retval EFI_INVALID_PARAMETER Attributes or size are invalid.
52 @retval EFI_ABORTED A lock policy exists, but an error prevented evaluation.
53 @retval EFI_NOT_READY Library has not been initialized.
59 IN CHAR16
*VariableName
,
60 IN EFI_GUID
*VendorGuid
,
68 This API function disables the variable policy enforcement. If it's
69 already been called once, will return EFI_ALREADY_STARTED.
72 @retval EFI_ALREADY_STARTED Has already been called once this boot.
73 @retval EFI_WRITE_PROTECTED Interface has been locked until reboot.
74 @retval EFI_WRITE_PROTECTED Interface option is disabled by platform PCD.
75 @retval EFI_NOT_READY Library has not yet been initialized.
80 DisableVariablePolicy (
86 This API function will dump the entire contents of the variable policy table.
88 Similar to GetVariable, the first call can be made with a 0 size and it will return
89 the size of the buffer required to hold the entire table.
91 @param[out] Policy Pointer to the policy buffer. Can be NULL if Size is 0.
92 @param[in,out] Size On input, the size of the output buffer. On output, the size
95 @retval EFI_SUCCESS Policy data is in the output buffer and Size has been updated.
96 @retval EFI_INVALID_PARAMETER Size is NULL, or Size is non-zero and Policy is NULL.
97 @retval EFI_BUFFER_TOO_SMALL Size is insufficient to hold policy. Size updated with required size.
98 @retval EFI_NOT_READY Library has not yet been initialized.
110 This API function returns whether or not the policy engine is
111 currently being enforced.
115 @retval FALSE Library has not yet been initialized.
120 IsVariablePolicyEnabled (
126 This API function locks the interface so that no more policy updates
127 can be performed or changes made to the enforcement until the next boot.
130 @retval EFI_NOT_READY Library has not yet been initialized.
141 This API function returns whether or not the policy interface is locked
142 for the remainder of the boot.
146 @retval FALSE Library has not yet been initialized.
151 IsVariablePolicyInterfaceLocked (
157 This helper function initializes the library and sets
158 up any required internal structures or handlers.
160 Also registers the internal pointer for the GetVariable helper.
162 @param[in] GetVariableHelper A function pointer matching the EFI_GET_VARIABLE prototype that will be used to
163 check policy criteria that involve the existence of other variables.
166 @retval EFI_ALREADY_STARTED The initialize function has been called more than once without a call to
172 InitVariablePolicyLib (
173 IN EFI_GET_VARIABLE GetVariableHelper
178 This helper function returns whether or not the library is currently initialized.
186 IsVariablePolicyLibInitialized (
192 This helper function tears down the library.
194 Should generally only be used for test harnesses.
197 @retval EFI_NOT_READY Deinitialize was called without first calling initialize.
202 DeinitVariablePolicyLib (
207 #endif // _VARIABLE_POLICY_LIB_H_