]>
Commit | Line | Data |
---|---|---|
efb01a10 | 1 | /** @file\r |
8021f4c7 SZ |
2 | Implementation functions and structures for var check protocol\r |
3 | and variable lock protocol based on VarCheckLib.\r | |
efb01a10 SZ |
4 | \r |
5 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
fa0737a8 SZ |
6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
efb01a10 SZ |
9 | http://opensource.org/licenses/bsd-license.php\r |
10 | \r | |
fa0737a8 | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
efb01a10 SZ |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "Variable.h"\r | |
efb01a10 SZ |
17 | \r |
18 | /**\r | |
8021f4c7 SZ |
19 | Mark a variable that will become read-only after leaving the DXE phase of execution.\r |
20 | Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.\r | |
efb01a10 | 21 | \r |
8021f4c7 SZ |
22 | @param[in] This The VARIABLE_LOCK_PROTOCOL instance.\r |
23 | @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.\r | |
24 | @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.\r | |
efb01a10 | 25 | \r |
8021f4c7 SZ |
26 | @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked\r |
27 | as pending to be read-only.\r | |
28 | @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r | |
29 | Or VariableName is an empty string.\r | |
30 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
31 | already been signaled.\r | |
32 | @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.\r | |
efb01a10 SZ |
33 | **/\r |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
8021f4c7 SZ |
36 | VariableLockRequestToLock (\r |
37 | IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r | |
38 | IN CHAR16 *VariableName,\r | |
39 | IN EFI_GUID *VendorGuid\r | |
efb01a10 SZ |
40 | )\r |
41 | {\r | |
42 | EFI_STATUS Status;\r | |
8021f4c7 | 43 | VAR_CHECK_VARIABLE_PROPERTY Property;\r |
efb01a10 | 44 | \r |
8021f4c7 | 45 | AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
efb01a10 | 46 | \r |
8021f4c7 SZ |
47 | Status = VarCheckLibVariablePropertyGet (VariableName, VendorGuid, &Property);\r |
48 | if (!EFI_ERROR (Status)) {\r | |
49 | Property.Property |= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;\r | |
50 | } else {\r | |
51 | Property.Revision = VAR_CHECK_VARIABLE_PROPERTY_REVISION;\r | |
52 | Property.Property = VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;\r | |
53 | Property.Attributes = 0;\r | |
54 | Property.MinSize = 1;\r | |
55 | Property.MaxSize = MAX_UINTN;\r | |
efb01a10 | 56 | }\r |
8021f4c7 | 57 | Status = VarCheckLibVariablePropertySet (VariableName, VendorGuid, &Property);\r |
efb01a10 | 58 | \r |
8021f4c7 | 59 | DEBUG ((EFI_D_INFO, "[Variable] Lock: %g:%s %r\n", VendorGuid, VariableName, Status));\r |
efb01a10 | 60 | \r |
8021f4c7 | 61 | ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
efb01a10 | 62 | \r |
8021f4c7 | 63 | return Status;\r |
efb01a10 SZ |
64 | }\r |
65 | \r | |
66 | /**\r | |
67 | Register SetVariable check handler.\r | |
68 | \r | |
69 | @param[in] Handler Pointer to check handler.\r | |
70 | \r | |
71 | @retval EFI_SUCCESS The SetVariable check handler was registered successfully.\r | |
72 | @retval EFI_INVALID_PARAMETER Handler is NULL.\r | |
73 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
74 | already been signaled.\r | |
75 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.\r | |
76 | @retval EFI_UNSUPPORTED This interface is not implemented.\r | |
77 | For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.\r | |
78 | \r | |
79 | **/\r | |
80 | EFI_STATUS\r | |
81 | EFIAPI\r | |
82 | VarCheckRegisterSetVariableCheckHandler (\r | |
83 | IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler\r | |
84 | )\r | |
85 | {\r | |
86 | EFI_STATUS Status;\r | |
87 | \r | |
fa0737a8 | 88 | AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
8021f4c7 | 89 | Status = VarCheckLibRegisterSetVariableCheckHandler (Handler);\r |
fa0737a8 SZ |
90 | ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
91 | \r | |
92 | return Status;\r | |
efb01a10 SZ |
93 | }\r |
94 | \r | |
efb01a10 SZ |
95 | /**\r |
96 | Variable property set.\r | |
97 | \r | |
98 | @param[in] Name Pointer to the variable name.\r | |
99 | @param[in] Guid Pointer to the vendor GUID.\r | |
100 | @param[in] VariableProperty Pointer to the input variable property.\r | |
101 | \r | |
102 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.\r | |
103 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,\r | |
104 | or the fields of VariableProperty are not valid.\r | |
105 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
106 | already been signaled.\r | |
107 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.\r | |
108 | \r | |
109 | **/\r | |
110 | EFI_STATUS\r | |
111 | EFIAPI\r | |
112 | VarCheckVariablePropertySet (\r | |
113 | IN CHAR16 *Name,\r | |
114 | IN EFI_GUID *Guid,\r | |
115 | IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
116 | )\r | |
117 | {\r | |
8021f4c7 | 118 | EFI_STATUS Status;\r |
efb01a10 | 119 | \r |
efb01a10 | 120 | AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
8021f4c7 | 121 | Status = VarCheckLibVariablePropertySet (Name, Guid, VariableProperty);\r |
efb01a10 SZ |
122 | ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
123 | \r | |
124 | return Status;\r | |
125 | }\r | |
126 | \r | |
4edb1866 SZ |
127 | /**\r |
128 | Variable property get.\r | |
129 | \r | |
130 | @param[in] Name Pointer to the variable name.\r | |
131 | @param[in] Guid Pointer to the vendor GUID.\r | |
132 | @param[out] VariableProperty Pointer to the output variable property.\r | |
133 | \r | |
134 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.\r | |
135 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.\r | |
136 | @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.\r | |
137 | \r | |
138 | **/\r | |
139 | EFI_STATUS\r | |
140 | EFIAPI\r | |
141 | VarCheckVariablePropertyGet (\r | |
142 | IN CHAR16 *Name,\r | |
143 | IN EFI_GUID *Guid,\r | |
144 | OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
145 | )\r | |
146 | {\r | |
147 | EFI_STATUS Status;\r | |
148 | \r | |
4edb1866 | 149 | AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
8021f4c7 | 150 | Status = VarCheckLibVariablePropertyGet (Name, Guid, VariableProperty);\r |
efb01a10 SZ |
151 | ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r |
152 | \r | |
4edb1866 | 153 | return Status;\r |
efb01a10 SZ |
154 | }\r |
155 | \r |