]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: FSP Python scripts to support 3.x.
authorChasel Chiu <chasel.chiu@intel.com>
Fri, 21 Jun 2019 00:43:22 +0000 (08:43 +0800)
committerChasel Chiu <chasel.chiu@intel.com>
Mon, 1 Jul 2019 11:18:34 +0000 (19:18 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1930

Updated FSP Python scripts to support both 2.x and
3.x.

Test:
  . Verified with Python 2.7.12 and 3.6.6.
  . Verified tool result is the same before the change.
  . Both py -2 and py -3 built binary can boot.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2Pkg/Tools/GenCfgOpt.py
IntelFsp2Pkg/Tools/PatchFv.py
IntelFsp2Pkg/Tools/SplitFspBin.py

index 450c4e3eb9ecb6528fa8f9ae0640a138b18d069d..c4e1e6239d9ed489cbf9d5bca310929b63843ac9 100644 (file)
@@ -1,6 +1,6 @@
 ## @ GenCfgOpt.py\r
 #\r
-# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -10,6 +10,7 @@ import re
 import sys\r
 import struct\r
 from   datetime import date\r
+from functools import reduce\r
 \r
 # Generated file copyright header\r
 \r
@@ -90,11 +91,11 @@ class CLogicalExpression:
         self.string   = ''\r
 \r
     def errExit(self, err = ''):\r
-        print "ERROR: Express parsing for:"\r
-        print "       %s" % self.string\r
-        print "       %s^" % (' ' * self.index)\r
+        print ("ERROR: Express parsing for:")\r
+        print ("       %s" % self.string)\r
+        print ("       %s^" % (' ' * self.index))\r
         if err:\r
-            print "INFO : %s" % err\r
+            print ("INFO : %s" % err)\r
         raise SystemExit\r
 \r
     def getNonNumber (self, n1, n2):\r
@@ -338,15 +339,15 @@ EndList
         else:\r
             Error = 0\r
             if self.Debug:\r
-                print "INFO : Macro dictionary:"\r
+                print ("INFO : Macro dictionary:")\r
                 for Each in self._MacroDict:\r
-                    print "       $(%s) = [ %s ]" % (Each , self._MacroDict[Each])\r
+                    print ("       $(%s) = [ %s ]" % (Each , self._MacroDict[Each]))\r
         return Error\r
 \r
     def EvaulateIfdef   (self, Macro):\r
         Result = Macro in self._MacroDict\r
         if self.Debug:\r
-            print "INFO : Eval Ifdef [%s] : %s" % (Macro, Result)\r
+            print ("INFO : Eval Ifdef [%s] : %s" % (Macro, Result))\r
         return  Result\r
 \r
     def ExpandMacros (self, Input):\r
@@ -359,7 +360,7 @@ EndList
                   Line = Line.replace(Each, self._MacroDict[Variable])\r
               else:\r
                   if self.Debug:\r
-                      print "WARN : %s is not defined" % Each\r
+                      print ("WARN : %s is not defined" % Each)\r
                   Line = Line.replace(Each, Each[2:-1])\r
         return Line\r
 \r
@@ -372,7 +373,7 @@ EndList
                   Line = Line.replace(PcdName, self._PcdsDict[PcdName])\r
               else:\r
                   if self.Debug:\r
-                      print "WARN : %s is not defined" % PcdName\r
+                      print ("WARN : %s is not defined" % PcdName)\r
         return Line\r
 \r
     def EvaluateExpress (self, Expr):\r
@@ -381,7 +382,7 @@ EndList
         LogExpr = CLogicalExpression()\r
         Result  = LogExpr.evaluateExpress (ExpExpr)\r
         if self.Debug:\r
-            print "INFO : Eval Express [%s] : %s" % (Expr, Result)\r
+            print ("INFO : Eval Express [%s] : %s" % (Expr, Result))\r
         return Result\r
 \r
     def FormatListValue(self, ConfigDict):\r
@@ -406,7 +407,7 @@ EndList
         bytearray = []\r
         for each in dataarray:\r
             value = each\r
-            for loop in xrange(unit):\r
+            for loop in range(int(unit)):\r
                 bytearray.append("0x%02X" % (value & 0xFF))\r
                 value = value >> 8\r
         newvalue  = '{'  + ','.join(bytearray) + '}'\r
@@ -548,7 +549,7 @@ EndList
                 if Match:\r
                     self._MacroDict[Match.group(1)] = Match.group(2)\r
                     if self.Debug:\r
-                        print "INFO : DEFINE %s = [ %s ]" % (Match.group(1), Match.group(2))\r
+                        print ("INFO : DEFINE %s = [ %s ]" % (Match.group(1), Match.group(2)))\r
             elif IsPcdSect:\r
                 #gSiPkgTokenSpaceGuid.PcdTxtEnable|FALSE\r
                 #gSiPkgTokenSpaceGuid.PcdOverclockEnable|TRUE\r
@@ -556,7 +557,7 @@ EndList
                 if Match:\r
                     self._PcdsDict[Match.group(1)] = Match.group(2)\r
                     if self.Debug:\r
-                        print "INFO : PCD %s = [ %s ]" % (Match.group(1), Match.group(2))\r
+                        print ("INFO : PCD %s = [ %s ]" % (Match.group(1), Match.group(2)))\r
                     i = 0\r
                     while i < len(BuildOptionPcd):\r
                         Match = re.match("\s*([\w\.]+)\s*\=\s*(\w+)", BuildOptionPcd[i])\r
@@ -774,7 +775,7 @@ EndList
         bitsvalue = bitsvalue[::-1]\r
         bitslen   = len(bitsvalue)\r
         if start > bitslen or end > bitslen:\r
-            print "Invalid bits offset [%d,%d] for %s" % (start, end, subitem['name'])\r
+            print ("Invalid bits offset [%d,%d] for %s" % (start, end, subitem['name']))\r
             raise SystemExit\r
         return hex(int(bitsvalue[start:end][::-1], 2))\r
 \r
@@ -1031,7 +1032,7 @@ EndList
 \r
            if Match and Match.group(3) == 'END':\r
                if (StructName != Match.group(1)) or (VariableName != Match.group(2)):\r
-                   print "Unmatched struct name '%s' and '%s' !"  % (StructName, Match.group(1))\r
+                   print ("Unmatched struct name '%s' and '%s' !"  % (StructName, Match.group(1)))\r
                else:\r
                    if IsUpdHdrDefined != True or IsUpdHeader != True:\r
                       NewTextBody.append ('} %s;\n\n' %  StructName)\r
@@ -1464,11 +1465,11 @@ EndList
 \r
 \r
 def Usage():\r
-    print "GenCfgOpt Version 0.53"\r
-    print "Usage:"\r
-    print "    GenCfgOpt  UPDTXT  PlatformDscFile BuildFvDir                 [-D Macros]"\r
-    print "    GenCfgOpt  HEADER  PlatformDscFile BuildFvDir  InputHFile     [-D Macros]"\r
-    print "    GenCfgOpt  GENBSF  PlatformDscFile BuildFvDir  BsfOutFile     [-D Macros]"\r
+    print ("GenCfgOpt Version 0.54")\r
+    print ("Usage:")\r
+    print ("    GenCfgOpt  UPDTXT  PlatformDscFile BuildFvDir                 [-D Macros]")\r
+    print ("    GenCfgOpt  HEADER  PlatformDscFile BuildFvDir  InputHFile     [-D Macros]")\r
+    print ("    GenCfgOpt  GENBSF  PlatformDscFile BuildFvDir  BsfOutFile     [-D Macros]")\r
 \r
 def Main():\r
     #\r
@@ -1489,7 +1490,7 @@ def Main():
     else:\r
         DscFile = sys.argv[2]\r
         if not os.path.exists(DscFile):\r
-            print "ERROR: Cannot open DSC file '%s' !" % DscFile\r
+            print ("ERROR: Cannot open DSC file '%s' !" % DscFile)\r
             return 2\r
 \r
         OutFile = ''\r
@@ -1501,7 +1502,7 @@ def Main():
                 Start = 5\r
             if argc > Start:\r
                 if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:\r
-                    print "ERROR: Macro parsing failed !"\r
+                    print ("ERROR: Macro parsing failed !")\r
                     return 3\r
 \r
         FvDir = sys.argv[3]\r
@@ -1509,11 +1510,11 @@ def Main():
             os.makedirs(FvDir)\r
 \r
         if GenCfgOpt.ParseDscFile(DscFile, FvDir) != 0:\r
-            print "ERROR: %s !" % GenCfgOpt.Error\r
+            print ("ERROR: %s !" % GenCfgOpt.Error)\r
             return 5\r
 \r
         if GenCfgOpt.UpdateSubRegionDefaultValue() != 0:\r
-            print "ERROR: %s !" % GenCfgOpt.Error\r
+            print ("ERROR: %s !" % GenCfgOpt.Error)\r
             return 7\r
 \r
         if sys.argv[1] == "UPDTXT":\r
@@ -1521,23 +1522,23 @@ def Main():
             if Ret != 0:\r
                 # No change is detected\r
                 if Ret == 256:\r
-                    print "INFO: %s !" % (GenCfgOpt.Error)\r
+                    print ("INFO: %s !" % (GenCfgOpt.Error))\r
                 else :\r
-                    print "ERROR: %s !" % (GenCfgOpt.Error)\r
+                    print ("ERROR: %s !" % (GenCfgOpt.Error))\r
             return Ret\r
         elif sys.argv[1] == "HEADER":\r
             if GenCfgOpt.CreateHeaderFile(OutFile) != 0:\r
-                print "ERROR: %s !" % GenCfgOpt.Error\r
+                print ("ERROR: %s !" % GenCfgOpt.Error)\r
                 return 8\r
         elif sys.argv[1] == "GENBSF":\r
             if GenCfgOpt.GenerateBsfFile(OutFile) != 0:\r
-                print "ERROR: %s !" % GenCfgOpt.Error\r
+                print ("ERROR: %s !" % GenCfgOpt.Error)\r
                 return 9\r
         else:\r
             if argc < 5:\r
                 Usage()\r
                 return 1\r
-            print "ERROR: Unknown command '%s' !" % sys.argv[1]\r
+            print ("ERROR: Unknown command '%s' !" % sys.argv[1])\r
             Usage()\r
             return 1\r
         return 0\r
index 19bffd146ae60bf11bc603515a7bf865e9d2d677..2173984dea5c7af0b1770b01b023937107a5c1c0 100644 (file)
@@ -1,6 +1,6 @@
 ## @ PatchFv.py\r
 #\r
-# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -25,7 +25,10 @@ def readDataFromFile (binfile, offset, len=1):
     if (offval & 0x80000000):\r
         offval = fsize - (0xFFFFFFFF - offval + 1)\r
     fd.seek(offval)\r
-    bytearray = [ord(b) for b in fd.read(len)]\r
+    if sys.version_info[0] < 3:\r
+        bytearray = [ord(b) for b in fd.read(len)]\r
+    else:\r
+        bytearray = [b for b in fd.read(len)]\r
     value = 0\r
     idx   = len - 1\r
     while  idx >= 0:\r
@@ -45,7 +48,7 @@ def IsFspHeaderValid (binfile):
     fd     = open (binfile, "rb")\r
     bindat = fd.read(0x200) # only read first 0x200 bytes\r
     fd.close()\r
-    HeaderList = ['FSPH' , 'FSPP' , 'FSPE']       # Check 'FSPH', 'FSPP', and 'FSPE' in the FSP header\r
+    HeaderList = [b'FSPH' , b'FSPP' , b'FSPE']       # Check 'FSPH', 'FSPP', and 'FSPE' in the FSP header\r
     OffsetList = []\r
     for each in HeaderList:\r
         if each in bindat:\r
@@ -55,7 +58,10 @@ def IsFspHeaderValid (binfile):
         OffsetList.append(idx)\r
     if not OffsetList[0] or not OffsetList[1]:    # If 'FSPH' or 'FSPP' is missing, it will return false\r
         return False\r
-    Revision = ord(bindat[OffsetList[0] + 0x0B])\r
+    if sys.version_info[0] < 3:\r
+        Revision = ord(bindat[OffsetList[0] + 0x0B])\r
+    else:\r
+        Revision = bindat[OffsetList[0] + 0x0B]\r
     #\r
     # if revision is bigger than 1, it means it is FSP v1.1 or greater revision, which must contain 'FSPE'.\r
     #\r
@@ -86,7 +92,10 @@ def patchDataInFile (binfile, offset, value, len=1):
         value          = value >> 8\r
         idx            = idx + 1\r
     fd.seek(offval)\r
-    fd.write("".join(chr(b) for b in bytearray))\r
+    if sys.version_info[0] < 3:\r
+        fd.write("".join(chr(b) for b in bytearray))\r
+    else:\r
+        fd.write(bytes(bytearray))\r
     fd.close()\r
     return len\r
 \r
@@ -791,7 +800,7 @@ class Symbols:
     #  retval      ret\r
     #\r
     def getSymbols(self, value):\r
-        if self.dictSymbolAddress.has_key(value):\r
+        if value in self.dictSymbolAddress:\r
             # Module:Function\r
             ret = int (self.dictSymbolAddress[value], 16)\r
         else:\r
@@ -827,8 +836,9 @@ class Symbols:
 #\r
 #  Print out the usage\r
 #\r
-def usage():\r
-    print "Usage: \n\tPatchFv FvBuildDir [FvFileBaseNames:]FdFileBaseNameToPatch \"Offset, Value\""\r
+def Usage():\r
+    print ("PatchFv Version 0.50")\r
+    print ("Usage: \n\tPatchFv FvBuildDir [FvFileBaseNames:]FdFileBaseNameToPatch \"Offset, Value\"")\r
 \r
 def main():\r
     #\r
@@ -847,7 +857,7 @@ def main():
     # If it fails to create dictionaries, then return an error.\r
     #\r
     if symTables.createDicts(sys.argv[1], sys.argv[2]) != 0:\r
-        print "ERROR: Failed to create symbol dictionary!!"\r
+        print ("ERROR: Failed to create symbol dictionary!!")\r
         return 2\r
 \r
     #\r
@@ -907,7 +917,7 @@ def main():
                 if ret:\r
                     raise Exception ("Patch failed for offset 0x%08X" % offset)\r
                 else:\r
-                    print  "Patched offset 0x%08X:[%08X] with value 0x%08X  # %s" % (offset, oldvalue, value, comment)\r
+                    print ("Patched offset 0x%08X:[%08X] with value 0x%08X  # %s" % (offset, oldvalue, value, comment))\r
 \r
             elif command == "COPY":\r
                 #\r
@@ -928,13 +938,13 @@ def main():
                 if ret:\r
                     raise Exception ("Copy failed from offset 0x%08X to offset 0x%08X!" % (src, dest))\r
                 else :\r
-                    print  "Copied %d bytes from offset 0x%08X ~ offset 0x%08X  # %s" % (clen, src, dest, comment)\r
+                    print ("Copied %d bytes from offset 0x%08X ~ offset 0x%08X  # %s" % (clen, src, dest, comment))\r
             else:\r
                 raise Exception ("Unknown command %s!" % command)\r
         return 0\r
 \r
-    except Exception as (ex):\r
-        print "ERROR: %s" % ex\r
+    except Exception as ex:\r
+        print ("ERROR: %s" % ex)\r
         return 1\r
 \r
 if __name__ == '__main__':\r
index 15c8bebee27839731b73daaaadd20d99cd12fd9b..b326241fa9daf080ecd7900d22198a277a1ca680 100644 (file)
@@ -12,6 +12,7 @@ import copy
 import struct\r
 import argparse\r
 from   ctypes import *\r
+from functools import reduce\r
 \r
 """\r
 This utility supports some operations for Intel FSP 1.x/2.x image.\r
@@ -340,6 +341,31 @@ def Bytes2Val (bytes):
 def Val2Bytes (value, blen):\r
     return [(value>>(i*8) & 0xff) for i in range(blen)]\r
 \r
+def IsIntegerType (val):\r
+    if sys.version_info[0] < 3:\r
+        if type(val) in (int, long):\r
+            return True\r
+    else:\r
+        if type(val) is int:\r
+            return True\r
+    return False\r
+\r
+def IsStrType (val):\r
+    if sys.version_info[0] < 3:\r
+        if type(val) is str:\r
+            return True\r
+    else:\r
+        if type(val) is bytes:\r
+            return True\r
+    return False\r
+\r
+def HandleNameStr (val):\r
+    if sys.version_info[0] < 3:\r
+        rep = "0x%X ('%s')" % (Bytes2Val (bytearray (val)), val)\r
+    else:\r
+        rep = "0x%X ('%s')" % (Bytes2Val (bytearray (val)), str (val, 'utf-8'))\r
+    return rep\r
+\r
 def OutputStruct (obj, indent = 0, plen = 0):\r
     if indent:\r
         body = ''\r
@@ -361,15 +387,19 @@ def OutputStruct (obj, indent = 0, plen = 0):
             body += OutputStruct (val, indent + 1)\r
             plen -= sizeof(val)\r
         else:\r
-            if type(val) is str:\r
-                rep = "0x%X ('%s')" % (Bytes2Val(bytearray(val)), val)\r
-            elif type(val) in (int, long):\r
+            if IsStrType (val):\r
+                rep = HandleNameStr (val)\r
+            elif IsIntegerType (val):\r
                 rep = '0x%X' % val\r
             elif isinstance(val, c_uint24):\r
                 rep = '0x%X' % val.get_value()\r
             elif 'c_ubyte_Array' in str(type(val)):\r
                 if sizeof(val) == 16:\r
-                    rep = str(uuid.UUID(bytes = str(bytearray(val)))).upper()\r
+                    if sys.version_info[0] < 3:\r
+                        rep = str(bytearray(val))\r
+                    else:\r
+                        rep = bytes(val)\r
+                    rep = str(uuid.UUID(bytes_le = rep)).upper()\r
                 else:\r
                     res = ['0x%02X'%i for i in bytearray(val)]\r
                     rep = '[%s]' % (','.join(res))\r
@@ -487,7 +517,7 @@ class FirmwareDevice:
         self.FvList  = []\r
         while offset < fdsize:\r
             fvh = EFI_FIRMWARE_VOLUME_HEADER.from_buffer (self.FdData, offset)\r
-            if '_FVH' != fvh.Signature:\r
+            if b'_FVH' != fvh.Signature:\r
                 raise Exception("ERROR: Invalid FV header !")\r
             fv = FirmwareVolume (offset, self.FdData[offset:offset + fvh.FvLength])\r
             fv.ParseFv ()\r
@@ -524,7 +554,7 @@ class FirmwareDevice:
                 fspoffset = fv.Offset\r
                 offset    = fspoffset + fihoffset\r
                 fih = FSP_INFORMATION_HEADER.from_buffer (self.FdData, offset)\r
-                if 'FSPH' != fih.Signature:\r
+                if b'FSPH' != fih.Signature:\r
                     continue\r
 \r
                 offset += fih.HeaderLength\r
@@ -532,7 +562,7 @@ class FirmwareDevice:
                 plist  = []\r
                 while True:\r
                     fch = FSP_COMMON_HEADER.from_buffer (self.FdData, offset)\r
-                    if 'FSPP' != fch.Signature:\r
+                    if b'FSPP' != fch.Signature:\r
                         offset += fch.HeaderLength\r
                         offset = AlignPtr(offset, 4)\r
                     else:\r
@@ -557,9 +587,9 @@ class PeTeImage:
     def __init__(self, offset, data):\r
         self.Offset    = offset\r
         tehdr          = EFI_TE_IMAGE_HEADER.from_buffer (data, 0)\r
-        if   tehdr.Signature == 'VZ': # TE image\r
+        if   tehdr.Signature == b'VZ': # TE image\r
             self.TeHdr   = tehdr\r
-        elif tehdr.Signature == 'MZ': # PE image\r
+        elif tehdr.Signature == b'MZ': # PE image\r
             self.TeHdr   = None\r
             self.DosHdr  = EFI_IMAGE_DOS_HEADER.from_buffer (data, 0)\r
             self.PeHdr   = EFI_IMAGE_NT_HEADERS32.from_buffer (data, self.DosHdr.e_lfanew)\r
@@ -604,7 +634,7 @@ class PeTeImage:
             offset += sizeof(blkhdr)\r
             # Read relocation type,offset pairs\r
             rlen  = blkhdr.BlockSize - sizeof(PE_RELOC_BLOCK_HEADER)\r
-            rnum  = rlen/sizeof(c_uint16)\r
+            rnum  = int (rlen/sizeof(c_uint16))\r
             rdata = (c_uint16 * rnum).from_buffer(self.Data, offset)\r
             for each in rdata:\r
                 roff  = each & 0xfff\r
@@ -666,8 +696,11 @@ def ShowFspInfo (fspfile):
         if not name:\r
             name = '\xff' * 16\r
         else:\r
-            name = str(bytearray(name))\r
-        guid = uuid.UUID(bytes = name)\r
+            if sys.version_info[0] < 3:\r
+                name = str(bytearray(name))\r
+            else:\r
+                name = bytes(name)\r
+        guid = uuid.UUID(bytes_le = name)\r
         print ("FV%d:" % idx)\r
         print ("  GUID   : %s" % str(guid).upper())\r
         print ("  Offset : 0x%08X" %  fv.Offset)\r
@@ -695,7 +728,10 @@ def GenFspHdr (fspfile, outdir, hfile):
     for fsp in fd.FspList:\r
         fih = fsp.Fih\r
         if firstfv:\r
-            hfsp.write("#define  FSP_IMAGE_ID    0x%016X    /* '%s' */\n" % (Bytes2Val(bytearray(fih.ImageId)), fih.ImageId))\r
+            if sys.version_info[0] < 3:\r
+                hfsp.write("#define  FSP_IMAGE_ID    0x%016X    /* '%s' */\n" % (Bytes2Val(bytearray(fih.ImageId)), fih.ImageId))\r
+            else:\r
+                hfsp.write("#define  FSP_IMAGE_ID    0x%016X    /* '%s' */\n" % (Bytes2Val(bytearray(fih.ImageId)), str (fih.ImageId, 'utf-8')))\r
             hfsp.write("#define  FSP_IMAGE_REV   0x%08X \n\n" % fih.ImageRevision)\r
             firstfv = False\r
         fv = fd.FvList[fsp.FvIdxList[0]]\r
@@ -733,7 +769,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
     numcomp  = len(FspComponent)\r
     baselist = FspBase\r
     if numcomp != len(baselist):\r
-        print "ERROR: Required number of base does not match number of FSP component !"\r
+        print ("ERROR: Required number of base does not match number of FSP component !")\r
         return\r
 \r
     newfspbin = fd.FdData[:]\r
@@ -753,7 +789,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
                 break\r
 \r
         if not found:\r
-            print "ERROR: Could not find FSP_%c component to rebase !" % fspcomp.upper()\r
+            print ("ERROR: Could not find FSP_%c component to rebase !" % fspcomp.upper())\r
             return\r
 \r
         fspbase = baselist[idx]\r
@@ -763,7 +799,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
             newbase = int(fspbase)\r
         oldbase = fsp.Fih.ImageBase\r
         delta = newbase - oldbase\r
-        print "Rebase FSP-%c from 0x%08X to 0x%08X:" % (ftype.upper(),oldbase,newbase)\r
+        print ("Rebase FSP-%c from 0x%08X to 0x%08X:" % (ftype.upper(),oldbase,newbase))\r
 \r
         imglist = []\r
         for fvidx in fsp.FvIdxList:\r
@@ -782,12 +818,12 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
             pcount += img.Rebase(delta, newfspbin)\r
             fcount += 1\r
 \r
-        print "  Patched %d entries in %d TE/PE32 images." % (pcount, fcount)\r
+        print ("  Patched %d entries in %d TE/PE32 images." % (pcount, fcount))\r
 \r
         (count, applied) = fsp.Patch(delta, newfspbin)\r
-        print "  Patched %d entries using FSP patch table." % applied\r
+        print ("  Patched %d entries using FSP patch table." % applied)\r
         if count != applied:\r
-            print "  %d invalid entries are ignored !" % (count - applied)\r
+            print ("  %d invalid entries are ignored !" % (count - applied))\r
 \r
     if OutputFile == '':\r
         filename = os.path.basename(FspBinary)\r