diff options
author | Yao, Jiewen <Jiewen.Yao@intel.com> | 2015-04-23 08:52:21 +0000 |
---|---|---|
committer | jyao1 <jyao1@Edk2> | 2015-04-23 08:52:21 +0000 |
commit | 9da591867c0bad1abbe17a321dc5b16d95226c6a (patch) | |
tree | d73d5eefb589fec2196b92e1cb741317300f16e0 /IntelFspPkg/Tools | |
parent | 3b7f0a488be0ca7a2a8e4c352b0e10496bee9530 (diff) | |
download | edk2-platforms-9da591867c0bad1abbe17a321dc5b16d95226c6a.tar.xz |
Update IntelFspPkg to support FSP1.1
-- Add BootLoaderTolumSize support
-- Extend FspApiCallingCheck with ApiParam for BootLoaderTolumSize
-- Rename all Bootloader to BootLoader as official name
-- Rename Ucode to Microcode
-- Remove FspSelfCheck API, because it is merged into SecPlatformInit
-- Add GetFspVpdDataPointer() in FspCommonLib.h
-- Document FspSecPlatformLib.h
-- Reorg FSP_PLAT_DATA data structure to let it match FSP spec.
-- Move helper function in FspSecCore to reduce platform enabling effort
-- Fix LibraryClasses declaration in DEC file.
-- Enhance PatchFv to check if it is valid FSP bin.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <Jiewen.Yao@intel.com>
Reviewed-by: "Ma, Maurice" <maurice.ma@intel.com>
Reviewed-by: "Rangarajan, Ravi P" <ravi.p.rangarajan@intel.com>
Reviewed-by: "Mudusuru, Giri P" <giri.p.mudusuru@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17196 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFspPkg/Tools')
-rw-r--r-- | IntelFspPkg/Tools/PatchFv.py | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/IntelFspPkg/Tools/PatchFv.py b/IntelFspPkg/Tools/PatchFv.py index cc22cc201e..2143161d2c 100644 --- a/IntelFspPkg/Tools/PatchFv.py +++ b/IntelFspPkg/Tools/PatchFv.py @@ -1,6 +1,6 @@ ## @ PatchFv.py
#
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that accompanies this distribution.
# The full text of the license may be found at
@@ -23,14 +23,33 @@ def readDataFromFile (binfile, offset, len=1): offval = fsize - (0xFFFFFFFF - offval + 1)
fd.seek(offval)
bytearray = [ord(b) for b in fd.read(len)]
- value = 0;
- idx = len - 1;
+ value = 0
+ idx = len - 1
while idx >= 0:
value = value << 8 | bytearray[idx]
idx = idx - 1
fd.close()
return value
+def IsFspHeaderValid (binfile):
+ fd = open (binfile, "rb")
+ bindat = fd.read(0x200)
+ fd.close()
+ HeaderList = ['FSPH' , 'FSPP' , 'FSPE']
+ OffsetList = []
+ for each in HeaderList:
+ if each in bindat:
+ idx = bindat.index(each)
+ else:
+ idx = 0
+ OffsetList.append(idx)
+ if not OffsetList[0] or not OffsetList[1]:
+ return False
+ Revision = ord(bindat[OffsetList[0] + 0x0B])
+ if Revision > 1 and not OffsetList[2]:
+ return False
+ return True
+
def patchDataInFile (binfile, offset, value, len=1):
fd = open(binfile, "r+b")
fsize = os.path.getsize(binfile)
@@ -38,7 +57,7 @@ def patchDataInFile (binfile, offset, value, len=1): if (offval & 0x80000000):
offval = fsize - (0xFFFFFFFF - offval + 1)
bytearray = []
- idx = 0;
+ idx = 0
while idx < len:
bytearray.append(value & 0xFF)
value = value >> 8
@@ -46,7 +65,7 @@ def patchDataInFile (binfile, offset, value, len=1): fd.seek(offval)
fd.write("".join(chr(b) for b in bytearray))
fd.close()
- return len;
+ return len
class Symbols:
@@ -346,7 +365,7 @@ class Symbols: values.append(self.parseBrace())
else:
break
- value = 1;
+ value = 1
for each in values:
value *= each
return value
@@ -354,7 +373,7 @@ class Symbols: def parseAndOr(self):
values = [self.parseMul()]
op = None
- value = 0xFFFFFFFF;
+ value = 0xFFFFFFFF
while True:
self.skipSpace()
char = self.getCurr()
@@ -500,6 +519,9 @@ def main(): fdSize = symTables.getFdSize()
try:
+ ret = IsFspHeaderValid(fdFile)
+ if ret == False:
+ raise Exception ("The FSP header is not valid. Stop patching FD.")
comment = ""
for fvFile in sys.argv[3:]:
items = fvFile.split(",")
|