2 The internal header file includes the common header files, defines
3 internal structure and functions used by Variable modules.
5 Copyright (c) 2006 - 2017, 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 EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
50 EFI_VARIABLE_BOOTSERVICE_ACCESS | \
51 EFI_VARIABLE_RUNTIME_ACCESS | \
52 EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
53 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
54 EFI_VARIABLE_APPEND_WRITE)
57 /// The size of a 3 character ISO639 language code.
59 #define ISO_639_2_ENTRY_SIZE 3
62 VariableStoreTypeVolatile
,
66 } VARIABLE_STORE_TYPE
;
69 VARIABLE_HEADER
*CurrPtr
;
71 // If both ADDED and IN_DELETED_TRANSITION variable are present,
72 // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.
73 // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,
74 // and InDeletedTransitionPtr will be NULL at the same time.
76 VARIABLE_HEADER
*InDeletedTransitionPtr
;
77 VARIABLE_HEADER
*EndPtr
;
78 VARIABLE_HEADER
*StartPtr
;
80 } VARIABLE_POINTER_TRACK
;
83 EFI_PHYSICAL_ADDRESS HobVariableBase
;
84 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
85 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
86 EFI_LOCK VariableServicesLock
;
87 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
184 Gets the pointer to the end of the variable storage area.
186 This function gets pointer to the end of the variable storage
187 area, according to the input variable store header.
189 @param VarStoreHeader Pointer to the Variable Store Header.
191 @return Pointer to the end of the variable storage area.
196 IN VARIABLE_STORE_HEADER
*VarStoreHeader
200 This code gets the size of variable header.
202 @return Size of variable header in bytes in type UINTN.
206 GetVariableHeaderSize (
212 This code gets the pointer to the variable name.
214 @param Variable Pointer to the Variable Header.
216 @return Pointer to Variable Name which is Unicode encoding.
221 IN VARIABLE_HEADER
*Variable
225 This code gets the pointer to the variable guid.
227 @param Variable Pointer to the Variable Header.
229 @return A EFI_GUID* pointer to Vendor Guid.
234 IN VARIABLE_HEADER
*Variable
239 This code gets the pointer to the variable data.
241 @param Variable Pointer to the Variable Header.
243 @return Pointer to Variable Data.
248 IN VARIABLE_HEADER
*Variable
253 This code gets the size of variable data.
255 @param Variable Pointer to the Variable Header.
257 @return Size of variable in bytes.
262 IN VARIABLE_HEADER
*Variable
266 This function is to check if the remaining variable space is enough to set
267 all Variables from argument list successfully. The purpose of the check
268 is to keep the consistency of the Variables to be in variable storage.
270 Note: Variables are assumed to be in same storage.
271 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
272 so follow the argument sequence to check the Variables.
274 @param[in] Attributes Variable attributes for Variable entries.
275 @param[in] Marker VA_LIST style variable argument list.
276 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
277 A NULL terminates the list. The VariableSize of
278 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
279 It will be changed to variable total size as output.
281 @retval TRUE Have enough variable space to set the Variables successfully.
282 @retval FALSE No enough variable space to set the Variables successfully.
287 CheckRemainingSpaceForConsistencyInternal (
288 IN UINT32 Attributes
,
293 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
294 index of associated public key is needed.
296 @param[in] VariableName Name of variable.
297 @param[in] VendorGuid Guid of variable.
298 @param[in] Data Variable data.
299 @param[in] DataSize Size of data. 0 means delete.
300 @param[in] Attributes Attributes of the variable.
301 @param[in] KeyIndex Index of associated public key.
302 @param[in] MonotonicCount Value of associated monotonic count.
303 @param[in, out] Variable The variable information that is used to keep track of variable usage.
305 @param[in] TimeStamp Value of associated TimeStamp.
307 @retval EFI_SUCCESS The update operation is success.
308 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
313 IN CHAR16
*VariableName
,
314 IN EFI_GUID
*VendorGuid
,
317 IN UINT32 Attributes OPTIONAL
,
318 IN UINT32 KeyIndex OPTIONAL
,
319 IN UINT64 MonotonicCount OPTIONAL
,
320 IN OUT VARIABLE_POINTER_TRACK
*Variable
,
321 IN EFI_TIME
*TimeStamp OPTIONAL
326 Return TRUE if ExitBootServices () has been called.
328 @retval TRUE If ExitBootServices () has been called.
336 Initializes a basic mutual exclusion lock.
338 This function initializes a basic mutual exclusion lock to the released state
339 and returns the lock. Each lock provides mutual exclusion access at its task
340 priority level. Since there is no preemption or multiprocessor support in EFI,
341 acquiring the lock only consists of raising to the locks TPL.
342 If Lock is NULL, then ASSERT().
343 If Priority is not a valid TPL value, then ASSERT().
345 @param Lock A pointer to the lock data structure to initialize.
346 @param Priority EFI TPL is associated with the lock.
353 IN OUT EFI_LOCK
*Lock
,
359 Acquires lock only at boot time. Simply returns at runtime.
361 This is a temperary function that will be removed when
362 EfiAcquireLock() in UefiLib can handle the call in UEFI
363 Runtimer driver in RT phase.
364 It calls EfiAcquireLock() at boot time, and simply returns
367 @param Lock A pointer to the lock to acquire.
371 AcquireLockOnlyAtBootTime (
377 Releases lock only at boot time. Simply returns at runtime.
379 This is a temperary function which will be removed when
380 EfiReleaseLock() in UefiLib can handle the call in UEFI
381 Runtimer driver in RT phase.
382 It calls EfiReleaseLock() at boot time and simply returns
385 @param Lock A pointer to the lock to release.
389 ReleaseLockOnlyAtBootTime (
394 Retrieve the FVB protocol interface by HANDLE.
396 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
397 reading, writing, and erasing the target block.
398 @param[out] FvBlock The interface of FVB protocol
400 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
401 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
402 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
407 IN EFI_HANDLE FvBlockHandle
,
408 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvBlock
412 Function returns an array of handles that support the FVB protocol
413 in a buffer allocated from pool.
415 @param[out] NumberHandles The number of handles returned in Buffer.
416 @param[out] Buffer A pointer to the buffer to return the requested
417 array of handles that support FVB protocol.
419 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
420 handles in Buffer was returned in NumberHandles.
421 @retval EFI_NOT_FOUND No FVB handle was found.
422 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
423 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
427 GetFvbCountAndBuffer (
428 OUT UINTN
*NumberHandles
,
429 OUT EFI_HANDLE
**Buffer
433 Initializes variable store area for non-volatile and volatile variable.
435 @retval EFI_SUCCESS Function successfully executed.
436 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
440 VariableCommonInitialize (
445 This function reclaims variable storage if free size is below the threshold.
454 Get non-volatile maximum variable size.
456 @return Non-volatile maximum variable size.
460 GetNonVolatileMaxVariableSize (
465 Get maximum variable size, covering both non-volatile and volatile variables.
467 @return Maximum variable size.
476 Initializes variable write service after FVB was ready.
478 @retval EFI_SUCCESS Function successfully executed.
479 @retval Others Fail to initialize the variable service.
483 VariableWriteServiceInitialize (
488 Retrieve the SMM Fault Tolerent Write protocol interface.
490 @param[out] FtwProtocol The interface of SMM Ftw protocol
492 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
493 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
494 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
499 OUT VOID
**FtwProtocol
503 Get the proper fvb handle and/or fvb protocol by the given Flash address.
505 @param[in] Address The Flash address.
506 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
507 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
511 GetFvbInfoByAddress (
512 IN EFI_PHYSICAL_ADDRESS Address
,
513 OUT EFI_HANDLE
*FvbHandle OPTIONAL
,
514 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvbProtocol OPTIONAL
519 This code finds variable in storage blocks (Volatile or Non-Volatile).
521 Caution: This function may receive untrusted input.
522 This function may be invoked in SMM mode, and datasize and data are external input.
523 This function will do basic validation, before parse the data.
525 @param VariableName Name of Variable to be found.
526 @param VendorGuid Variable vendor GUID.
527 @param Attributes Attribute value of the variable found.
528 @param DataSize Size of Data found. If size is less than the
529 data, this value contains the required size.
530 @param Data The buffer to return the contents of the variable. May be NULL
531 with a zero DataSize in order to determine the size buffer needed.
533 @return EFI_INVALID_PARAMETER Invalid parameter.
534 @return EFI_SUCCESS Find the specified variable.
535 @return EFI_NOT_FOUND Not found.
536 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
541 VariableServiceGetVariable (
542 IN CHAR16
*VariableName
,
543 IN EFI_GUID
*VendorGuid
,
544 OUT UINT32
*Attributes OPTIONAL
,
545 IN OUT UINTN
*DataSize
,
546 OUT VOID
*Data OPTIONAL
550 This code Finds the Next available variable.
552 Caution: This function may receive untrusted input.
553 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
555 @param[in] VariableName Pointer to variable name.
556 @param[in] VendorGuid Variable Vendor Guid.
557 @param[out] VariablePtr Pointer to variable header address.
559 @retval EFI_SUCCESS The function completed successfully.
560 @retval EFI_NOT_FOUND The next variable was not found.
561 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
562 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
563 GUID of an existing variable.
568 VariableServiceGetNextVariableInternal (
569 IN CHAR16
*VariableName
,
570 IN EFI_GUID
*VendorGuid
,
571 OUT VARIABLE_HEADER
**VariablePtr
576 This code Finds the Next available variable.
578 Caution: This function may receive untrusted input.
579 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
581 @param VariableNameSize The size of the VariableName buffer. The size must be large
582 enough to fit input string supplied in VariableName buffer.
583 @param VariableName Pointer to variable name.
584 @param VendorGuid Variable Vendor Guid.
586 @retval EFI_SUCCESS The function completed successfully.
587 @retval EFI_NOT_FOUND The next variable was not found.
588 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
589 VariableNameSize has been updated with the size needed to complete the request.
590 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
591 @retval EFI_INVALID_PARAMETER VariableName is NULL.
592 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
593 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
594 GUID of an existing variable.
595 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
596 the input VariableName buffer.
601 VariableServiceGetNextVariableName (
602 IN OUT UINTN
*VariableNameSize
,
603 IN OUT CHAR16
*VariableName
,
604 IN OUT EFI_GUID
*VendorGuid
609 This code sets variable in storage blocks (Volatile or Non-Volatile).
611 Caution: This function may receive untrusted input.
612 This function may be invoked in SMM mode, and datasize and data are external input.
613 This function will do basic validation, before parse the data.
614 This function will parse the authentication carefully to avoid security issues, like
615 buffer overflow, integer overflow.
616 This function will check attribute carefully to avoid authentication bypass.
618 @param VariableName Name of Variable to be found.
619 @param VendorGuid Variable vendor GUID.
620 @param Attributes Attribute value of the variable found
621 @param DataSize Size of Data found. If size is less than the
622 data, this value contains the required size.
623 @param Data Data pointer.
625 @return EFI_INVALID_PARAMETER Invalid parameter.
626 @return EFI_SUCCESS Set successfully.
627 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
628 @return EFI_NOT_FOUND Not found.
629 @return EFI_WRITE_PROTECTED Variable is read-only.
634 VariableServiceSetVariable (
635 IN CHAR16
*VariableName
,
636 IN EFI_GUID
*VendorGuid
,
637 IN UINT32 Attributes
,
644 This code returns information about the EFI variables.
646 Caution: This function may receive untrusted input.
647 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
649 @param Attributes Attributes bitmask to specify the type of variables
650 on which to return information.
651 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
652 for the EFI variables associated with the attributes specified.
653 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
654 for EFI variables associated with the attributes specified.
655 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
656 associated with the attributes specified.
658 @return EFI_SUCCESS Query successfully.
663 VariableServiceQueryVariableInfoInternal (
664 IN UINT32 Attributes
,
665 OUT UINT64
*MaximumVariableStorageSize
,
666 OUT UINT64
*RemainingVariableStorageSize
,
667 OUT UINT64
*MaximumVariableSize
672 This code returns information about the EFI variables.
674 Caution: This function may receive untrusted input.
675 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
677 @param Attributes Attributes bitmask to specify the type of variables
678 on which to return information.
679 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
680 for the EFI variables associated with the attributes specified.
681 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
682 for EFI variables associated with the attributes specified.
683 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
684 associated with the attributes specified.
686 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
687 @return EFI_SUCCESS Query successfully.
688 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
693 VariableServiceQueryVariableInfo (
694 IN UINT32 Attributes
,
695 OUT UINT64
*MaximumVariableStorageSize
,
696 OUT UINT64
*RemainingVariableStorageSize
,
697 OUT UINT64
*MaximumVariableSize
701 Mark a variable that will become read-only after leaving the DXE phase of execution.
703 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
704 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
705 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
707 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
708 as pending to be read-only.
709 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
710 Or VariableName is an empty string.
711 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
712 already been signaled.
713 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
717 VariableLockRequestToLock (
718 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
719 IN CHAR16
*VariableName
,
720 IN EFI_GUID
*VendorGuid
724 Register SetVariable check handler.
726 @param[in] Handler Pointer to check handler.
728 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
729 @retval EFI_INVALID_PARAMETER Handler is NULL.
730 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
731 already been signaled.
732 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
733 @retval EFI_UNSUPPORTED This interface is not implemented.
734 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
739 VarCheckRegisterSetVariableCheckHandler (
740 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
744 Variable property set.
746 @param[in] Name Pointer to the variable name.
747 @param[in] Guid Pointer to the vendor GUID.
748 @param[in] VariableProperty Pointer to the input variable property.
750 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
751 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
752 or the fields of VariableProperty are not valid.
753 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
754 already been signaled.
755 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
760 VarCheckVariablePropertySet (
763 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
767 Variable property get.
769 @param[in] Name Pointer to the variable name.
770 @param[in] Guid Pointer to the vendor GUID.
771 @param[out] VariableProperty Pointer to the output variable property.
773 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
774 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
775 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
780 VarCheckVariablePropertyGet (
783 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
787 Initialize variable quota.
791 InitializeVariableQuota (
795 extern VARIABLE_MODULE_GLOBAL
*mVariableModuleGlobal
;
797 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut
;
800 Finds variable in storage blocks of volatile and non-volatile storage areas.
802 This code finds variable in storage blocks of volatile and non-volatile storage areas.
803 If VariableName is an empty string, then we just return the first
804 qualified variable without comparing VariableName and VendorGuid.
806 @param[in] VariableName Name of the variable to be found.
807 @param[in] VendorGuid Variable vendor GUID to be found.
808 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
809 output of the variable found.
811 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
812 while VendorGuid is NULL.
813 @retval EFI_SUCCESS Variable successfully found.
814 @retval EFI_NOT_FOUND Variable not found
819 VariableExLibFindVariable (
820 IN CHAR16
*VariableName
,
821 IN EFI_GUID
*VendorGuid
,
822 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
826 Finds next variable in storage blocks of volatile and non-volatile storage areas.
828 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
829 If VariableName is an empty string, then we just return the first
830 qualified variable without comparing VariableName and VendorGuid.
832 @param[in] VariableName Name of the variable to be found.
833 @param[in] VendorGuid Variable vendor GUID to be found.
834 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
835 output of the next variable.
837 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
838 while VendorGuid is NULL.
839 @retval EFI_SUCCESS Variable successfully found.
840 @retval EFI_NOT_FOUND Variable not found
845 VariableExLibFindNextVariable (
846 IN CHAR16
*VariableName
,
847 IN EFI_GUID
*VendorGuid
,
848 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
852 Update the variable region with Variable information.
854 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
855 input of the variable.
857 @retval EFI_SUCCESS The update operation is success.
858 @retval EFI_INVALID_PARAMETER Invalid parameter.
859 @retval EFI_WRITE_PROTECTED Variable is write-protected.
860 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
865 VariableExLibUpdateVariable (
866 IN AUTH_VARIABLE_INFO
*AuthVariableInfo
872 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
873 the maximum supported buffer size, this value contains
874 the maximum supported buffer size as output.
875 @param[out] ScratchBuffer Pointer to scratch buffer address.
877 @retval EFI_SUCCESS Get scratch buffer successfully.
878 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
883 VariableExLibGetScratchBuffer (
884 IN OUT UINTN
*ScratchBufferSize
,
885 OUT VOID
**ScratchBuffer
889 This function is to check if the remaining variable space is enough to set
890 all Variables from argument list successfully. The purpose of the check
891 is to keep the consistency of the Variables to be in variable storage.
893 Note: Variables are assumed to be in same storage.
894 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
895 so follow the argument sequence to check the Variables.
897 @param[in] Attributes Variable attributes for Variable entries.
898 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
899 A NULL terminates the list. The VariableSize of
900 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
901 It will be changed to variable total size as output.
903 @retval TRUE Have enough variable space to set the Variables successfully.
904 @retval FALSE No enough variable space to set the Variables successfully.
909 VariableExLibCheckRemainingSpaceForConsistency (
910 IN UINT32 Attributes
,
915 Return TRUE if at OS runtime.
917 @retval TRUE If at OS runtime.
918 @retval FALSE If at boot time.
923 VariableExLibAtRuntime (