* [Patch] BaseTools GenFv: Report the correct spare FV image size
@ 2020-06-09 8:16 Liming Gao
2020-06-11 13:41 ` Bob Feng
0 siblings, 1 reply; 2+ messages in thread
From: Liming Gao @ 2020-06-09 8:16 UTC (permalink / raw)
To: devel; +Cc: Bob Feng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2790
If the top FFS is placed in FV image, current FV will show there is no space.
In fact, the pad ffs in FV image can be regarded as the spare space.
This change reports the max pad ffs size as the spare space for use.
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
---
BaseTools/Source/C/GenFv/GenFvInternalLib.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index d29a891c9c..b5ffed93a9 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -3140,6 +3140,7 @@ Returns:
--*/
{
UINTN CurrentOffset;
+ UINTN OrigOffset;
UINTN Index;
FILE *fpin;
UINTN FfsFileSize;
@@ -3148,8 +3149,10 @@ Returns:
UINT32 FfsHeaderSize;
EFI_FFS_FILE_HEADER FfsHeader;
UINTN VtfFileSize;
+ UINTN MaxPadFileSize;
FvExtendHeaderSize = 0;
+ MaxPadFileSize = 0;
VtfFileSize = 0;
fpin = NULL;
Index = 0;
@@ -3258,8 +3261,12 @@ Returns:
//
// Only EFI_FFS_FILE_HEADER is needed for a pad section.
//
+ OrigOffset = CurrentOffset;
CurrentOffset = (CurrentOffset + FfsHeaderSize + sizeof(EFI_FFS_FILE_HEADER) + FfsAlignment - 1) & ~(FfsAlignment - 1);
CurrentOffset -= FfsHeaderSize;
+ if ((CurrentOffset - OrigOffset) > MaxPadFileSize) {
+ MaxPadFileSize = CurrentOffset - OrigOffset;
+ }
}
}
@@ -3303,6 +3310,12 @@ Returns:
//
mFvTotalSize = FvInfoPtr->Size;
mFvTakenSize = CurrentOffset;
+ if ((mFvTakenSize == mFvTotalSize) && (MaxPadFileSize > 0)) {
+ //
+ // This FV means TOP FFS has been taken. Then, check whether there is padding data for use.
+ //
+ mFvTakenSize = mFvTakenSize - MaxPadFileSize;
+ }
return EFI_SUCCESS;
}
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] BaseTools GenFv: Report the correct spare FV image size
2020-06-09 8:16 [Patch] BaseTools GenFv: Report the correct spare FV image size Liming Gao
@ 2020-06-11 13:41 ` Bob Feng
0 siblings, 0 replies; 2+ messages in thread
From: Bob Feng @ 2020-06-11 13:41 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Gao, Liming <liming.gao@intel.com>
Sent: Tuesday, June 9, 2020 4:17 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>
Subject: [Patch] BaseTools GenFv: Report the correct spare FV image size
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2790
If the top FFS is placed in FV image, current FV will show there is no space.
In fact, the pad ffs in FV image can be regarded as the spare space.
This change reports the max pad ffs size as the spare space for use.
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
---
BaseTools/Source/C/GenFv/GenFvInternalLib.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index d29a891c9c..b5ffed93a9 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -3140,6 +3140,7 @@ Returns:
--*/
{
UINTN CurrentOffset;
+ UINTN OrigOffset;
UINTN Index;
FILE *fpin;
UINTN FfsFileSize;
@@ -3148,8 +3149,10 @@ Returns:
UINT32 FfsHeaderSize;
EFI_FFS_FILE_HEADER FfsHeader;
UINTN VtfFileSize;
+ UINTN MaxPadFileSize;
FvExtendHeaderSize = 0;
+ MaxPadFileSize = 0;
VtfFileSize = 0;
fpin = NULL;
Index = 0;
@@ -3258,8 +3261,12 @@ Returns:
//
// Only EFI_FFS_FILE_HEADER is needed for a pad section.
//
+ OrigOffset = CurrentOffset;
CurrentOffset = (CurrentOffset + FfsHeaderSize + sizeof(EFI_FFS_FILE_HEADER) + FfsAlignment - 1) & ~(FfsAlignment - 1);
CurrentOffset -= FfsHeaderSize;
+ if ((CurrentOffset - OrigOffset) > MaxPadFileSize) {
+ MaxPadFileSize = CurrentOffset - OrigOffset;
+ }
}
}
@@ -3303,6 +3310,12 @@ Returns:
//
mFvTotalSize = FvInfoPtr->Size;
mFvTakenSize = CurrentOffset;
+ if ((mFvTakenSize == mFvTotalSize) && (MaxPadFileSize > 0)) {
+ //
+ // This FV means TOP FFS has been taken. Then, check whether there is padding data for use.
+ //
+ mFvTakenSize = mFvTakenSize - MaxPadFileSize; }
return EFI_SUCCESS;
}
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-11 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-09 8:16 [Patch] BaseTools GenFv: Report the correct spare FV image size Liming Gao
2020-06-11 13:41 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox