diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2015-12-07 08:27:53 +0000 |
---|---|---|
committer | yzhu52 <yzhu52@Edk2> | 2015-12-07 08:27:53 +0000 |
commit | b21a13fbb61e0232ea98b0d7b305e24e67e50b0a (patch) | |
tree | af2a6065eea8e379673ddcfb53591d4d0c42b424 /BaseTools/Source/Python/GenFds/FfsInfStatement.py | |
parent | 84c7452165816ed26cd5bdeb5666d4dc0026f116 (diff) | |
download | edk2-platforms-b21a13fbb61e0232ea98b0d7b305e24e67e50b0a.tar.xz |
BaseTools: Add support for INF statement in FD region
FD region today can be file or data, but not a patched image.Add support
for an INF statement in an FD region, so the binary from the INF can be
patched prior to being added to the FD region.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19136 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsInfStatement.py')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index ed767d3fa6..7b221399b4 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -331,25 +331,63 @@ class FfsInfStatement(FfsInfStatementClassObject): # If passed in file does not end with efi, return as is
#
def PatchEfiFile(self, EfiFile, FileType):
+ #
+ # If the module does not have any patches, then return path to input file
+ #
if not self.PatchPcds:
return EfiFile
+
+ #
+ # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
+ #
if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":
return EfiFile
+
+ #
+ # Generate path to patched output file
+ #
+ Basename = os.path.basename(EfiFile)
+ Output = os.path.normpath (os.path.join(self.OutputPath, Basename))
+
+ #
+ # If this file has already been patched, then return the path to the patched file
+ #
+ if self.PatchedBinFile == Output:
+ return Output
+
+ #
+ # If a different file from the same module has already been patched, then generate an error
+ #
if self.PatchedBinFile:
EdkLogger.error("GenFds", GENFDS_ERROR,
'Only one binary file can be patched:\n'
' a binary file has been patched: %s\n'
' current file: %s' % (self.PatchedBinFile, EfiFile),
File=self.InfFileName)
- Basename = os.path.basename(EfiFile)
- Output = os.path.join(self.OutputPath, Basename)
+
+ #
+ # Copy unpatched file contents to output file location to perform patching
+ #
CopyLongFilePath(EfiFile, Output)
+
+ #
+ # Apply patches to patched output file
+ #
for Pcd, Value in self.PatchPcds:
RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Value, Pcd.MaxDatumSize)
if RetVal:
EdkLogger.error("GenFds", GENFDS_ERROR, RetStr, File=self.InfFileName)
- self.PatchedBinFile = os.path.normpath(EfiFile)
+
+ #
+ # Save the path of the patched output file
+ #
+ self.PatchedBinFile = Output
+
+ #
+ # Return path to patched output file
+ #
return Output
+
## GenFfs() method
#
# Generate FFS
|