summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-31 08:28:18 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-31 08:28:18 +0000
commitd3f75347729a8d5f151a20d60fcc68e673b74da3 (patch)
tree6cd03fb991499846307895ac9a389ba705da11cc /Tools
parentd66974717c9c3bd658701908a0549a87ef42fd55 (diff)
downloadedk2-platforms-d3f75347729a8d5f151a20d60fcc68e673b74da3.tar.xz
Modify GenFvImage tool to record the largest alignment of all the FFS files in the FV to FvHeader alignment attribute.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1876 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CCode/Source/GenFvImage/GenFvImageLib.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/Tools/CCode/Source/GenFvImage/GenFvImageLib.c b/Tools/CCode/Source/GenFvImage/GenFvImageLib.c
index eb36663b8d..45d4c8e848 100644
--- a/Tools/CCode/Source/GenFvImage/GenFvImageLib.c
+++ b/Tools/CCode/Source/GenFvImage/GenFvImageLib.c
@@ -48,7 +48,7 @@ Abstract:
#include "EfiCompress.h"
#include "WinNtInclude.h"
-
+static UINT32 MaxFfsAlignment = 0;
//
// Local function prototypes
//
@@ -1031,9 +1031,9 @@ Returns:
case 0:
//
- // 1 byte alignment
+ // 8 byte alignment, mini alignment requirement for FFS file.
//
- *Alignment = (1 << 0);
+ *Alignment = (1 << 3);
break;
case 1:
@@ -1741,6 +1741,13 @@ Returns:
free (FileBuffer);
return EFI_ABORTED;
}
+
+ //
+ // Find the largest alignment of all the FFS files in the FV
+ //
+ if (CurrentFileAlignment > MaxFfsAlignment) {
+ MaxFfsAlignment = CurrentFileAlignment;
+ }
//
// Add pad file if necessary
//
@@ -2644,6 +2651,31 @@ Returns:
// Determine final Sym file size
//
*SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;
+
+ //
+ // Update FV Alignment attribute to the largest alignment of all the FFS files in the FV
+ //
+ if (FvHeader->Attributes | EFI_FVB_ALIGNMENT_CAP) {
+ for (Index = 1; Index <= 16; Index ++) {
+ if ((1 << Index) < MaxFfsAlignment) {
+ //
+ // Unset the unsupported alignment attribute.
+ //
+ FvHeader->Attributes = FvHeader->Attributes & ~((1 << Index) * EFI_FVB_ALIGNMENT_CAP);
+ } else {
+ //
+ // Set the supported alignment attribute.
+ //
+ FvHeader->Attributes = FvHeader->Attributes | ((1 << Index) * EFI_FVB_ALIGNMENT_CAP);
+ }
+ }
+
+ //
+ // Update Checksum for FvHeader
+ //
+ FvHeader->Checksum = 0;
+ FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
+ }
return EFI_SUCCESS;
}