]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
BaseTools: Update Gensec to set PROCESSING_REQUIRED value
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index e385ccb1b546a467cfdd61067e43245818f2e320..45f6696a5fd74a8be1c42b41dc3063996705ae2e 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FV generation\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
@@ -50,6 +50,8 @@ class FV (FvClassObject):
         self.CapsuleName = None\r
         self.FvBaseAddress = None\r
         self.FvForceRebase = None\r
+        self.FvRegionInFD = None\r
+        self.UsedSizeEnable = False\r
         \r
     ## AddToBuffer()\r
     #\r
@@ -112,34 +114,6 @@ class FV (FvClassObject):
 \r
         # Process Modules in FfsList\r
         for FfsFile in self.FfsList :\r
-            if hasattr(FfsFile, 'FvFileType') and FfsFile.FvFileType == 'RAW':\r
-                if isinstance(FfsFile.FileName, list) and isinstance(FfsFile.Alignment, list) and len(FfsFile.FileName) == len(FfsFile.Alignment):\r
-                    FileContent = ''\r
-                    for Index, File in enumerate(FfsFile.FileName):\r
-                        try:\r
-                            f = open(File, 'r+b')\r
-                        except:\r
-                            GenFdsGlobalVariable.ErrorLogger("Error opening RAW file %s." % (File))\r
-                        Content = f.read()\r
-                        f.close()\r
-                        AlignValue = FfsFile.Alignment[Index]\r
-                        if AlignValue == None:\r
-                            AlignValue = 1\r
-                        FileContent += Content\r
-                        if len(FileContent) % AlignValue != 0:\r
-                            Size = AlignValue - len(FileContent) % AlignValue\r
-                            for i in range(0, Size):\r
-                                FileContent += pack('B', 0xFF)\r
-\r
-                    if FileContent:\r
-                        OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, FfsFile.NameGuid, FfsFile.NameGuid + '.raw')\r
-                        SaveFileOnChange(OutputRAWFile, FileContent, True)\r
-                        FfsFile.FileName = OutputRAWFile\r
-                        if max(FfsFile.Alignment):\r
-                            FfsFile.Alignment = str(max(FfsFile.Alignment))\r
-                        else:\r
-                            FfsFile.Alignment = None\r
-\r
             FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress)\r
             FfsFileList.append(FileName)\r
             self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
@@ -210,7 +184,7 @@ class FV (FvClassObject):
         # Write the Fv contents to Buffer\r
         #\r
         if os.path.isfile(FvOutputFile):\r
-            FvFileObj = open ( FvOutputFile,'r+b')\r
+            FvFileObj = open ( FvOutputFile,'rb')\r
 \r
             GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName)\r
             GenFdsGlobalVariable.SharpCounter = 0\r
@@ -223,9 +197,12 @@ class FV (FvClassObject):
             FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
             # FvAlignmentValue is larger than or equal to 1K\r
             if FvAlignmentValue >= 0x400:\r
-                if FvAlignmentValue >= 0x10000:\r
-                    #The max alignment supported by FFS is 64K.\r
-                    self.FvAlignment = "64K"\r
+                if FvAlignmentValue >= 0x100000:\r
+                    #The max alignment supported by FFS is 16M.\r
+                    if FvAlignmentValue >= 0x1000000:\r
+                        self.FvAlignment = "16M"\r
+                    else:\r
+                        self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
                 else:\r
                     self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"\r
             else:\r
@@ -331,6 +308,10 @@ class FV (FvClassObject):
                                           T_CHAR_LF)\r
         if not (self.FvAttributeDict == None):\r
             for FvAttribute in self.FvAttributeDict.keys() :\r
+                if FvAttribute == "FvUsedSizeEnable":\r
+                    if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :\r
+                        self.UsedSizeEnable = True\r
+                    continue\r
                 self.FvInfFile.writelines("EFI_"            + \\r
                                           FvAttribute       + \\r
                                           ' = '             + \\r
@@ -346,12 +327,22 @@ class FV (FvClassObject):
         # Generate FV extension header file\r
         #\r
         if self.FvNameGuid == None or self.FvNameGuid == '':\r
-            if len(self.FvExtEntryType) > 0:\r
+            if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable:\r
                 GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))\r
         \r
         if self.FvNameGuid <> None and self.FvNameGuid <> '':\r
             TotalSize = 16 + 4\r
             Buffer = ''\r
+            if self.UsedSizeEnable:\r
+                TotalSize += (4 + 4)\r
+                ## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03\r
+                #typedef  struct\r
+                # {\r
+                #    EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;\r
+                #    UINT32 UsedSize;\r
+                # } EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;\r
+                Buffer += pack('HHL', 8, 3, 0)\r
+\r
             if self.FvNameString == 'TRUE':\r
                 #\r
                 # Create EXT entry for FV UI name\r