]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/VariablePolicyHelperLib.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Include / Library / VariablePolicyHelperLib.h
CommitLineData
b6104bec
BB
1/** @file -- VariablePolicyHelperLib.h\r
2This library contains helper functions for marshalling and registering\r
3new policies with the VariablePolicy infrastructure.\r
4\r
5Copyright (c) Microsoft Corporation.\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef _EDKII_VARIABLE_POLICY_HELPER_LIB_H_\r
11#define _EDKII_VARIABLE_POLICY_HELPER_LIB_H_\r
12\r
13#include <Protocol/VariablePolicy.h>\r
14\r
15/**\r
16 This helper function will allocate and populate a new VariablePolicy\r
17 structure for a policy that does not contain any sub-structures (such as\r
18 VARIABLE_LOCK_ON_VAR_STATE_POLICY).\r
19\r
20 NOTE: Caller will need to free structure once finished.\r
21\r
22 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
23 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
24 Otherwise, will create a policy that targets an entire namespace.\r
25 @param[in] MinSize MinSize for the VariablePolicy.\r
26 @param[in] MaxSize MaxSize for the VariablePolicy.\r
27 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
28 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
29 @param[in] LockPolicyType LockPolicyType for the VariablePolicy.\r
30 @param[out] NewEntry If successful, will be set to a pointer to the allocated buffer containing the\r
31 new policy.\r
32\r
33 @retval EFI_SUCCESS Operation completed successfully and structure is populated.\r
34 @retval EFI_INVALID_PARAMETER Namespace is NULL.\r
35 @retval EFI_INVALID_PARAMETER LockPolicyType is invalid for a basic structure.\r
36 @retval EFI_BUFFER_TOO_SMALL Finished structure would not fit in UINT16 size.\r
37 @retval EFI_OUT_OF_RESOURCES Could not allocate sufficient space for structure.\r
38\r
39**/\r
40EFI_STATUS\r
41EFIAPI\r
42CreateBasicVariablePolicy (\r
1436aea4
MK
43 IN CONST EFI_GUID *Namespace,\r
44 IN CONST CHAR16 *Name OPTIONAL,\r
45 IN UINT32 MinSize,\r
46 IN UINT32 MaxSize,\r
47 IN UINT32 AttributesMustHave,\r
48 IN UINT32 AttributesCantHave,\r
49 IN UINT8 LockPolicyType,\r
50 OUT VARIABLE_POLICY_ENTRY **NewEntry\r
b6104bec
BB
51 );\r
52\r
b6104bec
BB
53/**\r
54 This helper function will allocate and populate a new VariablePolicy\r
55 structure for a policy with a lock type of VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE.\r
56\r
57 NOTE: Caller will need to free structure once finished.\r
58\r
59 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
60 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
61 Otherwise, will create a policy that targets an entire namespace.\r
62 @param[in] MinSize MinSize for the VariablePolicy.\r
63 @param[in] MaxSize MaxSize for the VariablePolicy.\r
64 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
65 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
66 @param[in] VarStateNamespace Pointer to the EFI_GUID for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Namespace.\r
67 @param[in] VarStateValue Value for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Value.\r
68 @param[in] VarStateName Pointer to the CHAR16 array for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Name.\r
69 @param[out] NewEntry If successful, will be set to a pointer to the allocated buffer containing the\r
70 new policy.\r
71\r
72 @retval EFI_SUCCESS Operation completed successfully and structure is populated.\r
73 @retval EFI_INVALID_PARAMETER Namespace, VarStateNamespace, VarStateName is NULL.\r
74 @retval EFI_BUFFER_TOO_SMALL Finished structure would not fit in UINT16 size.\r
75 @retval EFI_OUT_OF_RESOURCES Could not allocate sufficient space for structure.\r
76\r
77**/\r
78EFI_STATUS\r
79EFIAPI\r
80CreateVarStateVariablePolicy (\r
1436aea4
MK
81 IN CONST EFI_GUID *Namespace,\r
82 IN CONST CHAR16 *Name OPTIONAL,\r
83 IN UINT32 MinSize,\r
84 IN UINT32 MaxSize,\r
85 IN UINT32 AttributesMustHave,\r
86 IN UINT32 AttributesCantHave,\r
87 IN CONST EFI_GUID *VarStateNamespace,\r
88 IN UINT8 VarStateValue,\r
89 IN CONST CHAR16 *VarStateName,\r
90 OUT VARIABLE_POLICY_ENTRY **NewEntry\r
b6104bec
BB
91 );\r
92\r
b6104bec
BB
93/**\r
94 This helper function does everything that CreateBasicVariablePolicy() does, but also\r
95 uses the passed in protocol to register the policy with the infrastructure.\r
96 Does not return a buffer, does not require the caller to free anything.\r
97\r
98 @param[in] VariablePolicy Pointer to a valid instance of the VariablePolicy protocol.\r
99 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
100 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
101 Otherwise, will create a policy that targets an entire namespace.\r
102 @param[in] MinSize MinSize for the VariablePolicy.\r
103 @param[in] MaxSize MaxSize for the VariablePolicy.\r
104 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
105 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
106 @param[in] LockPolicyType LockPolicyType for the VariablePolicy.\r
107\r
108 @retval EFI_INVALID_PARAMETER VariablePolicy pointer is NULL.\r
109 @retval EFI_STATUS Status returned by CreateBasicVariablePolicy() or RegisterVariablePolicy().\r
110\r
111**/\r
112EFI_STATUS\r
113EFIAPI\r
114RegisterBasicVariablePolicy (\r
115 IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy,\r
116 IN CONST EFI_GUID *Namespace,\r
117 IN CONST CHAR16 *Name OPTIONAL,\r
118 IN UINT32 MinSize,\r
119 IN UINT32 MaxSize,\r
120 IN UINT32 AttributesMustHave,\r
121 IN UINT32 AttributesCantHave,\r
122 IN UINT8 LockPolicyType\r
123 );\r
124\r
b6104bec
BB
125/**\r
126 This helper function does everything that CreateBasicVariablePolicy() does, but also\r
127 uses the passed in protocol to register the policy with the infrastructure.\r
128 Does not return a buffer, does not require the caller to free anything.\r
129\r
130 @param[in] VariablePolicy Pointer to a valid instance of the VariablePolicy protocol.\r
131 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
132 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
133 Otherwise, will create a policy that targets an entire namespace.\r
134 @param[in] MinSize MinSize for the VariablePolicy.\r
135 @param[in] MaxSize MaxSize for the VariablePolicy.\r
136 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
137 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
138 @param[in] VarStateNamespace Pointer to the EFI_GUID for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Namespace.\r
139 @param[in] VarStateName Pointer to the CHAR16 array for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Name.\r
140 @param[in] VarStateValue Value for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Value.\r
141\r
142 @retval EFI_INVALID_PARAMETER VariablePolicy pointer is NULL.\r
143 @retval EFI_STATUS Status returned by CreateBasicVariablePolicy() or RegisterVariablePolicy().\r
144\r
145**/\r
146EFI_STATUS\r
147EFIAPI\r
148RegisterVarStateVariablePolicy (\r
149 IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy,\r
150 IN CONST EFI_GUID *Namespace,\r
151 IN CONST CHAR16 *Name OPTIONAL,\r
152 IN UINT32 MinSize,\r
153 IN UINT32 MaxSize,\r
154 IN UINT32 AttributesMustHave,\r
155 IN UINT32 AttributesCantHave,\r
156 IN CONST EFI_GUID *VarStateNamespace,\r
157 IN CONST CHAR16 *VarStateName,\r
158 IN UINT8 VarStateValue\r
159 );\r
160\r
161#endif // _EDKII_VARIABLE_POLICY_HELPER_LIB_H_\r