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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Mark a variable that will become read-only after leaving the DXE phase of execution.
20 Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.
22 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
23 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
24 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
26 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
27 as pending to be read-only.
28 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
29 Or VariableName is an empty string.
30 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
31 already been signaled.
32 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
36 VariableLockRequestToLock (
37 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
38 IN CHAR16
*VariableName
,
39 IN EFI_GUID
*VendorGuid
43 VAR_CHECK_VARIABLE_PROPERTY Property
;
45 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
47 Status
= VarCheckLibVariablePropertyGet (VariableName
, VendorGuid
, &Property
);
48 if (!EFI_ERROR (Status
)) {
49 Property
.Property
|= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
;
51 Property
.Revision
= VAR_CHECK_VARIABLE_PROPERTY_REVISION
;
52 Property
.Property
= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
;
53 Property
.Attributes
= 0;
55 Property
.MaxSize
= MAX_UINTN
;
57 Status
= VarCheckLibVariablePropertySet (VariableName
, VendorGuid
, &Property
);
59 DEBUG ((EFI_D_INFO
, "[Variable] Lock: %g:%s %r\n", VendorGuid
, VariableName
, Status
));
61 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
67 Register SetVariable check handler.
69 @param[in] Handler Pointer to check handler.
71 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
72 @retval EFI_INVALID_PARAMETER Handler is NULL.
73 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
74 already been signaled.
75 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
76 @retval EFI_UNSUPPORTED This interface is not implemented.
77 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
82 VarCheckRegisterSetVariableCheckHandler (
83 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
88 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
89 Status
= VarCheckLibRegisterSetVariableCheckHandler (Handler
);
90 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
96 Variable property set.
98 @param[in] Name Pointer to the variable name.
99 @param[in] Guid Pointer to the vendor GUID.
100 @param[in] VariableProperty Pointer to the input variable property.
102 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
103 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
104 or the fields of VariableProperty are not valid.
105 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
106 already been signaled.
107 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
112 VarCheckVariablePropertySet (
115 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
120 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
121 Status
= VarCheckLibVariablePropertySet (Name
, Guid
, VariableProperty
);
122 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
128 Variable property get.
130 @param[in] Name Pointer to the variable name.
131 @param[in] Guid Pointer to the vendor GUID.
132 @param[out] VariableProperty Pointer to the output variable property.
134 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
135 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
136 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
141 VarCheckVariablePropertyGet (
144 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
149 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);
150 Status
= VarCheckLibVariablePropertyGet (Name
, Guid
, VariableProperty
);
151 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal
->VariableGlobal
.VariableServicesLock
);