2 Implementation functions and structures for var check protocol
3 and variable lock protocol based on VarCheckLib.
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Mark a variable that will become read-only after leaving the DXE phase of execution.
14 Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.
16 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
17 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
18 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
20 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
21 as pending to be read-only.
22 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
23 Or VariableName is an empty string.
24 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
25 already been signaled.
26 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
30 VariableLockRequestToLock (
31 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
32 IN CHAR16
*VariableName
,
33 IN EFI_GUID
*VendorGuid
37 VAR_CHECK_VARIABLE_PROPERTY Property
;
39 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
41 Status
= VarCheckLibVariablePropertyGet (VariableName
, VendorGuid
, &Property
);
42 if (!EFI_ERROR (Status
)) {
43 Property
.Property
|= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
;
45 Property
.Revision
= VAR_CHECK_VARIABLE_PROPERTY_REVISION
;
46 Property
.Property
= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
;
47 Property
.Attributes
= 0;
49 Property
.MaxSize
= MAX_UINTN
;
51 Status
= VarCheckLibVariablePropertySet (VariableName
, VendorGuid
, &Property
);
53 DEBUG ((EFI_D_INFO
, "[Variable] Lock: %g:%s %r\n", VendorGuid
, VariableName
, Status
));
55 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
61 Register SetVariable check handler.
63 @param[in] Handler Pointer to check handler.
65 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
66 @retval EFI_INVALID_PARAMETER Handler is NULL.
67 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
68 already been signaled.
69 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
70 @retval EFI_UNSUPPORTED This interface is not implemented.
71 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
76 VarCheckRegisterSetVariableCheckHandler (
77 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
82 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
83 Status
= VarCheckLibRegisterSetVariableCheckHandler (Handler
);
84 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
90 Variable property set.
92 @param[in] Name Pointer to the variable name.
93 @param[in] Guid Pointer to the vendor GUID.
94 @param[in] VariableProperty Pointer to the input variable property.
96 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
97 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
98 or the fields of VariableProperty are not valid.
99 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
100 already been signaled.
101 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
106 VarCheckVariablePropertySet (
109 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
114 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
115 Status
= VarCheckLibVariablePropertySet (Name
, Guid
, VariableProperty
);
116 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
122 Variable property get.
124 @param[in] Name Pointer to the variable name.
125 @param[in] Guid Pointer to the vendor GUID.
126 @param[out] VariableProperty Pointer to the output variable property.
128 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
129 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
130 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
135 VarCheckVariablePropertyGet (
138 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
143 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
144 Status
= VarCheckLibVariablePropertyGet (Name
, Guid
, VariableProperty
);
145 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);