SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c File Reference


Functions

VOID AcquireLockOnlyAtBootTime (IN EFI_LOCK *Lock)
VOID ReleaseLockOnlyAtBootTime (IN EFI_LOCK *Lock)
EFI_STATUS AccessVariableStore (IN BOOLEAN Write, IN VARIABLE_GLOBAL *Global, IN BOOLEAN Volatile, IN UINTN Instance, IN EFI_PHYSICAL_ADDRESS StartAddress, IN UINT32 DataSize, IN OUT VOID *Buffer)
VOID GetVarStoreHeader (IN EFI_PHYSICAL_ADDRESS VarStoreAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance, OUT VARIABLE_STORE_HEADER *VarStoreHeader)
BOOLEAN IsValidVariableHeader (IN EFI_PHYSICAL_ADDRESS VariableAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance, OUT AUTHENTICATED_VARIABLE_HEADER *VariableHeader)
VARIABLE_STORE_STATUS GetVariableStoreStatus (IN VARIABLE_STORE_HEADER *VarStoreHeader)
UINTN NameSizeOfVariable (IN AUTHENTICATED_VARIABLE_HEADER *Variable)
UINTN DataSizeOfVariable (IN AUTHENTICATED_VARIABLE_HEADER *Variable)
VOID GetVariableNamePtr (IN EFI_PHYSICAL_ADDRESS VariableAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance, OUT CHAR16 *VariableName)
VOID GetVariableDataPtr (IN EFI_PHYSICAL_ADDRESS VariableAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance, OUT CHAR16 *VariableData)
EFI_PHYSICAL_ADDRESS GetNextVariablePtr (IN EFI_PHYSICAL_ADDRESS VariableAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance)
EFI_PHYSICAL_ADDRESS GetStartPointer (IN EFI_PHYSICAL_ADDRESS VarStoreHeaderAddress)
EFI_PHYSICAL_ADDRESS GetEndPointer (IN EFI_PHYSICAL_ADDRESS VarStoreHeaderAddress, IN BOOLEAN Volatile, IN VARIABLE_GLOBAL *Global, IN UINTN Instance)
VOID UpdateVariableInfo (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN BOOLEAN Volatile, IN BOOLEAN Read, IN BOOLEAN Write, IN BOOLEAN Delete, IN BOOLEAN Cache)
VOID UpdateVariableCache (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
EFI_STATUS FindVariableInCache (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes, IN OUT UINTN *DataSize, OUT VOID *Data)
EFI_STATUS FindVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT VARIABLE_POINTER_TRACK *PtrTrack, IN VARIABLE_GLOBAL *Global, IN UINTN Instance)
EFI_STATUS Reclaim (IN EFI_PHYSICAL_ADDRESS VariableBase, OUT UINTN *LastVariableOffset, IN BOOLEAN IsVolatile, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global, IN EFI_PHYSICAL_ADDRESS UpdatingVariable)
UINTN GetIndexFromSupportedLangCodes (IN CHAR8 *SupportedLang, IN CHAR8 *Lang, IN BOOLEAN Iso639Language)
CHAR8 * GetLangFromSupportedLangCodes (IN CHAR8 *SupportedLang, IN UINTN Index, IN BOOLEAN Iso639Language, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
CHAR8 * VariableGetBestLanguage (IN CONST CHAR8 *SupportedLanguages, IN BOOLEAN Iso639Language, IN BOOLEAN VirtualMode,...)
VOID AutoUpdateLangVariable (IN CHAR16 *VariableName, IN VOID *Data, IN UINTN DataSize, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
EFI_STATUS EFIAPI UpdateVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes, IN UINT32 KeyIndex, IN UINT64 MonotonicCount, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global, IN VARIABLE_POINTER_TRACK *Variable)
EFI_STATUS EFIAPI EsalGetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes, IN OUT UINTN *DataSize, OUT VOID *Data, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
EFI_STATUS EFIAPI EsalGetNextVariableName (IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
EFI_STATUS EFIAPI EsalSetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
EFI_STATUS EFIAPI EsalQueryVariableInfo (IN UINT32 Attributes, OUT UINT64 *MaximumVariableStorageSize, OUT UINT64 *RemainingVariableStorageSize, OUT UINT64 *MaximumVariableSize, IN BOOLEAN VirtualMode, IN ESAL_VARIABLE_GLOBAL *Global)
VOID EFIAPI ReclaimForOS (IN EFI_EVENT Event, IN VOID *Context)
VOID FlushHob2Nv (VOID)
EFI_STATUS VariableCommonInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)

Variables

ESAL_VARIABLE_GLOBALmVariableModuleGlobal
CHAR16 * mVariableName [NUM_VAR_NAME]
GLOBAL_REMOVE_IF_UNREFERENCED
VARIABLE_INFO_ENTRY * 
gVariableInfo = NULL
VARIABLE_CACHE_ENTRY mVariableCache []

Detailed Description

The implementation of Extended SAL variable services.

Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Function Documentation

EFI_STATUS AccessVariableStore ( IN BOOLEAN  Write,
IN VARIABLE_GLOBAL Global,
IN BOOLEAN  Volatile,
IN UINTN  Instance,
IN EFI_PHYSICAL_ADDRESS  StartAddress,
IN UINT32  DataSize,
IN OUT VOID *  Buffer 
)

Reads/Writes variable storage, volatile or non-volatile.

This function reads or writes volatile or non-volatile variable stroage. For volatile storage, it performs memory copy. For non-volatile storage, it accesses data on firmware storage. Data area to access can span multiple firmware blocks.

Parameters:
[in] Write TRUE - Write variable store. FALSE - Read variable store.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Instance Instance of FV Block services.
[in] StartAddress Start address of data to access.
[in] DataSize Size of data to access.
[in,out] Buffer For write, pointer to the buffer from which data is written. For read, pointer to the buffer to hold the data read.
Return values:
EFI_SUCCESS Variable store successfully accessed.
EFI_INVALID_PARAMETER Data area to access exceeds valid variable storage.

References EFI_STATUS(), and UINTN().

Referenced by AutoUpdateLangVariable(), GetEndPointer(), GetVariableDataPtr(), GetVariableNamePtr(), GetVarStoreHeader(), IsValidVariableHeader(), UpdateVariable(), and VariableCommonInitialize().

VOID AcquireLockOnlyAtBootTime ( IN EFI_LOCK *  Lock  ) 

Acquires lock only at boot time. Simply returns at runtime.

This is a temperary function which will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime.

Parameters:
[in] Lock A pointer to the lock to acquire.

Referenced by EsalGetNextVariableName(), EsalGetVariable(), EsalQueryVariableInfo(), and EsalSetVariable().

VOID AutoUpdateLangVariable ( IN CHAR16 *  VariableName,
IN VOID *  Data,
IN UINTN  DataSize,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

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.

Parameters:
[in] VariableName Name of variable.
[in] Data Variable data.
[in] DataSize Size of data. 0 means delete.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.

References AccessVariableStore(), BOOLEAN(), VARIABLE_POINTER_TRACK::CurrPtr, EFI_STATUS(), FindVariable(), GetEndPointer(), GetIndexFromSupportedLangCodes(), GetLangFromSupportedLangCodes(), GetVariableDataPtr(), ISO_639_2_ENTRY_SIZE, ESAL_VARIABLE_GLOBAL::PlatformLangCodes, TRUE, UINTN(), UpdateVariable(), VAR_LANG, VAR_LANG_CODES, VAR_PLATFORM_LANG, VAR_PLATFORM_LANG_CODES, VariableGetBestLanguage(), VARIABLE_POINTER_TRACK::Volatile, and VARIABLE_GLOBAL::VolatileVariableBase.

Referenced by EsalSetVariable().

UINTN DataSizeOfVariable ( IN AUTHENTICATED_VARIABLE_HEADER *  Variable  ) 

Gets the size of variable data area.

This function gets the size of variable data area. The variable is specified by its variable header. If variable header contains raw data, just return 0.

Parameters:
[in] Variable Pointer to the variable header.
Returns:
Size of variable data area in bytes.

References UINTN().

Referenced by AutenticatedVariableServiceInitialize(), EsalGetVariable(), GetNextVariablePtr(), and UpdateVariable().

EFI_STATUS EFIAPI EsalGetNextVariableName ( IN OUT UINTN *  VariableNameSize,
IN OUT CHAR16 *  VariableName,
IN OUT EFI_GUID *  VendorGuid,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

Implements EsalGetNextVariableName function of Extended SAL Variable Services Class.

This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class. It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().

Parameters:
[in,out] VariableNameSize Size of the variable
[in,out] VariableName On input, supplies the last VariableName that was returned by GetNextVariableName(). On output, returns the Null-terminated Unicode string of the current variable.
[in,out] VendorGuid On input, supplies the last VendorGuid that was returned by GetNextVariableName(). On output, returns the VendorGuid of the current variable.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
Return values:
EFI_SUCCESS The function completed successfully.
EFI_NOT_FOUND The next variable was not found.
EFI_BUFFER_TOO_SMALL 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_DEVICE_ERROR The variable name could not be retrieved due to a hardware error.

References AcquireLockOnlyAtBootTime(), BOOLEAN(), VARIABLE_POINTER_TRACK::CurrPtr, EFI_STATUS(), VARIABLE_POINTER_TRACK::EndPtr, FindVariable(), GetEndPointer(), GetNextVariablePtr(), GetStartPointer(), GetVariableNamePtr(), IsValidVariableHeader(), NameSizeOfVariable(), VARIABLE_GLOBAL::NonVolatileVariableBase, ReleaseLockOnlyAtBootTime(), VARIABLE_POINTER_TRACK::StartPtr, TRUE, UINTN(), VARIABLE_GLOBAL::VariableServicesLock, and VARIABLE_POINTER_TRACK::Volatile.

Referenced by EsalVariableCommonEntry().

EFI_STATUS EFIAPI EsalGetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
OUT UINT32 *  Attributes,
IN OUT UINTN *  DataSize,
OUT VOID *  Data,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

Implements EsalGetVariable function of Extended SAL Variable Services Class.

This function implements EsalGetVariable function of Extended SAL Variable Services Class. It is equivalent in functionality to the EFI Runtime Service GetVariable().

Parameters:
[in] VariableName A Null-terminated Unicode string that is the name of the vendor's variable.
[in] VendorGuid A unique identifier for the vendor.
[out] Attributes If not NULL, a pointer to the memory location to return the attributes bitmask for the variable.
[in,out] DataSize Size of Data found. If size is less than the data, this value contains the required size.
[out] Data On input, the size in bytes of the return Data buffer. On output, the size of data returned in Data.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
Return values:
EFI_SUCCESS The function completed successfully.
EFI_NOT_FOUND The variable was not found.
EFI_BUFFER_TOO_SMALL DataSize is too small for the result. DataSize has been updated with the size needed to complete the request.
EFI_INVALID_PARAMETER VariableName is NULL.
EFI_INVALID_PARAMETER VendorGuid is NULL.
EFI_INVALID_PARAMETER DataSize is NULL.
EFI_INVALID_PARAMETER 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.

References AcquireLockOnlyAtBootTime(), BOOLEAN(), VARIABLE_POINTER_TRACK::CurrPtr, DataSizeOfVariable(), EFI_STATUS(), FindVariable(), FindVariableInCache(), GetVariableDataPtr(), IsValidVariableHeader(), ReleaseLockOnlyAtBootTime(), TRUE, UINTN(), UpdateVariableCache(), UpdateVariableInfo(), VARIABLE_GLOBAL::VariableServicesLock, and VARIABLE_POINTER_TRACK::Volatile.

Referenced by EsalVariableCommonEntry().

EFI_STATUS EFIAPI EsalQueryVariableInfo ( IN UINT32  Attributes,
OUT UINT64 *  MaximumVariableStorageSize,
OUT UINT64 *  RemainingVariableStorageSize,
OUT UINT64 *  MaximumVariableSize,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

Implements EsalQueryVariableInfo function of Extended SAL Variable Services Class.

This function implements EsalQueryVariableInfo function of Extended SAL Variable Services Class. It is equivalent in functionality to the EFI Runtime Service QueryVariableInfo().

Parameters:
[in] Attributes Attributes bitmask to specify the type of variables on which to return information.
[out] MaximumVariableStorageSize On output the maximum size of the storage space available for the EFI variables associated with the attributes specified.
[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI variables associated with the attributes specified.
[out] MaximumVariableSize Returns the maximum size of an individual EFI variable associated with the attributes specified.
[in] VirtualMode Current calling mode for this function
[in] Global Context of this Extended SAL Variable Services Class call
Return values:
EFI_SUCCESS Valid answer returned.
EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
EFI_UNSUPPORTED The attribute is not supported on this platform, and the MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize are undefined.

References AcquireLockOnlyAtBootTime(), BOOLEAN(), GetEndPointer(), GetNextVariablePtr(), GetStartPointer(), GetVarStoreHeader(), IsValidVariableHeader(), VARIABLE_GLOBAL::NonVolatileVariableBase, ReleaseLockOnlyAtBootTime(), TRUE, VARIABLE_GLOBAL::VariableServicesLock, and VARIABLE_GLOBAL::VolatileVariableBase.

Referenced by EsalVariableCommonEntry().

EFI_STATUS EFIAPI EsalSetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
IN UINT32  Attributes,
IN UINTN  DataSize,
IN VOID *  Data,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

Implements EsalSetVariable function of Extended SAL Variable Services Class.

This function implements EsalSetVariable function of Extended SAL Variable Services Class. It is equivalent in functionality to the EFI Runtime Service SetVariable().

Parameters:
[in] VariableName A Null-terminated Unicode string that is the name of the vendor's variable. Each VariableName is unique for each VendorGuid. VariableName must contain 1 or more Unicode characters. If VariableName is an empty Unicode string, then EFI_INVALID_PARAMETER is returned.
[in] VendorGuid A unique identifier for the vendor.
[in] Attributes Attributes bitmask to set for the variable.
[in] DataSize The size in bytes of the Data buffer. A size of zero causes the variable to be deleted.
[in] Data The contents for the variable.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
Return values:
EFI_SUCCESS The firmware has successfully stored the variable and its data as defined by the Attributes.
EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the DataSize exceeds the maximum allowed.
EFI_INVALID_PARAMETER VariableName is an empty Unicode string.
EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.
EFI_WRITE_PROTECTED The variable in question is read-only.
EFI_WRITE_PROTECTED The variable in question cannot be deleted.
EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
EFI_NOT_FOUND The variable trying to be updated or deleted was not found.

References AcquireLockOnlyAtBootTime(), AUTHINFO_SIZE, AutoUpdateLangVariable(), EFI_STATUS(), FindVariable(), GetNextVariablePtr(), GetStartPointer(), IsValidVariableHeader(), VARIABLE_GLOBAL::NonVolatileVariableBase, ProcessVarWithKek(), ProcessVarWithPk(), ReleaseLockOnlyAtBootTime(), TRUE, UINTN(), UpdateVariable(), VAR_HW_ERR_REC, VAR_KEY_EXCHANGE_KEY, VAR_PLATFORM_KEY, VARIABLE_GLOBAL::VariableServicesLock, and VerifyVariable().

Referenced by EsalVariableCommonEntry(), and FlushHob2Nv().

EFI_STATUS FindVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
OUT VARIABLE_POINTER_TRACK PtrTrack,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance 
)

Finds variable in volatile and non-volatile storage areas.

This code finds variable in 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. Otherwise, VariableName and VendorGuid are compared.

Parameters:
[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] Instance Instance of FV Block services.
Return values:
EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
EFI_SUCCESS Variable successfully found.
EFI_INVALID_PARAMETER Variable not found.

References BOOLEAN(), GetEndPointer(), GetNextVariablePtr(), GetStartPointer(), GetVariableNamePtr(), IsValidVariableHeader(), MAX_NAME_SIZE, NameSizeOfVariable(), TRUE, and UINTN().

Referenced by AddPubKeyInStore(), AutenticatedVariableServiceInitialize(), AutoUpdateLangVariable(), EsalGetNextVariableName(), EsalGetVariable(), EsalSetVariable(), ProcessVarWithKek(), ProcessVarWithPk(), and UpdatePlatformMode().

EFI_STATUS FindVariableInCache ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
OUT UINT32 *  Attributes,
IN OUT UINTN *  DataSize,
OUT VOID *  Data 
)

Search the cache to check if the variable is in it.

This function searches the variable cache. If the variable to find exists, return its data and attributes.

Parameters:
[in] VariableName A Null-terminated Unicode string that is the name of the vendor's variable. Each VariableName is unique for each VendorGuid.
[in] VendorGuid A unique identifier for the vendor
[out] Attributes Pointer to the attributes bitmask of the variable for output.
[in,out] DataSize On input, size of the buffer of Data. On output, size of the variable's data.
[out] Data Pointer to the data buffer for output.
Return values:
EFI_SUCCESS VariableGuid & VariableName data was returned.
EFI_NOT_FOUND No matching variable found in cache.
EFI_BUFFER_TOO_SMALL *DataSize is smaller than size of the variable's data to return.

References VARIABLE_CACHE_ENTRY::Attributes, VARIABLE_CACHE_ENTRY::Data, VARIABLE_CACHE_ENTRY::DataSize, VARIABLE_CACHE_ENTRY::Guid, VARIABLE_CACHE_ENTRY::Name, and UINTN().

Referenced by EsalGetVariable().

VOID FlushHob2Nv ( VOID   ) 

Flush the HOB variable to NV variable storage.

References EFI_STATUS(), EsalSetVariable(), Physical, and UINTN().

Referenced by VariableServiceInitialize().

EFI_PHYSICAL_ADDRESS GetEndPointer ( IN EFI_PHYSICAL_ADDRESS  VarStoreHeaderAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance 
)

Gets the pointer to the end of given variable store area.

This function gets the pointer to the end of given variable store area. The variable store area is given by its start address.

Parameters:
[in] VarStoreHeaderAddress Pointer to the header of variable store area.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
Returns:
Pointer to the end of given variable store area.

References AccessVariableStore(), and EFI_STATUS().

Referenced by AutoUpdateLangVariable(), EsalGetNextVariableName(), EsalQueryVariableInfo(), FindVariable(), and UpdateVariable().

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".

Parameters:
[in] SupportedLang Platform supported language codes.
[in] Lang Configured language.
[in] Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646.
Returns:
The index of language in the language codes.

References ISO_639_2_ENTRY_SIZE, and UINTN().

Referenced by AutoUpdateLangVariable().

CHAR8* GetLangFromSupportedLangCodes ( IN CHAR8 *  SupportedLang,
IN UINTN  Index,
IN BOOLEAN  Iso639Language,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global 
)

Get language string from supported language codes according to index.

This code is used to get corresponding language string 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".

Parameters:
[in] SupportedLang Platform supported language codes.
[in] Index the index in supported language codes.
[in] Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
Returns:
The language string in the language codes.

References ISO_639_2_ENTRY_SIZE, TRUE, and UINTN().

Referenced by AutoUpdateLangVariable().

EFI_PHYSICAL_ADDRESS GetNextVariablePtr ( IN EFI_PHYSICAL_ADDRESS  VariableAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance 
)

Gets the pointer to the next variable header.

This function gets the pointer to the next variable header. The variable is specified by its variable header.

Parameters:
[in] VariableAddress Start address of variable header.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
Returns:
Pointer to the next variable header. NULL if variable header is invalid.

References DataSizeOfVariable(), IsValidVariableHeader(), and NameSizeOfVariable().

Referenced by EsalGetNextVariableName(), EsalQueryVariableInfo(), EsalSetVariable(), FindVariable(), Reclaim(), and VariableCommonInitialize().

EFI_PHYSICAL_ADDRESS GetStartPointer ( IN EFI_PHYSICAL_ADDRESS  VarStoreHeaderAddress  ) 

Gets the pointer to the first variable header in given variable store area.

This function gets the pointer to the first variable header in given variable store area. The variable store area is given by its start address.

Parameters:
[in] VarStoreHeaderAddress Pointer to the header of variable store area.
Returns:
Pointer to the first variable header.

Referenced by EsalGetNextVariableName(), EsalQueryVariableInfo(), EsalSetVariable(), FindVariable(), Reclaim(), and VariableCommonInitialize().

VOID GetVariableDataPtr ( IN EFI_PHYSICAL_ADDRESS  VariableAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance,
OUT CHAR16 *  VariableData 
)

Gets the pointer to variable data area.

This function gets the pointer to variable data area. The variable is specified by its variable header.

Parameters:
[in] VariableAddress Start address of variable header.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
[out] VariableData Buffer to hold variable data for output.

References AccessVariableStore(), BOOLEAN(), EFI_STATUS(), IsValidVariableHeader(), and NameSizeOfVariable().

Referenced by AutenticatedVariableServiceInitialize(), AutoUpdateLangVariable(), EsalGetVariable(), ProcessVarWithKek(), ProcessVarWithPk(), and UpdateVariable().

VOID GetVariableNamePtr ( IN EFI_PHYSICAL_ADDRESS  VariableAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance,
OUT CHAR16 *  VariableName 
)

Gets the pointer to variable name.

This function gets the pointer to variable name. The variable is specified by its variable header.

Parameters:
[in] VariableAddress Start address of variable header.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
[out] VariableName Buffer to hold variable name for output.

References AccessVariableStore(), BOOLEAN(), EFI_STATUS(), and IsValidVariableHeader().

Referenced by EsalGetNextVariableName(), FindVariable(), and Reclaim().

VARIABLE_STORE_STATUS GetVariableStoreStatus ( IN VARIABLE_STORE_HEADER *  VarStoreHeader  ) 

Gets status of variable store.

This function gets the current status of variable store.

Parameters:
[in] VarStoreHeader Pointer to header of variable store.
Return values:
EfiRaw Variable store status is raw.
EfiValid Variable store status is valid.
EfiInvalid Variable store status is invalid.

Referenced by VariableCommonInitialize().

VOID GetVarStoreHeader ( IN EFI_PHYSICAL_ADDRESS  VarStoreAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance,
OUT VARIABLE_STORE_HEADER *  VarStoreHeader 
)

Retrieves header of volatile or non-volatile variable stroage.

Parameters:
[in] VarStoreAddress Start address of variable storage.
[in] Volatile TRUE - Variable storage is volatile. FALSE - Variable storage is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
[out] VarStoreHeader Pointer to VARIABLE_STORE_HEADER for output.

References AccessVariableStore(), and EFI_STATUS().

Referenced by EsalQueryVariableInfo(), Reclaim(), and UpdateVariable().

BOOLEAN IsValidVariableHeader ( IN EFI_PHYSICAL_ADDRESS  VariableAddress,
IN BOOLEAN  Volatile,
IN VARIABLE_GLOBAL Global,
IN UINTN  Instance,
OUT AUTHENTICATED_VARIABLE_HEADER *  VariableHeader 
)

Checks variable header.

This function checks if variable header is valid or not.

Parameters:
[in] VariableAddress Start address of variable header.
[in] Volatile TRUE - Variable is volatile. FALSE - Variable is non-volatile.
[in] Global Pointer to VARAIBLE_GLOBAL structure.
[in] Instance Instance of FV Block services.
[out] VariableHeader Pointer to AUTHENTICATED_VARIABLE_HEADER for output.
Return values:
TRUE Variable header is valid.
FALSE Variable header is not valid.

References AccessVariableStore(), EFI_STATUS(), and TRUE.

Referenced by AutenticatedVariableServiceInitialize(), EsalGetNextVariableName(), EsalGetVariable(), EsalQueryVariableInfo(), EsalSetVariable(), FindVariable(), GetNextVariablePtr(), GetVariableDataPtr(), GetVariableNamePtr(), ProcessVarWithKek(), ProcessVarWithPk(), Reclaim(), UpdateVariable(), VariableCommonInitialize(), and VerifyVariable().

UINTN NameSizeOfVariable ( IN AUTHENTICATED_VARIABLE_HEADER *  Variable  ) 

Gets the size of variable name.

This function gets the size of variable name. The variable is specified by its variable header. If variable header contains raw data, just return 0.

Parameters:
[in] Variable Pointer to the variable header.
Returns:
Size of variable name in bytes.

References UINTN().

Referenced by EsalGetNextVariableName(), FindVariable(), GetNextVariablePtr(), GetVariableDataPtr(), and Reclaim().

EFI_STATUS Reclaim ( IN EFI_PHYSICAL_ADDRESS  VariableBase,
OUT UINTN *  LastVariableOffset,
IN BOOLEAN  IsVolatile,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global,
IN EFI_PHYSICAL_ADDRESS  UpdatingVariable 
)

Variable store garbage collection and reclaim operation.

Parameters:
[in] VariableBase Base address of variable store area.
[out] LastVariableOffset Offset of last variable.
[in] IsVolatile The variable store is volatile or not, if it is non-volatile, need FTW.
[in] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
[in] UpdatingVariable Pointer to header of the variable that is being updated.
Return values:
EFI_SUCCESS Variable store successfully reclaimed.
EFI_OUT_OF_RESOURCES Fail to allocate memory buffer to hold all valid variables.

References BOOLEAN(), EFI_STATUS(), FtwVariableSpace(), GetNextVariablePtr(), GetStartPointer(), GetVariableNamePtr(), GetVarStoreHeader(), IsValidVariableHeader(), MAX_NAME_SIZE, NameSizeOfVariable(), TRUE, and UINTN().

Referenced by ReclaimForOS(), UpdateVariable(), and VariableCommonInitialize().

VOID EFIAPI ReclaimForOS ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of EVT_GROUP_READY_TO_BOOT event group.

This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group. When the Boot Manager is about to load and execute a boot option, it reclaims variable storage if free size is below the threshold.

Parameters:
[in] Event Event whose notification function is being invoked.
[in] Context Pointer to the notification function's context.

References ESAL_VARIABLE_GLOBAL::CommonVariableTotalSize, EFI_STATUS(), ESAL_VARIABLE_GLOBAL::HwErrVariableTotalSize, ESAL_VARIABLE_GLOBAL::NonVolatileLastVariableOffset, VARIABLE_GLOBAL::NonVolatileVariableBase, Physical, Reclaim(), UINTN(), and ESAL_VARIABLE_GLOBAL::VariableGlobal.

Referenced by VariableCommonInitialize().

VOID ReleaseLockOnlyAtBootTime ( IN EFI_LOCK *  Lock  ) 

Releases lock only at boot time. Simply returns at runtime.

This is a temperary function which will be removed when EfiReleaseLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiReleaseLock() at boot time, and simply returns at runtime

Parameters:
[in] Lock A pointer to the lock to release.

Referenced by EsalGetNextVariableName(), EsalGetVariable(), EsalQueryVariableInfo(), and EsalSetVariable().

EFI_STATUS EFIAPI UpdateVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
IN VOID *  Data,
IN UINTN  DataSize,
IN UINT32  Attributes,
IN UINT32  KeyIndex,
IN UINT64  MonotonicCount,
IN BOOLEAN  VirtualMode,
IN ESAL_VARIABLE_GLOBAL Global,
IN VARIABLE_POINTER_TRACK Variable 
)

Update the variable region with Variable information. These are the same arguments as the EFI Variable services.

Parameters:
[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] VirtualMode Current calling mode for this function.
[in] Global Context of this Extended SAL Variable Services Class call.
[in] Variable The variable information which is used to keep track of variable usage.
Return values:
EFI_SUCCESS The update operation is success.
EFI_OUT_OF_RESOURCES Variable region is full, can not write other data into this region.

References AccessVariableStore(), BOOLEAN(), DataSizeOfVariable(), EFI_STATUS(), GetEndPointer(), GetVariableDataPtr(), GetVarStoreHeader(), IsValidVariableHeader(), VARIABLE_GLOBAL::NonVolatileVariableBase, Reclaim(), TRUE, UINTN(), UpdateVariableCache(), UpdateVariableInfo(), and VARIABLE_GLOBAL::VolatileVariableBase.

Referenced by AddPubKeyInStore(), AutenticatedVariableServiceInitialize(), AutoUpdateLangVariable(), EsalSetVariable(), ProcessVarWithKek(), ProcessVarWithPk(), and UpdatePlatformMode().

VOID UpdateVariableCache ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
IN UINT32  Attributes,
IN UINTN  DataSize,
IN VOID *  Data 
)

Updates variable in cache.

This function searches the variable cache. If the variable to set exists in the cache, it updates the variable in cache. It has the same parameters with UEFI SetVariable() service.

Parameters:
[in] VariableName A Null-terminated Unicode string that is the name of the vendor's variable. Each VariableName is unique for each VendorGuid.
[in] VendorGuid A unique identifier for the vendor.
[in] Attributes Attributes bitmask to set for the variable.
[in] DataSize The size in bytes of the Data buffer. A size of zero causes the variable to be deleted.
[in] Data The contents for the variable.

References VARIABLE_CACHE_ENTRY::Attributes, VARIABLE_CACHE_ENTRY::Data, VARIABLE_CACHE_ENTRY::DataSize, VARIABLE_CACHE_ENTRY::Guid, VARIABLE_CACHE_ENTRY::Name, and UINTN().

Referenced by EsalGetVariable(), and UpdateVariable().

VOID UpdateVariableInfo ( IN CHAR16 *  VariableName,
IN EFI_GUID *  VendorGuid,
IN BOOLEAN  Volatile,
IN BOOLEAN  Read,
IN BOOLEAN  Write,
IN BOOLEAN  Delete,
IN BOOLEAN  Cache 
)

Updates variable info entry in EFI system table for statistical information.

Routine used to track statistical information about variable usage. The data is stored in the EFI system table so it can be accessed later. VariableInfo.efi can dump out the table. Only Boot Services variable accesses are tracked by this code. The PcdVariableCollectStatistics build flag controls if this feature is enabled. A read that hits in the cache will have Read and Cache true for the transaction. Data is allocated by this routine, but never freed.

Parameters:
[in] VariableName Name of the Variable to track.
[in] VendorGuid Guid of the Variable to track.
[in] Volatile TRUE if volatile FALSE if non-volatile.
[in] Read TRUE if GetVariable() was called.
[in] Write TRUE if SetVariable() was called.
[in] Delete TRUE if deleted via SetVariable().
[in] Cache TRUE for a cache hit.

References gVariableInfo.

Referenced by EsalGetVariable(), and UpdateVariable().

EFI_STATUS VariableCommonInitialize ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE *  SystemTable 
)

