]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
Revert BaseTools: PYTHON3 migration
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index 3c3cd0b308042358984aff0a6a3f668a10f9762a..0d005ebf5bb630fa9e5a6124be2b690da4dd1e54 100644 (file)
@@ -1,3 +1,4 @@
+from __future__ import absolute_import\r
 ## @file\r
 # process FV generation\r
 #\r
@@ -18,7 +19,6 @@
 import Common.LongFilePathOs as os\r
 import subprocess\r
 from io import BytesIO\r
-from io import StringIO\r
 from struct import *\r
 \r
 from . import Ffs\r
@@ -205,16 +205,16 @@ class FV (FvClassObject):
                 # PI FvHeader is 0x48 byte\r
                 FvHeaderBuffer = FvFileObj.read(0x48)\r
                 # FV alignment position.\r
-                FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
+                FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
                 if FvAlignmentValue >= 0x400:\r
                     if FvAlignmentValue >= 0x100000:\r
                         if FvAlignmentValue >= 0x1000000:\r
                         #The max alignment supported by FFS is 16M.\r
                             self.FvAlignment = "16M"\r
                         else:\r
-                            self.FvAlignment = str(FvAlignmentValue // 0x100000) + "M"\r
+                            self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
                     else:\r
-                        self.FvAlignment = str(FvAlignmentValue // 0x400) + "K"\r
+                        self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"\r
                 else:\r
                     # FvAlignmentValue is less than 1K\r
                     self.FvAlignment = str (FvAlignmentValue)\r
@@ -265,7 +265,7 @@ class FV (FvClassObject):
         #\r
         self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,\r
                                    self.UiFvName + '.inf')\r
-        self.FvInfFile = StringIO()\r
+        self.FvInfFile = BytesIO()\r
 \r
         #\r
         # Add [Options]\r
@@ -340,7 +340,7 @@ class FV (FvClassObject):
                 GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))\r
         else:\r
             TotalSize = 16 + 4\r
-            Buffer = bytearray()\r
+            Buffer = ''\r
             if self.UsedSizeEnable:\r
                 TotalSize += (4 + 4)\r
                 ## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03\r
@@ -367,7 +367,7 @@ class FV (FvClassObject):
                 #\r
                 Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002)\r
                            + PackGUID(Guid)\r
-                           + bytes(self.UiFvName, 'utf-8'))\r
+                           + self.UiFvName)\r
 \r
             for Index in range (0, len(self.FvExtEntryType)):\r
                 if self.FvExtEntryType[Index] == 'FILE':\r