From d3f75347729a8d5f151a20d60fcc68e673b74da3 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 31 Oct 2006 08:28:18 +0000 Subject: [PATCH] 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 --- Tools/CCode/Source/GenFvImage/GenFvImageLib.c | 38 +++++++++++++++++-- 1 file 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; } -- 2.39.2