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 ScratchBufferSize
;
105 CHAR8
*PlatformLangCodes
;
108 CHAR8 Lang
[ISO_639_2_ENTRY_SIZE
+ 1];
109 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbInstance
;
110 } VARIABLE_MODULE_GLOBAL
;
113 Flush the HOB variable to flash.
115 @param[in] VariableName Name of variable has been updated or deleted.
116 @param[in] VendorGuid Guid of variable has been updated or deleted.
120 FlushHobVariableToFlash (
121 IN CHAR16
*VariableName
,
122 IN EFI_GUID
*VendorGuid
126 Writes a buffer to variable storage space, in the working block.
128 This function writes a buffer to variable storage space into a firmware
129 volume block device. The destination is specified by the parameter
130 VariableBase. Fault Tolerant Write protocol is used for writing.
132 @param VariableBase Base address of the variable to write.
133 @param VariableBuffer Point to the variable data buffer.
135 @retval EFI_SUCCESS The function completed successfully.
136 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
137 @retval EFI_ABORTED The function could not complete successfully.
142 IN EFI_PHYSICAL_ADDRESS VariableBase
,
143 IN VARIABLE_STORE_HEADER
*VariableBuffer
147 Finds variable in storage blocks of volatile and non-volatile storage areas.
149 This code finds variable in storage blocks of volatile and non-volatile storage areas.
150 If VariableName is an empty string, then we just return the first
151 qualified variable without comparing VariableName and VendorGuid.
152 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check
153 at runtime when searching existing variable, only VariableName and VendorGuid are compared.
154 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
156 @param[in] VariableName Name of the variable to be found.
157 @param[in] VendorGuid Vendor GUID to be found.
158 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,
159 including the range searched and the target position.
160 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including
161 base of volatile variable storage area, base of
162 NV variable storage area, and a lock.
163 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
164 check at runtime when searching variable.
166 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while
168 @retval EFI_SUCCESS Variable successfully found.
169 @retval EFI_NOT_FOUND Variable not found
174 IN CHAR16
*VariableName
,
175 IN EFI_GUID
*VendorGuid
,
176 OUT VARIABLE_POINTER_TRACK
*PtrTrack
,
177 IN VARIABLE_GLOBAL
*Global
,
178 IN BOOLEAN IgnoreRtCheck
183 Gets the pointer to the end of the variable storage area.
185 This function gets pointer to the end of the variable storage
186 area, according to the input variable store header.
188 @param VarStoreHeader Pointer to the Variable Store Header.
190 @return Pointer to the end of the variable storage area.
195 IN VARIABLE_STORE_HEADER
*VarStoreHeader
199 This code gets the size of variable header.
201 @return Size of variable header in bytes in type UINTN.
205 GetVariableHeaderSize (
211 This code gets the pointer to the variable name.
213 @param Variable Pointer to the Variable Header.
215 @return Pointer to Variable Name which is Unicode encoding.
220 IN VARIABLE_HEADER
*Variable
224 This code gets the pointer to the variable guid.
226 @param Variable Pointer to the Variable Header.
228 @return A EFI_GUID* pointer to Vendor Guid.
233 IN VARIABLE_HEADER
*Variable
238 This code gets the pointer to the variable data.
240 @param Variable Pointer to the Variable Header.
242 @return Pointer to Variable Data.
247 IN VARIABLE_HEADER
*Variable
252 This code gets the size of variable data.
254 @param Variable Pointer to the Variable Header.
256 @return Size of variable in bytes.
261 IN VARIABLE_HEADER
*Variable
265 This function is to check if the remaining variable space is enough to set
266 all Variables from argument list successfully. The purpose of the check
267 is to keep the consistency of the Variables to be in variable storage.
269 Note: Variables are assumed to be in same storage.
270 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
271 so follow the argument sequence to check the Variables.
273 @param[in] Attributes Variable attributes for Variable entries.
274 @param[in] Marker VA_LIST style variable argument list.
275 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
276 A NULL terminates the list. The VariableSize of
277 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
278 It will be changed to variable total size as output.
280 @retval TRUE Have enough variable space to set the Variables successfully.
281 @retval FALSE No enough variable space to set the Variables successfully.
286 CheckRemainingSpaceForConsistencyInternal (
287 IN UINT32 Attributes
,
292 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
293 index of associated public key is needed.
295 @param[in] VariableName Name of variable.
296 @param[in] VendorGuid Guid of variable.
297 @param[in] Data Variable data.
298 @param[in] DataSize Size of data. 0 means delete.
299 @param[in] Attributes Attributes of the variable.
300 @param[in] KeyIndex Index of associated public key.
301 @param[in] MonotonicCount Value of associated monotonic count.
302 @param[in, out] Variable The variable information that is used to keep track of variable usage.
304 @param[in] TimeStamp Value of associated TimeStamp.
306 @retval EFI_SUCCESS The update operation is success.
307 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
312 IN CHAR16
*VariableName
,
313 IN EFI_GUID
*VendorGuid
,
316 IN UINT32 Attributes OPTIONAL
,
317 IN UINT32 KeyIndex OPTIONAL
,
318 IN UINT64 MonotonicCount OPTIONAL
,
319 IN OUT VARIABLE_POINTER_TRACK
*Variable
,
320 IN EFI_TIME
*TimeStamp OPTIONAL
325 Return TRUE if ExitBootServices () has been called.
327 @retval TRUE If ExitBootServices () has been called.
335 Initializes a basic mutual exclusion lock.
337 This function initializes a basic mutual exclusion lock to the released state
338 and returns the lock. Each lock provides mutual exclusion access at its task
339 priority level. Since there is no preemption or multiprocessor support in EFI,
340 acquiring the lock only consists of raising to the locks TPL.
341 If Lock is NULL, then ASSERT().
342 If Priority is not a valid TPL value, then ASSERT().
344 @param Lock A pointer to the lock data structure to initialize.
345 @param Priority EFI TPL is associated with the lock.
352 IN OUT EFI_LOCK
*Lock
,
358 Acquires lock only at boot time. Simply returns at runtime.
360 This is a temperary function that will be removed when
361 EfiAcquireLock() in UefiLib can handle the call in UEFI
362 Runtimer driver in RT phase.
363 It calls EfiAcquireLock() at boot time, and simply returns
366 @param Lock A pointer to the lock to acquire.
370 AcquireLockOnlyAtBootTime (
376 Releases lock only at boot time. Simply returns at runtime.
378 This is a temperary function which will be removed when
379 EfiReleaseLock() in UefiLib can handle the call in UEFI
380 Runtimer driver in RT phase.
381 It calls EfiReleaseLock() at boot time and simply returns
384 @param Lock A pointer to the lock to release.
388 ReleaseLockOnlyAtBootTime (
393 Retrieve the FVB protocol interface by HANDLE.
395 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
396 reading, writing, and erasing the target block.
397 @param[out] FvBlock The interface of FVB protocol
399 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
400 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
401 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
406 IN EFI_HANDLE FvBlockHandle
,
407 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvBlock
411 Function returns an array of handles that support the FVB protocol
412 in a buffer allocated from pool.
414 @param[out] NumberHandles The number of handles returned in Buffer.
415 @param[out] Buffer A pointer to the buffer to return the requested
416 array of handles that support FVB protocol.
418 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
419 handles in Buffer was returned in NumberHandles.
420 @retval EFI_NOT_FOUND No FVB handle was found.
421 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
422 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
426 GetFvbCountAndBuffer (
427 OUT UINTN
*NumberHandles
,
428 OUT EFI_HANDLE
**Buffer
432 Initializes variable store area for non-volatile and volatile variable.
434 @retval EFI_SUCCESS Function successfully executed.
435 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
439 VariableCommonInitialize (
444 This function reclaims variable storage if free size is below the threshold.
453 Get non-volatile maximum variable size.
455 @return Non-volatile maximum variable size.
459 GetNonVolatileMaxVariableSize (
464 Initializes variable write service after FVB was ready.
466 @retval EFI_SUCCESS Function successfully executed.
467 @retval Others Fail to initialize the variable service.
471 VariableWriteServiceInitialize (
476 Retrieve the SMM Fault Tolerent Write protocol interface.
478 @param[out] FtwProtocol The interface of SMM Ftw protocol
480 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
481 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
482 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
487 OUT VOID
**FtwProtocol
491 Get the proper fvb handle and/or fvb protocol by the given Flash address.
493 @param[in] Address The Flash address.
494 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
495 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
499 GetFvbInfoByAddress (
500 IN EFI_PHYSICAL_ADDRESS Address
,
501 OUT EFI_HANDLE
*FvbHandle OPTIONAL
,
502 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
**FvbProtocol OPTIONAL
507 This code finds variable in storage blocks (Volatile or Non-Volatile).
509 Caution: This function may receive untrusted input.
510 This function may be invoked in SMM mode, and datasize and data are external input.
511 This function will do basic validation, before parse the data.
513 @param VariableName Name of Variable to be found.
514 @param VendorGuid Variable vendor GUID.
515 @param Attributes Attribute value of the variable found.
516 @param DataSize Size of Data found. If size is less than the
517 data, this value contains the required size.
518 @param Data The buffer to return the contents of the variable. May be NULL
519 with a zero DataSize in order to determine the size buffer needed.
521 @return EFI_INVALID_PARAMETER Invalid parameter.
522 @return EFI_SUCCESS Find the specified variable.
523 @return EFI_NOT_FOUND Not found.
524 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
529 VariableServiceGetVariable (
530 IN CHAR16
*VariableName
,
531 IN EFI_GUID
*VendorGuid
,
532 OUT UINT32
*Attributes OPTIONAL
,
533 IN OUT UINTN
*DataSize
,
534 OUT VOID
*Data OPTIONAL
538 This code Finds the Next available variable.
540 Caution: This function may receive untrusted input.
541 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
543 @param[in] VariableName Pointer to variable name.
544 @param[in] VendorGuid Variable Vendor Guid.
545 @param[out] VariablePtr Pointer to variable header address.
547 @retval EFI_SUCCESS The function completed successfully.
548 @retval EFI_NOT_FOUND The next variable was not found.
549 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
550 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
551 GUID of an existing variable.
556 VariableServiceGetNextVariableInternal (
557 IN CHAR16
*VariableName
,
558 IN EFI_GUID
*VendorGuid
,
559 OUT VARIABLE_HEADER
**VariablePtr
564 This code Finds the Next available variable.
566 Caution: This function may receive untrusted input.
567 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
569 @param VariableNameSize The size of the VariableName buffer. The size must be large
570 enough to fit input string supplied in VariableName buffer.
571 @param VariableName Pointer to variable name.
572 @param VendorGuid Variable Vendor Guid.
574 @retval EFI_SUCCESS The function completed successfully.
575 @retval EFI_NOT_FOUND The next variable was not found.
576 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
577 VariableNameSize has been updated with the size needed to complete the request.
578 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
579 @retval EFI_INVALID_PARAMETER VariableName is NULL.
580 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
581 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
582 GUID of an existing variable.
583 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
584 the input VariableName buffer.
589 VariableServiceGetNextVariableName (
590 IN OUT UINTN
*VariableNameSize
,
591 IN OUT CHAR16
*VariableName
,
592 IN OUT EFI_GUID
*VendorGuid
597 This code sets variable in storage blocks (Volatile or Non-Volatile).
599 Caution: This function may receive untrusted input.
600 This function may be invoked in SMM mode, and datasize and data are external input.
601 This function will do basic validation, before parse the data.
602 This function will parse the authentication carefully to avoid security issues, like
603 buffer overflow, integer overflow.
604 This function will check attribute carefully to avoid authentication bypass.
606 @param VariableName Name of Variable to be found.
607 @param VendorGuid Variable vendor GUID.
608 @param Attributes Attribute value of the variable found
609 @param DataSize Size of Data found. If size is less than the
610 data, this value contains the required size.
611 @param Data Data pointer.
613 @return EFI_INVALID_PARAMETER Invalid parameter.
614 @return EFI_SUCCESS Set successfully.
615 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
616 @return EFI_NOT_FOUND Not found.
617 @return EFI_WRITE_PROTECTED Variable is read-only.
622 VariableServiceSetVariable (
623 IN CHAR16
*VariableName
,
624 IN EFI_GUID
*VendorGuid
,
625 IN UINT32 Attributes
,
632 This code returns information about the EFI variables.
634 Caution: This function may receive untrusted input.
635 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
637 @param Attributes Attributes bitmask to specify the type of variables
638 on which to return information.
639 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
640 for the EFI variables associated with the attributes specified.
641 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
642 for EFI variables associated with the attributes specified.
643 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
644 associated with the attributes specified.
646 @return EFI_SUCCESS Query successfully.
651 VariableServiceQueryVariableInfoInternal (
652 IN UINT32 Attributes
,
653 OUT UINT64
*MaximumVariableStorageSize
,
654 OUT UINT64
*RemainingVariableStorageSize
,
655 OUT UINT64
*MaximumVariableSize
660 This code returns information about the EFI variables.
662 Caution: This function may receive untrusted input.
663 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
665 @param Attributes Attributes bitmask to specify the type of variables
666 on which to return information.
667 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
668 for the EFI variables associated with the attributes specified.
669 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
670 for EFI variables associated with the attributes specified.
671 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
672 associated with the attributes specified.
674 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
675 @return EFI_SUCCESS Query successfully.
676 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
681 VariableServiceQueryVariableInfo (
682 IN UINT32 Attributes
,
683 OUT UINT64
*MaximumVariableStorageSize
,
684 OUT UINT64
*RemainingVariableStorageSize
,
685 OUT UINT64
*MaximumVariableSize
689 Mark a variable that will become read-only after leaving the DXE phase of execution.
691 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
692 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
693 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
695 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
696 as pending to be read-only.
697 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
698 Or VariableName is an empty string.
699 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
700 already been signaled.
701 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
705 VariableLockRequestToLock (
706 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL
*This
,
707 IN CHAR16
*VariableName
,
708 IN EFI_GUID
*VendorGuid
712 Register SetVariable check handler.
714 @param[in] Handler Pointer to check handler.
716 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
717 @retval EFI_INVALID_PARAMETER Handler is NULL.
718 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
719 already been signaled.
720 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
721 @retval EFI_UNSUPPORTED This interface is not implemented.
722 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
727 VarCheckRegisterSetVariableCheckHandler (
728 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
732 Variable property set.
734 @param[in] Name Pointer to the variable name.
735 @param[in] Guid Pointer to the vendor GUID.
736 @param[in] VariableProperty Pointer to the input variable property.
738 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
739 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
740 or the fields of VariableProperty are not valid.
741 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
742 already been signaled.
743 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
748 VarCheckVariablePropertySet (
751 IN VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
755 Variable property get.
757 @param[in] Name Pointer to the variable name.
758 @param[in] Guid Pointer to the vendor GUID.
759 @param[out] VariableProperty Pointer to the output variable property.
761 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
762 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
763 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
768 VarCheckVariablePropertyGet (
771 OUT VAR_CHECK_VARIABLE_PROPERTY
*VariableProperty
775 Initialize variable quota.
779 InitializeVariableQuota (
783 extern VARIABLE_MODULE_GLOBAL
*mVariableModuleGlobal
;
785 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut
;
788 Finds variable in storage blocks of volatile and non-volatile storage areas.
790 This code finds variable in storage blocks of volatile and non-volatile storage areas.
791 If VariableName is an empty string, then we just return the first
792 qualified variable without comparing VariableName and VendorGuid.
794 @param[in] VariableName Name of the variable to be found.
795 @param[in] VendorGuid Variable vendor GUID to be found.
796 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
797 output of the variable found.
799 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
800 while VendorGuid is NULL.
801 @retval EFI_SUCCESS Variable successfully found.
802 @retval EFI_NOT_FOUND Variable not found
807 VariableExLibFindVariable (
808 IN CHAR16
*VariableName
,
809 IN EFI_GUID
*VendorGuid
,
810 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
814 Finds next variable in storage blocks of volatile and non-volatile storage areas.
816 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
817 If VariableName is an empty string, then we just return the first
818 qualified variable without comparing VariableName and VendorGuid.
820 @param[in] VariableName Name of the variable to be found.
821 @param[in] VendorGuid Variable vendor GUID to be found.
822 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
823 output of the next variable.
825 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
826 while VendorGuid is NULL.
827 @retval EFI_SUCCESS Variable successfully found.
828 @retval EFI_NOT_FOUND Variable not found
833 VariableExLibFindNextVariable (
834 IN CHAR16
*VariableName
,
835 IN EFI_GUID
*VendorGuid
,
836 OUT AUTH_VARIABLE_INFO
*AuthVariableInfo
840 Update the variable region with Variable information.
842 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
843 input of the variable.
845 @retval EFI_SUCCESS The update operation is success.
846 @retval EFI_INVALID_PARAMETER Invalid parameter.
847 @retval EFI_WRITE_PROTECTED Variable is write-protected.
848 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
853 VariableExLibUpdateVariable (
854 IN AUTH_VARIABLE_INFO
*AuthVariableInfo
860 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
861 the maximum supported buffer size, this value contains
862 the maximum supported buffer size as output.
863 @param[out] ScratchBuffer Pointer to scratch buffer address.
865 @retval EFI_SUCCESS Get scratch buffer successfully.
866 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
871 VariableExLibGetScratchBuffer (
872 IN OUT UINTN
*ScratchBufferSize
,
873 OUT VOID
**ScratchBuffer
877 This function is to check if the remaining variable space is enough to set
878 all Variables from argument list successfully. The purpose of the check
879 is to keep the consistency of the Variables to be in variable storage.
881 Note: Variables are assumed to be in same storage.
882 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
883 so follow the argument sequence to check the Variables.
885 @param[in] Attributes Variable attributes for Variable entries.
886 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
887 A NULL terminates the list. The VariableSize of
888 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
889 It will be changed to variable total size as output.
891 @retval TRUE Have enough variable space to set the Variables successfully.
892 @retval FALSE No enough variable space to set the Variables successfully.
897 VariableExLibCheckRemainingSpaceForConsistency (
898 IN UINT32 Attributes
,
903 Return TRUE if at OS runtime.
905 @retval TRUE If at OS runtime.
906 @retval FALSE If at boot time.
911 VariableExLibAtRuntime (