]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Modify GenFvImage tool to record the largest alignment of all the FFS files in the...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 31 Oct 2006 08:28:18 +0000 (08:28 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 31 Oct 2006 08:28:18 +0000 (08:28 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1876 6f19259b-4bc3-4df7-8a09-765794883524

Tools/CCode/Source/GenFvImage/GenFvImageLib.c

index eb36663b8dc411f93bb05ac96fe3fce65bfad4b4..45d4c8e848bf7897829e4e431c8feb1ba2c60b3a 100644 (file)
@@ -48,7 +48,7 @@ Abstract:
 #include "EfiCompress.h"\r
 #include "WinNtInclude.h"\r
 \r
 #include "EfiCompress.h"\r
 #include "WinNtInclude.h"\r
 \r
-\r
+static UINT32 MaxFfsAlignment = 0;\r
 //\r
 // Local function prototypes\r
 //\r
 //\r
 // Local function prototypes\r
 //\r
@@ -1031,9 +1031,9 @@ Returns:
 \r
   case 0:\r
     //\r
 \r
   case 0:\r
     //\r
-    // 1 byte alignment\r
+    // 8 byte alignment, mini alignment requirement for FFS file. \r
     //\r
     //\r
-    *Alignment = (1 << 0);\r
+    *Alignment = (1 << 3);\r
     break;\r
 \r
   case 1:\r
     break;\r
 \r
   case 1:\r
@@ -1741,6 +1741,13 @@ Returns:
     free (FileBuffer);\r
     return EFI_ABORTED;\r
   }\r
     free (FileBuffer);\r
     return EFI_ABORTED;\r
   }\r
+  \r
+  //\r
+  // Find the largest alignment of all the FFS files in the FV\r
+  //\r
+  if (CurrentFileAlignment > MaxFfsAlignment) {\r
+    MaxFfsAlignment = CurrentFileAlignment;\r
+  }\r
   //\r
   // Add pad file if necessary\r
   //\r
   //\r
   // Add pad file if necessary\r
   //\r
@@ -2644,6 +2651,31 @@ Returns:
   // Determine final Sym file size\r
   //\r
   *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;\r
   // Determine final Sym file size\r
   //\r
   *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;\r
+  \r
+  //\r
+  // Update FV Alignment attribute to the largest alignment of all the FFS files in the FV\r
+  //\r
+  if (FvHeader->Attributes | EFI_FVB_ALIGNMENT_CAP) {\r
+    for (Index = 1; Index <= 16; Index ++) {\r
+      if ((1 << Index) < MaxFfsAlignment) {\r
+        //\r
+        // Unset the unsupported alignment attribute.\r
+        //\r
+        FvHeader->Attributes = FvHeader->Attributes & ~((1 << Index) * EFI_FVB_ALIGNMENT_CAP);\r
+      } else {\r
+        //\r
+        // Set the supported alignment attribute.\r
+        //\r
+        FvHeader->Attributes = FvHeader->Attributes | ((1 << Index) * EFI_FVB_ALIGNMENT_CAP);\r
+      }\r
+    }\r
+    \r
+    //\r
+    // Update Checksum for FvHeader\r
+    //\r
+    FvHeader->Checksum      = 0;\r
+    FvHeader->Checksum      = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r