]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
SecurityPkg: AuthVariableLib: Fix GCC compile error
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index 03a742696fa169721854491b1efc87a69f4fc146..163ccd37f1582a03a3056bae04e587801dfa51a7 100644 (file)
@@ -30,6 +30,7 @@ from Common.LongFilePathSupport import CopyLongFilePath
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 T_CHAR_LF = '\n'\r
+FV_UI_EXT_ENTY_GUID = 'A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C'\r
 \r
 ## generate FV\r
 #\r
@@ -206,6 +207,30 @@ class FV (FvClassObject):
         GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
         return FvOutputFile\r
 \r
+    ## _GetBlockSize()\r
+    #\r
+    #   Calculate FV's block size\r
+    #   Inherit block size from FD if no block size specified in FV\r
+    #\r
+    def _GetBlockSize(self):\r
+        if self.BlockSizeList:\r
+            return True\r
+\r
+        for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+            for RegionObj in FdObj.RegionList:\r
+                if RegionObj.RegionType != 'FV':\r
+                    continue\r
+                for RegionData in RegionObj.RegionDataList:\r
+                    #\r
+                    # Found the FD and region that contain this FV\r
+                    #\r
+                    if self.UiFvName.upper() == RegionData.upper():\r
+                        RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, self)\r
+                        if self.BlockSizeList:\r
+                            return True\r
+        return False\r
+\r
     ## __InitializeInf__()\r
     #\r
     #   Initilize the inf file to create FV\r
@@ -244,8 +269,9 @@ class FV (FvClassObject):
                                       T_CHAR_LF)\r
         else:\r
             if self.BlockSizeList == []:\r
-                #set default block size is 1\r
-                self.FvInfFile.writelines("EFI_BLOCK_SIZE  = 0x1" + T_CHAR_LF)\r
+                if not self._GetBlockSize():\r
+                    #set default block size is 1\r
+                    self.FvInfFile.writelines("EFI_BLOCK_SIZE  = 0x1" + T_CHAR_LF)\r
             \r
             for BlockSize in self.BlockSizeList :\r
                 if BlockSize[0] != None:\r
@@ -295,6 +321,27 @@ class FV (FvClassObject):
         if self.FvNameGuid <> None and self.FvNameGuid <> '':\r
             TotalSize = 16 + 4\r
             Buffer = ''\r
+            if self.FvNameString == 'TRUE':\r
+                #\r
+                # Create EXT entry for FV UI name\r
+                # This GUID is used: A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C\r
+                #\r
+                FvUiLen = len(self.UiFvName)\r
+                TotalSize += (FvUiLen + 16 + 4)\r
+                Guid = FV_UI_EXT_ENTY_GUID.split('-')\r
+                #\r
+                # Layout:\r
+                #   EFI_FIRMWARE_VOLUME_EXT_ENTRY : size 4\r
+                #   GUID                          : size 16\r
+                #   FV UI name\r
+                #\r
+                Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002)\r
+                           + pack('=LHHBBBBBBBB', int(Guid[0], 16), int(Guid[1], 16), int(Guid[2], 16),\r
+                                  int(Guid[3][-4:-2], 16), int(Guid[3][-2:], 16), int(Guid[4][-12:-10], 16),\r
+                                  int(Guid[4][-10:-8], 16), int(Guid[4][-8:-6], 16), int(Guid[4][-6:-4], 16),\r
+                                  int(Guid[4][-4:-2], 16), int(Guid[4][-2:], 16))\r
+                           + self.UiFvName)\r
+\r
             for Index in range (0, len(self.FvExtEntryType)):\r
                 if self.FvExtEntryType[Index] == 'FILE':\r
                     # check if the path is absolute or relative\r