Initializes variable store area for non-volatile and volatile variable.

This function allocates and initializes memory space for global context of ESAL variable service and variable store area for non-volatile and volatile variable.

Parameters:
[in] ImageHandle The Image handle of this driver.
[in] SystemTable The pointer of EFI_SYSTEM_TABLE.
Return values:
EFI_SUCCESS Function successfully executed.
EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.

References AccessVariableStore(), ESAL_VARIABLE_GLOBAL::CommonVariableTotalSize, EFI_STATUS(), ESAL_VARIABLE_GLOBAL::FvbInstance, GetNextVariablePtr(), GetStartPointer(), GetVariableStoreStatus(), ESAL_VARIABLE_GLOBAL::GlobalVariableGuid, ESAL_VARIABLE_GLOBAL::HwErrVariableTotalSize, IsValidVariableHeader(), mVariableName, ESAL_VARIABLE_GLOBAL::NonVolatileLastVariableOffset, VARIABLE_GLOBAL::NonVolatileVariableBase, Physical, Reclaim(), ReclaimForOS(), TRUE, UINTN(), ESAL_VARIABLE_GLOBAL::VariableGlobal, ESAL_VARIABLE_GLOBAL::VariableName, VARIABLE_GLOBAL::VariableServicesLock, ESAL_VARIABLE_GLOBAL::VolatileLastVariableOffset, and VARIABLE_GLOBAL::VolatileVariableBase.

Referenced by VariableServiceInitialize().

CHAR8* VariableGetBestLanguage ( IN CONST CHAR8 *  SupportedLanguages,
IN BOOLEAN  Iso639Language,
IN BOOLEAN  VirtualMode,
  ... 
)

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().

Parameters:
[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 TRUE, then all language codes are assumed to be in ISO 639-2 format. If FALSE, then all language codes are assumed to be in RFC 4646 language format.
[in] VirtualMode Current calling mode for this function.
[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.
Return values:
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.

References ESAL_VARIABLE_GLOBAL::Lang, ESAL_VARIABLE_GLOBAL::PlatformLang, and UINTN().

Referenced by AutoUpdateLangVariable().


Variable Documentation

GLOBAL_REMOVE_IF_UNREFERENCED VARIABLE_INFO_ENTRY* gVariableInfo = NULL

Referenced by UpdateVariableInfo().

Initial value:

 {
  {
    &gEfiGlobalVariableGuid,
    L"Lang",
    0x00000000,
    0x00,
    NULL
  },
  {
    &gEfiGlobalVariableGuid,
    L"PlatformLang",
    0x00000000,
    0x00,
    NULL
  }
}

CHAR16* mVariableName[NUM_VAR_NAME]

Initial value:

 {
  L"PlatformLangCodes",
  L"LangCodes",
  L"PlatformLang",
  L"Lang",
  L"HwErrRec",
  AUTHVAR_KEYDB_NAME,
  EFI_SETUP_MODE_NAME,
  EFI_PLATFORM_KEY_NAME,
  EFI_KEY_EXCHANGE_KEY_NAME
}

Referenced by VariableCommonInitialize().


Generated on Thu Sep 24 23:44:25 2015 for SecurityPkg[ALL] by  doxygen 1.5.7.1