]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VarCheck.c
1 /** @file
2 Implementation functions and structures for var check protocol
3 and variable lock protocol based on VarCheckLib.
4
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 Copyright (c) Microsoft Corporation.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include "Variable.h"
12
13 /**
14 Register SetVariable check handler.
15
16 @param[in] Handler Pointer to check handler.
17
18 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
19 @retval EFI_INVALID_PARAMETER Handler is NULL.
20 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
21 already been signaled.
22 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
23 @retval EFI_UNSUPPORTED This interface is not implemented.
24 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
25
26 **/
27 EFI_STATUS
28 EFIAPI
29 VarCheckRegisterSetVariableCheckHandler (
30 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
31 )
32 {
33 EFI_STATUS Status;
34
35 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
36 Status = VarCheckLibRegisterSetVariableCheckHandler (Handler);
37 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
38
39 return Status;
40 }
41
42 /**
43 Variable property set.
44
45 @param[in] Name Pointer to the variable name.
46 @param[in] Guid Pointer to the vendor GUID.
47 @param[in] VariableProperty Pointer to the input variable property.
48
49 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
50 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
51 or the fields of VariableProperty are not valid.
52 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
53 already been signaled.
54 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
55
56 **/
57 EFI_STATUS
58 EFIAPI
59 VarCheckVariablePropertySet (
60 IN CHAR16 *Name,
61 IN EFI_GUID *Guid,
62 IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
63 )
64 {
65 EFI_STATUS Status;
66
67 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
68 Status = VarCheckLibVariablePropertySet (Name, Guid, VariableProperty);
69 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
70
71 return Status;
72 }
73
74 /**
75 Variable property get.
76
77 @param[in] Name Pointer to the variable name.
78 @param[in] Guid Pointer to the vendor GUID.
79 @param[out] VariableProperty Pointer to the output variable property.
80
81 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
82 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
83 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
84
85 **/
86 EFI_STATUS
87 EFIAPI
88 VarCheckVariablePropertyGet (
89 IN CHAR16 *Name,
90 IN EFI_GUID *Guid,
91 OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
92 )
93 {
94 EFI_STATUS Status;
95
96 AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
97 Status = VarCheckLibVariablePropertyGet (Name, Guid, VariableProperty);
98 ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
99
100 return Status;
101 }