From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.3014.1688021798729275668 for ; Wed, 28 Jun 2023 23:56:39 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bxtBpnUt; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: bob.c.feng@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688021798; x=1719557798; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=i8WnTmjNlUE5w4iWsIYx/A+YNGS/IVnPLCQUqvLBFAk=; b=bxtBpnUthO4GOlbRaxhBNfhdKFO/gyqfZhOdF3dbX3emMmnNell2A+0E K9ryP7U7XgM5AMCEPtJU2thH0wqWZ2pWfXNwV67uF6ux3rgqtULFI005v WZpKV62W0g5mH5qPmFMvlKZF8ApCtEDMsT36B5JG3LS+k57g/CjeOH9pw lZ7la3BdAP3/wwTm3OgoDUClGuyXoqrYDe+CszMygGIu8rtoxPddqqcwp uMOK4bgs0tkpyJjbdlVE0Jpzm0IrjxtA9wZ3l+wraa679cUSK/t2EBuZB fzLGwpOwJmf5geW7bn3++R91huYBy5qNWnseXLzXktLOMO1ZIARv0L3+D Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="425708598" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="425708598" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 23:56:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="787279465" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="787279465" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga004.fm.intel.com with ESMTP; 28 Jun 2023 23:56:35 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 23:56:35 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 23:56:35 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 28 Jun 2023 23:56:34 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.40) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 28 Jun 2023 23:56:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLVT/vYKIlHjav4gvICW3/BM6o7eL5ISJZjxJPIYzvbJcG8Bdb59xZPkWytmBu8Lb97UGWqCfNKxOW+My41wB47+XcKK9QR0aaAWrGoFlZEzfp1XSBa3pFFLrpD6IVz9/DoTF6wRkolKeAlX3kACFWKKZ42jJUK4nTm7wzHgkLPhxWUOfLzcGjcTs7jwm7aWVLkC6RWpZImVfp504TI2JI5kjOyJRoRtEvormwWeSzGNcSFPKYQ6AweRcCSjiEO/1uaLk2X0bgO7zJ/YDHciXpEq2WPRdgGV6AyVgxtNCTtUlVQi07TtF6BHRjbvPp8MoVhBdgETfwhHDlSP5KzJ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NX6VRVzAkYYDf1knBJY9n8TV8e3guoFAvgEphPH9q0U=; b=RrSk668coexj4pRlxpLhJPJWF7vDV0u5QW/BHmKu6/a/VXI9oYldc3SYlOYB9xwjllnupeFqwoBwuvxgxLOqVX/NeqW8MohkaTVZC4e/ZGtl7ZnYa+Hz1Cmj7LcTrZNEkFvocyT4PRdb+Kn3APuvX7fKxGqoQ8kKgW6yHCFsOwAvGCvPdQFdmb0/WnxXGMB5iNr8izvvsxN2eG6Xx9iUsII+RCZlubO0mXKTs3XxI54GqPBUSmLK2Jbd42OqbEovHa01S3wxtGqLC8zjLotXXRrBipamA6t74XXA2/TasORHepsAsMK+QtoGda3QkzrmGrWNYmTUbJiQv9RHa0HeWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH7PR11MB5863.namprd11.prod.outlook.com (2603:10b6:510:135::11) by CY5PR11MB6115.namprd11.prod.outlook.com (2603:10b6:930:2c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 29 Jun 2023 06:56:27 +0000 Received: from PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::c14c:19b2:4d95:30f9]) by PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::c14c:19b2:4d95:30f9%4]) with mapi id 15.20.6521.023; Thu, 29 Jun 2023 06:56:26 +0000 From: "Bob Feng" To: "Chen, Christine" , "devel@edk2.groups.io" CC: Rebecca Cran , "Gao, Liming" Subject: Re: [Patch V2 2/4] BaseTools: FMMT replace output file is not generated successfully Thread-Topic: [Patch V2 2/4] BaseTools: FMMT replace output file is not generated successfully Thread-Index: AQHZqjqsmBBdKkJctkuAqx4ZreNI1a+hWNEw Date: Thu, 29 Jun 2023 06:56:26 +0000 Message-ID: References: <20230629033448.452-1-yuwei.chen@intel.com> In-Reply-To: <20230629033448.452-1-yuwei.chen@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB5863:EE_|CY5PR11MB6115:EE_ x-ms-office365-filtering-correlation-id: 917e146b-2732-40ed-10b0-08db786df57a x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PqvLp/LLeqgjNC/V3ugg/o4qvbNheB8tdaQncWTFkDxhIjuqzK1wJot2npVc+dgl6/HJIw5aUcrca9t6pNlnaqmsoIExxOE3HWSsJOGMGqiiufXVHyoLFjWPZRn43fyuYAhFtravSBf+7JZRJOuXOYadfIEZspMx4O1NUqgxYSwQv6pfh+hLAMeAu8cZ/YAUyzx93uAi5iRW/mh9R4fPAVrbwqq2y+x4VxBA/OqDBk6CFcCHUQillf6H+3onH6kn9s5i7cYPMdRx39wLHEEESOHc5Tho0H+p9hhWeY9aZD1EEuWxQgPPf03z69uQg3/YFp93g2eI808+Wq9grEZTGvminr8VoteNlfJWz1PWpMntUJThKTWC1U3NDohyJQrgcqu82CqPBLSnlmkYL85dBJtH72xlYDEurea10LglXyJY78kztF8RNyznGuhFcscAic7p8iGugc6r97FzzK9RaKVfOLg0pkZ+muuWeUWDob7E6WbDaqCjVyxio8YrfMxJDdLIwHufZThziyL7qY3Epb38oVRGbBQrLLiVkxnATZDCKyVKUlywdftJwCo3kHXJebRTKsXWeII9IjTEA0Br4P3cBWBsfp+3QdKXspLu5GhMHKY1TuCwwTLC+Hlyqjwt x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB5863.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(39860400002)(376002)(366004)(396003)(451199021)(66446008)(38070700005)(9686003)(26005)(66556008)(66476007)(4326008)(66946007)(122000001)(86362001)(33656002)(8936002)(41300700001)(316002)(8676002)(55016003)(82960400001)(5660300002)(52536014)(64756008)(38100700002)(76116006)(110136005)(6506007)(53546011)(186003)(2906002)(83380400001)(71200400001)(54906003)(7696005)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?EbxPIQD5ubViw0FInlkoHh3h9Qh9OhJ8DETuZXeMZBazpgdHnDUzesrB7P8t?= =?us-ascii?Q?K8gXyb7ongFVp2uTWpq3w51LURU6z5KNuPGg3WwjmUt07yqX2EZy8eRt953x?= =?us-ascii?Q?k9TXZswpeAbQHfVEdqfNDFGFQTR0RhGEAzDAPkltxVGVa4B7Eza0f+ud04yC?= =?us-ascii?Q?RnCtk7uoOObIcO3MV8EnjhnLmk57WM23JHoAbx/MrtdYmowza2+GUTC7VVGU?= =?us-ascii?Q?vp9/+jCukhgQbpjMtmdsOgLBffVAFM2x4pBlB7gn92q0JqQWIptV1ECUYADE?= =?us-ascii?Q?IzcoWFDl24ziFIGATJjU/r+prCGYXHRKHMKkjFGa7qg/6UPv9YyHFoi0lAK+?= =?us-ascii?Q?0/viaIWLb8aw64a1rzV01WWhjRElY1ITDjETNKpYnBmWAhEAk9XEiPWMQARJ?= =?us-ascii?Q?XRovO/UwkF8Zmj9qa7U5sNkZHF6kn6fRo/E91LQT2mSdvBhGK+Wi8ezqgdPh?= =?us-ascii?Q?cnEjkte89UIKlhk3JT60hTZ1Cif+hz/3ScMzwu1k2UAFiexc1XO/2c+oHGW8?= =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/nIrEn4yN0M86tzaK0QUKeYdf?= =?us-ascii?Q?gi3nLBculHrZptYHbAqTitMinJKtjPPZOeekgSgFThDZY8zHi7vPVDkKPhTD?= =?us-ascii?Q?PMvO5wmiX1w1Nv3qEzDtSk5EUKAEPcsRZK3Qd1+W5g9lszf69bcM59Xnm6k5?= =?us-ascii?Q?mBF+xI1WduPDuzAUJTCjxn5bEKl1fWvP0wlAEMsb?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB5863.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 917e146b-2732-40ed-10b0-08db786df57a X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2023 06:56:26.8215 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5avtQyiHY/P96v5DiV/aBmj6Hcwiv9xzkiwNtz9LM+hKr/zWAYCrYEXtr8QtpnuHtugsCGV9tsRA0sPfGs1ZPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6115 Return-Path: bob.c.feng@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Chen, Christine =20 Sent: Thursday, June 29, 2023 11:35 AM To: devel@edk2.groups.io Cc: Rebecca Cran ; Feng, Bob C ; G= ao, Liming Subject: [Patch V2 2/4] BaseTools: FMMT replace output file is not generate= d successfully For replace function, when target Ffs and new ffs are with same size, the o= utput file can not be generated successfully. This patch fixes this issue. Cc: Rebecca Cran Cc: Bob Feng Cc: Liming Gao Signed-off-by: Yuwei Chen --- BaseTools/Source/Python/FMMT/core/BiosTree.py | 4 ++-- 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/Sour= ce/Python/FMMT/core/BiosTree.py index d8fa4743354a..137f49748b09 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) =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 @@ class BIO= STREE: 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/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Sou= rce/Python/FMMT/core/FvHandler.py index b0cc1951a1c6..49bbc35baa4d 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 >=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 @@ class FvHandler: 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 @@ class FvHandler: 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 @@ class FvHandler: 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 -- 2.27.0.windows.1