MdeModulePkg/Variable: Consolidate common parsing functions

This change moves the following functions into a dedicated file
so they may be used in other variable files as needed. These are
commonly needed for basic variable data structure parsing
operations. The functions are grouped together in VariableParsing.c
to support cohesiveness for these operations in the file.
Furthermore, it reduces the overall size of the common Variable.c
file.

 * DataSizeOfVariable ()
 * FindVariableEx ()
 * GetEndPointer ()
 * GetNextVariablePtr ()
 * GetStartPointer ()
 * GetVariableDataOffset ()
 * GetVariableDataPtr ()
 * GetVariableHeaderSize ()
 * GetVariableNamePtr ()
 * GetVariableStoreStatus ()
 * GetVendorGuidPtr ()
 * IsValidVariableHeader ()
 * NameSizeOfVariable ()
 * SetDataSizeOfVariable ()
 * SetNameSizeOfVariable ()
 * UpdateVariableInfo ()
 * VariableCompareTimeStampInternal ()
 * VariableServiceGetNextVariableInternal ()

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Michael Kubacki
2019-09-23 17:32:07 -07:00
parent a7d69b6aaf
commit 20a27a641b
9 changed files with 1047 additions and 845 deletions

View File

@@ -179,89 +179,6 @@ FindVariable (
IN BOOLEAN IgnoreRtCheck
);
/**
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.
@param VarStoreHeader Pointer to the Variable Store Header.
@return Pointer to the end of the variable storage area.
**/
VARIABLE_HEADER *
GetEndPointer (
IN VARIABLE_STORE_HEADER *VarStoreHeader
);
/**
This code gets the size of variable header.
@return Size of variable header in bytes in type UINTN.
**/
UINTN
GetVariableHeaderSize (
VOID
);
/**
This code gets the pointer to the variable name.
@param Variable Pointer to the Variable Header.
@return Pointer to Variable Name which is Unicode encoding.
**/
CHAR16 *
GetVariableNamePtr (
IN VARIABLE_HEADER *Variable
);
/**
This code gets the pointer to the variable guid.
@param Variable Pointer to the Variable Header.
@return A EFI_GUID* pointer to Vendor Guid.
**/
EFI_GUID *
GetVendorGuidPtr (
IN VARIABLE_HEADER *Variable
);
/**
This code gets the pointer to the variable data.
@param Variable Pointer to the Variable Header.
@return Pointer to Variable Data.
**/
UINT8 *
GetVariableDataPtr (
IN VARIABLE_HEADER *Variable
);
/**
This code gets the size of variable data.
@param Variable Pointer to the Variable Header.
@return Size of variable in bytes.
**/
UINTN
DataSizeOfVariable (
IN VARIABLE_HEADER *Variable
);
/**
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
@@ -450,17 +367,6 @@ ReclaimForOS(
VOID
);
/**
Get non-volatile maximum variable size.
@return Non-volatile maximum variable size.
**/
UINTN
GetNonVolatileMaxVariableSize (
VOID
);
/**
Get maximum variable size, covering both non-volatile and volatile variables.
@@ -546,31 +452,6 @@ VariableServiceGetVariable (
OUT VOID *Data OPTIONAL
);
/**
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.
@param[in] VariableName Pointer to variable name.
@param[in] VendorGuid Variable Vendor Guid.
@param[out] VariablePtr Pointer to variable header address.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_FOUND The next variable was not found.
@retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while VendorGuid is NULL.
@retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
GUID of an existing variable.
**/
EFI_STATUS
EFIAPI
VariableServiceGetNextVariableInternal (
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
OUT VARIABLE_HEADER **VariablePtr
);
/**
This code Finds the Next available variable.