From nobody Sat May 18 21:45:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+95312+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+95312+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1666080932; cv=none; d=zohomail.com; s=zohoarc; b=gZEhbXs58Y/JaSVAsPlNz6dE4ufOr34yjoMqOsPkEgIMYv1fLJ8UYI3E1FGy7WNZazzMyaWuUEKsjpggqAxG8Q66Yu2VJQXkfQ+/d23vTRlMU5upUWMUEubllvT9aS0P17wZu/o1P7X2jHTUR193B1nYI1ohQb7Y71uCMQu9Q8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666080932; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=BeKwRVl4vKzY1tG52yB6S7OOK46/fpEXq2oob2Twfq0=; b=ivau4GEC6KwbO6mVeJL++9CaYQOHQJeFLi5jjCZeqWl53ElTuA6JdOc2MNLt+emFg6ZGyVj3sslKeAZFkFFksD8MXEXBwL1913RodjPvqwJM66+8NpTnOSz2I7/iVzTLQPXG4cYddiagskKcLnsc++r3kLRnyQ4ZJS4CJojDJdg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+95312+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1666080932568411.8085701225489; Tue, 18 Oct 2022 01:15:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id edY3YY1788612xVXjGbb1lNQ; Tue, 18 Oct 2022 01:15:32 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.4516.1666080931094848594 for ; Tue, 18 Oct 2022 01:15:31 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="370235081" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="370235081" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:15:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="691694340" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="691694340" X-Received: from yuweipc.ccr.corp.intel.com ([10.239.158.38]) by fmsmga008.fm.intel.com with ESMTP; 18 Oct 2022 01:15:28 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [edk2-devel] [PATCH] BaseTools: FMMT replace output file is not generated successfully Date: Tue, 18 Oct 2022 16:15:15 +0800 Message-Id: <20221018081515.138-1-yuwei.chen@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuwei.chen@intel.com X-Gm-Message-State: LskXhHjZD3PCHmUzYr74dFsHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1666080932; bh=quOFxzANDy8NXHa89bXVQIpQPxA+QZ/DDyAg2V4fcwI=; h=Cc:Date:From:Reply-To:Subject:To; b=C/b7v/KEfeNaqfqWKCH7iN7FDy3+m5Y7HtJ2aZDdjr1fSSfY9WpFIgdNFxE0XA7OA4q R8EUj+mHWwQBQqtafRgBoI554Zj8N8Nx8PfXuab85wlHKAFU/FvTcsoy5GCykPCPypqPu NlBgmM5s6MSOYB7EJl4rklSQMQg+MY69f/Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1666080934281100002 Content-Type: text/plain; charset="utf-8" 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: Bob Feng Cc: Liming Gao Signed-off-by: Yuwei Chen --- edk2basetools/FMMT/core/BiosTree.py | 4 ++-- edk2basetools/FMMT/core/FvHandler.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/edk2basetools/FMMT/core/BiosTree.py b/edk2basetools/FMMT/core/= BiosTree.py index ae889f6..14fb007 100644 --- a/edk2basetools/FMMT/core/BiosTree.py +++ b/edk2basetools/FMMT/core/BiosTree.py @@ -56,7 +56,7 @@ def insertChild(self, newNode, pos: int=3DNone) -> None: if len(self.Child) =3D=3D 0: self.Child.append(newNode) else: - if not pos: + if not pos or pos =3D=3D len(self.Child): LastTree =3D self.Child[-1] self.Child.append(newNode) LastTree.NextRel =3D newNode @@ -195,4 +195,4 @@ def ExportTree(self,TreeInfo: dict=3DNone) -> dict: for item in self.Child: TreeInfo[key].setdefault('Files',[]).append( item.ExportTree()) =20 - return TreeInfo \ No newline at end of file + return TreeInfo diff --git a/edk2basetools/FMMT/core/FvHandler.py b/edk2basetools/FMMT/core= /FvHandler.py index dc303c2..25f0929 100644 --- a/edk2basetools/FMMT/core/FvHandler.py +++ b/edk2basetools/FMMT/core/FvHandler.py @@ -387,7 +387,21 @@ def ReplaceFfs(self) -> bool: if self.NewFfs.Data.Size >=3D self.TargetFfs.Data.Size: Needed_Space =3D 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 fr= ee space to NewFfs. - if TargetFv.Data.Free_Space >=3D Needed_Space: + if Needed_Space =3D=3D 0: + Target_index =3D 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 no= de data. + self.CompressData(TargetFv) + # return the Status + self.Status =3D True + elif TargetFv.Data.Free_Space >=3D Needed_Space: # Modify TargetFv Child info and BiosTree. TargetFv.Child[-1].Data.Data =3D b'\xff' * (TargetFv.Data.= Free_Space - Needed_Space) TargetFv.Data.Free_Space -=3D Needed_Space @@ -450,7 +464,6 @@ def ReplaceFfs(self) -> bool: Target_index =3D TargetFv.Child.index(self.TargetFfs) TargetFv.Child.remove(self.TargetFfs) TargetFv.insertChild(self.NewFfs, Target_index) - self.Status =3D True # If TargetFv do not have free space, create free space for Fv. else: New_Free_Space_Tree =3D BIOSTREE('FREE_SPACE') @@ -461,7 +474,6 @@ def ReplaceFfs(self) -> bool: Target_index =3D TargetFv.Child.index(self.TargetFfs) TargetFv.Child.remove(self.TargetFfs) TargetFv.insertChild(self.NewFfs, Target_index) - self.Status =3D True # Modify TargetFv Header and ExtHeader info. TargetFv.Data.ModFvExt() TargetFv.Data.ModFvSize() @@ -470,6 +482,7 @@ def ReplaceFfs(self) -> bool: TargetFv.Data.ModCheckSum() # Recompress from the Fv node to update all the related node d= ata. self.CompressData(TargetFv) + self.Status =3D True logger.debug('Done!') return self.Status =20 --=20 2.26.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#95312): https://edk2.groups.io/g/devel/message/95312 Mute This Topic: https://groups.io/mt/94403776/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-