]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
BaseTools: Add a keyword FvNameString in FDF
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index fd5ad0e9ac382f104a8a249bec7529dc940ca52f..d7705823265912eedf2a03dfa314accdb7c2e7e8 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FV generation\r
 #\r
-#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2014, 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
@@ -15,8 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
-import os\r
-import shutil\r
+import Common.LongFilePathOs as os\r
 import subprocess\r
 import StringIO\r
 from struct import *\r
@@ -27,8 +26,11 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
 from GenFds import GenFds\r
 from CommonDataClass.FdfClass import FvClassObject\r
 from Common.Misc import SaveFileOnChange\r
+from Common.LongFilePathSupport import CopyLongFilePath\r
+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
@@ -86,6 +88,8 @@ class FV (FvClassObject):
                                 GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))\r
 \r
         GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName)\r
+        GenFdsGlobalVariable.LargeFileInFvFlags.append(False)\r
+        FFSGuid = None\r
         \r
         if self.FvBaseAddress != None:\r
             BaseAddress = self.FvBaseAddress\r
@@ -126,16 +130,19 @@ class FV (FvClassObject):
             FvOutputFile = self.CreateFileName\r
 \r
         FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')\r
-        shutil.copy(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)\r
+        CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)\r
         OrigFvInfo = None\r
         if os.path.exists (FvInfoFileName):\r
             OrigFvInfo = open(FvInfoFileName, 'r').read()\r
+        if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
+            FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
         GenFdsGlobalVariable.GenerateFirmwareVolume(\r
                                 FvOutputFile,\r
                                 [self.InfFileName],\r
                                 AddressFile=FvInfoFileName,\r
                                 FfsList=FfsFileList,\r
-                                ForceRebase=self.FvForceRebase\r
+                                ForceRebase=self.FvForceRebase,\r
+                                FileSystemGuid=FFSGuid\r
                                 )\r
 \r
         NewFvInfo = None\r
@@ -159,13 +166,16 @@ class FV (FvClassObject):
                 for FfsFile in self.FfsList :\r
                     FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress)\r
                 \r
+                if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
+                    FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
                 #Update GenFv again\r
                 GenFdsGlobalVariable.GenerateFirmwareVolume(\r
                                         FvOutputFile,\r
                                         [self.InfFileName],\r
                                         AddressFile=FvInfoFileName,\r
                                         FfsList=FfsFileList,\r
-                                        ForceRebase=self.FvForceRebase\r
+                                        ForceRebase=self.FvForceRebase,\r
+                                        FileSystemGuid=FFSGuid\r
                                         )\r
 \r
         #\r
@@ -194,6 +204,7 @@ class FV (FvClassObject):
             self.FvAlignment = str (FvAlignmentValue)\r
         FvFileObj.close()\r
         GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
+        GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
         return FvOutputFile\r
 \r
     ## __InitializeInf__()\r
@@ -285,15 +296,36 @@ 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
-                    if os.path.isabs(self.FvExtEntryData[Index]):
-                        FileFullPath = os.path.normpath(self.FvExtEntryData[Index])
-                    else:
-                        FileFullPath = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index]))
-                    # check if the file path exists or not
-                    if not os.path.isfile(FileFullPath):
+                    # check if the path is absolute or relative\r
+                    if os.path.isabs(self.FvExtEntryData[Index]):\r
+                        FileFullPath = os.path.normpath(self.FvExtEntryData[Index])\r
+                    else:\r
+                        FileFullPath = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index]))\r
+                    # check if the file path exists or not\r
+                    if not os.path.isfile(FileFullPath):\r
                         GenFdsGlobalVariable.ErrorLogger("Error opening FV Extension Header Entry file %s." % (self.FvExtEntryData[Index]))\r
                     FvExtFile = open (FileFullPath,'rb')\r
                     FvExtFile.seek(0,2)\r
@@ -316,7 +348,7 @@ class FV (FvClassObject):
                         Buffer += pack('B', int(ByteList[Index1], 16))\r
 \r
             Guid = self.FvNameGuid.split('-')\r
-            Buffer = pack('LHHBBBBBBBBL', \r
+            Buffer = pack('=LHHBBBBBBBBL', \r
                         int(Guid[0], 16), \r
                         int(Guid[1], 16), \r
                         int(Guid[2], 16), \r