]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
UefiCpuPkg/CpuCommonFeaturesLib: Add check for input parameter.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFdsGlobalVariable.py
index c3f36243f04175eae6eae3930b6c2e92dbf46d40..83996beeea958f8518430909fc4cf4f99503328c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Global variables for GenFds\r
 #\r
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -420,8 +420,10 @@ class GenFdsGlobalVariable:
     def GetAlignment (AlignString):\r
         if AlignString == None:\r
             return 0\r
-        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K"):\r
+        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K"):\r
             return int (AlignString.rstrip('K')) * 1024\r
+        elif AlignString in ("1M", "2M", "4M", "8M", "16M"):\r
+            return int (AlignString.rstrip('M')) * 1024 * 1024\r
         else:\r
             return int (AlignString)\r
 \r
@@ -429,11 +431,18 @@ class GenFdsGlobalVariable:
     def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,\r
                     SectionAlign=None):\r
         Cmd = ["GenFfs", "-t", Type, "-g", Guid]\r
+        mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]\r
         if Fixed == True:\r
             Cmd += ["-x"]\r
         if CheckSum:\r
             Cmd += ["-s"]\r
         if Align not in [None, '']:\r
+            if Align not in mFfsValidAlign:\r
+                Align = GenFdsGlobalVariable.GetAlignment (Align)\r
+                for index in range(0, len(mFfsValidAlign) - 1):\r
+                    if ((Align > GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index])) and (Align <= GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index + 1]))):\r
+                        break\r
+                Align = mFfsValidAlign[index + 1]\r
             Cmd += ["-a", Align]\r
 \r
         Cmd += ["-o", Output]\r