]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
Sync BaseTool trunk (version r2640) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFdsGlobalVariable.py
index b457937628f2e3fa3d66f4e389b443dff1092c04..1cd31bccc351d5086affc104d2bddf160c8fd86c 100644 (file)
@@ -65,6 +65,19 @@ class GenFdsGlobalVariable:
     BuildRuleFamily = "MSFT"
     ToolChainFamily = "MSFT"
     __BuildRuleDatabase = None
+    
+    #
+    # The list whose element are flags to indicate if large FFS or SECTION files exist in FV.
+    # At the beginning of each generation of FV, false flag is appended to the list,
+    # after the call to GenerateSection returns, check the size of the output file,
+    # if it is greater than 0xFFFFFF, the tail flag in list is set to true,
+    # and EFI_FIRMWARE_FILE_SYSTEM3_GUID is passed to C GenFv.
+    # At the end of generation of FV, pop the flag.
+    # List is used as a stack to handle nested FV generation.
+    #
+    LargeFileInFvFlags = []
+    EFI_FIRMWARE_FILE_SYSTEM3_GUID = '5473C07A-3DCB-4dca-BD6F-1E9689E7349A'
+    LARGE_FILE_SIZE = 0x1000000
 
     SectionHeader = struct.Struct("3B 1B")
     
@@ -345,7 +358,7 @@ class GenFdsGlobalVariable:
 
     @staticmethod
     def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
-                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None):
+                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None):
         Cmd = ["GenSec"]
         if Type not in [None, '']:
             Cmd += ["-s", Type]
@@ -364,6 +377,7 @@ class GenFdsGlobalVariable:
             for SecAlign in InputAlign:
                 Cmd += ["--sectionalign", SecAlign]
 
+        CommandFile = Output + '.txt'
         if Ui not in [None, '']:
             #Cmd += ["-n", '"' + Ui + '"']
             SectionData = array.array('B', [0,0,0,0])
@@ -374,25 +388,28 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
             SaveFileOnChange(Output,  SectionData.tostring())
         elif Ver not in [None, '']:
-            #Cmd += ["-j", Ver]
-            SectionData = array.array('B', [0,0,0,0])
-            SectionData.fromstring(Ver.encode("utf_16_le"))
-            SectionData.append(0)
-            SectionData.append(0)
-            Len = len(SectionData)
-            GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14)
-            SaveFileOnChange(Output,  SectionData.tostring())
-        else:
+            Cmd += ["-n", Ver]
+            if BuildNumber:
+                Cmd += ["-j", BuildNumber]
             Cmd += ["-o", Output]
-            Cmd += Input
 
-            CommandFile = Output + '.txt'
             SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
             if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
                 return
-            GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
 
             GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
+        else:
+            Cmd += ["-o", Output]
+            Cmd += Input
+
+            SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
+            if GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
+                GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
+                GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
+
+            if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and
+                GenFdsGlobalVariable.LargeFileInFvFlags):
+                GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True 
 
     @staticmethod
     def GetAlignment (AlignString):
@@ -430,7 +447,7 @@ class GenFdsGlobalVariable:
 
     @staticmethod
     def GenerateFirmwareVolume(Output, Input, BaseAddress=None, ForceRebase=None, Capsule=False, Dump=False,
-                               AddressFile=None, MapFile=None, FfsList=[]):
+                               AddressFile=None, MapFile=None, FfsList=[], FileSystemGuid=None):
         if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList):
             return
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
@@ -452,6 +469,8 @@ class GenFdsGlobalVariable:
             Cmd += ["-a", AddressFile]
         if MapFile not in [None, '']:
             Cmd += ["-m", MapFile]
+        if FileSystemGuid:
+            Cmd += ["-g", FileSystemGuid]
         Cmd += ["-o", Output]
         for I in Input:
             Cmd += ["-i", I]