public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging][PATCH] BaseTools/FMMT: Fix FV add FFs issue
@ 2020-04-21  3:21 Feng, YunhuaX
  0 siblings, 0 replies; only message in thread
From: Feng, YunhuaX @ 2020-04-21  3:21 UTC (permalink / raw)
  To: devel@edk2.groups.io; +Cc: Gao, Liming, Feng, Bob C

when Fv not include any FFS, will encounter not enough space to add issue.

Change-Id: Ie401f0edcf3f9b6bcae706a877b284e840f61fe9
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
index 415096742d..59fda0b729 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
@@ -477,10 +477,12 @@ AddFfs(UINT8 *FdBuffer, UINT32 ImageAddress, EFI_FIRMWARE_VOLUME_HEADER* Fv, EFI
   UINTN Offset;
   UINTN FfsSize;
   EFI_STATUS Status;
   EFI_FFS_FILE_HEADER2 *CurrentFile;
   EFI_FFS_FILE_HEADER FreeHeader;
+  EFI_FIRMWARE_VOLUME_HEADER* hdr;
+  EFI_FIRMWARE_VOLUME_EXT_HEADER * FwVolExtHeader;

   if (Fv->Attributes & EFI_FVB2_ERASE_POLARITY) {
     memset(&FreeHeader, -1, sizeof(EFI_FFS_FILE_HEADER));
   }
   else {
@@ -499,10 +501,20 @@ AddFfs(UINT8 *FdBuffer, UINT32 ImageAddress, EFI_FIRMWARE_VOLUME_HEADER* Fv, EFI
       //
       FreeOffset = (UINTN)ALIGN_POINTER(Offset, 8);
     }
     Status = FvBufFindNextFile(FdBuffer + ImageAddress, &Offset, (VOID **)&CurrentFile);
     if (Status == EFI_NOT_FOUND) {
+      if (FreeOffset == 0) {
+        hdr = ( EFI_FIRMWARE_VOLUME_HEADER*)((UINT8*)FdBuffer + ImageAddress);
+        if (hdr->ExtHeaderOffset != 0) {
+          FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)hdr + hdr->ExtHeaderOffset);
+          FreeOffset = (UINTN)hdr->ExtHeaderOffset + FwVolExtHeader->ExtHeaderSize;
+          FreeOffset = (UINTN)ALIGN_POINTER(FreeOffset, 8);
+        } else {
+          FreeOffset = hdr->HeaderLength;
+        }
+      }
       CurrentFile = NULL;
       break;
     }
     else if (EFI_ERROR(Status)) {
       return Status;
--
2.12.2.windows.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-21  3:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-21  3:21 [edk2-staging][PATCH] BaseTools/FMMT: Fix FV add FFs issue Feng, YunhuaX

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