MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

CacheOffset could be removed in UpdateVariable() after
//
// update the memory copy of Flash region.
//
CopyMem (
  (UINT8 *)mNvVariableCache + CacheOffset,
  (UINT8 *)NextVariable, VarSize
   );

is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
value is updated, like right before
mVariableModuleGlobal->NonVolatileLastVariableOffset +=
  HEADER_ALIGN (VarSize);

Except for the movement above, the patch also capitalizes the first
character of "update the memory copy of Flash region".

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Julien Grall <julien.grall@arm.com>
Acked-by: Julien Grall <julien.grall@arm.com>
This commit is contained in:
Star Zeng 2019-01-12 16:31:51 +08:00
parent b59fd889ac
commit ebe34c96f4

View File

@ -2139,7 +2139,6 @@ UpdateVariable (
VARIABLE_POINTER_TRACK *Variable;
VARIABLE_POINTER_TRACK NvVariable;
VARIABLE_STORE_HEADER *VariableStoreHeader;
UINTN CacheOffset;
UINT8 *BufferForMerge;
UINTN MergedBufSize;
BOOLEAN DataReady;
@ -2577,7 +2576,6 @@ UpdateVariable (
//
// Step 1:
//
CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
Status = UpdateVariableStore (
&mVariableModuleGlobal->VariableGlobal,
FALSE,
@ -2643,6 +2641,11 @@ UpdateVariable (
goto Done;
}
//
// Update the memory copy of Flash region.
//
CopyMem ((UINT8 *)mNvVariableCache + mVariableModuleGlobal->NonVolatileLastVariableOffset, (UINT8 *)NextVariable, VarSize);
mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN (VarSize);
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
@ -2653,10 +2656,6 @@ UpdateVariable (
mVariableModuleGlobal->CommonUserVariableTotalSize += HEADER_ALIGN (VarSize);
}
}
//
// update the memory copy of Flash region.
//
CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8 *)NextVariable, VarSize);
} else {
//
// Create a volatile variable.