TianoCore EDK2 master
|
#include "Variable.h"
#include "VariableNonVolatile.h"
#include "VariableParsing.h"
#include "VariableRuntimeCache.h"
Go to the source code of this file.
Functions | |
EFI_STATUS | UpdateVariableStore (IN VARIABLE_GLOBAL *Global, IN BOOLEAN Volatile, IN BOOLEAN SetByIndex, IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, IN UINTN DataPtrIndex, IN UINT32 DataSize, IN UINT8 *Buffer) |
VOID | RecordVarErrorFlag (IN VAR_ERROR_FLAG Flag, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN VariableSize) |
VOID | InitializeVarErrorFlag (VOID) |
BOOLEAN | IsUserVariable (IN VARIABLE_HEADER *Variable) |
VOID | CalculateCommonUserVariableTotalSize (VOID) |
VOID | InitializeVariableQuota (VOID) |
EFI_STATUS | Reclaim (IN EFI_PHYSICAL_ADDRESS VariableBase, OUT UINTN *LastVariableOffset, IN BOOLEAN IsVolatile, IN OUT VARIABLE_POINTER_TRACK *UpdatingPtrTrack, IN VARIABLE_HEADER *NewVariable, IN UINTN NewVariableSize) |
EFI_STATUS | FindVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT VARIABLE_POINTER_TRACK *PtrTrack, IN VARIABLE_GLOBAL *Global, IN BOOLEAN IgnoreRtCheck) |
UINTN | GetIndexFromSupportedLangCodes (IN CHAR8 *SupportedLang, IN CHAR8 *Lang, IN BOOLEAN Iso639Language) |
CHAR8 * | GetLangFromSupportedLangCodes (IN CHAR8 *SupportedLang, IN UINTN Index, IN BOOLEAN Iso639Language) |
CHAR8 *EFIAPI | VariableGetBestLanguage (IN CONST CHAR8 *SupportedLanguages, IN UINTN Iso639Language,...) |
BOOLEAN EFIAPI | CheckRemainingSpaceForConsistencyInternal (IN UINT32 Attributes, IN VA_LIST Marker) |
BOOLEAN EFIAPI | CheckRemainingSpaceForConsistency (IN UINT32 Attributes,...) |
EFI_STATUS | AutoUpdateLangVariable (IN CHAR16 *VariableName, IN VOID *Data, IN UINTN DataSize) |
EFI_STATUS | UpdateVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes OPTIONAL, IN UINT32 KeyIndex OPTIONAL, IN UINT64 MonotonicCount OPTIONAL, IN OUT VARIABLE_POINTER_TRACK *CacheVariable, IN EFI_TIME *TimeStamp OPTIONAL) |
EFI_STATUS EFIAPI | VariableServiceGetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data OPTIONAL) |
EFI_STATUS EFIAPI | VariableServiceGetNextVariableName (IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid) |
EFI_STATUS EFIAPI | VariableServiceSetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data) |
EFI_STATUS EFIAPI | VariableServiceQueryVariableInfoInternal (IN UINT32 Attributes, OUT UINT64 *MaximumVariableStorageSize, OUT UINT64 *RemainingVariableStorageSize, OUT UINT64 *MaximumVariableSize) |
EFI_STATUS EFIAPI | VariableServiceQueryVariableInfo (IN UINT32 Attributes, OUT UINT64 *MaximumVariableStorageSize, OUT UINT64 *RemainingVariableStorageSize, OUT UINT64 *MaximumVariableSize) |
VOID | ReclaimForOS (VOID) |
UINTN | GetMaxVariableSize (VOID) |
VOID | FlushHobVariableToFlash (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid) |
EFI_STATUS | VariableWriteServiceInitialize (VOID) |
VOID * | ConvertNormalVarStorageToAuthVarStorage (VARIABLE_STORE_HEADER *NormalVarStorage) |
EFI_STATUS | GetHobVariableStore (IN EFI_GUID *VariableGuid) |
EFI_STATUS | VariableCommonInitialize (VOID) |
EFI_STATUS | GetFvbInfoByAddress (IN EFI_PHYSICAL_ADDRESS Address, OUT EFI_HANDLE *FvbHandle OPTIONAL, OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL) |
Variables | |
VARIABLE_MODULE_GLOBAL * | mVariableModuleGlobal |
VARIABLE_STORE_HEADER * | mNvVariableCache = NULL |
EFI_FIRMWARE_VOLUME_HEADER * | mNvFvHeaderCache = NULL |
VARIABLE_INFO_ENTRY * | gVariableInfo = NULL |
BOOLEAN | mEndOfDxe = FALSE |
VAR_CHECK_REQUEST_SOURCE | mRequestSource = VarCheckFromUntrusted |
VAR_ERROR_FLAG | mCurrentBootVarErrFlag = VAR_ERROR_FLAG_NO_ERROR |
VARIABLE_ENTRY_PROPERTY | mVariableEntryProperty [] |
AUTH_VAR_LIB_CONTEXT_IN | mAuthContextIn |
AUTH_VAR_LIB_CONTEXT_OUT | mAuthContextOut |
The common variable operation routines shared by DXE_RUNTIME variable module and DXE_SMM variable module.
Caution: This module requires additional review when modified. This driver will have external input - variable data. They may be input in SMM mode. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.
VariableServiceGetNextVariableName () and VariableServiceQueryVariableInfo() are external API. They need check input parameter.
VariableServiceGetVariable() and VariableServiceSetVariable() are external API to receive datasize and data buffer. The size should be checked carefully.
VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow, integer overflow. It should also check attribute to avoid authentication bypass.
Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
Copyright (c) Microsoft Corporation.
Copyright (c) 2022, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Variable.c.
EFI_STATUS AutoUpdateLangVariable | ( | IN CHAR16 * | VariableName, |
IN VOID * | Data, | ||
IN UINTN | DataSize | ||
) |
Hook the operations in PlatformLangCodes, LangCodes, PlatformLang and Lang.
When setting Lang/LangCodes, simultaneously update PlatformLang/PlatformLangCodes.
According to UEFI spec, PlatformLangCodes/LangCodes are only set once in firmware initialization, and are read-only. Therefore, in variable driver, only store the original value for other use.
[in] | VariableName | Name of variable. |
[in] | Data | Variable data. |
[in] | DataSize | Size of data. 0 means delete. |
EFI_SUCCESS | The update operation is successful or ignored. |
EFI_WRITE_PROTECTED | Update PlatformLangCodes/LangCodes at runtime. |
EFI_OUT_OF_RESOURCES | No enough variable space to do the update operation. |
Others | Other errors happened during the update operation. |
Definition at line 1415 of file Variable.c.
VOID CalculateCommonUserVariableTotalSize | ( | VOID | ) |
Calculate common user variable total size.
Definition at line 445 of file Variable.c.
BOOLEAN EFIAPI CheckRemainingSpaceForConsistency | ( | IN UINT32 | Attributes, |
... | |||
) |
This function is to check if the remaining variable space is enough to set all Variables from argument list successfully. The purpose of the check is to keep the consistency of the Variables to be in variable storage.
Note: Variables are assumed to be in same storage. The set sequence of Variables will be same with the sequence of VariableEntry from argument list, so follow the argument sequence to check the Variables.
[in] | Attributes | Variable attributes for Variable entries. |
... | The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *. A NULL terminates the list. The VariableSize of VARIABLE_ENTRY_CONSISTENCY is the variable data size as input. It will be changed to variable total size as output. |
TRUE | Have enough variable space to set the Variables successfully. |
FALSE | No enough variable space to set the Variables successfully. |
Definition at line 1377 of file Variable.c.
BOOLEAN EFIAPI CheckRemainingSpaceForConsistencyInternal | ( | IN UINT32 | Attributes, |
IN VA_LIST | Marker | ||
) |
This function is to check if the remaining variable space is enough to set all Variables from argument list successfully. The purpose of the check is to keep the consistency of the Variables to be in variable storage.
Note: Variables are assumed to be in same storage. The set sequence of Variables will be same with the sequence of VariableEntry from argument list, so follow the argument sequence to check the Variables.
[in] | Attributes | Variable attributes for Variable entries. |
[in] | Marker | VA_LIST style variable argument list. The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *. A NULL terminates the list. The VariableSize of VARIABLE_ENTRY_CONSISTENCY is the variable data size as input. It will be changed to variable total size as output. |
TRUE | Have enough variable space to set the Variables successfully. |
FALSE | No enough variable space to set the Variables successfully. |
Definition at line 1240 of file Variable.c.
VOID * ConvertNormalVarStorageToAuthVarStorage | ( | VARIABLE_STORE_HEADER * | NormalVarStorage | ) |
Convert normal variable storage to the allocated auth variable storage.
[in] | NormalVarStorage | Pointer to the normal variable storage header |
the | allocated auth variable storage |
Definition at line 3512 of file Variable.c.
EFI_STATUS FindVariable | ( | IN CHAR16 * | VariableName, |
IN EFI_GUID * | VendorGuid, | ||
OUT VARIABLE_POINTER_TRACK * | PtrTrack, | ||
IN VARIABLE_GLOBAL * | Global, | ||
IN BOOLEAN | IgnoreRtCheck | ||
) |
Finds variable in storage blocks of volatile and non-volatile storage areas.
This code finds variable in storage blocks of volatile and non-volatile storage areas. If VariableName is an empty string, then we just return the first qualified variable without comparing VariableName and VendorGuid. If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check at runtime when searching existing variable, only VariableName and VendorGuid are compared. Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
[in] | VariableName | Name of the variable to be found. |
[in] | VendorGuid | Vendor GUID to be found. |
[out] | PtrTrack | VARIABLE_POINTER_TRACK structure for output, including the range searched and the target position. |
[in] | Global | Pointer to VARIABLE_GLOBAL structure, including base of volatile variable storage area, base of NV variable storage area, and a lock. |
[in] | IgnoreRtCheck | Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute check at runtime when searching variable. |
EFI_INVALID_PARAMETER | If VariableName is not an empty string, while VendorGuid is NULL. |
EFI_SUCCESS | Variable successfully found. |
EFI_NOT_FOUND | Variable not found |
Definition at line 851 of file Variable.c.
Flush the HOB variable to flash.
[in] | VariableName | Name of variable has been updated or deleted. |
[in] | VendorGuid | Guid of variable has been updated or deleted. |
Definition at line 3283 of file Variable.c.
EFI_STATUS GetFvbInfoByAddress | ( | IN EFI_PHYSICAL_ADDRESS | Address, |
OUT EFI_HANDLE *FvbHandle | OPTIONAL, | ||
OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol | OPTIONAL | ||
) |
Get the proper fvb handle and/or fvb protocol by the given Flash address.
[in] | Address | The Flash address. |
[out] | FvbHandle | In output, if it is not NULL, it points to the proper FVB handle. |
[out] | FvbProtocol | In output, if it is not NULL, it points to the proper FVB protocol. |
Definition at line 3811 of file Variable.c.
EFI_STATUS GetHobVariableStore | ( | IN EFI_GUID * | VariableGuid | ) |
Get HOB variable store.
[in] | VariableGuid | NV variable store signature. |
EFI_SUCCESS | Function successfully executed. |
EFI_OUT_OF_RESOURCES | Fail to allocate enough memory resource. |
Definition at line 3621 of file Variable.c.
UINTN GetIndexFromSupportedLangCodes | ( | IN CHAR8 * | SupportedLang, |
IN CHAR8 * | Lang, | ||
IN BOOLEAN | Iso639Language | ||
) |
Get index from supported language codes according to language string.
This code is used to get corresponding index in supported language codes. It can handle RFC4646 and ISO639 language tags. In ISO639 language tags, take 3-characters as a delimitation to find matched string and calculate the index. In RFC4646 language tags, take semicolon as a delimitation to find matched string and calculate the index.
For example: SupportedLang = "engfraengfra" Lang = "eng" Iso639Language = TRUE The return value is "0". Another example: SupportedLang = "en;fr;en-US;fr-FR" Lang = "fr-FR" Iso639Language = FALSE The return value is "3".
SupportedLang | Platform supported language codes. |
Lang | Configured language. |
Iso639Language | A bool value to signify if the handler is operated on ISO639 or RFC4646. |
The | index of language in the language codes. |
Definition at line 930 of file Variable.c.
CHAR8 * GetLangFromSupportedLangCodes | ( | IN CHAR8 * | SupportedLang, |
IN UINTN | Index, | ||
IN BOOLEAN | Iso639Language | ||
) |
Get language string from supported language codes according to index.
This code is used to get corresponding language strings in supported language codes. It can handle RFC4646 and ISO639 language tags. In ISO639 language tags, take 3-characters as a delimitation. Find language string according to the index. In RFC4646 language tags, take semicolon as a delimitation. Find language string according to the index.
For example: SupportedLang = "engfraengfra" Index = "1" Iso639Language = TRUE The return value is "fra". Another example: SupportedLang = "en;fr;en-US;fr-FR" Index = "1" Iso639Language = FALSE The return value is "fr".
SupportedLang | Platform supported language codes. |
Index | The index in supported language codes. |
Iso639Language | A bool value to signify if the handler is operated on ISO639 or RFC4646. |
The | language string in the language codes. |
Definition at line 1017 of file Variable.c.
UINTN GetMaxVariableSize | ( | VOID | ) |
Get maximum variable size, covering both non-volatile and volatile variables.
Definition at line 3257 of file Variable.c.
VOID InitializeVarErrorFlag | ( | VOID | ) |
Initialize variable error flag.
Before EndOfDxe, the variable indicates the last boot variable error flag, then it means the last boot variable error flag must be got before EndOfDxe. After EndOfDxe, the variable indicates the current boot variable error flag, then it means the current boot variable error flag must be got after EndOfDxe.
Definition at line 362 of file Variable.c.
VOID InitializeVariableQuota | ( | VOID | ) |
Initialize variable quota.
Definition at line 488 of file Variable.c.
BOOLEAN IsUserVariable | ( | IN VARIABLE_HEADER * | Variable | ) |
Is user variable?
[in] | Variable | Pointer to variable header. |
TRUE | User variable. |
FALSE | System variable. |
Definition at line 415 of file Variable.c.
EFI_STATUS Reclaim | ( | IN EFI_PHYSICAL_ADDRESS | VariableBase, |
OUT UINTN * | LastVariableOffset, | ||
IN BOOLEAN | IsVolatile, | ||
IN OUT VARIABLE_POINTER_TRACK * | UpdatingPtrTrack, | ||
IN VARIABLE_HEADER * | NewVariable, | ||
IN UINTN | NewVariableSize | ||
) |
Variable store garbage collection and reclaim operation.
[in] | VariableBase | Base address of variable store. |
[out] | LastVariableOffset | Offset of last variable. |
[in] | IsVolatile | The variable store is volatile or not; if it is non-volatile, need FTW. |
[in,out] | UpdatingPtrTrack | Pointer to updating variable pointer track structure. |
[in] | NewVariable | Pointer to new variable. |
[in] | NewVariableSize | New variable size. |
Definition at line 518 of file Variable.c.
VOID ReclaimForOS | ( | VOID | ) |
This function reclaims variable storage if free size is below the threshold.
Caution: This function may be invoked at SMM mode. Care must be taken to make sure not security issue.
Definition at line 3202 of file Variable.c.
VOID RecordVarErrorFlag | ( | IN VAR_ERROR_FLAG | Flag, |
IN CHAR16 * | VariableName, | ||
IN EFI_GUID * | VendorGuid, | ||
IN UINT32 | Attributes, | ||
IN UINTN | VariableSize | ||
) |
Record variable error flag.
[in] | Flag | Variable error flag to record. |
[in] | VariableName | Name of variable. |
[in] | VendorGuid | Guid of variable. |
[in] | Attributes | Attributes of the variable. |
[in] | VariableSize | Size of the variable. |
Definition at line 272 of file Variable.c.
EFI_STATUS UpdateVariable | ( | IN CHAR16 * | VariableName, |
IN EFI_GUID * | VendorGuid, | ||
IN VOID * | Data, | ||
IN UINTN | DataSize, | ||
IN UINT32 Attributes | OPTIONAL, | ||
IN UINT32 KeyIndex | OPTIONAL, | ||
IN UINT64 MonotonicCount | OPTIONAL, | ||
IN OUT VARIABLE_POINTER_TRACK * | CacheVariable, | ||
IN EFI_TIME *TimeStamp | OPTIONAL | ||
) |
Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set, index of associated public key is needed.
[in] | VariableName | Name of variable. |
[in] | VendorGuid | Guid of variable. |
[in] | Data | Variable data. |
[in] | DataSize | Size of data. 0 means delete. |
[in] | Attributes | Attributes of the variable. |
[in] | KeyIndex | Index of associated public key. |
[in] | MonotonicCount | Value of associated monotonic count. |
[in,out] | CacheVariable | The variable information which is used to keep track of variable usage. |
[in] | TimeStamp | Value of associated TimeStamp. |
EFI_SUCCESS | The update operation is success. |
EFI_OUT_OF_RESOURCES | Variable region is full, can not write other data into this region. |
Definition at line 1678 of file Variable.c.
EFI_STATUS UpdateVariableStore | ( | IN VARIABLE_GLOBAL * | Global, |
IN BOOLEAN | Volatile, | ||
IN BOOLEAN | SetByIndex, | ||
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | Fvb, | ||
IN UINTN | DataPtrIndex, | ||
IN UINT32 | DataSize, | ||
IN UINT8 * | Buffer | ||
) |
This function writes data to the FWH at the correct LBA even if the LBAs are fragmented.
Global | Pointer to VARAIBLE_GLOBAL structure. |
Volatile | Point out the Variable is Volatile or Non-Volatile. |
SetByIndex | TRUE if target pointer is given as index. FALSE if target pointer is absolute. |
Fvb | Pointer to the writable FVB protocol. |
DataPtrIndex | Pointer to the Data from the end of VARIABLE_STORE_HEADER structure. |
DataSize | Size of data to be written. |
Buffer | Pointer to the buffer from which data is written. |
EFI_INVALID_PARAMETER | Parameters not valid. |
EFI_UNSUPPORTED | Fvb is a NULL for Non-Volatile variable update. |
EFI_OUT_OF_RESOURCES | The remaining size is not enough. |
EFI_SUCCESS | Variable store successfully updated. |
Definition at line 123 of file Variable.c.
EFI_STATUS VariableCommonInitialize | ( | VOID | ) |
Initializes variable store area for non-volatile and volatile variable.
EFI_SUCCESS | Function successfully executed. |
EFI_OUT_OF_RESOURCES | Fail to allocate enough memory resource. |
Definition at line 3703 of file Variable.c.
CHAR8 *EFIAPI VariableGetBestLanguage | ( | IN CONST CHAR8 * | SupportedLanguages, |
IN UINTN | Iso639Language, | ||
... | |||
) |
Returns a pointer to an allocated buffer that contains the best matching language from a set of supported languages.
This function supports both ISO 639-2 and RFC 4646 language codes, but language code types may not be mixed in a single call to this function. This function supports a variable argument list that allows the caller to pass in a prioritized list of language codes to test against all the language codes in SupportedLanguages.
If SupportedLanguages is NULL, then ASSERT().
[in] | SupportedLanguages | A pointer to a Null-terminated ASCII string that contains a set of language codes in the format specified by Iso639Language. |
[in] | Iso639Language | If not zero, then all language codes are assumed to be in ISO 639-2 format. If zero, then all language codes are assumed to be in RFC 4646 language format |
[in] | ... | A variable argument list that contains pointers to Null-terminated ASCII strings that contain one or more language codes in the format specified by Iso639Language. The first language code from each of these language code lists is used to determine if it is an exact or close match to any of the language codes in SupportedLanguages. Close matches only apply to RFC 4646 language codes, and the matching algorithm from RFC 4647 is used to determine if a close match is present. If an exact or close match is found, then the matching language code from SupportedLanguages is returned. If no matches are found, then the next variable argument parameter is evaluated. The variable argument list is terminated by a NULL. |
NULL | The best matching language could not be found in SupportedLanguages. |
NULL | There are not enough resources available to return the best matching language. |
Other | A pointer to a Null-terminated ASCII string that is the best matching language in SupportedLanguages. |
Definition at line 1118 of file Variable.c.
EFI_STATUS EFIAPI VariableServiceGetNextVariableName | ( | IN OUT UINTN * | VariableNameSize, |
IN OUT CHAR16 * | VariableName, | ||
IN OUT EFI_GUID * | VendorGuid | ||
) |
This code Finds the Next available variable.
Caution: This function may receive untrusted input. This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
VariableNameSize | The size of the VariableName buffer. The size must be large enough to fit input string supplied in VariableName buffer. |
VariableName | Pointer to variable name. |
VendorGuid | Variable Vendor Guid. |
EFI_SUCCESS | The function completed successfully. |
EFI_NOT_FOUND | The next variable was not found. |
EFI_BUFFER_TOO_SMALL | The VariableNameSize is too small for the result. VariableNameSize has been updated with the size needed to complete the request. |
EFI_INVALID_PARAMETER | VariableNameSize is NULL. |
EFI_INVALID_PARAMETER | VariableName is NULL. |
EFI_INVALID_PARAMETER | VendorGuid is NULL. |
EFI_INVALID_PARAMETER | The input values of VariableName and VendorGuid are not a name and GUID of an existing variable. |
EFI_INVALID_PARAMETER | Null-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer. |
EFI_DEVICE_ERROR | The variable could not be retrieved due to a hardware error. |
EFI_UNSUPPORTED | After ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table. |
Definition at line 2502 of file Variable.c.
EFI_STATUS EFIAPI VariableServiceGetVariable | ( | IN CHAR16 * | VariableName, |
IN EFI_GUID * | VendorGuid, | ||
OUT UINT32 *Attributes | OPTIONAL, | ||
IN OUT UINTN * | DataSize, | ||
OUT VOID *Data | OPTIONAL | ||
) |
This code finds variable in storage blocks (Volatile or Non-Volatile).
Caution: This function may receive untrusted input. This function may be invoked in SMM mode, and datasize is external input. This function will do basic validation, before parse the data.
VariableName | Name of Variable to be found. |
VendorGuid | Variable vendor GUID. |
Attributes | Attribute value of the variable found. |
DataSize | Size of Data found. If size is less than the data, this value contains the required size. |
Data | The buffer to return the contents of the variable. May be NULL with a zero DataSize in order to determine the size buffer needed. |
EFI_SUCCESS | The function completed successfully. |
EFI_NOT_FOUND | The variable was not found. |
EFI_BUFFER_TOO_SMALL | The DataSize is too small for the result. |
EFI_INVALID_PARAMETER | VariableName is NULL. |
EFI_INVALID_PARAMETER | VendorGuid is NULL. |
EFI_INVALID_PARAMETER | DataSize is NULL. |
EFI_INVALID_PARAMETER | The DataSize is not too small and Data is NULL. |
EFI_DEVICE_ERROR | The variable could not be retrieved due to a hardware error. |
EFI_SECURITY_VIOLATION | The variable could not be retrieved due to an authentication failure. |
EFI_UNSUPPORTED | After ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table. |
Definition at line 2407 of file Variable.c.
EFI_STATUS EFIAPI VariableServiceQueryVariableInfo | ( | IN UINT32 | Attributes, |
OUT UINT64 * | MaximumVariableStorageSize, | ||
OUT UINT64 * | RemainingVariableStorageSize, | ||
OUT UINT64 * | MaximumVariableSize | ||
) |
This code returns information about the EFI variables.
Caution: This function may receive untrusted input. This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
Attributes | Attributes bitmask to specify the type of variables on which to return information. |
MaximumVariableStorageSize | Pointer to the maximum size of the storage space available for the EFI variables associated with the attributes specified. |
RemainingVariableStorageSize | Pointer to the remaining size of the storage space available for EFI variables associated with the attributes specified. |
MaximumVariableSize | Pointer to the maximum size of an individual EFI variables associated with the attributes specified. |
Definition at line 3120 of file Variable.c.
EFI_STATUS EFIAPI VariableServiceQueryVariableInfoInternal | ( | IN UINT32 | Attributes, |
OUT UINT64 * | MaximumVariableStorageSize, | ||
OUT UINT64 * | RemainingVariableStorageSize, | ||
OUT UINT64 * | MaximumVariableSize | ||
) |
This code returns information about the EFI variables.
Caution: This function may receive untrusted input. This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
Attributes | Attributes bitmask to specify the type of variables on which to return information. |
MaximumVariableStorageSize | Pointer to the maximum size of the storage space available for the EFI variables associated with the attributes specified. |
RemainingVariableStorageSize | Pointer to the remaining size of the storage space available for EFI variables associated with the attributes specified. |
MaximumVariableSize | Pointer to the maximum size of an individual EFI variables associated with the attributes specified. |
Definition at line 2940 of file Variable.c.
EFI_STATUS EFIAPI VariableServiceSetVariable | ( | IN CHAR16 * | VariableName, |
IN EFI_GUID * | VendorGuid, | ||
IN UINT32 | Attributes, | ||
IN UINTN | DataSize, | ||
IN VOID * | Data | ||
) |
This code sets variable in storage blocks (Volatile or Non-Volatile).
Caution: This function may receive untrusted input. This function may be invoked in SMM mode, and datasize and data are external input. This function will do basic validation, before parse the data. This function will parse the authentication carefully to avoid security issues, like buffer overflow, integer overflow. This function will check attribute carefully to avoid authentication bypass.
VariableName | Name of Variable to be found. |
VendorGuid | Variable vendor GUID. |
Attributes | Attribute value of the variable found |
DataSize | Size of Data found. If size is less than the data, this value contains the required size. |
Data | Data pointer. |
EFI_SUCCESS | The function completed successfully. |
EFI_NOT_FOUND | The variable was not found. |
EFI_BUFFER_TOO_SMALL | The DataSize is too small for the result. |
EFI_INVALID_PARAMETER | VariableName is NULL. |
EFI_INVALID_PARAMETER | VendorGuid is NULL. |
EFI_INVALID_PARAMETER | DataSize is NULL. |
EFI_INVALID_PARAMETER | The DataSize is not too small and Data is NULL. |
EFI_DEVICE_ERROR | The variable could not be retrieved due to a hardware error. |
EFI_SECURITY_VIOLATION | The variable could not be retrieved due to an authentication failure. |
EFI_UNSUPPORTED | After ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table. |
Definition at line 2612 of file Variable.c.
EFI_STATUS VariableWriteServiceInitialize | ( | VOID | ) |
Initializes variable write service.
EFI_SUCCESS | Function successfully executed. |
Others | Fail to initialize the variable service. |
Definition at line 3415 of file Variable.c.
VARIABLE_INFO_ENTRY* gVariableInfo = NULL |
The memory entry used for variable statistics data.
Definition at line 49 of file Variable.c.
AUTH_VAR_LIB_CONTEXT_IN mAuthContextIn |
Definition at line 81 of file Variable.c.
AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut |
Definition at line 99 of file Variable.c.
VAR_ERROR_FLAG mCurrentBootVarErrFlag = VAR_ERROR_FLAG_NO_ERROR |
Definition at line 65 of file Variable.c.
BOOLEAN mEndOfDxe = FALSE |
The flag to indicate whether the platform has left the DXE phase of execution.
Definition at line 54 of file Variable.c.
EFI_FIRMWARE_VOLUME_HEADER* mNvFvHeaderCache = NULL |
Memory cache of Fv Header.
Definition at line 44 of file Variable.c.
VARIABLE_STORE_HEADER* mNvVariableCache = NULL |
Define a memory cache that improves the search performance for a variable. For EmuNvMode == TRUE, it will be equal to NonVolatileVariableBase.
Definition at line 39 of file Variable.c.
VAR_CHECK_REQUEST_SOURCE mRequestSource = VarCheckFromUntrusted |
It indicates the var check request source. In the implementation, DXE is regarded as untrusted, and SMM is trusted.
Definition at line 60 of file Variable.c.
VARIABLE_ENTRY_PROPERTY mVariableEntryProperty[] |
Definition at line 67 of file Variable.c.
VARIABLE_MODULE_GLOBAL* mVariableModuleGlobal |
Definition at line 33 of file Variable.c.