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
;
99 VARIABLE_GLOBAL VariableGlobal
;
100 UINTN VolatileLastVariableOffset
;
101 UINTN NonVolatileLastVariableOffset
;
102 UINTN CommonVariableSpace
;
103 UINTN CommonMaxUserVariableSpace
;
104 UINTN CommonRuntimeVariableSpace
;
105 UINTN CommonVariableTotalSize
;
106 UINTN CommonUserVariableTotalSize
;
107 UINTN HwErrVariableTotalSize
;
108 UINTN MaxVariableSize
;
109 UINTN MaxAuthVariableSize
;
110 UINTN MaxVolatileVariableSize
;
111 UINTN ScratchBufferSize
;
112 CHAR8
*PlatformLangCodes
;
115 CHAR8 Lang
[ISO_639_2_ENTRY_SIZE
+ 1];
116 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbInstance
;
117 } VARIABLE_MODULE_GLOBAL
;
120 Flush the HOB variable to flash.
122 @param[in] VariableName Name of variable has been updated or deleted.
123 @param[in] VendorGuid Guid of variable has been updated or deleted.
127 FlushHobVariableToFlash (
128 IN CHAR16
*VariableName
,
129 IN EFI_GUID
*VendorGuid
133 Writes a buffer to variable storage space, in the working block.
135 This function writes a buffer to variable storage space into a firmware
136 volume block device. The destination is specified by the parameter
137 VariableBase. Fault Tolerant Write protocol is used for writing.
139 @param VariableBase Base address of the variable to write.
140 @param VariableBuffer Point to the variable data buffer.
142 @retval EFI_SUCCESS The function completed successfully.
143 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
144 @retval EFI_ABORTED The function could not complete successfully.
149 IN EFI_PHYSICAL_ADDRESS VariableBase
,
150 IN VARIABLE_STORE_HEADER
*VariableBuffer
154 Finds variable in storage blocks of volatile and non-volatile storage areas.
156 This code finds variable in storage blocks of volatile and non-volatile storage areas.
157 If VariableName is an empty string, then we just return the first
158 qualified variable without comparing VariableName and VendorGuid.
159 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check
160 at runtime when searching existing variable, only VariableName and VendorGuid are compared.
161 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
163 @param[in] VariableName Name of the variable to be found.
164 @param[in] VendorGuid Vendor GUID to be found.
165 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,
166 including the range searched and the target position.
167 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including
168 base of volatile variable storage area, base of
169 NV variable storage area, and a lock.
170 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
171 check at runtime when searching variable.
173 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while
175 @retval EFI_SUCCESS Variable successfully found.
176 @retval EFI_NOT_FOUND Variable not found
181 IN CHAR16
*VariableName
,
182 IN EFI_GUID
*VendorGuid
,
183 OUT VARIABLE_POINTER_TRACK
*PtrTrack
,
184 IN VARIABLE_GLOBAL
*Global
,
185 IN BOOLEAN IgnoreRtCheck
190 Gets the pointer to the end of the variable storage area.
192 This function gets pointer to the end of the variable storage
193 area, according to the input variable store header.
195 @param VarStoreHeader Pointer to the Variable Store Header.
197 @return Pointer to the end of the variable storage area.
202 IN VARIABLE_STORE_HEADER
*VarStoreHeader
206 This code gets the size of variable header.
208 @return Size of variable header in bytes in type UINTN.
212 GetVariableHeaderSize (
218 This code gets the pointer to the variable name.
220 @param Variable Pointer to the Variable Header.
222 @return Pointer to Variable Name which is Unicode encoding.
227 IN VARIABLE_HEADER
*Variable
231 This code gets the pointer to the variable guid.
233 @param Variable Pointer to the Variable Header.
235 @return A EFI_GUID* pointer to Vendor Guid.
240 IN VARIABLE_HEADER
*Variable
245 This code gets the pointer to the variable data.
247 @param Variable Pointer to the Variable Header.
249 @return Pointer to Variable Data.
254 IN VARIABLE_HEADER
*Variable
259 This code gets the size of variable data.
261 @param Variable Pointer to the Variable Header.
263 @return Size of variable in bytes.
268 IN VARIABLE_HEADER
*Variable
272 This function is to check if the remaining variable space is enough to set
273 all Variables from argument list successfully. The purpose of the check
274 is to keep the consistency of the Variables to be in variable storage.
276 Note: Variables are assumed to be in same storage.
277 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
278 so follow the argument sequence to check the Variables.
280 @param[in] Attributes Variable attributes for Variable entries.
281 @param[in] Marker VA_LIST style variable argument list.
282 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
283 A NULL terminates the list. The VariableSize of
284 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
285 It will be changed to variable total size as output.
287 @retval TRUE Have enough variable space to set the Variables successfully.
288 @retval FALSE No enough variable space to set the Variables successfully.
293 CheckRemainingSpaceForConsistencyInternal (
294 IN UINT32 Attributes
,
299 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
300 index of associated public key is needed.
302 @param[in] VariableName Name of variable.
303 @param[in] VendorGuid Guid of variable.
304 @param[in] Data Variable data.
305 @param[in] DataSize Size of data. 0 means delete.
306 @param[in] Attributes Attributes of the variable.
307 @param[in] KeyIndex Index of associated public key.
308 @param[in] MonotonicCount Value of associated monotonic count.
309 @param[in, out] Variable The variable information that is used to keep track of variable usage.
311 @param[in] TimeStamp Value of associated TimeStamp.
313 @retval EFI_SUCCESS The update operation is success.
314 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
319 IN CHAR16
*VariableName
,
320 IN EFI_GUID
*VendorGuid
,
323 IN UINT32 Attributes OPTIONAL
,
324 IN UINT32 KeyIndex OPTIONAL
,
325 IN UINT64 MonotonicCount OPTIONAL
,
326 IN OUT VARIABLE_POINTER_TRACK
*Variable
,
327 IN EFI_TIME
*TimeStamp OPTIONAL
332 Return TRUE if ExitBootServices () has been called.
334 @retval TRUE If ExitBootServices () has been called.
342 Initializes a basic mutual exclusion lock.
344 This function initializes a basic mutual exclusion lock to the released state
345 and returns the lock. Each lock provides mutual exclusion access at its task
346 priority level. Since there is no preemption or multiprocessor support in EFI,
347 acquiring the lock only consists of raising to the locks TPL.
348 If Lock is NULL, then ASSERT().
349 If Priority is not a valid TPL value, then ASSERT().
351 @param Lock A pointer to the lock data structure to initialize.
352 @param Priority EFI TPL is associated with the lock.
359 IN OUT EFI_LOCK
*Lock
,
365 Acquires lock only at boot time. Simply returns at runtime.
367 This is a temperary function that will be removed when
368 EfiAcquireLock() in UefiLib can handle the call in UEFI
369 Runtimer driver in RT phase.
370 It calls EfiAcquireLock() at boot time, and simply returns
373 @param Lock A pointer to the lock to acquire.
377 AcquireLockOnlyAtBootTime (
383 Releases lock only at boot time. Simply returns at runtime.
385 This is a temperary function which will be removed when
386 EfiReleaseLock() in UefiLib can handle the call in UEFI
387 Runtimer driver in RT phase.
388 It calls EfiReleaseLock() at boot time and simply returns
391 @param Lock A pointer to the lock to release.
395 ReleaseLockOnlyAtBootTime (
400 Retrieve the FVB protocol interface by HANDLE.
402 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
403 reading, writing, and erasing the target block.
404 @param[out] FvBlock The interface of FVB protocol
406 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
407 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
408 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
413 IN EFI_HANDLE FvBlockHandle
,
414 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvBlock
418 Function returns an array of handles that support the FVB protocol
419 in a buffer allocated from pool.
421 @param[out] NumberHandles The number of handles returned in Buffer.
422 @param[out] Buffer A pointer to the buffer to return the requested
423 array of handles that support FVB protocol.
425 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
426 handles in Buffer was returned in NumberHandles.
427 @retval EFI_NOT_FOUND No FVB handle was found.
428 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
429 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
433 GetFvbCountAndBuffer (
434 OUT UINTN
*NumberHandles
,
435 OUT EFI_HANDLE
**Buffer
439 Initializes variable store area for non-volatile and volatile variable.
441 @retval EFI_SUCCESS Function successfully executed.
442 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
446 VariableCommonInitialize (
451 This function reclaims variable storage if free size is below the threshold.
460 Get non-volatile maximum variable size.
462 @return Non-volatile maximum variable size.
466 GetNonVolatileMaxVariableSize (
471 Get maximum variable size, covering both non-volatile and volatile variables.
473 @return Maximum variable size.
482 Initializes variable write service.
484 @retval EFI_SUCCESS Function successfully executed.
485 @retval Others Fail to initialize the variable service.
489 VariableWriteServiceInitialize (
494 Retrieve the SMM Fault Tolerent Write protocol interface.
496 @param[out] FtwProtocol The interface of SMM Ftw protocol
498 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
499 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
500 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
505 OUT VOID
**FtwProtocol
509 Get the proper fvb handle and/or fvb protocol by the given Flash address.
511 @param[in] Address The Flash address.
512 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
513 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
517 GetFvbInfoByAddress (
518 IN EFI_PHYSICAL_ADDRESS Address
,
519 OUT EFI_HANDLE
*FvbHandle OPTIONAL
,
520 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvbProtocol OPTIONAL
525 This code finds variable in storage blocks (Volatile or Non-Volatile).
527 Caution: This function may receive untrusted input.
528 This function may be invoked in SMM mode, and datasize and data are external input.
529 This function will do basic validation, before parse the data.
531 @param VariableName Name of Variable to be found.
532 @param VendorGuid Variable vendor GUID.
533 @param Attributes Attribute value of the variable found.
534 @param DataSize Size of Data found. If size is less than the
535 data, this value contains the required size.
536 @param Data The buffer to return the contents of the variable. May be NULL
537 with a zero DataSize in order to determine the size buffer needed.
539 @return EFI_INVALID_PARAMETER Invalid parameter.
540 @return EFI_SUCCESS Find the specified variable.
541 @return EFI_NOT_FOUND Not found.
542 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
547 VariableServiceGetVariable (
548 IN CHAR16
*VariableName
,
549 IN EFI_GUID
*VendorGuid
,
550 OUT UINT32
*Attributes OPTIONAL
,
551 IN OUT UINTN
*DataSize
,
552 OUT VOID
*Data OPTIONAL
556 This code Finds the Next available variable.
558 Caution: This function may receive untrusted input.
559 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
561 @param[in] VariableName Pointer to variable name.
562 @param[in] VendorGuid Variable Vendor Guid.
563 @param[out] VariablePtr Pointer to variable header address.
565 @retval EFI_SUCCESS The function completed successfully.
566 @retval EFI_NOT_FOUND The next variable was not found.
567 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
568 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
569 GUID of an existing variable.
574 VariableServiceGetNextVariableInternal (
575 IN CHAR16
*VariableName
,
576 IN EFI_GUID
*VendorGuid
,
577 OUT VARIABLE_HEADER
**VariablePtr
582 This code Finds the Next available variable.
584 Caution: This function may receive untrusted input.
585 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
587 @param VariableNameSize The size of the VariableName buffer. The size must be large
588 enough to fit input string supplied in VariableName buffer.
589 @param VariableName Pointer to variable name.
590 @param VendorGuid Variable Vendor Guid.
592 @retval EFI_SUCCESS The function completed successfully.
593 @retval EFI_NOT_FOUND The next variable was not found.
594 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
595 VariableNameSize has been updated with the size needed to complete the request.
596 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
597 @retval EFI_INVALID_PARAMETER VariableName is NULL.
598 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
599 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
600 GUID of an existing variable.
601 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
602 the input VariableName buffer.
607 VariableServiceGetNextVariableName (
608 IN OUT UINTN
*VariableNameSize
,
609 IN OUT CHAR16
*VariableName
,
610 IN OUT EFI_GUID
*VendorGuid
615 This code sets variable in storage blocks (Volatile or Non-Volatile).
617 Caution: This function may receive untrusted input.
618 This function may be invoked in SMM mode, and datasize and data are external input.
619 This function will do basic validation, before parse the data.
620 This function will parse the authentication carefully to avoid security issues, like
621 buffer overflow, integer overflow.
622 This function will check attribute carefully to avoid authentication bypass.
624 @param VariableName Name of Variable to be found.
625 @param VendorGuid Variable vendor GUID.
626 @param Attributes Attribute value of the variable found
627 @param DataSize Size of Data found. If size is less than the
628 data, this value contains the required size.
629 @param Data Data pointer.
631 @return EFI_INVALID_PARAMETER Invalid parameter.
632 @return EFI_SUCCESS Set successfully.
633 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
634 @return EFI_NOT_FOUND Not found.
635 @return EFI_WRITE_PROTECTED Variable is read-only.
640 VariableServiceSetVariable (
641 IN CHAR16
*VariableName
,
642 IN EFI_GUID
*VendorGuid
,
643 IN UINT32 Attributes
,
650 This code returns information about the EFI variables.
652 Caution: This function may receive untrusted input.
653 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
655 @param Attributes Attributes bitmask to specify the type of variables
656 on which to return information.
657 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
658 for the EFI variables associated with the attributes specified.
659 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
660 for EFI variables associated with the attributes specified.
661 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
662 associated with the attributes specified.
664 @return EFI_SUCCESS Query successfully.
669 VariableServiceQueryVariableInfoInternal (
670 IN UINT32 Attributes
,
671 OUT UINT64
*MaximumVariableStorageSize
,
672 OUT UINT64
*RemainingVariableStorageSize
,
673 OUT UINT64
*MaximumVariableSize
678 This code returns information about the EFI variables.
680 Caution: This function may receive untrusted input.
681 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
683 @param Attributes Attributes bitmask to specify the type of variables
684 on which to return information.
685 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
686 for the EFI variables associated with the attributes specified.
687 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
688 for EFI variables associated with the attributes specified.
689 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
690 associated with the attributes specified.
692 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
693 @return EFI_SUCCESS Query successfully.
694 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
699 VariableServiceQueryVariableInfo (
700 IN UINT32 Attributes
,
701 OUT UINT64
*MaximumVariableStorageSize
,
702 OUT UINT64
*RemainingVariableStorageSize
,
703 OUT UINT64
*MaximumVariableSize
707 Mark a variable that will become read-only after leaving the DXE phase of execution.
709 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
710 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
711 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
713 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
714 as pending to be read-only.
715 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
716 Or VariableName is an empty string.
717 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
718 already been signaled.
719 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
723 VariableLockRequestToLock (
724 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
725 IN CHAR16
*VariableName
,
726 IN EFI_GUID
*VendorGuid
730 Register SetVariable check handler.
732 @param[in] Handler Pointer to check handler.
734 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
735 @retval EFI_INVALID_PARAMETER Handler is NULL.
736 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
737 already been signaled.
738 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
739 @retval EFI_UNSUPPORTED This interface is not implemented.
740 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
745 VarCheckRegisterSetVariableCheckHandler (
746 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
750 Variable property set.
752 @param[in] Name Pointer to the variable name.
753 @param[in] Guid Pointer to the vendor GUID.
754 @param[in] VariableProperty Pointer to the input variable property.
756 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
757 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
758 or the fields of VariableProperty are not valid.
759 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
760 already been signaled.
761 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
766 VarCheckVariablePropertySet (
769 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
773 Variable property get.
775 @param[in] Name Pointer to the variable name.
776 @param[in] Guid Pointer to the vendor GUID.
777 @param[out] VariableProperty Pointer to the output variable property.
779 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
780 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
781 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
786 VarCheckVariablePropertyGet (
789 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
793 Initialize variable quota.
797 InitializeVariableQuota (
801 extern VARIABLE_MODULE_GLOBAL
*mVariableModuleGlobal
;
802 extern EFI_FIRMWARE_VOLUME_HEADER
*mNvFvHeaderCache
;
803 extern VARIABLE_STORE_HEADER
*mNvVariableCache
;
804 extern VARIABLE_INFO_ENTRY
*gVariableInfo
;
805 extern BOOLEAN mEndOfDxe
;
806 extern VAR_CHECK_REQUEST_SOURCE mRequestSource
;
808 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut
;
811 Finds variable in storage blocks of volatile and non-volatile storage areas.
813 This code finds variable in storage blocks of volatile and non-volatile storage areas.
814 If VariableName is an empty string, then we just return the first
815 qualified variable without comparing VariableName and VendorGuid.
817 @param[in] VariableName Name of the variable to be found.
818 @param[in] VendorGuid Variable vendor GUID to be found.
819 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
820 output of the variable found.
822 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
823 while VendorGuid is NULL.
824 @retval EFI_SUCCESS Variable successfully found.
825 @retval EFI_NOT_FOUND Variable not found
830 VariableExLibFindVariable (
831 IN CHAR16
*VariableName
,
832 IN EFI_GUID
*VendorGuid
,
833 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
837 Finds next variable in storage blocks of volatile and non-volatile storage areas.
839 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
840 If VariableName is an empty string, then we just return the first
841 qualified variable without comparing VariableName and VendorGuid.
843 @param[in] VariableName Name of the variable to be found.
844 @param[in] VendorGuid Variable vendor GUID to be found.
845 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
846 output of the next variable.
848 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
849 while VendorGuid is NULL.
850 @retval EFI_SUCCESS Variable successfully found.
851 @retval EFI_NOT_FOUND Variable not found
856 VariableExLibFindNextVariable (
857 IN CHAR16
*VariableName
,
858 IN EFI_GUID
*VendorGuid
,
859 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
863 Update the variable region with Variable information.
865 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
866 input of the variable.
868 @retval EFI_SUCCESS The update operation is success.
869 @retval EFI_INVALID_PARAMETER Invalid parameter.
870 @retval EFI_WRITE_PROTECTED Variable is write-protected.
871 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
876 VariableExLibUpdateVariable (
877 IN AUTH_VARIABLE_INFO
*AuthVariableInfo
883 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
884 the maximum supported buffer size, this value contains
885 the maximum supported buffer size as output.
886 @param[out] ScratchBuffer Pointer to scratch buffer address.
888 @retval EFI_SUCCESS Get scratch buffer successfully.
889 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
894 VariableExLibGetScratchBuffer (
895 IN OUT UINTN
*ScratchBufferSize
,
896 OUT VOID
**ScratchBuffer
900 This function is to check if the remaining variable space is enough to set
901 all Variables from argument list successfully. The purpose of the check
902 is to keep the consistency of the Variables to be in variable storage.
904 Note: Variables are assumed to be in same storage.
905 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
906 so follow the argument sequence to check the Variables.
908 @param[in] Attributes Variable attributes for Variable entries.
909 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
910 A NULL terminates the list. The VariableSize of
911 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
912 It will be changed to variable total size as output.
914 @retval TRUE Have enough variable space to set the Variables successfully.
915 @retval FALSE No enough variable space to set the Variables successfully.
920 VariableExLibCheckRemainingSpaceForConsistency (
921 IN UINT32 Attributes
,
926 Return TRUE if at OS runtime.
928 @retval TRUE If at OS runtime.
929 @retval FALSE If at boot time.
934 VariableExLibAtRuntime (