]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFfs/GenFfs.c
BaseTools: extend FFS alignment to 16M
[mirror_edk2.git] / BaseTools / Source / C / GenFfs / GenFfs.c
index eaef8a2232286b6d20e29265814fd11196c3840c..cb16f385eec2f55f4d7226461371c47006b907f1 100644 (file)
@@ -50,14 +50,17 @@ STATIC CHAR8 *mFfsFileType[] = {
 \r
 STATIC CHAR8 *mAlignName[] = {\r
   "1", "2", "4", "8", "16", "32", "64", "128", "256", "512",\r
-  "1K", "2K", "4K", "8K", "16K", "32K", "64K"\r
+  "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K",\r
+  "512K", "1M", "2M", "4M", "8M", "16M"\r
  };\r
 \r
 STATIC CHAR8 *mFfsValidAlignName[] = {\r
-  "8", "16", "128", "512", "1K", "4K", "32K", "64K"\r
+  "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K","256K",\r
+  "512K", "1M", "2M", "4M", "8M", "16M"\r
  };\r
 \r
-STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536};\r
+STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536, 131072, 262144,\r
+                                  524288, 1048576, 2097152, 4194304, 8388608, 16777216};\r
 \r
 STATIC EFI_GUID mZeroGuid = {0};\r
 \r
@@ -144,12 +147,13 @@ Returns:
   fprintf (stdout, "  -s, --checksum        Indicates to calculate file checksum.\n");\r
   fprintf (stdout, "  -a FileAlign, --align FileAlign\n\\r
                         FileAlign points to file alignment, which only support\n\\r
-                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n");\r
+                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n\\r
+                        128K,256K,512K,1M,2M,4M,8M,16M\n");\r
   fprintf (stdout, "  -i SectionFile, --sectionfile SectionFile\n\\r
                         Section file will be contained in this FFS file.\n");\r
   fprintf (stdout, "  -n SectionAlign, --sectionalign SectionAlign\n\\r
                         SectionAlign points to section alignment, which support\n\\r
-                        the alignment scope 1~64K. It is specified together\n\\r
+                        the alignment scope 1~16M. It is specified together\n\\r
                         with sectionfile to point its alignment in FFS file.\n");\r
   fprintf (stdout, "  -v, --verbose         Turn on verbose output with informational messages.\n");\r
   fprintf (stdout, "  -q, --quiet           Disable all messages except key message and fatal error\n");\r
@@ -168,7 +172,7 @@ StringtoAlignment (
 \r
 Routine Description:\r
 \r
-  Converts Align String to align value (1~64K). \r
+  Converts Align String to align value (1~16M).\r
 \r
 Arguments:\r
 \r
@@ -893,7 +897,12 @@ Returns:
   }\r
   VerboseMsg ("the size of the generated FFS file is %u bytes", (unsigned) FileSize);\r
 \r
-  FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));\r
+  //FfsAlign larger than 7, set FFS_ATTRIB_DATA_ALIGNMENT2\r
+  if (FfsAlign < 8) {\r
+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));\r
+  } else {\r
+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | ((FfsAlign & 0x7) << 3) | FFS_ATTRIB_DATA_ALIGNMENT2);\r
+  }\r
 \r
   //\r
   // Fill in checksums and state, these must be zero for checksumming\r