From: "Sean Rhodes" <sean@starlabs.systems>
To: devel@edk2.groups.io
Cc: guo.dong@intel.com, Sean Rhodes <sean@starlabs.systems>,
Hao A Wu <hao.a.wu@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH 1/2] MdeModulePkg/FaultTolerantWriteDxe: Add Pcd for Memory Mapped Boot Media
Date: Sat, 26 Feb 2022 22:52:05 +0000 [thread overview]
Message-ID: <5a7b0fa09948fd239dde8d9bc688b43a70545e58.1645915926.git.sean@starlabs.systems> (raw)
Add PCD PcdMemoryMappedBootMedia to indiciate if Boot Media is memory mapped.
If set to true, don't check for Block Alignment as it is not necessary.
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
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.
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
+ ## Indicates if the Boot Media is memory mapped.
+ # If enabled, don't check for block alignent as it is not necessary.
+ # TRUE - Do not check for block aligment.
+ # FALSE - Check for block alignment.
+ # @Prompt Boot Media Memory Mapped.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia|FALSE|BOOLEAN|0x30001058
+
[PcdsFixedAtBuild, PcdsPatchableInModule]
## Dynamic type PCD can be registered callback function for Pcd setting action.
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
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.<BR>"
" FALSE - Capsule In Ram is not supported."
+#string STR_gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia_PROMPT #language en-US "Boot Media is memory mapped."
+
+#string STR_gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia_HELP #language en-US "Indicates if the Boot Media is memory mapped."
+
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_PROMPT #language en-US "Capsule On Disk relocation device path."
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_HELP #language en-US "Full device path of platform specific device to store Capsule On Disk temp relocation file.<BR>"
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
index 96165614d1..b3209567d9 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
@@ -72,6 +72,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia ## CONSUMES
#
# gBS->CalculateCrc32() is consumed in EntryPoint.
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeModulePkg/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 = BlockSize;
FtwDevice->FtwWorkSpaceBase = (UINTN)(FtwDevice->WorkSpaceAddress - (FvbBaseAddress + FtwDevice->WorkBlockSize * (LbaIndex - 1)));
FtwDevice->NumberOfWorkSpaceBlock = FTW_BLOCKS (FtwDevice->FtwWorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize);
- if (FtwDevice->FtwWorkSpaceSize >= FtwDevice->WorkBlockSize) {
+ if ((!PcdGetBool (PcdMemoryMappedBootMedia)) &&
+ (FtwDevice->FtwWorkSpaceSize >= FtwDevice->WorkBlockSize))
+ {
//
// 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.
//
@@ -1173,8 +1175,9 @@ FindFvbForFtw (
//
// Check the alignment of spare area address and length, they should be block size aligned
//
- if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize - 1)) != 0) ||
- ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0))
+ if ((!PcdGetBool (PcdMemoryMappedBootMedia)) &&
+ (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize - 1)) != 0) ||
+ ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0)))
{
DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
FreePool (HandleBuffer);
--
2.32.0
next reply other threads:[~2022-02-26 22:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-26 22:52 Sean Rhodes [this message]
2022-02-26 22:52 ` [PATCH 2/2] UefiPayloadPkg: Hookup Memory Mapped Media Sean Rhodes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5a7b0fa09948fd239dde8d9bc688b43a70545e58.1645915926.git.sean@starlabs.systems \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox