2 The internal header file includes the common header files, defines
3 internal structure and functions used by Variable modules.
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Protocol/VariableWrite.h>
15 #include <Protocol/FaultTolerantWrite.h>
16 #include <Protocol/FirmwareVolumeBlock.h>
17 #include <Protocol/Variable.h>
18 #include <Protocol/VariableLock.h>
19 #include <Protocol/VarCheck.h>
20 #include <Library/PcdLib.h>
21 #include <Library/HobLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/DxeServicesTableLib.h>
24 #include <Library/UefiRuntimeLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/SynchronizationLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/AuthVariableLib.h>
33 #include <Library/VarCheckLib.h>
34 #include <Guid/GlobalVariable.h>
35 #include <Guid/EventGroup.h>
36 #include <Guid/VariableFormat.h>
37 #include <Guid/SystemNvDataGuid.h>
38 #include <Guid/FaultTolerantWrite.h>
39 #include <Guid/VarErrorFlag.h>
41 #include "PrivilegePolymorphic.h"
43 #define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS) \
44 (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
45 PcdGet64 (PcdFlashNvStorageVariableBase64) : \
46 PcdGet32 (PcdFlashNvStorageVariableBase))
48 #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
49 EFI_VARIABLE_BOOTSERVICE_ACCESS | \
50 EFI_VARIABLE_RUNTIME_ACCESS | \
51 EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
52 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
53 EFI_VARIABLE_APPEND_WRITE)
56 /// The size of a 3 character ISO639 language code.
58 #define ISO_639_2_ENTRY_SIZE 3
61 VariableStoreTypeVolatile
,
65 } VARIABLE_STORE_TYPE
;
68 VARIABLE_HEADER
*CurrPtr
;
70 // If both ADDED and IN_DELETED_TRANSITION variable are present,
71 // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.
72 // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,
73 // and InDeletedTransitionPtr will be NULL at the same time.
75 VARIABLE_HEADER
*InDeletedTransitionPtr
;
76 VARIABLE_HEADER
*EndPtr
;
77 VARIABLE_HEADER
*StartPtr
;
79 } VARIABLE_POINTER_TRACK
;
82 EFI_PHYSICAL_ADDRESS HobVariableBase
;
83 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
84 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
85 EFI_LOCK VariableServicesLock
;
86 UINT32 ReentrantState
;
93 VARIABLE_GLOBAL VariableGlobal
;
94 UINTN VolatileLastVariableOffset
;
95 UINTN NonVolatileLastVariableOffset
;
96 UINTN CommonVariableSpace
;
97 UINTN CommonMaxUserVariableSpace
;
98 UINTN CommonRuntimeVariableSpace
;
99 UINTN CommonVariableTotalSize
;
100 UINTN CommonUserVariableTotalSize
;
101 UINTN HwErrVariableTotalSize
;
102 UINTN MaxVariableSize
;
103 UINTN MaxAuthVariableSize
;
104 UINTN MaxVolatileVariableSize
;
105 UINTN ScratchBufferSize
;
106 CHAR8
*PlatformLangCodes
;
109 CHAR8 Lang
[ISO_639_2_ENTRY_SIZE
+ 1];
110 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbInstance
;
111 } VARIABLE_MODULE_GLOBAL
;
114 Flush the HOB variable to flash.
116 @param[in] VariableName Name of variable has been updated or deleted.
117 @param[in] VendorGuid Guid of variable has been updated or deleted.
121 FlushHobVariableToFlash (
122 IN CHAR16
*VariableName
,
123 IN EFI_GUID
*VendorGuid
127 Writes a buffer to variable storage space, in the working block.
129 This function writes a buffer to variable storage space into a firmware
130 volume block device. The destination is specified by the parameter
131 VariableBase. Fault Tolerant Write protocol is used for writing.
133 @param VariableBase Base address of the variable to write.
134 @param VariableBuffer Point to the variable data buffer.
136 @retval EFI_SUCCESS The function completed successfully.
137 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
138 @retval EFI_ABORTED The function could not complete successfully.
143 IN EFI_PHYSICAL_ADDRESS VariableBase
,
144 IN VARIABLE_STORE_HEADER
*VariableBuffer
148 Finds variable in storage blocks of volatile and non-volatile storage areas.
150 This code finds variable in storage blocks of volatile and non-volatile storage areas.
151 If VariableName is an empty string, then we just return the first
152 qualified variable without comparing VariableName and VendorGuid.
153 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check
154 at runtime when searching existing variable, only VariableName and VendorGuid are compared.
155 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
157 @param[in] VariableName Name of the variable to be found.
158 @param[in] VendorGuid Vendor GUID to be found.
159 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,
160 including the range searched and the target position.
161 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including
162 base of volatile variable storage area, base of
163 NV variable storage area, and a lock.
164 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
165 check at runtime when searching variable.
167 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while
169 @retval EFI_SUCCESS Variable successfully found.
170 @retval EFI_NOT_FOUND Variable not found
175 IN CHAR16
*VariableName
,
176 IN EFI_GUID
*VendorGuid
,
177 OUT VARIABLE_POINTER_TRACK
*PtrTrack
,
178 IN VARIABLE_GLOBAL
*Global
,
179 IN BOOLEAN IgnoreRtCheck
183 This function is to check if the remaining variable space is enough to set
184 all Variables from argument list successfully. The purpose of the check
185 is to keep the consistency of the Variables to be in variable storage.
187 Note: Variables are assumed to be in same storage.
188 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
189 so follow the argument sequence to check the Variables.
191 @param[in] Attributes Variable attributes for Variable entries.
192 @param[in] Marker VA_LIST style variable argument list.
193 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
194 A NULL terminates the list. The VariableSize of
195 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
196 It will be changed to variable total size as output.
198 @retval TRUE Have enough variable space to set the Variables successfully.
199 @retval FALSE No enough variable space to set the Variables successfully.
204 CheckRemainingSpaceForConsistencyInternal (
205 IN UINT32 Attributes
,
210 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
211 index of associated public key is needed.
213 @param[in] VariableName Name of variable.
214 @param[in] VendorGuid Guid of variable.
215 @param[in] Data Variable data.
216 @param[in] DataSize Size of data. 0 means delete.
217 @param[in] Attributes Attributes of the variable.
218 @param[in] KeyIndex Index of associated public key.
219 @param[in] MonotonicCount Value of associated monotonic count.
220 @param[in, out] Variable The variable information that is used to keep track of variable usage.
222 @param[in] TimeStamp Value of associated TimeStamp.
224 @retval EFI_SUCCESS The update operation is success.
225 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
230 IN CHAR16
*VariableName
,
231 IN EFI_GUID
*VendorGuid
,
234 IN UINT32 Attributes OPTIONAL
,
235 IN UINT32 KeyIndex OPTIONAL
,
236 IN UINT64 MonotonicCount OPTIONAL
,
237 IN OUT VARIABLE_POINTER_TRACK
*Variable
,
238 IN EFI_TIME
*TimeStamp OPTIONAL
243 Return TRUE if ExitBootServices () has been called.
245 @retval TRUE If ExitBootServices () has been called.
253 Initializes a basic mutual exclusion lock.
255 This function initializes a basic mutual exclusion lock to the released state
256 and returns the lock. Each lock provides mutual exclusion access at its task
257 priority level. Since there is no preemption or multiprocessor support in EFI,
258 acquiring the lock only consists of raising to the locks TPL.
259 If Lock is NULL, then ASSERT().
260 If Priority is not a valid TPL value, then ASSERT().
262 @param Lock A pointer to the lock data structure to initialize.
263 @param Priority EFI TPL is associated with the lock.
270 IN OUT EFI_LOCK
*Lock
,
276 Acquires lock only at boot time. Simply returns at runtime.
278 This is a temperary function that will be removed when
279 EfiAcquireLock() in UefiLib can handle the call in UEFI
280 Runtimer driver in RT phase.
281 It calls EfiAcquireLock() at boot time, and simply returns
284 @param Lock A pointer to the lock to acquire.
288 AcquireLockOnlyAtBootTime (
294 Releases lock only at boot time. Simply returns at runtime.
296 This is a temperary function which will be removed when
297 EfiReleaseLock() in UefiLib can handle the call in UEFI
298 Runtimer driver in RT phase.
299 It calls EfiReleaseLock() at boot time and simply returns
302 @param Lock A pointer to the lock to release.
306 ReleaseLockOnlyAtBootTime (
311 Retrieve the FVB protocol interface by HANDLE.
313 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
314 reading, writing, and erasing the target block.
315 @param[out] FvBlock The interface of FVB protocol
317 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
318 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
319 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
324 IN EFI_HANDLE FvBlockHandle
,
325 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvBlock
329 Function returns an array of handles that support the FVB protocol
330 in a buffer allocated from pool.
332 @param[out] NumberHandles The number of handles returned in Buffer.
333 @param[out] Buffer A pointer to the buffer to return the requested
334 array of handles that support FVB protocol.
336 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
337 handles in Buffer was returned in NumberHandles.
338 @retval EFI_NOT_FOUND No FVB handle was found.
339 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
340 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
344 GetFvbCountAndBuffer (
345 OUT UINTN
*NumberHandles
,
346 OUT EFI_HANDLE
**Buffer
350 Initializes variable store area for non-volatile and volatile variable.
352 @retval EFI_SUCCESS Function successfully executed.
353 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
357 VariableCommonInitialize (
362 This function reclaims variable storage if free size is below the threshold.
371 Get maximum variable size, covering both non-volatile and volatile variables.
373 @return Maximum variable size.
382 Initializes variable write service.
384 @retval EFI_SUCCESS Function successfully executed.
385 @retval Others Fail to initialize the variable service.
389 VariableWriteServiceInitialize (
394 Retrieve the SMM Fault Tolerent Write protocol interface.
396 @param[out] FtwProtocol The interface of SMM Ftw protocol
398 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
399 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
400 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
405 OUT VOID
**FtwProtocol
409 Get the proper fvb handle and/or fvb protocol by the given Flash address.
411 @param[in] Address The Flash address.
412 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
413 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
417 GetFvbInfoByAddress (
418 IN EFI_PHYSICAL_ADDRESS Address
,
419 OUT EFI_HANDLE
*FvbHandle OPTIONAL
,
420 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvbProtocol OPTIONAL
425 This code finds variable in storage blocks (Volatile or Non-Volatile).
427 Caution: This function may receive untrusted input.
428 This function may be invoked in SMM mode, and datasize and data are external input.
429 This function will do basic validation, before parse the data.
431 @param VariableName Name of Variable to be found.
432 @param VendorGuid Variable vendor GUID.
433 @param Attributes Attribute value of the variable found.
434 @param DataSize Size of Data found. If size is less than the
435 data, this value contains the required size.
436 @param Data The buffer to return the contents of the variable. May be NULL
437 with a zero DataSize in order to determine the size buffer needed.
439 @return EFI_INVALID_PARAMETER Invalid parameter.
440 @return EFI_SUCCESS Find the specified variable.
441 @return EFI_NOT_FOUND Not found.
442 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
447 VariableServiceGetVariable (
448 IN CHAR16
*VariableName
,
449 IN EFI_GUID
*VendorGuid
,
450 OUT UINT32
*Attributes OPTIONAL
,
451 IN OUT UINTN
*DataSize
,
452 OUT VOID
*Data OPTIONAL
457 This code Finds the Next available variable.
459 Caution: This function may receive untrusted input.
460 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
462 @param VariableNameSize The size of the VariableName buffer. The size must be large
463 enough to fit input string supplied in VariableName buffer.
464 @param VariableName Pointer to variable name.
465 @param VendorGuid Variable Vendor Guid.
467 @retval EFI_SUCCESS The function completed successfully.
468 @retval EFI_NOT_FOUND The next variable was not found.
469 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
470 VariableNameSize has been updated with the size needed to complete the request.
471 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
472 @retval EFI_INVALID_PARAMETER VariableName is NULL.
473 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
474 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
475 GUID of an existing variable.
476 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
477 the input VariableName buffer.
482 VariableServiceGetNextVariableName (
483 IN OUT UINTN
*VariableNameSize
,
484 IN OUT CHAR16
*VariableName
,
485 IN OUT EFI_GUID
*VendorGuid
490 This code sets variable in storage blocks (Volatile or Non-Volatile).
492 Caution: This function may receive untrusted input.
493 This function may be invoked in SMM mode, and datasize and data are external input.
494 This function will do basic validation, before parse the data.
495 This function will parse the authentication carefully to avoid security issues, like
496 buffer overflow, integer overflow.
497 This function will check attribute carefully to avoid authentication bypass.
499 @param VariableName Name of Variable to be found.
500 @param VendorGuid Variable vendor GUID.
501 @param Attributes Attribute value of the variable found
502 @param DataSize Size of Data found. If size is less than the
503 data, this value contains the required size.
504 @param Data Data pointer.
506 @return EFI_INVALID_PARAMETER Invalid parameter.
507 @return EFI_SUCCESS Set successfully.
508 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
509 @return EFI_NOT_FOUND Not found.
510 @return EFI_WRITE_PROTECTED Variable is read-only.
515 VariableServiceSetVariable (
516 IN CHAR16
*VariableName
,
517 IN EFI_GUID
*VendorGuid
,
518 IN UINT32 Attributes
,
525 This code returns information about the EFI variables.
527 Caution: This function may receive untrusted input.
528 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
530 @param Attributes Attributes bitmask to specify the type of variables
531 on which to return information.
532 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
533 for the EFI variables associated with the attributes specified.
534 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
535 for EFI variables associated with the attributes specified.
536 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
537 associated with the attributes specified.
539 @return EFI_SUCCESS Query successfully.
544 VariableServiceQueryVariableInfoInternal (
545 IN UINT32 Attributes
,
546 OUT UINT64
*MaximumVariableStorageSize
,
547 OUT UINT64
*RemainingVariableStorageSize
,
548 OUT UINT64
*MaximumVariableSize
553 This code returns information about the EFI variables.
555 Caution: This function may receive untrusted input.
556 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
558 @param Attributes Attributes bitmask to specify the type of variables
559 on which to return information.
560 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
561 for the EFI variables associated with the attributes specified.
562 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
563 for EFI variables associated with the attributes specified.
564 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
565 associated with the attributes specified.
567 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
568 @return EFI_SUCCESS Query successfully.
569 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
574 VariableServiceQueryVariableInfo (
575 IN UINT32 Attributes
,
576 OUT UINT64
*MaximumVariableStorageSize
,
577 OUT UINT64
*RemainingVariableStorageSize
,
578 OUT UINT64
*MaximumVariableSize
582 Mark a variable that will become read-only after leaving the DXE phase of execution.
584 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
585 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
586 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
588 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
589 as pending to be read-only.
590 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
591 Or VariableName is an empty string.
592 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
593 already been signaled.
594 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
598 VariableLockRequestToLock (
599 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
600 IN CHAR16
*VariableName
,
601 IN EFI_GUID
*VendorGuid
605 Register SetVariable check handler.
607 @param[in] Handler Pointer to check handler.
609 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
610 @retval EFI_INVALID_PARAMETER Handler is NULL.
611 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
612 already been signaled.
613 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
614 @retval EFI_UNSUPPORTED This interface is not implemented.
615 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
620 VarCheckRegisterSetVariableCheckHandler (
621 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
625 Variable property set.
627 @param[in] Name Pointer to the variable name.
628 @param[in] Guid Pointer to the vendor GUID.
629 @param[in] VariableProperty Pointer to the input variable property.
631 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
632 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
633 or the fields of VariableProperty are not valid.
634 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
635 already been signaled.
636 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
641 VarCheckVariablePropertySet (
644 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
648 Variable property get.
650 @param[in] Name Pointer to the variable name.
651 @param[in] Guid Pointer to the vendor GUID.
652 @param[out] VariableProperty Pointer to the output variable property.
654 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
655 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
656 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
661 VarCheckVariablePropertyGet (
664 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
668 Initialize variable quota.
672 InitializeVariableQuota (
676 extern VARIABLE_MODULE_GLOBAL
*mVariableModuleGlobal
;
677 extern EFI_FIRMWARE_VOLUME_HEADER
*mNvFvHeaderCache
;
678 extern VARIABLE_STORE_HEADER
*mNvVariableCache
;
679 extern VARIABLE_INFO_ENTRY
*gVariableInfo
;
680 extern BOOLEAN mEndOfDxe
;
681 extern VAR_CHECK_REQUEST_SOURCE mRequestSource
;
683 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut
;
686 Finds variable in storage blocks of volatile and non-volatile storage areas.
688 This code finds variable in storage blocks of volatile and non-volatile storage areas.
689 If VariableName is an empty string, then we just return the first
690 qualified variable without comparing VariableName and VendorGuid.
692 @param[in] VariableName Name of the variable to be found.
693 @param[in] VendorGuid Variable vendor GUID to be found.
694 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
695 output of the variable found.
697 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
698 while VendorGuid is NULL.
699 @retval EFI_SUCCESS Variable successfully found.
700 @retval EFI_NOT_FOUND Variable not found
705 VariableExLibFindVariable (
706 IN CHAR16
*VariableName
,
707 IN EFI_GUID
*VendorGuid
,
708 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
712 Finds next variable in storage blocks of volatile and non-volatile storage areas.
714 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
715 If VariableName is an empty string, then we just return the first
716 qualified variable without comparing VariableName and VendorGuid.
718 @param[in] VariableName Name of the variable to be found.
719 @param[in] VendorGuid Variable vendor GUID to be found.
720 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
721 output of the next variable.
723 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
724 while VendorGuid is NULL.
725 @retval EFI_SUCCESS Variable successfully found.
726 @retval EFI_NOT_FOUND Variable not found
731 VariableExLibFindNextVariable (
732 IN CHAR16
*VariableName
,
733 IN EFI_GUID
*VendorGuid
,
734 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
738 Update the variable region with Variable information.
740 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
741 input of the variable.
743 @retval EFI_SUCCESS The update operation is success.
744 @retval EFI_INVALID_PARAMETER Invalid parameter.
745 @retval EFI_WRITE_PROTECTED Variable is write-protected.
746 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
751 VariableExLibUpdateVariable (
752 IN AUTH_VARIABLE_INFO
*AuthVariableInfo
758 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
759 the maximum supported buffer size, this value contains
760 the maximum supported buffer size as output.
761 @param[out] ScratchBuffer Pointer to scratch buffer address.
763 @retval EFI_SUCCESS Get scratch buffer successfully.
764 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
769 VariableExLibGetScratchBuffer (
770 IN OUT UINTN
*ScratchBufferSize
,
771 OUT VOID
**ScratchBuffer
775 This function is to check if the remaining variable space is enough to set
776 all Variables from argument list successfully. The purpose of the check
777 is to keep the consistency of the Variables to be in variable storage.
779 Note: Variables are assumed to be in same storage.
780 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
781 so follow the argument sequence to check the Variables.
783 @param[in] Attributes Variable attributes for Variable entries.
784 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
785 A NULL terminates the list. The VariableSize of
786 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
787 It will be changed to variable total size as output.
789 @retval TRUE Have enough variable space to set the Variables successfully.
790 @retval FALSE No enough variable space to set the Variables successfully.
795 VariableExLibCheckRemainingSpaceForConsistency (
796 IN UINT32 Attributes
,
801 Return TRUE if at OS runtime.
803 @retval TRUE If at OS runtime.
804 @retval FALSE If at boot time.
809 VariableExLibAtRuntime (