]>
Commit | Line | Data |
---|---|---|
504214c4 | 1 | /** @file\r |
504214c4 | 2 | The internal header file includes the common header files, defines\r |
8a2d4996 | 3 | internal structure and functions used by Variable modules.\r |
504214c4 | 4 | \r |
746645bd | 5 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 6 | This program and the accompanying materials\r |
8d3a5c82 | 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 | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
504214c4 | 14 | **/\r |
8d3a5c82 | 15 | \r |
7c80e839 | 16 | #ifndef _VARIABLE_H_\r |
17 | #define _VARIABLE_H_\r | |
8d3a5c82 | 18 | \r |
39099938 | 19 | #include <PiDxe.h>\r |
8d3a5c82 | 20 | #include <Protocol/VariableWrite.h>\r |
88a5561c | 21 | #include <Protocol/FaultTolerantWrite.h>\r |
8d3a5c82 | 22 | #include <Protocol/FirmwareVolumeBlock.h>\r |
23 | #include <Protocol/Variable.h>\r | |
ff843847 | 24 | #include <Protocol/VariableLock.h>\r |
efb01a10 | 25 | #include <Protocol/VarCheck.h>\r |
8d3a5c82 | 26 | #include <Library/PcdLib.h>\r |
0f7aff72 | 27 | #include <Library/HobLib.h>\r |
8d3a5c82 | 28 | #include <Library/UefiDriverEntryPoint.h>\r |
29 | #include <Library/DxeServicesTableLib.h>\r | |
30 | #include <Library/UefiRuntimeLib.h>\r | |
31 | #include <Library/DebugLib.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
8d3a5c82 | 33 | #include <Library/UefiBootServicesTableLib.h>\r |
34 | #include <Library/UefiLib.h>\r | |
35 | #include <Library/BaseLib.h>\r | |
4cf894eb | 36 | #include <Library/SynchronizationLib.h>\r |
8d3a5c82 | 37 | #include <Library/MemoryAllocationLib.h>\r |
fa0737a8 | 38 | #include <Library/AuthVariableLib.h>\r |
8021f4c7 | 39 | #include <Library/VarCheckLib.h>\r |
052ad7e1 | 40 | #include <Guid/GlobalVariable.h>\r |
01a5c994 | 41 | #include <Guid/EventGroup.h>\r |
3709c4cd | 42 | #include <Guid/VariableFormat.h>\r |
d6550260 | 43 | #include <Guid/SystemNvDataGuid.h>\r |
3e02ebb2 | 44 | #include <Guid/FaultTolerantWrite.h>\r |
4edb1866 | 45 | #include <Guid/VarErrorFlag.h>\r |
8d3a5c82 | 46 | \r |
00663d04 LE |
47 | #include "PrivilegePolymorphic.h"\r |
48 | \r | |
fa0737a8 SZ |
49 | #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \\r |
50 | EFI_VARIABLE_BOOTSERVICE_ACCESS | \\r | |
51 | EFI_VARIABLE_RUNTIME_ACCESS | \\r | |
52 | EFI_VARIABLE_HARDWARE_ERROR_RECORD | \\r | |
fa0737a8 SZ |
53 | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \\r |
54 | EFI_VARIABLE_APPEND_WRITE)\r | |
55 | \r | |
255a3f33 RN |
56 | ///\r |
57 | /// The size of a 3 character ISO639 language code.\r | |
58 | ///\r | |
59 | #define ISO_639_2_ENTRY_SIZE 3\r | |
60 | \r | |
0f7aff72 RN |
61 | typedef enum {\r |
62 | VariableStoreTypeVolatile,\r | |
63 | VariableStoreTypeHob,\r | |
64 | VariableStoreTypeNv,\r | |
65 | VariableStoreTypeMax\r | |
66 | } VARIABLE_STORE_TYPE;\r | |
67 | \r | |
8d3a5c82 | 68 | typedef struct {\r |
69 | VARIABLE_HEADER *CurrPtr;\r | |
23b06935 SZ |
70 | //\r |
71 | // If both ADDED and IN_DELETED_TRANSITION variable are present,\r | |
72 | // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.\r | |
73 | // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,\r | |
74 | // and InDeletedTransitionPtr will be NULL at the same time.\r | |
75 | //\r | |
76 | VARIABLE_HEADER *InDeletedTransitionPtr;\r | |
8d3a5c82 | 77 | VARIABLE_HEADER *EndPtr;\r |
78 | VARIABLE_HEADER *StartPtr;\r | |
79 | BOOLEAN Volatile;\r | |
80 | } VARIABLE_POINTER_TRACK;\r | |
81 | \r | |
82 | typedef struct {\r | |
0f7aff72 | 83 | EFI_PHYSICAL_ADDRESS HobVariableBase;\r |
8d3a5c82 | 84 | EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r |
85 | EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r | |
86 | EFI_LOCK VariableServicesLock;\r | |
fdb7765f | 87 | UINT32 ReentrantState;\r |
fa0737a8 SZ |
88 | BOOLEAN AuthFormat;\r |
89 | BOOLEAN AuthSupport;\r | |
8d3a5c82 | 90 | } VARIABLE_GLOBAL;\r |
91 | \r | |
92 | typedef struct {\r | |
052ad7e1 | 93 | VARIABLE_GLOBAL VariableGlobal;\r |
8d3a5c82 | 94 | UINTN VolatileLastVariableOffset;\r |
95 | UINTN NonVolatileLastVariableOffset;\r | |
4edb1866 SZ |
96 | UINTN CommonVariableSpace;\r |
97 | UINTN CommonMaxUserVariableSpace;\r | |
98 | UINTN CommonRuntimeVariableSpace;\r | |
2fcdca1d | 99 | UINTN CommonVariableTotalSize;\r |
4edb1866 | 100 | UINTN CommonUserVariableTotalSize;\r |
2fcdca1d | 101 | UINTN HwErrVariableTotalSize;\r |
fa0737a8 SZ |
102 | UINTN MaxVariableSize;\r |
103 | UINTN MaxAuthVariableSize;\r | |
104 | UINTN ScratchBufferSize;\r | |
255a3f33 RN |
105 | CHAR8 *PlatformLangCodes;\r |
106 | CHAR8 *LangCodes;\r | |
107 | CHAR8 *PlatformLang;\r | |
108 | CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];\r | |
8a9e0b72 | 109 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;\r |
052ad7e1 A |
110 | } VARIABLE_MODULE_GLOBAL;\r |
111 | \r | |
335e2681 SZ |
112 | /**\r |
113 | Flush the HOB variable to flash.\r | |
114 | \r | |
115 | @param[in] VariableName Name of variable has been updated or deleted.\r | |
116 | @param[in] VendorGuid Guid of variable has been updated or deleted.\r | |
117 | \r | |
118 | **/\r | |
119 | VOID\r | |
120 | FlushHobVariableToFlash (\r | |
121 | IN CHAR16 *VariableName,\r | |
122 | IN EFI_GUID *VendorGuid\r | |
123 | );\r | |
124 | \r | |
c24b392c | 125 | /**\r |
126 | Writes a buffer to variable storage space, in the working block.\r | |
127 | \r | |
8a2d4996 | 128 | This function writes a buffer to variable storage space into a firmware\r |
129 | volume block device. The destination is specified by the parameter\r | |
c24b392c | 130 | VariableBase. Fault Tolerant Write protocol is used for writing.\r |
131 | \r | |
8a2d4996 | 132 | @param VariableBase Base address of the variable to write.\r |
128ef095 | 133 | @param VariableBuffer Point to the variable data buffer.\r |
c24b392c | 134 | \r |
8a2d4996 | 135 | @retval EFI_SUCCESS The function completed successfully.\r |
136 | @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.\r | |
137 | @retval EFI_ABORTED The function could not complete successfully.\r | |
c24b392c | 138 | \r |
139 | **/\r | |
140 | EFI_STATUS\r | |
141 | FtwVariableSpace (\r | |
142 | IN EFI_PHYSICAL_ADDRESS VariableBase,\r | |
128ef095 | 143 | IN VARIABLE_STORE_HEADER *VariableBuffer\r |
c24b392c | 144 | );\r |
145 | \r | |
fa0737a8 SZ |
146 | /**\r |
147 | Finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
148 | \r | |
149 | This code finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
150 | If VariableName is an empty string, then we just return the first\r | |
151 | qualified variable without comparing VariableName and VendorGuid.\r | |
152 | If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check\r | |
153 | at runtime when searching existing variable, only VariableName and VendorGuid are compared.\r | |
154 | Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.\r | |
155 | \r | |
156 | @param[in] VariableName Name of the variable to be found.\r | |
157 | @param[in] VendorGuid Vendor GUID to be found.\r | |
158 | @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,\r | |
159 | including the range searched and the target position.\r | |
160 | @param[in] Global Pointer to VARIABLE_GLOBAL structure, including\r | |
161 | base of volatile variable storage area, base of\r | |
162 | NV variable storage area, and a lock.\r | |
163 | @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute\r | |
164 | check at runtime when searching variable.\r | |
165 | \r | |
166 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while\r | |
167 | VendorGuid is NULL.\r | |
168 | @retval EFI_SUCCESS Variable successfully found.\r | |
169 | @retval EFI_NOT_FOUND Variable not found\r | |
170 | \r | |
171 | **/\r | |
172 | EFI_STATUS\r | |
173 | FindVariable (\r | |
174 | IN CHAR16 *VariableName,\r | |
175 | IN EFI_GUID *VendorGuid,\r | |
176 | OUT VARIABLE_POINTER_TRACK *PtrTrack,\r | |
177 | IN VARIABLE_GLOBAL *Global,\r | |
178 | IN BOOLEAN IgnoreRtCheck\r | |
179 | );\r | |
c24b392c | 180 | \r |
8a2d4996 | 181 | /**\r |
8a2d4996 | 182 | \r |
fa0737a8 | 183 | Gets the pointer to the end of the variable storage area.\r |
8a2d4996 | 184 | \r |
fa0737a8 SZ |
185 | This function gets pointer to the end of the variable storage\r |
186 | area, according to the input variable store header.\r | |
8a2d4996 | 187 | \r |
fa0737a8 | 188 | @param VarStoreHeader Pointer to the Variable Store Header.\r |
8a2d4996 | 189 | \r |
fa0737a8 SZ |
190 | @return Pointer to the end of the variable storage area.\r |
191 | \r | |
192 | **/\r | |
193 | VARIABLE_HEADER *\r | |
194 | GetEndPointer (\r | |
195 | IN VARIABLE_STORE_HEADER *VarStoreHeader\r | |
196 | );\r | |
197 | \r | |
198 | /**\r | |
199 | This code gets the size of variable header.\r | |
200 | \r | |
201 | @return Size of variable header in bytes in type UINTN.\r | |
202 | \r | |
203 | **/\r | |
204 | UINTN\r | |
205 | GetVariableHeaderSize (\r | |
206 | VOID\r | |
207 | );\r | |
208 | \r | |
209 | /**\r | |
210 | \r | |
211 | This code gets the pointer to the variable name.\r | |
212 | \r | |
213 | @param Variable Pointer to the Variable Header.\r | |
214 | \r | |
215 | @return Pointer to Variable Name which is Unicode encoding.\r | |
216 | \r | |
217 | **/\r | |
218 | CHAR16 *\r | |
219 | GetVariableNamePtr (\r | |
220 | IN VARIABLE_HEADER *Variable\r | |
221 | );\r | |
222 | \r | |
223 | /**\r | |
224 | This code gets the pointer to the variable guid.\r | |
225 | \r | |
226 | @param Variable Pointer to the Variable Header.\r | |
227 | \r | |
228 | @return A EFI_GUID* pointer to Vendor Guid.\r | |
229 | \r | |
230 | **/\r | |
231 | EFI_GUID *\r | |
232 | GetVendorGuidPtr (\r | |
233 | IN VARIABLE_HEADER *Variable\r | |
234 | );\r | |
235 | \r | |
236 | /**\r | |
237 | \r | |
238 | This code gets the pointer to the variable data.\r | |
239 | \r | |
240 | @param Variable Pointer to the Variable Header.\r | |
241 | \r | |
242 | @return Pointer to Variable Data.\r | |
243 | \r | |
244 | **/\r | |
245 | UINT8 *\r | |
246 | GetVariableDataPtr (\r | |
247 | IN VARIABLE_HEADER *Variable\r | |
248 | );\r | |
249 | \r | |
250 | /**\r | |
251 | \r | |
252 | This code gets the size of variable data.\r | |
253 | \r | |
254 | @param Variable Pointer to the Variable Header.\r | |
255 | \r | |
256 | @return Size of variable in bytes.\r | |
257 | \r | |
258 | **/\r | |
259 | UINTN\r | |
260 | DataSizeOfVariable (\r | |
261 | IN VARIABLE_HEADER *Variable\r | |
262 | );\r | |
263 | \r | |
264 | /**\r | |
265 | This function is to check if the remaining variable space is enough to set\r | |
266 | all Variables from argument list successfully. The purpose of the check\r | |
267 | is to keep the consistency of the Variables to be in variable storage.\r | |
8a2d4996 | 268 | \r |
fa0737a8 SZ |
269 | Note: Variables are assumed to be in same storage.\r |
270 | The set sequence of Variables will be same with the sequence of VariableEntry from argument list,\r | |
271 | so follow the argument sequence to check the Variables.\r | |
272 | \r | |
273 | @param[in] Attributes Variable attributes for Variable entries.\r | |
274 | @param[in] Marker VA_LIST style variable argument list.\r | |
275 | The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.\r | |
276 | A NULL terminates the list. The VariableSize of\r | |
277 | VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.\r | |
278 | It will be changed to variable total size as output.\r | |
279 | \r | |
280 | @retval TRUE Have enough variable space to set the Variables successfully.\r | |
281 | @retval FALSE No enough variable space to set the Variables successfully.\r | |
282 | \r | |
283 | **/\r | |
284 | BOOLEAN\r | |
285 | EFIAPI\r | |
286 | CheckRemainingSpaceForConsistencyInternal (\r | |
287 | IN UINT32 Attributes,\r | |
288 | IN VA_LIST Marker\r | |
289 | );\r | |
290 | \r | |
291 | /**\r | |
292 | Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,\r | |
293 | index of associated public key is needed.\r | |
8a2d4996 | 294 | \r |
fa0737a8 SZ |
295 | @param[in] VariableName Name of variable.\r |
296 | @param[in] VendorGuid Guid of variable.\r | |
297 | @param[in] Data Variable data.\r | |
298 | @param[in] DataSize Size of data. 0 means delete.\r | |
299 | @param[in] Attributes Attributes of the variable.\r | |
300 | @param[in] KeyIndex Index of associated public key.\r | |
301 | @param[in] MonotonicCount Value of associated monotonic count.\r | |
23b06935 | 302 | @param[in, out] Variable The variable information that is used to keep track of variable usage.\r |
8a2d4996 | 303 | \r |
fa0737a8 | 304 | @param[in] TimeStamp Value of associated TimeStamp.\r |
8a2d4996 | 305 | \r |
fa0737a8 | 306 | @retval EFI_SUCCESS The update operation is success.\r |
8a2d4996 | 307 | @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.\r |
308 | \r | |
309 | **/\r | |
310 | EFI_STATUS\r | |
311 | UpdateVariable (\r | |
312 | IN CHAR16 *VariableName,\r | |
313 | IN EFI_GUID *VendorGuid,\r | |
314 | IN VOID *Data,\r | |
315 | IN UINTN DataSize,\r | |
316 | IN UINT32 Attributes OPTIONAL,\r | |
fa0737a8 SZ |
317 | IN UINT32 KeyIndex OPTIONAL,\r |
318 | IN UINT64 MonotonicCount OPTIONAL,\r | |
319 | IN OUT VARIABLE_POINTER_TRACK *Variable,\r | |
320 | IN EFI_TIME *TimeStamp OPTIONAL\r | |
8a2d4996 | 321 | );\r |
322 | \r | |
323 | \r | |
324 | /**\r | |
325 | Return TRUE if ExitBootServices () has been called.\r | |
fa0737a8 | 326 | \r |
8a2d4996 | 327 | @retval TRUE If ExitBootServices () has been called.\r |
328 | **/\r | |
329 | BOOLEAN\r | |
330 | AtRuntime (\r | |
331 | VOID\r | |
332 | );\r | |
333 | \r | |
334 | /**\r | |
335 | Initializes a basic mutual exclusion lock.\r | |
336 | \r | |
fa0737a8 SZ |
337 | This function initializes a basic mutual exclusion lock to the released state\r |
338 | and returns the lock. Each lock provides mutual exclusion access at its task\r | |
8a2d4996 | 339 | priority level. Since there is no preemption or multiprocessor support in EFI,\r |
340 | acquiring the lock only consists of raising to the locks TPL.\r | |
341 | If Lock is NULL, then ASSERT().\r | |
342 | If Priority is not a valid TPL value, then ASSERT().\r | |
343 | \r | |
344 | @param Lock A pointer to the lock data structure to initialize.\r | |
345 | @param Priority EFI TPL is associated with the lock.\r | |
346 | \r | |
347 | @return The lock.\r | |
348 | \r | |
349 | **/\r | |
350 | EFI_LOCK *\r | |
351 | InitializeLock (\r | |
352 | IN OUT EFI_LOCK *Lock,\r | |
353 | IN EFI_TPL Priority\r | |
354 | );\r | |
355 | \r | |
fa0737a8 | 356 | \r |
8a2d4996 | 357 | /**\r |
358 | Acquires lock only at boot time. Simply returns at runtime.\r | |
359 | \r | |
360 | This is a temperary function that will be removed when\r | |
361 | EfiAcquireLock() in UefiLib can handle the call in UEFI\r | |
362 | Runtimer driver in RT phase.\r | |
363 | It calls EfiAcquireLock() at boot time, and simply returns\r | |
364 | at runtime.\r | |
365 | \r | |
366 | @param Lock A pointer to the lock to acquire.\r | |
367 | \r | |
368 | **/\r | |
369 | VOID\r | |
370 | AcquireLockOnlyAtBootTime (\r | |
371 | IN EFI_LOCK *Lock\r | |
372 | );\r | |
373 | \r | |
374 | \r | |
375 | /**\r | |
376 | Releases lock only at boot time. Simply returns at runtime.\r | |
377 | \r | |
378 | This is a temperary function which will be removed when\r | |
379 | EfiReleaseLock() in UefiLib can handle the call in UEFI\r | |
380 | Runtimer driver in RT phase.\r | |
381 | It calls EfiReleaseLock() at boot time and simply returns\r | |
382 | at runtime.\r | |
383 | \r | |
384 | @param Lock A pointer to the lock to release.\r | |
385 | \r | |
386 | **/\r | |
387 | VOID\r | |
388 | ReleaseLockOnlyAtBootTime (\r | |
389 | IN EFI_LOCK *Lock\r | |
fa0737a8 | 390 | );\r |
8a2d4996 | 391 | \r |
392 | /**\r | |
0a18956d | 393 | Retrieve the FVB protocol interface by HANDLE.\r |
8a2d4996 | 394 | \r |
395 | @param[in] FvBlockHandle The handle of FVB protocol that provides services for\r | |
396 | reading, writing, and erasing the target block.\r | |
397 | @param[out] FvBlock The interface of FVB protocol\r | |
398 | \r | |
399 | @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r | |
400 | @retval EFI_UNSUPPORTED The device does not support the FVB protocol.\r | |
401 | @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r | |
fa0737a8 | 402 | \r |
8a2d4996 | 403 | **/\r |
404 | EFI_STATUS\r | |
405 | GetFvbByHandle (\r | |
406 | IN EFI_HANDLE FvBlockHandle,\r | |
407 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
408 | );\r | |
409 | \r | |
8a2d4996 | 410 | /**\r |
411 | Function returns an array of handles that support the FVB protocol\r | |
fa0737a8 | 412 | in a buffer allocated from pool.\r |
8a2d4996 | 413 | \r |
414 | @param[out] NumberHandles The number of handles returned in Buffer.\r | |
415 | @param[out] Buffer A pointer to the buffer to return the requested\r | |
416 | array of handles that support FVB protocol.\r | |
417 | \r | |
418 | @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r | |
419 | handles in Buffer was returned in NumberHandles.\r | |
420 | @retval EFI_NOT_FOUND No FVB handle was found.\r | |
421 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r | |
422 | @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r | |
fa0737a8 | 423 | \r |
8a2d4996 | 424 | **/\r |
425 | EFI_STATUS\r | |
426 | GetFvbCountAndBuffer (\r | |
427 | OUT UINTN *NumberHandles,\r | |
428 | OUT EFI_HANDLE **Buffer\r | |
429 | );\r | |
430 | \r | |
431 | /**\r | |
432 | Initializes variable store area for non-volatile and volatile variable.\r | |
433 | \r | |
434 | @retval EFI_SUCCESS Function successfully executed.\r | |
435 | @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r | |
436 | \r | |
437 | **/\r | |
438 | EFI_STATUS\r | |
439 | VariableCommonInitialize (\r | |
440 | VOID\r | |
441 | );\r | |
442 | \r | |
443 | /**\r | |
444 | This function reclaims variable storage if free size is below the threshold.\r | |
fa0737a8 | 445 | \r |
8a2d4996 | 446 | **/\r |
447 | VOID\r | |
448 | ReclaimForOS(\r | |
449 | VOID\r | |
fa0737a8 SZ |
450 | );\r |
451 | \r | |
452 | /**\r | |
453 | Get non-volatile maximum variable size.\r | |
8a2d4996 | 454 | \r |
fa0737a8 SZ |
455 | @return Non-volatile maximum variable size.\r |
456 | \r | |
457 | **/\r | |
458 | UINTN\r | |
459 | GetNonVolatileMaxVariableSize (\r | |
460 | VOID\r | |
461 | );\r | |
8a2d4996 | 462 | \r |
463 | /**\r | |
464 | Initializes variable write service after FVB was ready.\r | |
465 | \r | |
466 | @retval EFI_SUCCESS Function successfully executed.\r | |
467 | @retval Others Fail to initialize the variable service.\r | |
468 | \r | |
469 | **/\r | |
470 | EFI_STATUS\r | |
471 | VariableWriteServiceInitialize (\r | |
472 | VOID\r | |
473 | );\r | |
fa0737a8 | 474 | \r |
8a2d4996 | 475 | /**\r |
0a18956d | 476 | Retrieve the SMM Fault Tolerent Write protocol interface.\r |
8a2d4996 | 477 | \r |
478 | @param[out] FtwProtocol The interface of SMM Ftw protocol\r | |
479 | \r | |
480 | @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.\r | |
481 | @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.\r | |
482 | @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r | |
483 | \r | |
484 | **/\r | |
485 | EFI_STATUS\r | |
486 | GetFtwProtocol (\r | |
487 | OUT VOID **FtwProtocol\r | |
488 | );\r | |
489 | \r | |
490 | /**\r | |
491 | Get the proper fvb handle and/or fvb protocol by the given Flash address.\r | |
492 | \r | |
493 | @param[in] Address The Flash address.\r | |
494 | @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.\r | |
495 | @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.\r | |
496 | \r | |
497 | **/\r | |
498 | EFI_STATUS\r | |
499 | GetFvbInfoByAddress (\r | |
500 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
501 | OUT EFI_HANDLE *FvbHandle OPTIONAL,\r | |
502 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL\r | |
503 | );\r | |
504 | \r | |
505 | /**\r | |
506 | \r | |
507 | This code finds variable in storage blocks (Volatile or Non-Volatile).\r | |
508 | \r | |
fa0737a8 SZ |
509 | Caution: This function may receive untrusted input.\r |
510 | This function may be invoked in SMM mode, and datasize and data are external input.\r | |
511 | This function will do basic validation, before parse the data.\r | |
512 | \r | |
8a2d4996 | 513 | @param VariableName Name of Variable to be found.\r |
514 | @param VendorGuid Variable vendor GUID.\r | |
515 | @param Attributes Attribute value of the variable found.\r | |
516 | @param DataSize Size of Data found. If size is less than the\r | |
517 | data, this value contains the required size.\r | |
746645bd SZ |
518 | @param Data The buffer to return the contents of the variable. May be NULL\r |
519 | with a zero DataSize in order to determine the size buffer needed.\r | |
fa0737a8 | 520 | \r |
8a2d4996 | 521 | @return EFI_INVALID_PARAMETER Invalid parameter.\r |
522 | @return EFI_SUCCESS Find the specified variable.\r | |
523 | @return EFI_NOT_FOUND Not found.\r | |
524 | @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r | |
525 | \r | |
526 | **/\r | |
527 | EFI_STATUS\r | |
528 | EFIAPI\r | |
529 | VariableServiceGetVariable (\r | |
530 | IN CHAR16 *VariableName,\r | |
531 | IN EFI_GUID *VendorGuid,\r | |
532 | OUT UINT32 *Attributes OPTIONAL,\r | |
533 | IN OUT UINTN *DataSize,\r | |
746645bd | 534 | OUT VOID *Data OPTIONAL\r |
8a2d4996 | 535 | );\r |
536 | \r | |
fa0737a8 SZ |
537 | /**\r |
538 | This code Finds the Next available variable.\r | |
539 | \r | |
540 | Caution: This function may receive untrusted input.\r | |
541 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
542 | \r | |
543 | @param[in] VariableName Pointer to variable name.\r | |
544 | @param[in] VendorGuid Variable Vendor Guid.\r | |
545 | @param[out] VariablePtr Pointer to variable header address.\r | |
546 | \r | |
6f817f9b SZ |
547 | @retval EFI_SUCCESS The function completed successfully.\r |
548 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
549 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.\r | |
550 | @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and\r | |
551 | GUID of an existing variable.\r | |
fa0737a8 SZ |
552 | \r |
553 | **/\r | |
554 | EFI_STATUS\r | |
555 | EFIAPI\r | |
556 | VariableServiceGetNextVariableInternal (\r | |
557 | IN CHAR16 *VariableName,\r | |
558 | IN EFI_GUID *VendorGuid,\r | |
559 | OUT VARIABLE_HEADER **VariablePtr\r | |
560 | );\r | |
561 | \r | |
8a2d4996 | 562 | /**\r |
563 | \r | |
564 | This code Finds the Next available variable.\r | |
565 | \r | |
efb01a10 SZ |
566 | Caution: This function may receive untrusted input.\r |
567 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
568 | \r | |
6f817f9b SZ |
569 | @param VariableNameSize The size of the VariableName buffer. The size must be large\r |
570 | enough to fit input string supplied in VariableName buffer.\r | |
8a2d4996 | 571 | @param VariableName Pointer to variable name.\r |
572 | @param VendorGuid Variable Vendor Guid.\r | |
573 | \r | |
6f817f9b SZ |
574 | @retval EFI_SUCCESS The function completed successfully.\r |
575 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
576 | @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.\r | |
577 | VariableNameSize has been updated with the size needed to complete the request.\r | |
578 | @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.\r | |
579 | @retval EFI_INVALID_PARAMETER VariableName is NULL.\r | |
580 | @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r | |
581 | @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and\r | |
582 | GUID of an existing variable.\r | |
583 | @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of\r | |
584 | the input VariableName buffer.\r | |
8a2d4996 | 585 | \r |
586 | **/\r | |
587 | EFI_STATUS\r | |
588 | EFIAPI\r | |
589 | VariableServiceGetNextVariableName (\r | |
590 | IN OUT UINTN *VariableNameSize,\r | |
591 | IN OUT CHAR16 *VariableName,\r | |
592 | IN OUT EFI_GUID *VendorGuid\r | |
593 | );\r | |
594 | \r | |
595 | /**\r | |
596 | \r | |
597 | This code sets variable in storage blocks (Volatile or Non-Volatile).\r | |
598 | \r | |
efb01a10 SZ |
599 | Caution: This function may receive untrusted input.\r |
600 | This function may be invoked in SMM mode, and datasize and data are external input.\r | |
601 | This function will do basic validation, before parse the data.\r | |
fa0737a8 SZ |
602 | This function will parse the authentication carefully to avoid security issues, like\r |
603 | buffer overflow, integer overflow.\r | |
604 | This function will check attribute carefully to avoid authentication bypass.\r | |
efb01a10 | 605 | \r |
8a2d4996 | 606 | @param VariableName Name of Variable to be found.\r |
607 | @param VendorGuid Variable vendor GUID.\r | |
608 | @param Attributes Attribute value of the variable found\r | |
609 | @param DataSize Size of Data found. If size is less than the\r | |
610 | data, this value contains the required size.\r | |
611 | @param Data Data pointer.\r | |
612 | \r | |
613 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
614 | @return EFI_SUCCESS Set successfully.\r | |
615 | @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.\r | |
616 | @return EFI_NOT_FOUND Not found.\r | |
617 | @return EFI_WRITE_PROTECTED Variable is read-only.\r | |
618 | \r | |
619 | **/\r | |
620 | EFI_STATUS\r | |
621 | EFIAPI\r | |
622 | VariableServiceSetVariable (\r | |
623 | IN CHAR16 *VariableName,\r | |
624 | IN EFI_GUID *VendorGuid,\r | |
625 | IN UINT32 Attributes,\r | |
626 | IN UINTN DataSize,\r | |
627 | IN VOID *Data\r | |
628 | );\r | |
629 | \r | |
b2bd493e SZ |
630 | /**\r |
631 | \r | |
632 | This code returns information about the EFI variables.\r | |
633 | \r | |
efb01a10 SZ |
634 | Caution: This function may receive untrusted input.\r |
635 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
636 | \r | |
b2bd493e SZ |
637 | @param Attributes Attributes bitmask to specify the type of variables\r |
638 | on which to return information.\r | |
639 | @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
640 | for the EFI variables associated with the attributes specified.\r | |
641 | @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r | |
642 | for EFI variables associated with the attributes specified.\r | |
643 | @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r | |
644 | associated with the attributes specified.\r | |
645 | \r | |
646 | @return EFI_SUCCESS Query successfully.\r | |
647 | \r | |
648 | **/\r | |
649 | EFI_STATUS\r | |
650 | EFIAPI\r | |
651 | VariableServiceQueryVariableInfoInternal (\r | |
652 | IN UINT32 Attributes,\r | |
653 | OUT UINT64 *MaximumVariableStorageSize,\r | |
654 | OUT UINT64 *RemainingVariableStorageSize,\r | |
655 | OUT UINT64 *MaximumVariableSize\r | |
656 | );\r | |
657 | \r | |
8a2d4996 | 658 | /**\r |
659 | \r | |
660 | This code returns information about the EFI variables.\r | |
661 | \r | |
efb01a10 SZ |
662 | Caution: This function may receive untrusted input.\r |
663 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
664 | \r | |
8a2d4996 | 665 | @param Attributes Attributes bitmask to specify the type of variables\r |
666 | on which to return information.\r | |
667 | @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
668 | for the EFI variables associated with the attributes specified.\r | |
669 | @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r | |
670 | for EFI variables associated with the attributes specified.\r | |
671 | @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r | |
672 | associated with the attributes specified.\r | |
673 | \r | |
674 | @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r | |
675 | @return EFI_SUCCESS Query successfully.\r | |
676 | @return EFI_UNSUPPORTED The attribute is not supported on this platform.\r | |
677 | \r | |
678 | **/\r | |
679 | EFI_STATUS\r | |
680 | EFIAPI\r | |
681 | VariableServiceQueryVariableInfo (\r | |
682 | IN UINT32 Attributes,\r | |
683 | OUT UINT64 *MaximumVariableStorageSize,\r | |
684 | OUT UINT64 *RemainingVariableStorageSize,\r | |
685 | OUT UINT64 *MaximumVariableSize\r | |
fa0737a8 | 686 | );\r |
ff843847 RN |
687 | \r |
688 | /**\r | |
689 | Mark a variable that will become read-only after leaving the DXE phase of execution.\r | |
690 | \r | |
691 | @param[in] This The VARIABLE_LOCK_PROTOCOL instance.\r | |
692 | @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.\r | |
693 | @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.\r | |
694 | \r | |
695 | @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked\r | |
696 | as pending to be read-only.\r | |
697 | @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r | |
698 | Or VariableName is an empty string.\r | |
699 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
700 | already been signaled.\r | |
701 | @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.\r | |
702 | **/\r | |
703 | EFI_STATUS\r | |
704 | EFIAPI\r | |
705 | VariableLockRequestToLock (\r | |
706 | IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r | |
707 | IN CHAR16 *VariableName,\r | |
708 | IN EFI_GUID *VendorGuid\r | |
709 | );\r | |
710 | \r | |
efb01a10 SZ |
711 | /**\r |
712 | Register SetVariable check handler.\r | |
713 | \r | |
714 | @param[in] Handler Pointer to check handler.\r | |
715 | \r | |
716 | @retval EFI_SUCCESS The SetVariable check handler was registered successfully.\r | |
717 | @retval EFI_INVALID_PARAMETER Handler is NULL.\r | |
718 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
719 | already been signaled.\r | |
720 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.\r | |
721 | @retval EFI_UNSUPPORTED This interface is not implemented.\r | |
722 | For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.\r | |
723 | \r | |
724 | **/\r | |
725 | EFI_STATUS\r | |
726 | EFIAPI\r | |
727 | VarCheckRegisterSetVariableCheckHandler (\r | |
728 | IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler\r | |
729 | );\r | |
730 | \r | |
4edb1866 | 731 | /**\r |
fa0737a8 | 732 | Variable property set.\r |
4edb1866 | 733 | \r |
fa0737a8 SZ |
734 | @param[in] Name Pointer to the variable name.\r |
735 | @param[in] Guid Pointer to the vendor GUID.\r | |
736 | @param[in] VariableProperty Pointer to the input variable property.\r | |
4edb1866 | 737 | \r |
fa0737a8 SZ |
738 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.\r |
739 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,\r | |
740 | or the fields of VariableProperty are not valid.\r | |
741 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
742 | already been signaled.\r | |
743 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.\r | |
4edb1866 SZ |
744 | \r |
745 | **/\r | |
746 | EFI_STATUS\r | |
747 | EFIAPI\r | |
fa0737a8 | 748 | VarCheckVariablePropertySet (\r |
4edb1866 SZ |
749 | IN CHAR16 *Name,\r |
750 | IN EFI_GUID *Guid,\r | |
fa0737a8 | 751 | IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r |
4edb1866 SZ |
752 | );\r |
753 | \r | |
efb01a10 SZ |
754 | /**\r |
755 | Variable property get.\r | |
756 | \r | |
757 | @param[in] Name Pointer to the variable name.\r | |
758 | @param[in] Guid Pointer to the vendor GUID.\r | |
759 | @param[out] VariableProperty Pointer to the output variable property.\r | |
760 | \r | |
761 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.\r | |
762 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.\r | |
763 | @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.\r | |
764 | \r | |
765 | **/\r | |
766 | EFI_STATUS\r | |
767 | EFIAPI\r | |
768 | VarCheckVariablePropertyGet (\r | |
769 | IN CHAR16 *Name,\r | |
770 | IN EFI_GUID *Guid,\r | |
771 | OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
772 | );\r | |
773 | \r | |
4edb1866 SZ |
774 | /**\r |
775 | Initialize variable quota.\r | |
776 | \r | |
777 | **/\r | |
778 | VOID\r | |
779 | InitializeVariableQuota (\r | |
780 | VOID\r | |
781 | );\r | |
782 | \r | |
8a2d4996 | 783 | extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;\r |
784 | \r | |
8021f4c7 | 785 | extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;\r |
fa0737a8 SZ |
786 | \r |
787 | /**\r | |
788 | Finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
789 | \r | |
790 | This code finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
791 | If VariableName is an empty string, then we just return the first\r | |
792 | qualified variable without comparing VariableName and VendorGuid.\r | |
793 | \r | |
794 | @param[in] VariableName Name of the variable to be found.\r | |
795 | @param[in] VendorGuid Variable vendor GUID to be found.\r | |
796 | @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for\r | |
797 | output of the variable found.\r | |
798 | \r | |
799 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,\r | |
800 | while VendorGuid is NULL.\r | |
801 | @retval EFI_SUCCESS Variable successfully found.\r | |
802 | @retval EFI_NOT_FOUND Variable not found\r | |
803 | \r | |
804 | **/\r | |
805 | EFI_STATUS\r | |
806 | EFIAPI\r | |
807 | VariableExLibFindVariable (\r | |
808 | IN CHAR16 *VariableName,\r | |
809 | IN EFI_GUID *VendorGuid,\r | |
810 | OUT AUTH_VARIABLE_INFO *AuthVariableInfo\r | |
811 | );\r | |
812 | \r | |
813 | /**\r | |
814 | Finds next variable in storage blocks of volatile and non-volatile storage areas.\r | |
815 | \r | |
816 | This code finds next variable in storage blocks of volatile and non-volatile storage areas.\r | |
817 | If VariableName is an empty string, then we just return the first\r | |
818 | qualified variable without comparing VariableName and VendorGuid.\r | |
819 | \r | |
820 | @param[in] VariableName Name of the variable to be found.\r | |
821 | @param[in] VendorGuid Variable vendor GUID to be found.\r | |
822 | @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for\r | |
823 | output of the next variable.\r | |
824 | \r | |
825 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,\r | |
826 | while VendorGuid is NULL.\r | |
827 | @retval EFI_SUCCESS Variable successfully found.\r | |
828 | @retval EFI_NOT_FOUND Variable not found\r | |
829 | \r | |
830 | **/\r | |
831 | EFI_STATUS\r | |
832 | EFIAPI\r | |
833 | VariableExLibFindNextVariable (\r | |
834 | IN CHAR16 *VariableName,\r | |
835 | IN EFI_GUID *VendorGuid,\r | |
836 | OUT AUTH_VARIABLE_INFO *AuthVariableInfo\r | |
837 | );\r | |
838 | \r | |
839 | /**\r | |
840 | Update the variable region with Variable information.\r | |
841 | \r | |
842 | @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for\r | |
843 | input of the variable.\r | |
844 | \r | |
845 | @retval EFI_SUCCESS The update operation is success.\r | |
846 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
847 | @retval EFI_WRITE_PROTECTED Variable is write-protected.\r | |
848 | @retval EFI_OUT_OF_RESOURCES There is not enough resource.\r | |
849 | \r | |
850 | **/\r | |
851 | EFI_STATUS\r | |
852 | EFIAPI\r | |
853 | VariableExLibUpdateVariable (\r | |
854 | IN AUTH_VARIABLE_INFO *AuthVariableInfo\r | |
855 | );\r | |
856 | \r | |
857 | /**\r | |
858 | Get scratch buffer.\r | |
859 | \r | |
860 | @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than\r | |
861 | the maximum supported buffer size, this value contains\r | |
862 | the maximum supported buffer size as output.\r | |
863 | @param[out] ScratchBuffer Pointer to scratch buffer address.\r | |
864 | \r | |
865 | @retval EFI_SUCCESS Get scratch buffer successfully.\r | |
866 | @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.\r | |
867 | \r | |
868 | **/\r | |
869 | EFI_STATUS\r | |
870 | EFIAPI\r | |
871 | VariableExLibGetScratchBuffer (\r | |
872 | IN OUT UINTN *ScratchBufferSize,\r | |
873 | OUT VOID **ScratchBuffer\r | |
874 | );\r | |
875 | \r | |
876 | /**\r | |
877 | This function is to check if the remaining variable space is enough to set\r | |
878 | all Variables from argument list successfully. The purpose of the check\r | |
879 | is to keep the consistency of the Variables to be in variable storage.\r | |
880 | \r | |
881 | Note: Variables are assumed to be in same storage.\r | |
882 | The set sequence of Variables will be same with the sequence of VariableEntry from argument list,\r | |
883 | so follow the argument sequence to check the Variables.\r | |
884 | \r | |
885 | @param[in] Attributes Variable attributes for Variable entries.\r | |
886 | @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.\r | |
887 | A NULL terminates the list. The VariableSize of\r | |
888 | VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.\r | |
889 | It will be changed to variable total size as output.\r | |
890 | \r | |
891 | @retval TRUE Have enough variable space to set the Variables successfully.\r | |
892 | @retval FALSE No enough variable space to set the Variables successfully.\r | |
893 | \r | |
894 | **/\r | |
895 | BOOLEAN\r | |
896 | EFIAPI\r | |
897 | VariableExLibCheckRemainingSpaceForConsistency (\r | |
898 | IN UINT32 Attributes,\r | |
899 | ...\r | |
900 | );\r | |
901 | \r | |
902 | /**\r | |
903 | Return TRUE if at OS runtime.\r | |
904 | \r | |
905 | @retval TRUE If at OS runtime.\r | |
906 | @retval FALSE If at boot time.\r | |
907 | \r | |
908 | **/\r | |
909 | BOOLEAN\r | |
910 | EFIAPI\r | |
911 | VariableExLibAtRuntime (\r | |
912 | VOID\r | |
913 | );\r | |
914 | \r | |
8d3a5c82 | 915 | #endif\r |