Skip to content

Commit

Permalink
MdeModulePkg/Variable: Consolidate common parsing functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
makubacki committed Nov 6, 2019
1 parent a7d69b6 commit 20a27a6
Show file tree
Hide file tree
Showing 9 changed files with 1,047 additions and 845 deletions.
726 changes: 1 addition & 725 deletions MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

Large diffs are not rendered by default.

119 changes: 0 additions & 119 deletions MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/** @file
Provides variable driver extended services.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include "Variable.h"
#include "VariableParsing.h"

/**
Finds variable in storage blocks of volatile and non-volatile storage areas.
Expand Down
Loading

0 comments on commit 20a27a6

Please sign in to comment.