mirror of https://github.com/acidanthera/audk.git
MdeModulePkg Variable: Handle ftw driver executes prior to variable driver
Variable driver uses gEdkiiFaultTolerantWriteGuid hob and copies data to NvStorageData if hob exists. But if ftw driver executes prior to variable driver then spare block is erased. So the patch is to enhance the code to do not check FTW last write data hob if FTW protocol has been installed. Cc: Liming Gao <liming.gao@intel.com> Reported-by: Baraneedharan Anbazhagan <anbazhagan@hp.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Baraneedharan Anbazhagan <anbazhagan@hp.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19577 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
bc003bc076
commit
14326ed091
|
@ -3626,6 +3626,8 @@ InitNonVolatileVariableStore (
|
||||||
UINT32 HwErrStorageSize;
|
UINT32 HwErrStorageSize;
|
||||||
UINT32 MaxUserNvVariableSpaceSize;
|
UINT32 MaxUserNvVariableSpaceSize;
|
||||||
UINT32 BoottimeReservedNvVariableSpaceSize;
|
UINT32 BoottimeReservedNvVariableSpaceSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
VOID *FtwProtocol;
|
||||||
|
|
||||||
mVariableModuleGlobal->FvbInstance = NULL;
|
mVariableModuleGlobal->FvbInstance = NULL;
|
||||||
|
|
||||||
|
@ -3648,30 +3650,36 @@ InitNonVolatileVariableStore (
|
||||||
//
|
//
|
||||||
CopyMem (NvStorageData, (UINT8 *) (UINTN) NvStorageBase, NvStorageSize);
|
CopyMem (NvStorageData, (UINT8 *) (UINTN) NvStorageBase, NvStorageSize);
|
||||||
|
|
||||||
|
Status = GetFtwProtocol ((VOID **)&FtwProtocol);
|
||||||
//
|
//
|
||||||
// Check the FTW last write data hob.
|
// If FTW protocol has been installed, no need to check FTW last write data hob.
|
||||||
//
|
//
|
||||||
GuidHob = GetFirstGuidHob (&gEdkiiFaultTolerantWriteGuid);
|
if (EFI_ERROR (Status)) {
|
||||||
if (GuidHob != NULL) {
|
//
|
||||||
FtwLastWriteData = (FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *) GET_GUID_HOB_DATA (GuidHob);
|
// Check the FTW last write data hob.
|
||||||
if (FtwLastWriteData->TargetAddress == NvStorageBase) {
|
//
|
||||||
DEBUG ((EFI_D_INFO, "Variable: NV storage is backed up in spare block: 0x%x\n", (UINTN) FtwLastWriteData->SpareAddress));
|
GuidHob = GetFirstGuidHob (&gEdkiiFaultTolerantWriteGuid);
|
||||||
//
|
if (GuidHob != NULL) {
|
||||||
// Copy the backed up NV storage data to the memory buffer from spare block.
|
FtwLastWriteData = (FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *) GET_GUID_HOB_DATA (GuidHob);
|
||||||
//
|
if (FtwLastWriteData->TargetAddress == NvStorageBase) {
|
||||||
CopyMem (NvStorageData, (UINT8 *) (UINTN) (FtwLastWriteData->SpareAddress), NvStorageSize);
|
DEBUG ((EFI_D_INFO, "Variable: NV storage is backed up in spare block: 0x%x\n", (UINTN) FtwLastWriteData->SpareAddress));
|
||||||
} else if ((FtwLastWriteData->TargetAddress > NvStorageBase) &&
|
//
|
||||||
(FtwLastWriteData->TargetAddress < (NvStorageBase + NvStorageSize))) {
|
// Copy the backed up NV storage data to the memory buffer from spare block.
|
||||||
//
|
//
|
||||||
// Flash NV storage from the Offset is backed up in spare block.
|
CopyMem (NvStorageData, (UINT8 *) (UINTN) (FtwLastWriteData->SpareAddress), NvStorageSize);
|
||||||
//
|
} else if ((FtwLastWriteData->TargetAddress > NvStorageBase) &&
|
||||||
BackUpOffset = (UINT32) (FtwLastWriteData->TargetAddress - NvStorageBase);
|
(FtwLastWriteData->TargetAddress < (NvStorageBase + NvStorageSize))) {
|
||||||
BackUpSize = NvStorageSize - BackUpOffset;
|
//
|
||||||
DEBUG ((EFI_D_INFO, "Variable: High partial NV storage from offset: %x is backed up in spare block: 0x%x\n", BackUpOffset, (UINTN) FtwLastWriteData->SpareAddress));
|
// Flash NV storage from the Offset is backed up in spare block.
|
||||||
//
|
//
|
||||||
// Copy the partial backed up NV storage data to the memory buffer from spare block.
|
BackUpOffset = (UINT32) (FtwLastWriteData->TargetAddress - NvStorageBase);
|
||||||
//
|
BackUpSize = NvStorageSize - BackUpOffset;
|
||||||
CopyMem (NvStorageData + BackUpOffset, (UINT8 *) (UINTN) FtwLastWriteData->SpareAddress, BackUpSize);
|
DEBUG ((EFI_D_INFO, "Variable: High partial NV storage from offset: %x is backed up in spare block: 0x%x\n", BackUpOffset, (UINTN) FtwLastWriteData->SpareAddress));
|
||||||
|
//
|
||||||
|
// Copy the partial backed up NV storage data to the memory buffer from spare block.
|
||||||
|
//
|
||||||
|
CopyMem (NvStorageData + BackUpOffset, (UINT8 *) (UINTN) FtwLastWriteData->SpareAddress, BackUpSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue