]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/VariablePolicyHelperLib.h
MdeModulePkg/UniversalPayload: Add definition for extra info in payload
[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
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
51 );\r
52\r
53\r
54/**\r
55 This helper function will allocate and populate a new VariablePolicy\r
56 structure for a policy with a lock type of VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE.\r
57\r
58 NOTE: Caller will need to free structure once finished.\r
59\r
60 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
61 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
62 Otherwise, will create a policy that targets an entire namespace.\r
63 @param[in] MinSize MinSize for the VariablePolicy.\r
64 @param[in] MaxSize MaxSize for the VariablePolicy.\r
65 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
66 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
67 @param[in] VarStateNamespace Pointer to the EFI_GUID for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Namespace.\r
68 @param[in] VarStateValue Value for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Value.\r
69 @param[in] VarStateName Pointer to the CHAR16 array for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Name.\r
70 @param[out] NewEntry If successful, will be set to a pointer to the allocated buffer containing the\r
71 new policy.\r
72\r
73 @retval EFI_SUCCESS Operation completed successfully and structure is populated.\r
74 @retval EFI_INVALID_PARAMETER Namespace, VarStateNamespace, VarStateName is NULL.\r
75 @retval EFI_BUFFER_TOO_SMALL Finished structure would not fit in UINT16 size.\r
76 @retval EFI_OUT_OF_RESOURCES Could not allocate sufficient space for structure.\r
77\r
78**/\r
79EFI_STATUS\r
80EFIAPI\r
81CreateVarStateVariablePolicy (\r
82 IN CONST EFI_GUID *Namespace,\r
83 IN CONST CHAR16 *Name OPTIONAL,\r
84 IN UINT32 MinSize,\r
85 IN UINT32 MaxSize,\r
86 IN UINT32 AttributesMustHave,\r
87 IN UINT32 AttributesCantHave,\r
88 IN CONST EFI_GUID *VarStateNamespace,\r
89 IN UINT8 VarStateValue,\r
90 IN CONST CHAR16 *VarStateName,\r
91 OUT VARIABLE_POLICY_ENTRY **NewEntry\r
92 );\r
93\r
94\r
95/**\r
96 This helper function does everything that CreateBasicVariablePolicy() does, but also\r
97 uses the passed in protocol to register the policy with the infrastructure.\r
98 Does not return a buffer, does not require the caller to free anything.\r
99\r
100 @param[in] VariablePolicy Pointer to a valid instance of the VariablePolicy protocol.\r
101 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
102 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
103 Otherwise, will create a policy that targets an entire namespace.\r
104 @param[in] MinSize MinSize for the VariablePolicy.\r
105 @param[in] MaxSize MaxSize for the VariablePolicy.\r
106 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
107 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
108 @param[in] LockPolicyType LockPolicyType for the VariablePolicy.\r
109\r
110 @retval EFI_INVALID_PARAMETER VariablePolicy pointer is NULL.\r
111 @retval EFI_STATUS Status returned by CreateBasicVariablePolicy() or RegisterVariablePolicy().\r
112\r
113**/\r
114EFI_STATUS\r
115EFIAPI\r
116RegisterBasicVariablePolicy (\r
117 IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy,\r
118 IN CONST EFI_GUID *Namespace,\r
119 IN CONST CHAR16 *Name OPTIONAL,\r
120 IN UINT32 MinSize,\r
121 IN UINT32 MaxSize,\r
122 IN UINT32 AttributesMustHave,\r
123 IN UINT32 AttributesCantHave,\r
124 IN UINT8 LockPolicyType\r
125 );\r
126\r
127\r
128/**\r
129 This helper function does everything that CreateBasicVariablePolicy() does, but also\r
130 uses the passed in protocol to register the policy with the infrastructure.\r
131 Does not return a buffer, does not require the caller to free anything.\r
132\r
133 @param[in] VariablePolicy Pointer to a valid instance of the VariablePolicy protocol.\r
134 @param[in] Namespace Pointer to an EFI_GUID for the target variable namespace that this policy will protect.\r
135 @param[in] Name [Optional] If provided, a pointer to the CHAR16 array for the target variable name.\r
136 Otherwise, will create a policy that targets an entire namespace.\r
137 @param[in] MinSize MinSize for the VariablePolicy.\r
138 @param[in] MaxSize MaxSize for the VariablePolicy.\r
139 @param[in] AttributesMustHave AttributesMustHave for the VariablePolicy.\r
140 @param[in] AttributesCantHave AttributesCantHave for the VariablePolicy.\r
141 @param[in] VarStateNamespace Pointer to the EFI_GUID for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Namespace.\r
142 @param[in] VarStateName Pointer to the CHAR16 array for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Name.\r
143 @param[in] VarStateValue Value for the VARIABLE_LOCK_ON_VAR_STATE_POLICY.Value.\r
144\r
145 @retval EFI_INVALID_PARAMETER VariablePolicy pointer is NULL.\r
146 @retval EFI_STATUS Status returned by CreateBasicVariablePolicy() or RegisterVariablePolicy().\r
147\r
148**/\r
149EFI_STATUS\r
150EFIAPI\r
151RegisterVarStateVariablePolicy (\r
152 IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy,\r
153 IN CONST EFI_GUID *Namespace,\r
154 IN CONST CHAR16 *Name OPTIONAL,\r
155 IN UINT32 MinSize,\r
156 IN UINT32 MaxSize,\r
157 IN UINT32 AttributesMustHave,\r
158 IN UINT32 AttributesCantHave,\r
159 IN CONST EFI_GUID *VarStateNamespace,\r
160 IN CONST CHAR16 *VarStateName,\r
161 IN UINT8 VarStateValue\r
162 );\r
163\r
164#endif // _EDKII_VARIABLE_POLICY_HELPER_LIB_H_\r