public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: extend FFS alignment to 16M
@ 2017-09-21  6:01 Yonghong Zhu
  2017-09-21  8:05 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-09-21  6:01 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

Current FFS only supports 64KiB alignment for data, Per PI 1.6
requirement, we extend FFS alignment to 16M.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/GenFfs/GenFfs.c                 | 19 +++++--
 BaseTools/Source/C/GenFv/GenFvInternalLib.c        | 60 ++++++++++++++++++----
 BaseTools/Source/C/GenSec/GenSec.c                 |  5 +-
 BaseTools/Source/C/Include/Common/PiFirmwareFile.h |  3 +-
 BaseTools/Source/Python/Common/FdfParserLite.py    | 20 +++++---
 BaseTools/Source/Python/GenFds/DataSection.py      |  6 ++-
 BaseTools/Source/Python/GenFds/EfiSection.py       |  6 ++-
 BaseTools/Source/Python/GenFds/FdfParser.py        | 24 ++++++---
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  | 10 ++--
 BaseTools/Source/Python/GenFds/Fv.py               |  9 ++--
 BaseTools/Source/Python/GenFds/FvImageSection.py   | 20 +++++---
 .../Source/Python/GenFds/GenFdsGlobalVariable.py   |  8 +--
 12 files changed, 137 insertions(+), 53 deletions(-)

diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
index eaef8a2..4ecfe99 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -48,18 +48,21 @@ STATIC CHAR8 *mFfsFileType[] = {
   "EFI_FV_FILETYPE_MM_CORE_STANDALONE"    // 0x0F
 };
 
 STATIC CHAR8 *mAlignName[] = {
   "1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
-  "1K", "2K", "4K", "8K", "16K", "32K", "64K"
+  "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K",
+  "512K", "1M", "2M", "4M", "8M", "16M"
  };
 
 STATIC CHAR8 *mFfsValidAlignName[] = {
-  "8", "16", "128", "512", "1K", "4K", "32K", "64K"
+  "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K","256K",
+  "512K", "1M", "2M", "4M", "8M", "16M"
  };
 
-STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536};
+STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536, 131072, 262144,
+                                  524288, 1048576, 2097152, 4194304, 8388608, 16777216};
 
 STATIC EFI_GUID mZeroGuid = {0};
 
 STATIC EFI_GUID mEfiFfsSectionAlignmentPaddingGuid = EFI_FFS_SECTION_ALIGNMENT_PADDING_GUID;
 
@@ -142,11 +145,12 @@ Returns:
   fprintf (stdout, "  -x, --fixed           Indicates that the file may not be moved\n\
                         from its present location.\n");
   fprintf (stdout, "  -s, --checksum        Indicates to calculate file checksum.\n");
   fprintf (stdout, "  -a FileAlign, --align FileAlign\n\
                         FileAlign points to file alignment, which only support\n\
-                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n");
+                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n\
+                        128K,256K,512K,1M,2M,4M,8M,16M");
   fprintf (stdout, "  -i SectionFile, --sectionfile SectionFile\n\
                         Section file will be contained in this FFS file.\n");
   fprintf (stdout, "  -n SectionAlign, --sectionalign SectionAlign\n\
                         SectionAlign points to section alignment, which support\n\
                         the alignment scope 1~64K. It is specified together\n\
@@ -891,11 +895,16 @@ Returns:
     FfsFileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);
     FfsFileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);
   }
   VerboseMsg ("the size of the generated FFS file is %u bytes", (unsigned) FileSize);
 
