]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
BaseTools: Handle the bytes and str difference
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index 2bca6d7341815256b1c4bed15db4bbb26cd38a55..7653cf692ba42c805463162f0dc928d8f50d9f1d 100644 (file)
@@ -18,6 +18,7 @@
 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
@@ -204,7 +205,7 @@ class FV (FvClassObject):
                 # PI FvHeader is 0x48 byte\r
                 FvHeaderBuffer = FvFileObj.read(0x48)\r
                 # FV alignment position.\r
-                FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                 if FvAlignmentValue >= 0x400:\r
                     if FvAlignmentValue >= 0x100000:\r
                         if FvAlignmentValue >= 0x1000000:\r
@@ -264,7 +265,7 @@ class FV (FvClassObject):
         #\r
         self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,\r
                                    self.UiFvName + '.inf')\r
-        self.FvInfFile = BytesIO()\r
+        self.FvInfFile = StringIO()\r
 \r
         #\r
         # Add [Options]\r
@@ -339,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 = ''\r
+            Buffer = bytearray()\r
             if self.UsedSizeEnable:\r
                 TotalSize += (4 + 4)\r
                 ## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03\r
@@ -366,7 +367,7 @@ class FV (FvClassObject):
                 #\r
                 Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002)\r
                            + PackGUID(Guid)\r
-                           + self.UiFvName)\r
+                           + bytes(self.UiFvName, 'utf-8'))\r
 \r
             for Index in range (0, len(self.FvExtEntryType)):\r
                 if self.FvExtEntryType[Index] == 'FILE':\r