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 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.
20 #include <Protocol/VariableWrite.h>
21 #include <Protocol/FaultTolerantWrite.h>
22 #include <Protocol/FirmwareVolumeBlock.h>
23 #include <Protocol/Variable.h>
24 #include <Protocol/VariableLock.h>
25 #include <Protocol/VarCheck.h>
26 #include <Library/PcdLib.h>
27 #include <Library/HobLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/DxeServicesTableLib.h>
30 #include <Library/UefiRuntimeLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/UefiLib.h>
35 #include <Library/BaseLib.h>
36 #include <Library/SynchronizationLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/AuthVariableLib.h>
39 #include <Library/VarCheckLib.h>
40 #include <Guid/GlobalVariable.h>
41 #include <Guid/EventGroup.h>
42 #include <Guid/VariableFormat.h>
43 #include <Guid/SystemNvDataGuid.h>
44 #include <Guid/FaultTolerantWrite.h>
45 #include <Guid/VarErrorFlag.h>
47 #include "PrivilegePolymorphic.h"
49 #define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS) \
50 (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
51 PcdGet64 (PcdFlashNvStorageVariableBase64) : \
52 PcdGet32 (PcdFlashNvStorageVariableBase))
54 #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
55 EFI_VARIABLE_BOOTSERVICE_ACCESS | \
56 EFI_VARIABLE_RUNTIME_ACCESS | \
57 EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
58 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
59 EFI_VARIABLE_APPEND_WRITE)
62 /// The size of a 3 character ISO639 language code.
64 #define ISO_639_2_ENTRY_SIZE 3
67 VariableStoreTypeVolatile
,
71 } VARIABLE_STORE_TYPE
;
74 VARIABLE_HEADER
*CurrPtr
;
76 // If both ADDED and IN_DELETED_TRANSITION variable are present,
77 // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.
78 // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,
79 // and InDeletedTransitionPtr will be NULL at the same time.
81 VARIABLE_HEADER
*InDeletedTransitionPtr
;
82 VARIABLE_HEADER
*EndPtr
;
83 VARIABLE_HEADER
*StartPtr
;
85 } VARIABLE_POINTER_TRACK
;
88 EFI_PHYSICAL_ADDRESS HobVariableBase
;
89 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
90 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
91 EFI_LOCK VariableServicesLock
;
92 UINT32 ReentrantState
;
98 VARIABLE_GLOBAL VariableGlobal
;
99 UINTN VolatileLastVariableOffset
;
100 UINTN NonVolatileLastVariableOffset
;
101 UINTN CommonVariableSpace
;
102 UINTN CommonMaxUserVariableSpace
;
103 UINTN CommonRuntimeVariableSpace
;
104 UINTN CommonVariableTotalSize
;
105 UINTN CommonUserVariableTotalSize
;
106 UINTN HwErrVariableTotalSize
;
107 UINTN MaxVariableSize
;
108 UINTN MaxAuthVariableSize
;
109 UINTN MaxVolatileVariableSize
;
110 UINTN ScratchBufferSize
;
111 CHAR8
*PlatformLangCodes
;
114 CHAR8 Lang
[ISO_639_2_ENTRY_SIZE
+ 1];
115 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbInstance
;
116 } VARIABLE_MODULE_GLOBAL
;
119 Flush the HOB variable to flash.
121 @param[in] VariableName Name of variable has been updated or deleted.
122 @param[in] VendorGuid Guid of variable has been updated or deleted.
126 FlushHobVariableToFlash (
127 IN CHAR16
*VariableName
,
128 IN EFI_GUID
*VendorGuid
132 Writes a buffer to variable storage space, in the working block.
134 This function writes a buffer to variable storage space into a firmware
135 volume block device. The destination is specified by the parameter
136 VariableBase. Fault Tolerant Write protocol is used for writing.
138 @param VariableBase Base address of the variable to write.
139 @param VariableBuffer Point to the variable data buffer.
141 @retval EFI_SUCCESS The function completed successfully.
142 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
143 @retval EFI_ABORTED The function could not complete successfully.
148 IN EFI_PHYSICAL_ADDRESS VariableBase
,
149 IN VARIABLE_STORE_HEADER
*VariableBuffer
153 Finds variable in storage blocks of volatile and non-volatile storage areas.
155 This code finds variable in storage blocks of volatile and non-volatile storage areas.
156 If VariableName is an empty string, then we just return the first
157 qualified variable without comparing VariableName and VendorGuid.
158 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check
159 at runtime when searching existing variable, only VariableName and VendorGuid are compared.
160 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
162 @param[in] VariableName Name of the variable to be found.
163 @param[in] VendorGuid Vendor GUID to be found.
164 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,
165 including the range searched and the target position.
166 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including
167 base of volatile variable storage area, base of
168 NV variable storage area, and a lock.
169 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
170 check at runtime when searching variable.
172 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while
174 @retval EFI_SUCCESS Variable successfully found.
175 @retval EFI_NOT_FOUND Variable not found
180 IN CHAR16
*VariableName
,
181 IN EFI_GUID
*VendorGuid
,
182 OUT VARIABLE_POINTER_TRACK
*PtrTrack
,
183 IN VARIABLE_GLOBAL
*Global
,
184 IN BOOLEAN IgnoreRtCheck
189 Gets the pointer to the end of the variable storage area.
191 This function gets pointer to the end of the variable storage
192 area, according to the input variable store header.
194 @param VarStoreHeader Pointer to the Variable Store Header.
196 @return Pointer to the end of the variable storage area.
201 IN VARIABLE_STORE_HEADER
*VarStoreHeader
205 This code gets the size of variable header.
207 @return Size of variable header in bytes in type UINTN.
211 GetVariableHeaderSize (
217 This code gets the pointer to the variable name.
219 @param Variable Pointer to the Variable Header.
221 @return Pointer to Variable Name which is Unicode encoding.
226 IN VARIABLE_HEADER
*Variable
230 This code gets the pointer to the variable guid.
232 @param Variable Pointer to the Variable Header.
234 @return A EFI_GUID* pointer to Vendor Guid.
239 IN VARIABLE_HEADER
*Variable
244 This code gets the pointer to the variable data.
246 @param Variable Pointer to the Variable Header.
248 @return Pointer to Variable Data.
253 IN VARIABLE_HEADER
*Variable
258 This code gets the size of variable data.
260 @param Variable Pointer to the Variable Header.
262 @return Size of variable in bytes.
267 IN VARIABLE_HEADER
*Variable
271 This function is to check if the remaining variable space is enough to set
272 all Variables from argument list successfully. The purpose of the check
273 is to keep the consistency of the Variables to be in variable storage.
275 Note: Variables are assumed to be in same storage.
276 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
277 so follow the argument sequence to check the Variables.
279 @param[in] Attributes Variable attributes for Variable entries.
280 @param[in] Marker VA_LIST style variable argument list.
281 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
282 A NULL terminates the list. The VariableSize of
283 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
284 It will be changed to variable total size as output.
286 @retval TRUE Have enough variable space to set the Variables successfully.
287 @retval FALSE No enough variable space to set the Variables successfully.
292 CheckRemainingSpaceForConsistencyInternal (
293 IN UINT32 Attributes
,
298 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
299 index of associated public key is needed.
301 @param[in] VariableName Name of variable.
302 @param[in] VendorGuid Guid of variable.
303 @param[in] Data Variable data.
304 @param[in] DataSize Size of data. 0 means delete.
305 @param[in] Attributes Attributes of the variable.
306 @param[in] KeyIndex Index of associated public key.
307 @param[in] MonotonicCount Value of associated monotonic count.
308 @param[in, out] Variable The variable information that is used to keep track of variable usage.
310 @param[in] TimeStamp Value of associated TimeStamp.
312 @retval EFI_SUCCESS The update operation is success.
313 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
318 IN CHAR16
*VariableName
,
319 IN EFI_GUID
*VendorGuid
,
322 IN UINT32 Attributes OPTIONAL
,
323 IN UINT32 KeyIndex OPTIONAL
,
324 IN UINT64 MonotonicCount OPTIONAL
,
325 IN OUT VARIABLE_POINTER_TRACK
*Variable
,
326 IN EFI_TIME
*TimeStamp OPTIONAL
331 Return TRUE if ExitBootServices () has been called.
333 @retval TRUE If ExitBootServices () has been called.
341 Initializes a basic mutual exclusion lock.
343 This function initializes a basic mutual exclusion lock to the released state
344 and returns the lock. Each lock provides mutual exclusion access at its task
345 priority level. Since there is no preemption or multiprocessor support in EFI,
346 acquiring the lock only consists of raising to the locks TPL.
347 If Lock is NULL, then ASSERT().
348 If Priority is not a valid TPL value, then ASSERT().
350 @param Lock A pointer to the lock data structure to initialize.
351 @param Priority EFI TPL is associated with the lock.
358 IN OUT EFI_LOCK
*Lock
,
364 Acquires lock only at boot time. Simply returns at runtime.
366 This is a temperary function that will be removed when
367 EfiAcquireLock() in UefiLib can handle the call in UEFI
368 Runtimer driver in RT phase.
369 It calls EfiAcquireLock() at boot time, and simply returns
372 @param Lock A pointer to the lock to acquire.
376 AcquireLockOnlyAtBootTime (
382 Releases lock only at boot time. Simply returns at runtime.
384 This is a temperary function which will be removed when
385 EfiReleaseLock() in UefiLib can handle the call in UEFI
386 Runtimer driver in RT phase.
387 It calls EfiReleaseLock() at boot time and simply returns
390 @param Lock A pointer to the lock to release.
394 ReleaseLockOnlyAtBootTime (
399 Retrieve the FVB protocol interface by HANDLE.
401 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
402 reading, writing, and erasing the target block.
403 @param[out] FvBlock The interface of FVB protocol
405 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
406 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
407 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
412 IN EFI_HANDLE FvBlockHandle
,
413 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvBlock
417 Function returns an array of handles that support the FVB protocol
418 in a buffer allocated from pool.
420 @param[out] NumberHandles The number of handles returned in Buffer.
421 @param[out] Buffer A pointer to the buffer to return the requested
422 array of handles that support FVB protocol.
424 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
425 handles in Buffer was returned in NumberHandles.
426 @retval EFI_NOT_FOUND No FVB handle was found.
427 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
428 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
432 GetFvbCountAndBuffer (
433 OUT UINTN
*NumberHandles
,
434 OUT EFI_HANDLE
**Buffer
438 Initializes variable store area for non-volatile and volatile variable.
440 @retval EFI_SUCCESS Function successfully executed.
441 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
445 VariableCommonInitialize (
450 This function reclaims variable storage if free size is below the threshold.
459 Get non-volatile maximum variable size.
461 @return Non-volatile maximum variable size.
465 GetNonVolatileMaxVariableSize (
470 Get maximum variable size, covering both non-volatile and volatile variables.
472 @return Maximum variable size.
481 Initializes variable write service.
483 @retval EFI_SUCCESS Function successfully executed.
484 @retval Others Fail to initialize the variable service.
488 VariableWriteServiceInitialize (
493 Retrieve the SMM Fault Tolerent Write protocol interface.
495 @param[out] FtwProtocol The interface of SMM Ftw protocol
497 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
498 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
499 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
504 OUT VOID
**FtwProtocol
508 Get the proper fvb handle and/or fvb protocol by the given Flash address.
510 @param[in] Address The Flash address.
511 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
512 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
516 GetFvbInfoByAddress (
517 IN EFI_PHYSICAL_ADDRESS Address
,
518 OUT EFI_HANDLE
*FvbHandle OPTIONAL
,
519 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvbProtocol OPTIONAL
524 This code finds variable in storage blocks (Volatile or Non-Volatile).
526 Caution: This function may receive untrusted input.
527 This function may be invoked in SMM mode, and datasize and data are external input.
528 This function will do basic validation, before parse the data.
530 @param VariableName Name of Variable to be found.
531 @param VendorGuid Variable vendor GUID.
532 @param Attributes Attribute value of the variable found.
533 @param DataSize Size of Data found. If size is less than the
534 data, this value contains the required size.
535 @param Data The buffer to return the contents of the variable. May be NULL
536 with a zero DataSize in order to determine the size buffer needed.
538 @return EFI_INVALID_PARAMETER Invalid parameter.
539 @return EFI_SUCCESS Find the specified variable.
540 @return EFI_NOT_FOUND Not found.
541 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
546 VariableServiceGetVariable (
547 IN CHAR16
*VariableName
,
548 IN EFI_GUID
*VendorGuid
,
549 OUT UINT32
*Attributes OPTIONAL
,
550 IN OUT UINTN
*DataSize
,
551 OUT VOID
*Data OPTIONAL
555 This code Finds the Next available variable.
557 Caution: This function may receive untrusted input.
558 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
560 @param[in] VariableName Pointer to variable name.
561 @param[in] VendorGuid Variable Vendor Guid.
562 @param[out] VariablePtr Pointer to variable header address.
564 @retval EFI_SUCCESS The function completed successfully.
565 @retval EFI_NOT_FOUND The next variable was not found.
566 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
567 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
568 GUID of an existing variable.
573 VariableServiceGetNextVariableInternal (
574 IN CHAR16
*VariableName
,
575 IN EFI_GUID
*VendorGuid
,
576 OUT VARIABLE_HEADER
**VariablePtr
581 This code Finds the Next available variable.
583 Caution: This function may receive untrusted input.
584 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
586 @param VariableNameSize The size of the VariableName buffer. The size must be large
587 enough to fit input string supplied in VariableName buffer.
588 @param VariableName Pointer to variable name.
589 @param VendorGuid Variable Vendor Guid.
591 @retval EFI_SUCCESS The function completed successfully.
592 @retval EFI_NOT_FOUND The next variable was not found.
593 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
594 VariableNameSize has been updated with the size needed to complete the request.
595 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
596 @retval EFI_INVALID_PARAMETER VariableName is NULL.
597 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
598 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
599 GUID of an existing variable.
600 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
601 the input VariableName buffer.
606 VariableServiceGetNextVariableName (
607 IN OUT UINTN
*VariableNameSize
,
608 IN OUT CHAR16
*VariableName
,
609 IN OUT EFI_GUID
*VendorGuid
614 This code sets variable in storage blocks (Volatile or Non-Volatile).
616 Caution: This function may receive untrusted input.
617 This function may be invoked in SMM mode, and datasize and data are external input.
618 This function will do basic validation, before parse the data.
619 This function will parse the authentication carefully to avoid security issues, like
620 buffer overflow, integer overflow.
621 This function will check attribute carefully to avoid authentication bypass.
623 @param VariableName Name of Variable to be found.
624 @param VendorGuid Variable vendor GUID.
625 @param Attributes Attribute value of the variable found
626 @param DataSize Size of Data found. If size is less than the
627 data, this value contains the required size.
628 @param Data Data pointer.
630 @return EFI_INVALID_PARAMETER Invalid parameter.
631 @return EFI_SUCCESS Set successfully.
632 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
633 @return EFI_NOT_FOUND Not found.
634 @return EFI_WRITE_PROTECTED Variable is read-only.
639 VariableServiceSetVariable (
640 IN CHAR16
*VariableName
,
641 IN EFI_GUID
*VendorGuid
,
642 IN UINT32 Attributes
,
649 This code returns information about the EFI variables.
651 Caution: This function may receive untrusted input.
652 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
654 @param Attributes Attributes bitmask to specify the type of variables
655 on which to return information.
656 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
657 for the EFI variables associated with the attributes specified.
658 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
659 for EFI variables associated with the attributes specified.
660 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
661 associated with the attributes specified.
663 @return EFI_SUCCESS Query successfully.
668 VariableServiceQueryVariableInfoInternal (
669 IN UINT32 Attributes
,
670 OUT UINT64
*MaximumVariableStorageSize
,
671 OUT UINT64
*RemainingVariableStorageSize
,
672 OUT UINT64
*MaximumVariableSize
677 This code returns information about the EFI variables.
679 Caution: This function may receive untrusted input.
680 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
682 @param Attributes Attributes bitmask to specify the type of variables
683 on which to return information.
684 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
685 for the EFI variables associated with the attributes specified.
686 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
687 for EFI variables associated with the attributes specified.
688 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
689 associated with the attributes specified.
691 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
692 @return EFI_SUCCESS Query successfully.
693 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
698 VariableServiceQueryVariableInfo (
699 IN UINT32 Attributes
,
700 OUT UINT64
*MaximumVariableStorageSize
,
701 OUT UINT64
*RemainingVariableStorageSize
,
702 OUT UINT64
*MaximumVariableSize
706 Mark a variable that will become read-only after leaving the DXE phase of execution.
708 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
709 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
710 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
712 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
713 as pending to be read-only.
714 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
715 Or VariableName is an empty string.
716 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
717 already been signaled.
718 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
722 VariableLockRequestToLock (
723 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
724 IN CHAR16
*VariableName
,
725 IN EFI_GUID
*VendorGuid
729 Register SetVariable check handler.
731 @param[in] Handler Pointer to check handler.
733 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
734 @retval EFI_INVALID_PARAMETER Handler is NULL.
735 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
736 already been signaled.
737 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
738 @retval EFI_UNSUPPORTED This interface is not implemented.
739 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
744 VarCheckRegisterSetVariableCheckHandler (
745 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
749 Variable property set.
751 @param[in] Name Pointer to the variable name.
752 @param[in] Guid Pointer to the vendor GUID.
753 @param[in] VariableProperty Pointer to the input variable property.
755 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
756 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
757 or the fields of VariableProperty are not valid.
758 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
759 already been signaled.
760 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
765 VarCheckVariablePropertySet (
768 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
772 Variable property get.
774 @param[in] Name Pointer to the variable name.
775 @param[in] Guid Pointer to the vendor GUID.
776 @param[out] VariableProperty Pointer to the output variable property.
778 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
779 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
780 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
785 VarCheckVariablePropertyGet (
788 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
792 Initialize variable quota.
796 InitializeVariableQuota (
800 extern VARIABLE_MODULE_GLOBAL
*mVariableModuleGlobal
;
801 extern EFI_FIRMWARE_VOLUME_HEADER
*mNvFvHeaderCache
;
802 extern VARIABLE_STORE_HEADER
*mNvVariableCache
;
803 extern VARIABLE_INFO_ENTRY
*gVariableInfo
;
804 extern BOOLEAN mEndOfDxe
;
805 extern VAR_CHECK_REQUEST_SOURCE mRequestSource
;
807 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut
;
810 Finds variable in storage blocks of volatile and non-volatile storage areas.
812 This code finds variable in storage blocks of volatile and non-volatile storage areas.
813 If VariableName is an empty string, then we just return the first
814 qualified variable without comparing VariableName and VendorGuid.
816 @param[in] VariableName Name of the variable to be found.
817 @param[in] VendorGuid Variable vendor GUID to be found.
818 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
819 output of the variable found.
821 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
822 while VendorGuid is NULL.
823 @retval EFI_SUCCESS Variable successfully found.
824 @retval EFI_NOT_FOUND Variable not found
829 VariableExLibFindVariable (
830 IN CHAR16
*VariableName
,
831 IN EFI_GUID
*VendorGuid
,
832 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
836 Finds next variable in storage blocks of volatile and non-volatile storage areas.
838 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
839 If VariableName is an empty string, then we just return the first
840 qualified variable without comparing VariableName and VendorGuid.
842 @param[in] VariableName Name of the variable to be found.
843 @param[in] VendorGuid Variable vendor GUID to be found.
844 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
845 output of the next variable.
847 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
848 while VendorGuid is NULL.
849 @retval EFI_SUCCESS Variable successfully found.
850 @retval EFI_NOT_FOUND Variable not found
855 VariableExLibFindNextVariable (
856 IN CHAR16
*VariableName
,
857 IN EFI_GUID
*VendorGuid
,
858 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
862 Update the variable region with Variable information.
864 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
865 input of the variable.
867 @retval EFI_SUCCESS The update operation is success.
868 @retval EFI_INVALID_PARAMETER Invalid parameter.
869 @retval EFI_WRITE_PROTECTED Variable is write-protected.
870 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
875 VariableExLibUpdateVariable (
876 IN AUTH_VARIABLE_INFO
*AuthVariableInfo
882 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
883 the maximum supported buffer size, this value contains
884 the maximum supported buffer size as output.
885 @param[out] ScratchBuffer Pointer to scratch buffer address.
887 @retval EFI_SUCCESS Get scratch buffer successfully.
888 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
893 VariableExLibGetScratchBuffer (
894 IN OUT UINTN
*ScratchBufferSize
,
895 OUT VOID
**ScratchBuffer
899 This function is to check if the remaining variable space is enough to set
900 all Variables from argument list successfully. The purpose of the check
901 is to keep the consistency of the Variables to be in variable storage.
903 Note: Variables are assumed to be in same storage.
904 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
905 so follow the argument sequence to check the Variables.
907 @param[in] Attributes Variable attributes for Variable entries.
908 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
909 A NULL terminates the list. The VariableSize of
910 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
911 It will be changed to variable total size as output.
913 @retval TRUE Have enough variable space to set the Variables successfully.
914 @retval FALSE No enough variable space to set the Variables successfully.
919 VariableExLibCheckRemainingSpaceForConsistency (
920 IN UINT32 Attributes
,
925 Return TRUE if at OS runtime.
927 @retval TRUE If at OS runtime.
928 @retval FALSE If at boot time.
933 VariableExLibAtRuntime (