IntelFsp2Pkg: Improve FSP Python scripts to support 3.x.

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2041

When running with Python 3.x and relying on GenCfgOpt.py to
automatically assign UPD offsets, the script crashed
because some float type variable not compatible with
the operations.
Converted those float variable to int to fix these issues.

Cc: Amy Chan <amy.chan@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Ching JenX Cheng <ching.jenx.cheng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
This commit is contained in:
Ching JenX Cheng 2019-08-01 12:16:46 +08:00 committed by Chasel Chiu
parent 46e34cc956
commit 5e4ebd9ea5
1 changed files with 3 additions and 3 deletions

View File

@ -715,7 +715,7 @@ EndList
if (ConfigDict['embed'].find(':END') != -1): if (ConfigDict['embed'].find(':END') != -1):
Remainder = Offset % (MaxAlign/8) # MaxAlign is either 32 or 64 Remainder = Offset % (MaxAlign/8) # MaxAlign is either 32 or 64
if Remainder: if Remainder:
Diff = (MaxAlign/8) - Remainder Diff = int((MaxAlign/8) - Remainder)
Offset = Offset + Diff Offset = Offset + Diff
ItemOffset = ItemOffset + Diff ItemOffset = ItemOffset + Diff
MaxAlign = 32 # Reset to default 32 align when struct end MaxAlign = 32 # Reset to default 32 align when struct end
@ -727,7 +727,7 @@ EndList
Remainder = Offset % max(ItemLength/8, 4, SizeAlign) Remainder = Offset % max(ItemLength/8, 4, SizeAlign)
Offset = Offset + ItemLength Offset = Offset + ItemLength
if Remainder: if Remainder:
Diff = max(ItemLength/8, 4, SizeAlign) - Remainder Diff = int(max(ItemLength/8, 4, SizeAlign) - Remainder)
ItemOffset = ItemOffset + Diff ItemOffset = ItemOffset + Diff
ConfigDict['offset'] = ItemOffset ConfigDict['offset'] = ItemOffset
@ -1416,7 +1416,7 @@ EndList
if BitsRemain: if BitsRemain:
BsfFd.write(" Skip %d bits\n" % BitsRemain) BsfFd.write(" Skip %d bits\n" % BitsRemain)
BitsGap -= BitsRemain BitsGap -= BitsRemain
BytesRemain = BitsGap / 8 BytesRemain = int(BitsGap / 8)
if BytesRemain: if BytesRemain:
BsfFd.write(" Skip %d bytes\n" % BytesRemain) BsfFd.write(" Skip %d bytes\n" % BytesRemain)
NextOffset = Item['offset'] + Item['length'] NextOffset = Item['offset'] + Item['length']