19#include <Protocol/VariablePolicy.h>
43 IN UINT32 AttributesMustHave,
44 IN UINT32 AttributesCantHave,
45 IN UINT8 LockPolicyType
48 EntPtr->Version = VARIABLE_POLICY_ENTRY_REVISION;
49 CopyGuid (&EntPtr->Namespace, Namespace);
50 EntPtr->MinSize = MinSize;
51 EntPtr->MaxSize = MaxSize;
52 EntPtr->AttributesMustHave = AttributesMustHave;
53 EntPtr->AttributesCantHave = AttributesCantHave;
54 EntPtr->LockPolicyType = LockPolicyType;
57 if (EntPtr->MaxSize == 0) {
58 EntPtr->MaxSize = VARIABLE_POLICY_NO_MAX_SIZE;
91CreateBasicVariablePolicy (
96 IN UINT32 AttributesMustHave,
97 IN UINT32 AttributesCantHave,
98 IN UINT8 LockPolicyType,
108 if ((Namespace ==
NULL) || (NewEntry ==
NULL)) {
109 return EFI_INVALID_PARAMETER;
112 if ((LockPolicyType != VARIABLE_POLICY_TYPE_NO_LOCK) &&
113 (LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_NOW) &&
114 (LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_CREATE))
116 return EFI_INVALID_PARAMETER;
129 TotalSize += NameSize;
133 ASSERT (TotalSize <= MAX_UINT16);
134 if (TotalSize > MAX_UINT16) {
135 return EFI_BUFFER_TOO_SMALL;
140 if (*NewEntry ==
NULL) {
141 return EFI_OUT_OF_RESOURCES;
156 EntPtr->Size = (UINT16)TotalSize;
159 CopyName = (CHAR16 *)((UINT8 *)EntPtr + EntPtr->OffsetToName);
160 CopyMem (CopyName, Name, NameSize);
193CreateVarStateVariablePolicy (
195 IN CONST CHAR16 *Name OPTIONAL,
198 IN UINT32 AttributesMustHave,
199 IN UINT32 AttributesCantHave,
201 IN UINT8 VarStateValue,
208 UINTN VarStateNameSize;
214 if ((Namespace ==
NULL) || (VarStateNamespace ==
NULL) ||
215 (VarStateName ==
NULL) || (NewEntry ==
NULL))
217 return EFI_INVALID_PARAMETER;
222 VarStateNameSize =
StrnSizeS (VarStateName, MAX_UINT16);
228 TotalSize += NameSize;
232 ASSERT (TotalSize <= MAX_UINT16);
233 if (TotalSize > MAX_UINT16) {
234 return EFI_BUFFER_TOO_SMALL;
239 if (*NewEntry ==
NULL) {
240 return EFI_OUT_OF_RESOURCES;
253 VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE
255 EntPtr->Size = (UINT16)TotalSize;
258 (UINT16)VarStateNameSize;
262 CopyGuid (&CopyPolicy->Namespace, VarStateNamespace);
263 CopyPolicy->Value = VarStateValue;
264 CopyMem (CopyName, VarStateName, VarStateNameSize);
267 CopyName = (CHAR16 *)((UINT8 *)EntPtr + EntPtr->OffsetToName);
268 CopyMem (CopyName, Name, NameSize);
295RegisterBasicVariablePolicy (
298 IN CONST CHAR16 *Name OPTIONAL,
301 IN UINT32 AttributesMustHave,
302 IN UINT32 AttributesCantHave,
303 IN UINT8 LockPolicyType
310 if (VariablePolicy ==
NULL) {
311 return EFI_INVALID_PARAMETER;
316 Status = CreateBasicVariablePolicy (
328 if (!EFI_ERROR (Status)) {
329 Status = VariablePolicy->RegisterVariablePolicy (NewEntry);
333 if (NewEntry !=
NULL) {
363RegisterVarStateVariablePolicy (
366 IN CONST CHAR16 *Name OPTIONAL,
369 IN UINT32 AttributesMustHave,
370 IN UINT32 AttributesCantHave,
373 IN UINT8 VarStateValue
380 if (VariablePolicy ==
NULL) {
381 return EFI_INVALID_PARAMETER;
386 Status = CreateVarStateVariablePolicy (
400 if (!EFI_ERROR (Status)) {
401 Status = VariablePolicy->RegisterVariablePolicy (NewEntry);
405 if (NewEntry !=
NULL) {
UINTN EFIAPI StrnSizeS(IN CONST CHAR16 *String, IN UINTN MaxSize)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)