X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FCCode%2FSource%2FGenFvImage%2FGenFvImageLib.c;h=45d4c8e848bf7897829e4e431c8feb1ba2c60b3a;hp=eb36663b8dc411f93bb05ac96fe3fce65bfad4b4;hb=d3f75347729a8d5f151a20d60fcc68e673b74da3;hpb=d66974717c9c3bd658701908a0549a87ef42fd55 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; }