public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] MdeModulePkg/FaultTolerantWriteDxe: Add Pcd for Memory Mapped Boot Media
@ 2022-02-26 22:52 Sean Rhodes
  2022-02-26 22:52 ` [PATCH 2/2] UefiPayloadPkg: Hookup Memory Mapped Media Sean Rhodes
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Rhodes @ 2022-02-26 22:52 UTC (permalink / raw)
  To: devel; +Cc: guo.dong, Sean Rhodes, Hao A Wu, Liming Gao

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] UefiPayloadPkg: Hookup Memory Mapped Media
  2022-02-26 22:52 [PATCH 1/2] MdeModulePkg/FaultTolerantWriteDxe: Add Pcd for Memory Mapped Boot Media Sean Rhodes
@ 2022-02-26 22:52 ` Sean Rhodes
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Rhodes @ 2022-02-26 22:52 UTC (permalink / raw)
  To: devel; +Cc: guo.dong, Sean Rhodes, Ray Ni, Maurice Ma, Benjamin You

Hook MEMORY_MAPPED_MEDIA build option to PcdMemoryMappedBootMedia PCD.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 1ce96a51c1..5b5b290d24 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -33,6 +33,7 @@
   DEFINE UNIVERSAL_PAYLOAD            = FALSE
   DEFINE SECURITY_STUB_ENABLE         = TRUE
   DEFINE SMM_SUPPORT                  = FALSE
+  DIFINE MEMORY_MAPPED_MEDIA          = FALSE
   #
   # SBL:      UEFI payload for Slim Bootloader
   # COREBOOT: UEFI payload for coreboot
@@ -398,6 +399,7 @@
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask       | 0x1
 !endif
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryMappedBootMedia|$(MEMORY_MAPPED_MEDIA)
 
 [PcdsPatchableInModule.X64]
   gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-26 22:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-26 22:52 [PATCH 1/2] MdeModulePkg/FaultTolerantWriteDxe: Add Pcd for Memory Mapped Boot Media Sean Rhodes
2022-02-26 22:52 ` [PATCH 2/2] UefiPayloadPkg: Hookup Memory Mapped Media Sean Rhodes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox