TianoCore EDK2 master
Loading...
Searching...
No Matches
VariableParsing.c File Reference
#include "VariableParsing.h"

Go to the source code of this file.

Functions

BOOLEAN IsValidVariableHeader (IN VARIABLE_HEADER *Variable, IN VARIABLE_HEADER *VariableStoreEnd)
 
VARIABLE_STORE_STATUS GetVariableStoreStatus (IN VARIABLE_STORE_HEADER *VarStoreHeader)
 
UINTN GetVariableHeaderSize (IN BOOLEAN AuthFormat)
 
UINTN NameSizeOfVariable (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
VOID SetNameSizeOfVariable (IN VARIABLE_HEADER *Variable, IN UINTN NameSize, IN BOOLEAN AuthFormat)
 
UINTN DataSizeOfVariable (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
VOID SetDataSizeOfVariable (IN VARIABLE_HEADER *Variable, IN UINTN DataSize, IN BOOLEAN AuthFormat)
 
CHAR16 * GetVariableNamePtr (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
EFI_GUIDGetVendorGuidPtr (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
UINT8 * GetVariableDataPtr (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
UINTN GetVariableDataOffset (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
VARIABLE_HEADERGetNextVariablePtr (IN VARIABLE_HEADER *Variable, IN BOOLEAN AuthFormat)
 
VARIABLE_HEADERGetStartPointer (IN VARIABLE_STORE_HEADER *VarStoreHeader)
 
VARIABLE_HEADERGetEndPointer (IN VARIABLE_STORE_HEADER *VarStoreHeader)
 
BOOLEAN VariableCompareTimeStampInternal (IN EFI_TIME *FirstTime, IN EFI_TIME *SecondTime)
 
EFI_STATUS FindVariableEx (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN BOOLEAN IgnoreRtCheck, IN OUT VARIABLE_POINTER_TRACK *PtrTrack, IN BOOLEAN AuthFormat)
 
EFI_STATUS EFIAPI VariableServiceGetNextVariableInternal (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VARIABLE_STORE_HEADER **VariableStoreList, OUT VARIABLE_HEADER **VariablePtr, IN BOOLEAN AuthFormat)
 
VOID UpdateVariableInfo (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN BOOLEAN Volatile, IN BOOLEAN Read, IN BOOLEAN Write, IN BOOLEAN Delete, IN BOOLEAN Cache, IN OUT VARIABLE_INFO_ENTRY **VariableInfo)
 

Detailed Description

Functions in this module are associated with variable parsing operations and are intended to be usable across variable driver source files.

Copyright (c) 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VariableParsing.c.

Function Documentation

◆ DataSizeOfVariable()

UINTN DataSizeOfVariable ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the size of variable data.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Size of variable in bytes.

Definition at line 184 of file VariableParsing.c.

◆ FindVariableEx()

EFI_STATUS FindVariableEx ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
IN BOOLEAN  IgnoreRtCheck,
IN OUT VARIABLE_POINTER_TRACK PtrTrack,
IN BOOLEAN  AuthFormat 
)

Find the variable in the specified variable store.

Parameters
[in]VariableNameName of the variable to be found
[in]VendorGuidVendor GUID to be found.
[in]IgnoreRtCheckIgnore EFI_VARIABLE_RUNTIME_ACCESS attribute check at runtime when searching variable.
[in,out]PtrTrackVariable Track Pointer structure that contains Variable Information.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Return values
EFI_SUCCESSVariable found successfully
EFI_NOT_FOUNDVariable not found

Definition at line 463 of file VariableParsing.c.

◆ GetEndPointer()

VARIABLE_HEADER * GetEndPointer ( IN VARIABLE_STORE_HEADER VarStoreHeader)

Gets the pointer to the end of the variable storage area.

This function gets pointer to the end of the variable storage area, according to the input variable store header.

Parameters
[in]VarStoreHeaderPointer to the Variable Store Header.
Returns
Pointer to the end of the variable storage area.

Definition at line 406 of file VariableParsing.c.

◆ GetNextVariablePtr()

VARIABLE_HEADER * GetNextVariablePtr ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the pointer to the next variable header.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Pointer to next variable header.

Definition at line 356 of file VariableParsing.c.

◆ GetStartPointer()

VARIABLE_HEADER * GetStartPointer ( IN VARIABLE_STORE_HEADER VarStoreHeader)

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

Parameters
[in]VarStoreHeaderPointer to the Variable Store Header.
Returns
Pointer to the first variable header.

Definition at line 383 of file VariableParsing.c.

◆ GetVariableDataOffset()

UINTN GetVariableDataOffset ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the variable data offset related to variable header.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Variable Data offset.

Definition at line 327 of file VariableParsing.c.

◆ GetVariableDataPtr()

UINT8 * GetVariableDataPtr ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the pointer to the variable data.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Pointer to Variable Data.

Definition at line 299 of file VariableParsing.c.

◆ GetVariableHeaderSize()

UINTN GetVariableHeaderSize ( IN BOOLEAN  AuthFormat)

This code gets the size of variable header.

Parameters
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Size of variable header in bytes in type UINTN.

Definition at line 88 of file VariableParsing.c.

◆ GetVariableNamePtr()

CHAR16 * GetVariableNamePtr ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the pointer to the variable name.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
Pointer to Variable Name which is Unicode encoding.

Definition at line 253 of file VariableParsing.c.

◆ GetVariableStoreStatus()

VARIABLE_STORE_STATUS GetVariableStoreStatus ( IN VARIABLE_STORE_HEADER VarStoreHeader)

This code gets the current status of Variable Store.

Parameters
[in]VarStoreHeaderPointer to the Variable Store Header.
Return values
EfiRawVariable store status is raw.
EfiValidVariable store status is valid.
EfiInvalidVariable store status is invalid.

Definition at line 52 of file VariableParsing.c.

◆ GetVendorGuidPtr()

EFI_GUID * GetVendorGuidPtr ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the pointer to the variable guid.

Parameters
[in]VariablePointer to the Variable Header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
A EFI_GUID* pointer to Vendor Guid.

Definition at line 272 of file VariableParsing.c.

◆ IsValidVariableHeader()

BOOLEAN IsValidVariableHeader ( IN VARIABLE_HEADER Variable,
IN VARIABLE_HEADER VariableStoreEnd 
)

This code checks if variable header is valid or not.

Parameters
[in]VariablePointer to the Variable Header.
[in]VariableStoreEndPointer to the Variable Store End.
Return values
TRUEVariable header is valid.
FALSEVariable header is not valid.

Definition at line 24 of file VariableParsing.c.

◆ NameSizeOfVariable()

UINTN NameSizeOfVariable ( IN VARIABLE_HEADER Variable,
IN BOOLEAN  AuthFormat 
)

This code gets the size of name of variable.

Parameters
[in]VariablePointer to the variable header.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Returns
UINTN Size of variable in bytes.

Definition at line 115 of file VariableParsing.c.

◆ SetDataSizeOfVariable()

VOID SetDataSizeOfVariable ( IN VARIABLE_HEADER Variable,
IN UINTN  DataSize,
IN BOOLEAN  AuthFormat 
)

This code sets the size of variable data.

Parameters
[in]VariablePointer to the Variable Header.
[in]DataSizeData size to set.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.

Definition at line 225 of file VariableParsing.c.

◆ SetNameSizeOfVariable()

VOID SetNameSizeOfVariable ( IN VARIABLE_HEADER Variable,
IN UINTN  NameSize,
IN BOOLEAN  AuthFormat 
)

This code sets the size of name of variable.

Parameters
[in]VariablePointer to the Variable Header.
[in]NameSizeName size to set.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.

Definition at line 156 of file VariableParsing.c.

◆ UpdateVariableInfo()

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

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]VariableNameName of the Variable to track.
[in]VendorGuidGuid of the Variable to track.
[in]VolatileTRUE if volatile FALSE if non-volatile.
[in]ReadTRUE if GetVariable() was called.
[in]WriteTRUE if SetVariable() was called.
[in]DeleteTRUE if deleted via SetVariable().
[in]CacheTRUE for a cache hit.
[in,out]VariableInfoPointer to a pointer of VARIABLE_INFO_ENTRY structures.

Definition at line 729 of file VariableParsing.c.

◆ VariableCompareTimeStampInternal()

BOOLEAN VariableCompareTimeStampInternal ( IN EFI_TIME FirstTime,
IN EFI_TIME SecondTime 
)

Compare two EFI_TIME data.

Parameters
[in]FirstTimeA pointer to the first EFI_TIME data.
[in]SecondTimeA pointer to the second EFI_TIME data.
Return values
TRUEThe FirstTime is not later than the SecondTime.
FALSEThe FirstTime is later than the SecondTime.

Definition at line 428 of file VariableParsing.c.

◆ VariableServiceGetNextVariableInternal()

EFI_STATUS EFIAPI VariableServiceGetNextVariableInternal ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
IN VARIABLE_STORE_HEADER **  VariableStoreList,
OUT VARIABLE_HEADER **  VariablePtr,
IN BOOLEAN  AuthFormat 
)

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.

Parameters
[in]VariableNamePointer to variable name.
[in]VendorGuidVariable Vendor Guid.
[in]VariableStoreListA list of variable stores that should be used to get the next variable. The maximum number of entries is the max value of VARIABLE_STORE_TYPE.
[out]VariablePtrPointer to variable header address.
[in]AuthFormatTRUE indicates authenticated variables are used. FALSE indicates authenticated variables are not used.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe next variable was not found.
EFI_INVALID_PARAMETERIf VariableName is not an empty string, while VendorGuid is NULL.
EFI_INVALID_PARAMETERThe input values of VariableName and VendorGuid are not a name and GUID of an existing variable.

Definition at line 544 of file VariableParsing.c.