From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01c.ixn.mail.zen.net.uk (smarthost01c.ixn.mail.zen.net.uk [212.23.1.22]) by mx.groups.io with SMTP id smtpd.web10.4073.1645915936902994673 for ; Sat, 26 Feb 2022 14:52:17 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=permerror, err=parse error for token &{10 18 sdn.klaviyomail.com}: permanent DNS error (domain: starlabs.systems, ip: 212.23.1.22, mailfrom: sean@starlabs.systems) Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01c.ixn.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nO5v7-0000SE-Uv; Sat, 26 Feb 2022 22:52:10 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: guo.dong@intel.com, Sean Rhodes , Hao A Wu , Liming Gao Subject: [PATCH 1/2] MdeModulePkg/FaultTolerantWriteDxe: Add Pcd for Memory Mapped Boot Media Date: Sat, 26 Feb 2022 22:52:05 +0000 Message-Id: <5a7b0fa09948fd239dde8d9bc688b43a70545e58.1645915926.git.sean@starlabs.systems> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Originating-smarthost01c-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Content-Transfer-Encoding: quoted-printable Add PCD PcdMemoryMappedBootMedia to indiciate if Boot Media is memory mappe= d. If set to true, don't check for Block Alignment as it is not necessary. Cc: Hao A Wu Cc: Liming Gao Signed-off-by: Sean Rhodes --- MdeModulePkg/MdeModulePkg.dec | 7 +++++++ MdeModulePkg/MdeModulePkg.uni | 4 ++++ .../FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf | 1 + MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c | 9 ++++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 463e889e9a..e181a5216b 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1077,6 +1077,13 @@ # @Prompt Enable UEFI Stack Guard.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055= =0D =0D + ## Indicates if the Boot Media is memory mapped.=0D + # If enabled, don't check for block alignent as it is not necessary.=0D + # TRUE - Do not check for block aligment.=0D + # FALSE - Check for block alignment.=0D + # @Prompt Boot Media Memory Mapped.=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia|FALSE|BOOLEAN|0x= 30001058=0D +=0D [PcdsFixedAtBuild, PcdsPatchableInModule]=0D ## Dynamic type PCD can be registered callback function for Pcd setting = action.=0D # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of= callback function=0D diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 27889a7280..deafee3d5a 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -1173,6 +1173,10 @@ = " TRUE - Capsule In Ram is supported.
"=0D = " FALSE - Capsule In Ram is not supported."=0D =0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia_PROMPT= #language en-US "Boot Media is memory mapped."=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia_HELP = #language en-US "Indicates if the Boot Media is memory mapped."=0D +=0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_PROMPT = #language en-US "Capsule On Disk relocation device path."=0D =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_HELP #= language en-US "Full device path of platform specific device to store Cap= sule On Disk temp relocation file.
"=0D diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrit= eDxe.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteD= xe.inf index 96165614d1..b3209567d9 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf @@ -72,6 +72,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOM= ETIMES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CON= SUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CON= SUMES=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia ## CON= SUMES=0D =0D #=0D # gBS->CalculateCrc32() is consumed in EntryPoint.=0D diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeMo= dulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c index 661e148767..4c3fcbec6b 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c @@ -1119,7 +1119,9 @@ FindFvbForFtw ( FtwDevice->WorkBlockSize =3D BlockSize;=0D FtwDevice->FtwWorkSpaceBase =3D (UINTN)(FtwDevice->WorkSpa= ceAddress - (FvbBaseAddress + FtwDevice->WorkBlockSize * (LbaIndex - 1)));= =0D FtwDevice->NumberOfWorkSpaceBlock =3D FTW_BLOCKS (FtwDevice->Ftw= WorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize);=0D - if (FtwDevice->FtwWorkSpaceSize >=3D FtwDevice->WorkBlockSize) {= =0D + if ((!PcdGetBool (PcdMemoryMappedBootMedia)) &&=0D + (FtwDevice->FtwWorkSpaceSize >=3D FtwDevice->WorkBlockSize))= =0D + {=0D //=0D // Check the alignment of work space address and length, they = should be block size aligned when work space size is larger than one block = size.=0D //=0D @@ -1173,8 +1175,9 @@ FindFvbForFtw ( //=0D // Check the alignment of spare area address and length, they sh= ould be block size aligned=0D //=0D - if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize -= 1)) !=3D 0) ||=0D - ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - = 1)) !=3D 0))=0D + if ((!PcdGetBool (PcdMemoryMappedBootMedia)) &&=0D + (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize = - 1)) !=3D 0) ||=0D + ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize -= 1)) !=3D 0)))=0D {=0D DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not= block size aligned\n"));=0D FreePool (HandleBuffer);=0D --=20 2.32.0