-  FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));
+  //FfsAlign larger than 7, set FFS_ATTRIB_DATA_ALIGNMENT2
+  if (FfsAlign < 8) {
+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));
+  } else {
+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | ((FfsAlign & 0x7) << 3) | FFS_ATTRIB_DATA_ALIGNMENT2);
+  }
 
   //
   // Fill in checksums and state, these must be zero for checksumming
   //
   // FileHeader.IntegrityCheck.Checksum.Header = 0;
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 8072c01..01c862e 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1,9 +1,9 @@
 /** @file
 This file contains the internal functions required to generate a Firmware Volume.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
 Portions Copyright (c) 2016 HP Development Company, L.P.<BR>
 This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution.  The full text of the license may be found at        
@@ -462,61 +462,101 @@ Returns:
   switch ((FfsFile->Attributes >> 3) & 0x07) {
 
   case 0:
     //
     // 1 byte alignment
+    //if bit 1 have set, 128K byte alignmnet
     //
-    *Alignment = 0;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 17;
+    } else {
+      *Alignment = 0;
+    }
     break;
 
   case 1:
     //
     // 16 byte alignment
+    //if bit 1 have set, 256K byte alignment
     //
-    *Alignment = 4;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 18;
+    } else {
+      *Alignment = 4;
+    }
     break;
 
   case 2:
     //
     // 128 byte alignment
+    //if bit 1 have set, 512K byte alignment
     //
-    *Alignment = 7;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 19;
+    } else {
+      *Alignment = 7;
+    }
     break;
 
   case 3:
     //
     // 512 byte alignment
+    //if bit 1 have set, 1M byte alignment
     //
-    *Alignment = 9;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 20;
+    } else {
+      *Alignment = 9;
+    }
     break;
 
   case 4:
     //
     // 1K byte alignment
+    //if bit 1 have set, 2M byte alignment
     //
-    *Alignment = 10;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 21;
+    } else {
+      *Alignment = 10;
+    }
     break;
 
   case 5:
     //
     // 4K byte alignment
+    //if bit 1 have set, 4M byte alignment
     //
-    *Alignment = 12;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 22;
+    } else {
+      *Alignment = 12;
+    }
     break;
 
   case 6:
     //
     // 32K byte alignment
+    //if bit 1 have set , 8M byte alignment
     //
-    *Alignment = 15;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 23;
+    } else {
+      *Alignment = 15;
+    }
     break;
 
   case 7:
     //
     // 64K byte alignment
+    //if bit 1 have set, 16M alignment
     //
-    *Alignment = 16;
+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
+      *Alignment = 24;
+    } else {
+      *Alignment = 16;
+    }
     break;
 
   default:
     break;
   }
@@ -1058,11 +1098,11 @@ Returns:
 
   //
   // Clear the alignment bits: these have become meaningless now that we have
   // adjusted the padding section.
   //
-  FfsFile->Attributes &= ~FFS_ATTRIB_DATA_ALIGNMENT;
+  FfsFile->Attributes &= ~(FFS_ATTRIB_DATA_ALIGNMENT | FFS_ATTRIB_DATA_ALIGNMENT2);
 
   //
   // Recalculate the FFS header checksum. Instead of setting Header and State
   // both to zero, set Header to (UINT8)(-State) so State preserves its original
   // value
diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
index c0e4de2..6169ae2 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -72,11 +72,12 @@ STATIC CHAR8      *mCompressionTypeName[]    = { "PI_NONE", "PI_STD" };
 #define EFI_GUIDED_SECTION_NONE 0x80
 STATIC CHAR8      *mGUIDedSectionAttribue[]  = { "NONE", "PROCESSING_REQUIRED", "AUTH_STATUS_VALID"};
 
 STATIC CHAR8 *mAlignName[] = {
   "1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
-  "1K", "2K", "4K", "8K", "16K", "32K", "64K"
+  "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K",
+  "512K", "1M", "2M", "4M", "8M", "16M"
 };
 
 //
 // Crc32 GUID section related definitions.
 //
@@ -182,11 +183,11 @@ Returns:
   fprintf (stdout, "  -j Number, --buildnumber Number\n\
                         Number is an integer value between 0 and 65535\n\
                         used in Ver section.\n");
   fprintf (stdout, "  --sectionalign SectionAlign\n\
                         SectionAlign points to section alignment, which support\n\
-                        the alignment scope 1~64K. It is specified in same\n\
+                        the alignment scope 1~16M. It is specified in same\n\
                         order that the section file is input.\n");
   fprintf (stdout, "  -v, --verbose         Turn on verbose output with informational messages.\n");
   fprintf (stdout, "  -q, --quiet           Disable all messages except key message and fatal error\n");
   fprintf (stdout, "  -d, --debug level     Enable debug messages, at input debug level.\n");
   fprintf (stdout, "  --version             Show program's version number and exit.\n");
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
index 8c54021..133c88c 100644
--- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
+++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
@@ -2,11 +2,11 @@
   The firmware file related definitions in PI.
   
   @par Revision Reference:
   Version 1.4.
 
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution.  The full text of the license may be found at
     http://opensource.org/licenses/bsd-license.php
@@ -63,10 +63,11 @@ typedef UINT8 EFI_FFS_FILE_STATE;
 #define EFI_FV_FILETYPE_FFS_PAD               0xf0
 // 
 // FFS File Attributes.
 // 
 #define FFS_ATTRIB_LARGE_FILE         0x01
+#define FFS_ATTRIB_DATA_ALIGNMENT2    0x02
 #define FFS_ATTRIB_FIXED              0x04
 #define FFS_ATTRIB_DATA_ALIGNMENT     0x38
 #define FFS_ATTRIB_CHECKSUM           0x40
 //
 // FFS_FIXED_CHECKSUM is the checksum value used when the
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py
index 8e68a67..7d129bf 100644
--- a/BaseTools/Source/Python/Common/FdfParserLite.py
+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
@@ -1,9 +1,9 @@
 ## @file
 # parse FDF file
 #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -2338,11 +2338,12 @@ class FdfParser(object):
             else:
                 return False
         
         AlignValue = None
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             AlignValue = self.__Token
             
         BuildNum = None
         if self.__IsKeyword( "BUILD_NUM"):
@@ -2606,11 +2607,12 @@ class FdfParser(object):
             else:
                 return False
         
         AlignValue = None
         if self.__GetAlignment():
-            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             AlignValue = self.__Token
             
         if not self.__GetCglSection(FfsFileObj, AlignValue):
             self.SetFileBufferPos(OldPos)
@@ -2922,11 +2924,12 @@ class FdfParser(object):
         if self.__IsKeyword("CheckSum", True):
             CheckSum = True
             
         AlignValue = ""
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
             AlignValue = self.__Token
 
         if self.__IsToken("{"):
             # Complex file rule expected
@@ -2986,11 +2989,12 @@ class FdfParser(object):
     
             if self.__IsKeyword("CheckSum", True):
                 CheckSum = True
     
             if self.__GetAlignment():
-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                     raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
                 if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
                     raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
                 AlignValue = self.__Token
             
@@ -3060,11 +3064,12 @@ class FdfParser(object):
                 if not self.__IsKeyword("FV"):
                     raise Warning("expected 'FV' At Line ", self.FileName, self.CurrentLineNumber)
                 FvImageSectionObj.FvFileType = self.__Token
                 
                 if self.__GetAlignment():
-                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                            "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                         raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
                     FvImageSectionObj.Alignment = self.__Token
                 
                 if self.__IsToken('|'):
                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
@@ -3127,11 +3132,12 @@ class FdfParser(object):
                 if not self.__GetNextToken():
                     raise Warning("expected Build number At Line ", self.FileName, self.CurrentLineNumber)
                 EfiSectionObj.BuildNum = self.__Token
                 
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             EfiSectionObj.Alignment = self.__Token
         
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index ba3677e..78c0af4 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -1,9 +1,9 @@
 ## @file
 # process data section generation
 #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -77,12 +77,14 @@ class DataSection (DataSectionClassObject):
         #Get PE Section alignment when align is set to AUTO
         if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
             ImageObj = PeImageClass (Filename)
             if ImageObj.SectionAlignment < 0x400:
                 self.Alignment = str (ImageObj.SectionAlignment)
-            else:
+            elif ImageObj.SectionAlignment < 0x100000:
                 self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
+            else:
+                self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
         NoStrip = True
         if self.SecType in ('TE', 'PE32'):
             if self.KeepReloc != None:
                 NoStrip = self.KeepReloc
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 09fb28f..7da3c1e 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -1,9 +1,9 @@
 ## @file
 # process rule section generation
 #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -229,12 +229,14 @@ class EfiSection (EfiSectionClassObject):
                     #Get PE Section alignment when align is set to AUTO
                     if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
                         ImageObj = PeImageClass (File)
                         if ImageObj.SectionAlignment < 0x400:
                             Align = str (ImageObj.SectionAlignment)
-                        else:
+                        elif ImageObj.SectionAlignment < 0x100000:
                             Align = str (ImageObj.SectionAlignment / 0x400) + 'K'
+                        else:
+                            Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
                     if File[(len(File)-4):] == '.efi':
                         MapFile = File.replace('.efi', '.map')
                         if os.path.exists(MapFile):
                             CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 8f49f9f..499d0a6 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2765,11 +2765,12 @@ class FdfParser:
         FfsFileObj.FileName = []
         FfsFileObj.SubAlignment = []
         while True:
             AlignValue = None
             if self.__GetAlignment():
-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
                 #For FFS, Auto is default option same to ""
                 if not self.__Token == "Auto":
                     AlignValue = self.__Token
             if not self.__GetNextToken():
@@ -2824,11 +2825,12 @@ class FdfParser:
 
         if self.__IsKeyword( "CHECKSUM", True):
             FfsFileObj.CheckSum = True
 
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             #For FFS, Auto is default option same to ""
             if not self.__Token == "Auto":
                 FfsFileObj.Alignment = self.__Token
 
@@ -2895,11 +2897,12 @@ class FdfParser:
             else:
                 return False
 
         AlignValue = None
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             AlignValue = self.__Token
 
         BuildNum = None
         if self.__IsKeyword( "BUILD_NUM"):
@@ -3184,11 +3187,12 @@ class FdfParser:
             else:
                 return False
 
         AlignValue = None
         if self.__GetAlignment():
-            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             AlignValue = self.__Token
 
         if not self.__GetCglSection(FfsFileObj, AlignValue):
             self.SetFileBufferPos(OldPos)
@@ -3775,11 +3779,12 @@ class FdfParser:
         if self.__IsKeyword("CheckSum", True):
             CheckSum = True
 
         AlignValue = ""
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             #For FFS, Auto is default option same to ""
             if not self.__Token == "Auto":
                 AlignValue = self.__Token
 
@@ -3824,11 +3829,12 @@ class FdfParser:
             if self.__IsKeyword("CheckSum", True):
                 CheckSum = True
 
             SectAlignment = ""
             if self.__GetAlignment():
-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
                 if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
                     raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
                 SectAlignment = self.__Token
 
@@ -3903,11 +3909,12 @@ class FdfParser:
                 if not self.__IsKeyword("FV"):
                     raise Warning("expected 'FV'", self.FileName, self.CurrentLineNumber)
                 FvImageSectionObj.FvFileType = self.__Token
 
                 if self.__GetAlignment():
-                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                            "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                         raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
                     FvImageSectionObj.Alignment = self.__Token
 
                 if self.__IsToken('|'):
                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
@@ -3970,11 +3977,12 @@ class FdfParser:
                 if not self.__GetNextToken():
                     raise Warning("expected Build number", self.FileName, self.CurrentLineNumber)
                 EfiSectionObj.BuildNum = self.__Token
 
         if self.__GetAlignment():
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
             if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             EfiSectionObj.Alignment = self.__Token
 
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index c61c227..958cecf 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -1,9 +1,9 @@
 ## @file
 # process FFS generation from INF statement
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #  Copyright (c) 2014-2016 Hewlett-Packard Development Company, L.P.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -729,12 +729,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 #Get PE Section alignment when align is set to AUTO
                 if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
                     ImageObj = PeImageClass (File)
                     if ImageObj.SectionAlignment < 0x400:
                         self.Alignment = str (ImageObj.SectionAlignment)
-                    else:
+                    elif ImageObj.SectionAlignment < 0x100000:
                         self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
+                    else:
+                        self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
                 if not NoStrip:
                     FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
                     if not os.path.exists(FileBeforeStrip) or \
                            (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
@@ -768,12 +770,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
             #Get PE Section alignment when align is set to AUTO
             if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
                 ImageObj = PeImageClass (GenSecInputFile)
                 if ImageObj.SectionAlignment < 0x400:
                     self.Alignment = str (ImageObj.SectionAlignment)
-                else:
+                elif ImageObj.SectionAlignment < 0x100000:
                     self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
+                else:
+                    self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
             if not NoStrip:
                 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
                 if not os.path.exists(FileBeforeStrip) or \
                        (os.path.getmtime(GenSecInputFile) > os.path.getmtime(FileBeforeStrip)):
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index f6ccb59..4b03adc 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -194,13 +194,16 @@ class FV (FvClassObject):
             FvHeaderBuffer = FvFileObj.read(0x48)
             # FV alignment position.
             FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
             # FvAlignmentValue is larger than or equal to 1K
             if FvAlignmentValue >= 0x400:
-                if FvAlignmentValue >= 0x10000:
-                    #The max alignment supported by FFS is 64K.
-                    self.FvAlignment = "64K"
+                if FvAlignmentValue >= 0x100000:
+                    #The max alignment supported by FFS is 16M.
+                    if FvAlignmentValue >= 0x1000000:
+                        self.FvAlignment = "16M"
+                    else:
+                        self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"
                 else:
                     self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"
             else:
                 # FvAlignmentValue is less than 1K
                 self.FvAlignment = str (FvAlignmentValue)
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 5989978..68f17c3 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -1,9 +1,9 @@
 ## @file
 # process FV image section generation
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -78,13 +78,16 @@ class FvImageSection(FvImageSectionClassObject):
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
                 OutputFileList.append(OutputFile)
 
             # MaxFvAlignment is larger than or equal to 1K
             if MaxFvAlignment >= 0x400:
-                if MaxFvAlignment >= 0x10000:
-                    #The max alignment supported by FFS is 64K.
-                    self.Alignment = "64K"
+                if MaxFvAlignment >= 0x100000:
+                    #The max alignment supported by FFS is 16M.
+                    if MaxFvAlignment >=1000000:
+                        self.Alignment = "16M"
+                    else:
+                        self.Alignment = str(MaxFvAlignment / 0x100000) + "M"
                 else:
                     self.Alignment = str (MaxFvAlignment / 0x400) + "K"
             else:
                 # MaxFvAlignment is less than 1K
                 self.Alignment = str (MaxFvAlignment)
@@ -115,13 +118,16 @@ class FvImageSection(FvImageSectionClassObject):
                         FvHeaderBuffer = FvFileObj.read(0x48)
                         # FV alignment position.
                         FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
                         # FvAlignmentValue is larger than or equal to 1K
                         if FvAlignmentValue >= 0x400:
-                            if FvAlignmentValue >= 0x10000:
-                                #The max alignment supported by FFS is 64K.
-                                self.Alignment = "64K"
+                            if FvAlignmentValue >= 0x100000:
+                                #The max alignment supported by FFS is 16M.
+                                if FvAlignmentValue >= 0x1000000:
+                                    self.Alignment = "16M"
+                                else:
+                                    self.Alignment = str(FvAlignmentValue / 0x100000) + "M"
                             else:
                                 self.Alignment = str (FvAlignmentValue / 0x400) + "K"
                         else:
                             # FvAlignmentValue is less than 1K
                             self.Alignment = str (FvAlignmentValue)
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index d02befe..83996be 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -1,9 +1,9 @@
 ## @file
 # Global variables for GenFds
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -418,20 +418,22 @@ class GenFdsGlobalVariable:
 
     @staticmethod
     def GetAlignment (AlignString):
         if AlignString == None:
             return 0
-        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K"):
+        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K"):
             return int (AlignString.rstrip('K')) * 1024
+        elif AlignString in ("1M", "2M", "4M", "8M", "16M"):
+            return int (AlignString.rstrip('M')) * 1024 * 1024
         else:
             return int (AlignString)
 
     @staticmethod
     def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,
                     SectionAlign=None):
         Cmd = ["GenFfs", "-t", Type, "-g", Guid]
-        mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K"]
+        mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]
         if Fixed == True:
             Cmd += ["-x"]
         if CheckSum:
             Cmd += ["-s"]
         if Align not in [None, '']:
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: extend FFS alignment to 16M
  2017-09-21  6:01 [Patch] BaseTools: extend FFS alignment to 16M Yonghong Zhu
@ 2017-09-21  8:05 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2017-09-21  8:05 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Thursday, September 21, 2017 2:01 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: extend FFS alignment to 16M
>
>Current FFS only supports 64KiB alignment for data, Per PI 1.6
>requirement, we extend FFS alignment to 16M.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/C/GenFfs/GenFfs.c                 | 19 +++++--
> BaseTools/Source/C/GenFv/GenFvInternalLib.c        | 60
>++++++++++++++++++----
> BaseTools/Source/C/GenSec/GenSec.c                 |  5 +-
> BaseTools/Source/C/Include/Common/PiFirmwareFile.h |  3 +-
> BaseTools/Source/Python/Common/FdfParserLite.py    | 20 +++++---
> BaseTools/Source/Python/GenFds/DataSection.py      |  6 ++-
> BaseTools/Source/Python/GenFds/EfiSection.py       |  6 ++-
> BaseTools/Source/Python/GenFds/FdfParser.py        | 24 ++++++---
> BaseTools/Source/Python/GenFds/FfsInfStatement.py  | 10 ++--
> BaseTools/Source/Python/GenFds/Fv.py               |  9 ++--
> BaseTools/Source/Python/GenFds/FvImageSection.py   | 20 +++++---
> .../Source/Python/GenFds/GenFdsGlobalVariable.py   |  8 +--
> 12 files changed, 137 insertions(+), 53 deletions(-)
>
>diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c
>b/BaseTools/Source/C/GenFfs/GenFfs.c
>index eaef8a2..4ecfe99 100644
>--- a/BaseTools/Source/C/GenFfs/GenFfs.c
>+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
>@@ -48,18 +48,21 @@ STATIC CHAR8 *mFfsFileType[] = {
>   "EFI_FV_FILETYPE_MM_CORE_STANDALONE"    // 0x0F
> };
>
> STATIC CHAR8 *mAlignName[] = {
>   "1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
>-  "1K", "2K", "4K", "8K", "16K", "32K", "64K"
>+  "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K",
>+  "512K", "1M", "2M", "4M", "8M", "16M"
>  };
>
> STATIC CHAR8 *mFfsValidAlignName[] = {
>-  "8", "16", "128", "512", "1K", "4K", "32K", "64K"
>+  "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K","256K",
>+  "512K", "1M", "2M", "4M", "8M", "16M"
>  };
>
>-STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536};
>+STATIC UINT32 mFfsValidAlign[] = {0, 8, 16, 128, 512, 1024, 4096, 32768, 65536,
>131072, 262144,
>+                                  524288, 1048576, 2097152, 4194304, 8388608, 16777216};
>
> STATIC EFI_GUID mZeroGuid = {0};
>
> STATIC EFI_GUID mEfiFfsSectionAlignmentPaddingGuid =
>EFI_FFS_SECTION_ALIGNMENT_PADDING_GUID;
>
>@@ -142,11 +145,12 @@ Returns:
>   fprintf (stdout, "  -x, --fixed           Indicates that the file may not be moved\n\
>                         from its present location.\n");
>   fprintf (stdout, "  -s, --checksum        Indicates to calculate file checksum.\n");
>   fprintf (stdout, "  -a FileAlign, --align FileAlign\n\
>                         FileAlign points to file alignment, which only support\n\
>-                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n");
>+                        the following align: 1,2,4,8,16,128,512,1K,4K,32K,64K\n\
>+                        128K,256K,512K,1M,2M,4M,8M,16M");
>   fprintf (stdout, "  -i SectionFile, --sectionfile SectionFile\n\
>                         Section file will be contained in this FFS file.\n");
>   fprintf (stdout, "  -n SectionAlign, --sectionalign SectionAlign\n\
>                         SectionAlign points to section alignment, which support\n\
>                         the alignment scope 1~64K. It is specified together\n\
>@@ -891,11 +895,16 @@ Returns:
>     FfsFileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);
>     FfsFileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);
>   }
>   VerboseMsg ("the size of the generated FFS file is %u bytes", (unsigned)
>FileSize);
>
>-  FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign
><< 3));
>+  //FfsAlign larger than 7, set FFS_ATTRIB_DATA_ALIGNMENT2
>+  if (FfsAlign < 8) {
>+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib |
>(FfsAlign << 3));
>+  } else {
>+    FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib |
>((FfsAlign & 0x7) << 3) | FFS_ATTRIB_DATA_ALIGNMENT2);
>+  }
>
>   //
>   // Fill in checksums and state, these must be zero for checksumming
>   //
>   // FileHeader.IntegrityCheck.Checksum.Header = 0;
>diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>index 8072c01..01c862e 100644
>--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>@@ -1,9 +1,9 @@
> /** @file
> This file contains the internal functions required to generate a Firmware
>Volume.
>
>-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
>+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
> Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
> Portions Copyright (c) 2016 HP Development Company, L.P.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
>License
> which accompanies this distribution.  The full text of the license may be found
>at
>@@ -462,61 +462,101 @@ Returns:
>   switch ((FfsFile->Attributes >> 3) & 0x07) {
>
>   case 0:
>     //
>     // 1 byte alignment
>+    //if bit 1 have set, 128K byte alignmnet
>     //
>-    *Alignment = 0;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 17;
>+    } else {
>+      *Alignment = 0;
>+    }
>     break;
>
>   case 1:
>     //
>     // 16 byte alignment
>+    //if bit 1 have set, 256K byte alignment
>     //
>-    *Alignment = 4;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 18;
>+    } else {
>+      *Alignment = 4;
>+    }
>     break;
>
>   case 2:
>     //
>     // 128 byte alignment
>+    //if bit 1 have set, 512K byte alignment
>     //
>-    *Alignment = 7;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 19;
>+    } else {
>+      *Alignment = 7;
>+    }
>     break;
>
>   case 3:
>     //
>     // 512 byte alignment
>+    //if bit 1 have set, 1M byte alignment
>     //
>-    *Alignment = 9;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 20;
>+    } else {
>+      *Alignment = 9;
>+    }
>     break;
>
>   case 4:
>     //
>     // 1K byte alignment
>+    //if bit 1 have set, 2M byte alignment
>     //
>-    *Alignment = 10;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 21;
>+    } else {
>+      *Alignment = 10;
>+    }
>     break;
>
>   case 5:
>     //
>     // 4K byte alignment
>+    //if bit 1 have set, 4M byte alignment
>     //
>-    *Alignment = 12;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 22;
>+    } else {
>+      *Alignment = 12;
>+    }
>     break;
>
>   case 6:
>     //
>     // 32K byte alignment
>+    //if bit 1 have set , 8M byte alignment
>     //
>-    *Alignment = 15;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 23;
>+    } else {
>+      *Alignment = 15;
>+    }
>     break;
>
>   case 7:
>     //
>     // 64K byte alignment
>+    //if bit 1 have set, 16M alignment
>     //
>-    *Alignment = 16;
>+    if (FfsFile->Attributes & FFS_ATTRIB_DATA_ALIGNMENT2) {
>+      *Alignment = 24;
>+    } else {
>+      *Alignment = 16;
>+    }
>     break;
>
>   default:
>     break;
>   }
>@@ -1058,11 +1098,11 @@ Returns:
>
>   //
>   // Clear the alignment bits: these have become meaningless now that we
>have
>   // adjusted the padding section.
>   //
>-  FfsFile->Attributes &= ~FFS_ATTRIB_DATA_ALIGNMENT;
>+  FfsFile->Attributes &= ~(FFS_ATTRIB_DATA_ALIGNMENT |
>FFS_ATTRIB_DATA_ALIGNMENT2);
>
>   //
>   // Recalculate the FFS header checksum. Instead of setting Header and State
>   // both to zero, set Header to (UINT8)(-State) so State preserves its original
>   // value
>diff --git a/BaseTools/Source/C/GenSec/GenSec.c
>b/BaseTools/Source/C/GenSec/GenSec.c
>index c0e4de2..6169ae2 100644
>--- a/BaseTools/Source/C/GenSec/GenSec.c
>+++ b/BaseTools/Source/C/GenSec/GenSec.c
>@@ -72,11 +72,12 @@ STATIC CHAR8      *mCompressionTypeName[]    =
>{ "PI_NONE", "PI_STD" };
> #define EFI_GUIDED_SECTION_NONE 0x80
> STATIC CHAR8      *mGUIDedSectionAttribue[]  = { "NONE",
>"PROCESSING_REQUIRED", "AUTH_STATUS_VALID"};
>
> STATIC CHAR8 *mAlignName[] = {
>   "1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
>-  "1K", "2K", "4K", "8K", "16K", "32K", "64K"
>+  "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K",
>+  "512K", "1M", "2M", "4M", "8M", "16M"
> };
>
> //
> // Crc32 GUID section related definitions.
> //
>@@ -182,11 +183,11 @@ Returns:
>   fprintf (stdout, "  -j Number, --buildnumber Number\n\
>                         Number is an integer value between 0 and 65535\n\
>                         used in Ver section.\n");
>   fprintf (stdout, "  --sectionalign SectionAlign\n\
>                         SectionAlign points to section alignment, which support\n\
>-                        the alignment scope 1~64K. It is specified in same\n\
>+                        the alignment scope 1~16M. It is specified in same\n\
>                         order that the section file is input.\n");
>   fprintf (stdout, "  -v, --verbose         Turn on verbose output with
>informational messages.\n");
>   fprintf (stdout, "  -q, --quiet           Disable all messages except key message
>and fatal error\n");
>   fprintf (stdout, "  -d, --debug level     Enable debug messages, at input debug
>level.\n");
>   fprintf (stdout, "  --version             Show program's version number and
>exit.\n");
>diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
>b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
>index 8c54021..133c88c 100644
>--- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
>+++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
>@@ -2,11 +2,11 @@
>   The firmware file related definitions in PI.
>
>   @par Revision Reference:
>   Version 1.4.
>
>-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
>+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
>
>   This program and the accompanying materials are licensed and made
>available
>   under the terms and conditions of the BSD License which accompanies this
>   distribution.  The full text of the license may be found at
>     http://opensource.org/licenses/bsd-license.php
>@@ -63,10 +63,11 @@ typedef UINT8 EFI_FFS_FILE_STATE;
> #define EFI_FV_FILETYPE_FFS_PAD               0xf0
> //
> // FFS File Attributes.
> //
> #define FFS_ATTRIB_LARGE_FILE         0x01
>+#define FFS_ATTRIB_DATA_ALIGNMENT2    0x02
> #define FFS_ATTRIB_FIXED              0x04
> #define FFS_ATTRIB_DATA_ALIGNMENT     0x38
> #define FFS_ATTRIB_CHECKSUM           0x40
> //
> // FFS_FIXED_CHECKSUM is the checksum value used when the
>diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py
>b/BaseTools/Source/Python/Common/FdfParserLite.py
>index 8e68a67..7d129bf 100644
>--- a/BaseTools/Source/Python/Common/FdfParserLite.py
>+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
>@@ -1,9 +1,9 @@
> ## @file
> # parse FDF file
> #
>-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -2338,11 +2338,12 @@ class FdfParser(object):
>             else:
>                 return False
>
>         AlignValue = None
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             AlignValue = self.__Token
>
>         BuildNum = None
>         if self.__IsKeyword( "BUILD_NUM"):
>@@ -2606,11 +2607,12 @@ class FdfParser(object):
>             else:
>                 return False
>
>         AlignValue = None
>         if self.__GetAlignment():
>-            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K"):
>+            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             AlignValue = self.__Token
>
>         if not self.__GetCglSection(FfsFileObj, AlignValue):
>             self.SetFileBufferPos(OldPos)
>@@ -2922,11 +2924,12 @@ class FdfParser(object):
>         if self.__IsKeyword("CheckSum", True):
>             CheckSum = True
>
>         AlignValue = ""
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment At Line ", self.FileName,
>self.CurrentLineNumber)
>             AlignValue = self.__Token
>
>         if self.__IsToken("{"):
>             # Complex file rule expected
>@@ -2986,11 +2989,12 @@ class FdfParser(object):
>
>             if self.__IsKeyword("CheckSum", True):
>                 CheckSum = True
>
>             if self.__GetAlignment():
>-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                     raise Warning("Incorrect alignment At Line ", self.FileName,
>self.CurrentLineNumber)
>                 if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
>SectionName == 'TE'):
>                     raise Warning("Auto alignment can only be used in PE32 or TE
>section ", self.FileName, self.CurrentLineNumber)
>                 AlignValue = self.__Token
>
>@@ -3060,11 +3064,12 @@ class FdfParser(object):
>                 if not self.__IsKeyword("FV"):
>                     raise Warning("expected 'FV' At Line ", self.FileName,
>self.CurrentLineNumber)
>                 FvImageSectionObj.FvFileType = self.__Token
>
>                 if self.__GetAlignment():
>-                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K"):
>+                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K", "128K",
>+                                            "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                         raise Warning("Incorrect alignment At Line ", self.FileName,
>self.CurrentLineNumber)
>                     FvImageSectionObj.Alignment = self.__Token
>
>                 if self.__IsToken('|'):
>                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
>@@ -3127,11 +3132,12 @@ class FdfParser(object):
>                 if not self.__GetNextToken():
>                     raise Warning("expected Build number At Line ", self.FileName,
>self.CurrentLineNumber)
>                 EfiSectionObj.BuildNum = self.__Token
>
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
>SectionName == 'TE'):
>                 raise Warning("Auto alignment can only be used in PE32 or TE section
>", self.FileName, self.CurrentLineNumber)
>             EfiSectionObj.Alignment = self.__Token
>
>diff --git a/BaseTools/Source/Python/GenFds/DataSection.py
>b/BaseTools/Source/Python/GenFds/DataSection.py
>index ba3677e..78c0af4 100644
>--- a/BaseTools/Source/Python/GenFds/DataSection.py
>+++ b/BaseTools/Source/Python/GenFds/DataSection.py
>@@ -1,9 +1,9 @@
> ## @file
> # process data section generation
> #
>-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -77,12 +77,14 @@ class DataSection (DataSectionClassObject):
>         #Get PE Section alignment when align is set to AUTO
>         if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
>             ImageObj = PeImageClass (Filename)
>             if ImageObj.SectionAlignment < 0x400:
>                 self.Alignment = str (ImageObj.SectionAlignment)
>-            else:
>+            elif ImageObj.SectionAlignment < 0x100000:
>                 self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
>+            else:
>+                self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
>
>         NoStrip = True
>         if self.SecType in ('TE', 'PE32'):
>             if self.KeepReloc != None:
>                 NoStrip = self.KeepReloc
>diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py
>b/BaseTools/Source/Python/GenFds/EfiSection.py
>index 09fb28f..7da3c1e 100644
>--- a/BaseTools/Source/Python/GenFds/EfiSection.py
>+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
>@@ -1,9 +1,9 @@
> ## @file
> # process rule section generation
> #
>-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -229,12 +229,14 @@ class EfiSection (EfiSectionClassObject):
>                     #Get PE Section alignment when align is set to AUTO
>                     if self.Alignment == 'Auto' and (SectionType == 'PE32' or
>SectionType == 'TE'):
>                         ImageObj = PeImageClass (File)
>                         if ImageObj.SectionAlignment < 0x400:
>                             Align = str (ImageObj.SectionAlignment)
>-                        else:
>+                        elif ImageObj.SectionAlignment < 0x100000:
>                             Align = str (ImageObj.SectionAlignment / 0x400) + 'K'
>+                        else:
>+                            Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'
>
>                     if File[(len(File)-4):] == '.efi':
>                         MapFile = File.replace('.efi', '.map')
>                         if os.path.exists(MapFile):
>                             CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
>diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
>b/BaseTools/Source/Python/GenFds/FdfParser.py
>index 8f49f9f..499d0a6 100644
>--- a/BaseTools/Source/Python/GenFds/FdfParser.py
>+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
>@@ -2765,11 +2765,12 @@ class FdfParser:
>         FfsFileObj.FileName = []
>         FfsFileObj.SubAlignment = []
>         while True:
>             AlignValue = None
>             if self.__GetAlignment():
>-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                     raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>                 #For FFS, Auto is default option same to ""
>                 if not self.__Token == "Auto":
>                     AlignValue = self.__Token
>             if not self.__GetNextToken():
>@@ -2824,11 +2825,12 @@ class FdfParser:
>
>         if self.__IsKeyword( "CHECKSUM", True):
>             FfsFileObj.CheckSum = True
>
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             #For FFS, Auto is default option same to ""
>             if not self.__Token == "Auto":
>                 FfsFileObj.Alignment = self.__Token
>
>@@ -2895,11 +2897,12 @@ class FdfParser:
>             else:
>                 return False
>
>         AlignValue = None
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             AlignValue = self.__Token
>
>         BuildNum = None
>         if self.__IsKeyword( "BUILD_NUM"):
>@@ -3184,11 +3187,12 @@ class FdfParser:
>             else:
>                 return False
>
>         AlignValue = None
>         if self.__GetAlignment():
>-            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K"):
>+            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             AlignValue = self.__Token
>
>         if not self.__GetCglSection(FfsFileObj, AlignValue):
>             self.SetFileBufferPos(OldPos)
>@@ -3775,11 +3779,12 @@ class FdfParser:
>         if self.__IsKeyword("CheckSum", True):
>             CheckSum = True
>
>         AlignValue = ""
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             #For FFS, Auto is default option same to ""
>             if not self.__Token == "Auto":
>                 AlignValue = self.__Token
>
>@@ -3824,11 +3829,12 @@ class FdfParser:
>             if self.__IsKeyword("CheckSum", True):
>                 CheckSum = True
>
>             SectAlignment = ""
>             if self.__GetAlignment():
>-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                     raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>                 if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
>SectionName == 'TE'):
>                     raise Warning("Auto alignment can only be used in PE32 or TE
>section ", self.FileName, self.CurrentLineNumber)
>                 SectAlignment = self.__Token
>
>@@ -3903,11 +3909,12 @@ class FdfParser:
>                 if not self.__IsKeyword("FV"):
>                     raise Warning("expected 'FV'", self.FileName,
>self.CurrentLineNumber)
>                 FvImageSectionObj.FvFileType = self.__Token
>
>                 if self.__GetAlignment():
>-                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K"):
>+                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K",
>"32K" ,"64K", "128K",
>+                                            "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                         raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>                     FvImageSectionObj.Alignment = self.__Token
>
>                 if self.__IsToken('|'):
>                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
>@@ -3970,11 +3977,12 @@ class FdfParser:
>                 if not self.__GetNextToken():
>                     raise Warning("expected Build number", self.FileName,
>self.CurrentLineNumber)
>                 EfiSectionObj.BuildNum = self.__Token
>
>         if self.__GetAlignment():
>-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K"):
>+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
>"4K", "32K" ,"64K", "128K",
>+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                 raise Warning("Incorrect alignment '%s'" % self.__Token,
>self.FileName, self.CurrentLineNumber)
>             if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
>SectionName == 'TE'):
>                 raise Warning("Auto alignment can only be used in PE32 or TE section
>", self.FileName, self.CurrentLineNumber)
>             EfiSectionObj.Alignment = self.__Token
>
>diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
>b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
>index c61c227..958cecf 100644
>--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
>+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
>@@ -1,9 +1,9 @@
> ## @file
> # process FFS generation from INF statement
> #
>-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #  Copyright (c) 2014-2016 Hewlett-Packard Development Company, L.P.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
>@@ -729,12 +729,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
>                 #Get PE Section alignment when align is set to AUTO
>                 if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType
>== 'TE'):
>                     ImageObj = PeImageClass (File)
>                     if ImageObj.SectionAlignment < 0x400:
>                         self.Alignment = str (ImageObj.SectionAlignment)
>-                    else:
>+                    elif ImageObj.SectionAlignment < 0x100000:
>                         self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
>+                    else:
>+                        self.Alignment = str (ImageObj.SectionAlignment / 0x100000) +
>'M'
>
>                 if not NoStrip:
>                     FileBeforeStrip = os.path.join(self.OutputPath, ModuleName +
>'.reloc')
>                     if not os.path.exists(FileBeforeStrip) or \
>                            (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
>@@ -768,12 +770,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
>             #Get PE Section alignment when align is set to AUTO
>             if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType ==
>'TE'):
>                 ImageObj = PeImageClass (GenSecInputFile)
>                 if ImageObj.SectionAlignment < 0x400:
>                     self.Alignment = str (ImageObj.SectionAlignment)
>-                else:
>+                elif ImageObj.SectionAlignment < 0x100000:
>                     self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
>+                else:
>+                    self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
>
>             if not NoStrip:
>                 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName +
>'.reloc')
>                 if not os.path.exists(FileBeforeStrip) or \
>                        (os.path.getmtime(GenSecInputFile) >
>os.path.getmtime(FileBeforeStrip)):
>diff --git a/BaseTools/Source/Python/GenFds/Fv.py
>b/BaseTools/Source/Python/GenFds/Fv.py
>index f6ccb59..4b03adc 100644
>--- a/BaseTools/Source/Python/GenFds/Fv.py
>+++ b/BaseTools/Source/Python/GenFds/Fv.py
>@@ -194,13 +194,16 @@ class FV (FvClassObject):
>             FvHeaderBuffer = FvFileObj.read(0x48)
>             # FV alignment position.
>             FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
>             # FvAlignmentValue is larger than or equal to 1K
>             if FvAlignmentValue >= 0x400:
>-                if FvAlignmentValue >= 0x10000:
>-                    #The max alignment supported by FFS is 64K.
>-                    self.FvAlignment = "64K"
>+                if FvAlignmentValue >= 0x100000:
>+                    #The max alignment supported by FFS is 16M.
>+                    if FvAlignmentValue >= 0x1000000:
>+                        self.FvAlignment = "16M"
>+                    else:
>+                        self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"
>                 else:
>                     self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"
>             else:
>                 # FvAlignmentValue is less than 1K
>                 self.FvAlignment = str (FvAlignmentValue)
>diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py
>b/BaseTools/Source/Python/GenFds/FvImageSection.py
>index 5989978..68f17c3 100644
>--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
>+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
>@@ -1,9 +1,9 @@
> ## @file
> # process FV image section generation
> #
>-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -78,13 +78,16 @@ class FvImageSection(FvImageSectionClassObject):
>                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],
>'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
>                 OutputFileList.append(OutputFile)
>
>             # MaxFvAlignment is larger than or equal to 1K
>             if MaxFvAlignment >= 0x400:
>-                if MaxFvAlignment >= 0x10000:
>-                    #The max alignment supported by FFS is 64K.
>-                    self.Alignment = "64K"
>+                if MaxFvAlignment >= 0x100000:
>+                    #The max alignment supported by FFS is 16M.
>+                    if MaxFvAlignment >=1000000:
>+                        self.Alignment = "16M"
>+                    else:
>+                        self.Alignment = str(MaxFvAlignment / 0x100000) + "M"
>                 else:
>                     self.Alignment = str (MaxFvAlignment / 0x400) + "K"
>             else:
>                 # MaxFvAlignment is less than 1K
>                 self.Alignment = str (MaxFvAlignment)
>@@ -115,13 +118,16 @@ class FvImageSection(FvImageSectionClassObject):
>                         FvHeaderBuffer = FvFileObj.read(0x48)
>                         # FV alignment position.
>                         FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
>                         # FvAlignmentValue is larger than or equal to 1K
>                         if FvAlignmentValue >= 0x400:
>-                            if FvAlignmentValue >= 0x10000:
>-                                #The max alignment supported by FFS is 64K.
>-                                self.Alignment = "64K"
>+                            if FvAlignmentValue >= 0x100000:
>+                                #The max alignment supported by FFS is 16M.
>+                                if FvAlignmentValue >= 0x1000000:
>+                                    self.Alignment = "16M"
>+                                else:
>+                                    self.Alignment = str(FvAlignmentValue / 0x100000) + "M"
>                             else:
>                                 self.Alignment = str (FvAlignmentValue / 0x400) + "K"
>                         else:
>                             # FvAlignmentValue is less than 1K
>                             self.Alignment = str (FvAlignmentValue)
>diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
>b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
>index d02befe..83996be 100644
>--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
>+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
>@@ -1,9 +1,9 @@
> ## @file
> # Global variables for GenFds
> #
>-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -418,20 +418,22 @@ class GenFdsGlobalVariable:
>
>     @staticmethod
>     def GetAlignment (AlignString):
>         if AlignString == None:
>             return 0
>-        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K"):
>+        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K",
>"256K", "512K"):
>             return int (AlignString.rstrip('K')) * 1024
>+        elif AlignString in ("1M", "2M", "4M", "8M", "16M"):
>+            return int (AlignString.rstrip('M')) * 1024 * 1024
>         else:
>             return int (AlignString)
>
>     @staticmethod
>     def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False,
>Align=None,
>                     SectionAlign=None):
>         Cmd = ["GenFfs", "-t", Type, "-g", Guid]
>-        mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K"]
>+        mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K",
>"128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]
>         if Fixed == True:
>             Cmd += ["-x"]
>         if CheckSum:
>             Cmd += ["-s"]
>         if Align not in [None, '']:
>--
>2.6.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-21  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21  6:01 [Patch] BaseTools: extend FFS alignment to 16M Yonghong Zhu
2017-09-21  8:05 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox