MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479 Adds support to the UEFI variable fault tolerant write (FTW) drivers to receive FTW base and size information dynamically via the Variable Flash Information library. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
4dbebc2d10
commit
8db39c60cd
@ -16,6 +16,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
|
||||
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||
@ -212,25 +214,31 @@ PeimFaultTolerantWriteInitialize (
|
||||
EFI_PHYSICAL_ADDRESS SpareAreaAddress;
|
||||
UINTN SpareAreaLength;
|
||||
EFI_PHYSICAL_ADDRESS WorkSpaceInSpareArea;
|
||||
UINT64 Size;
|
||||
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA FtwLastWrite;
|
||||
|
||||
FtwWorkingBlockHeader = NULL;
|
||||
FtwLastWriteHeader = NULL;
|
||||
FtwLastWriteRecord = NULL;
|
||||
|
||||
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
|
||||
if (WorkSpaceAddress == 0) {
|
||||
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
|
||||
}
|
||||
SpareAreaAddress = 0;
|
||||
SpareAreaLength = 0;
|
||||
WorkSpaceAddress = 0;
|
||||
WorkSpaceLength = 0;
|
||||
|
||||
WorkSpaceLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||
Status = GetVariableFlashFtwWorkingInfo (&WorkSpaceAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwSpareBase64);
|
||||
if (SpareAreaAddress == 0) {
|
||||
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwSpareBase);
|
||||
}
|
||||
Status = SafeUint64ToUintn (Size, &WorkSpaceLength);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
Status = GetVariableFlashFtwSpareInfo (&SpareAreaAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUintn (Size, &SpareAreaLength);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// The address of FTW working base and spare base must not be 0.
|
||||
|
@ -39,6 +39,8 @@
|
||||
HobLib
|
||||
BaseMemoryLib
|
||||
PcdLib
|
||||
SafeIntLib
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
## SOMETIMES_PRODUCES ## HOB
|
||||
@ -47,14 +49,6 @@
|
||||
gEdkiiWorkingBlockSignatureGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiSystemNvDataFvGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
|
||||
|
Reference in New Issue
Block a user