MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

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

Add macro NV_STORAGE_VARIABLE_BASE.
Not get NV PCD in VariableWriteServiceInitialize, but in
FtwNotificationEvent/SmmFtwNotificationEvent, then
VariableWriteServiceInitialize could be not aware the NV
storage is real or emulated.

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>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.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 15:40:19 +08:00
parent 5f0871e3d8
commit 904e0ca997
4 changed files with 27 additions and 30 deletions

View File

@@ -3770,10 +3770,7 @@ InitRealNonVolatileVariableStore (
return EFI_OUT_OF_RESOURCES;
}
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
if (NvStorageBase == 0) {
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
}
NvStorageBase = NV_STORAGE_VARIABLE_BASE;
ASSERT (NvStorageBase != 0);
//
@@ -4027,7 +4024,7 @@ FlushHobVariableToFlash (
}
/**
Initializes variable write service after FTW was ready.
Initializes variable write service.
@retval EFI_SUCCESS Function successfully executed.
@retval Others Fail to initialize the variable service.
@@ -4041,23 +4038,10 @@ VariableWriteServiceInitialize (
EFI_STATUS Status;
UINTN Index;
UINT8 Data;
EFI_PHYSICAL_ADDRESS VariableStoreBase;
EFI_PHYSICAL_ADDRESS NvStorageBase;
VARIABLE_ENTRY_PROPERTY *VariableEntry;
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
if (NvStorageBase == 0) {
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
}
VariableStoreBase = NvStorageBase + (mNvFvHeaderCache->HeaderLength);
//
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
//
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
//
// Check if the free area is really free.
//