diff options
author | Yuwei Chen <yuwei.chen@intel.com> | 2023-06-29 11:34:48 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-12-11 10:12:52 +0000 |
commit | 96274476257bd8e4e5d9e3b8983382c159972e64 (patch) | |
tree | fa8e4269742b3da8c9d84e88d8859cd83c6cf577 /BaseTools/Source | |
parent | b5f5106c1e2fb027776a88178fab844f81930b59 (diff) | |
download | edk2-96274476257bd8e4e5d9e3b8983382c159972e64.tar.gz edk2-96274476257bd8e4e5d9e3b8983382c159972e64.tar.bz2 edk2-96274476257bd8e4e5d9e3b8983382c159972e64.zip |
BaseTools: FMMT replace output file is not generated successfully
For replace function, when target Ffs and new ffs are with
same size, the output file can not be generated successfully.
This patch fixes this issue.
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source')
-rw-r--r-- | BaseTools/Source/Python/FMMT/core/BiosTree.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/FMMT/core/FvHandler.py | 19 |
2 files changed, 18 insertions, 5 deletions
diff --git a/BaseTools/Source/Python/FMMT/core/BiosTree.py b/BaseTools/Source/Python/FMMT/core/BiosTree.py index d8fa474335..137f49748b 100644 --- a/BaseTools/Source/Python/FMMT/core/BiosTree.py +++ b/BaseTools/Source/Python/FMMT/core/BiosTree.py @@ -56,7 +56,7 @@ class BIOSTREE: if len(self.Child) == 0:
self.Child.append(newNode)
else:
- if not pos:
+ if not pos or pos == len(self.Child):
LastTree = self.Child[-1]
self.Child.append(newNode)
LastTree.NextRel = newNode
@@ -195,4 +195,4 @@ class BIOSTREE: for item in self.Child:
TreeInfo[key].setdefault('Files',[]).append( item.ExportTree())
- return TreeInfo
\ No newline at end of file + return TreeInfo
diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py index 058b29321f..c7aca95bf2 100644 --- a/BaseTools/Source/Python/FMMT/core/FvHandler.py +++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py @@ -387,7 +387,21 @@ class FvHandler: if self.NewFfs.Data.Size >= self.TargetFfs.Data.Size:
Needed_Space = self.NewFfs.Data.Size + len(self.NewFfs.Data.PadData) - self.TargetFfs.Data.Size - len(self.TargetFfs.Data.PadData)
# If TargetFv have enough free space, just move part of the free space to NewFfs.
- if TargetFv.Data.Free_Space >= Needed_Space:
+ if Needed_Space == 0:
+ Target_index = TargetFv.Child.index(self.TargetFfs)
+ TargetFv.Child.remove(self.TargetFfs)
+ TargetFv.insertChild(self.NewFfs, Target_index)
+ # Modify TargetFv Header and ExtHeader info.
+ TargetFv.Data.ModFvExt()
+ TargetFv.Data.ModFvSize()
+ TargetFv.Data.ModExtHeaderData()
+ ModifyFvExtData(TargetFv)
+ TargetFv.Data.ModCheckSum()
+ # Recompress from the Fv node to update all the related node data.
+ self.CompressData(TargetFv)
+ # return the Status
+ self.Status = True
+ elif TargetFv.Data.Free_Space >= Needed_Space:
# Modify TargetFv Child info and BiosTree.
TargetFv.Child[-1].Data.Data = b'\xff' * (TargetFv.Data.Free_Space - Needed_Space)
TargetFv.Data.Free_Space -= Needed_Space
@@ -450,7 +464,6 @@ class FvHandler: Target_index = TargetFv.Child.index(self.TargetFfs)
TargetFv.Child.remove(self.TargetFfs)
TargetFv.insertChild(self.NewFfs, Target_index)
- self.Status = True
# If TargetFv do not have free space, create free space for Fv.
else:
New_Free_Space_Tree = BIOSTREE('FREE_SPACE')
@@ -461,7 +474,6 @@ class FvHandler: Target_index = TargetFv.Child.index(self.TargetFfs)
TargetFv.Child.remove(self.TargetFfs)
TargetFv.insertChild(self.NewFfs, Target_index)
- self.Status = True
# Modify TargetFv Header and ExtHeader info.
TargetFv.Data.ModFvExt()
TargetFv.Data.ModFvSize()
@@ -470,6 +482,7 @@ class FvHandler: TargetFv.Data.ModCheckSum()
# Recompress from the Fv node to update all the related node data.
self.CompressData(TargetFv)
+ self.Status = True
logger.debug('Done!')
return self.Status
|