From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.6631.1618824529388554917 for ; Mon, 19 Apr 2021 02:28:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=I2UK/J+4; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: bob.c.feng@intel.com) IronPort-SDR: /8ix+tEOw3cYAgCSNjOXtat62Niv+c5XajTgOxq7oeI9rTtR4WxCaqJ9E5OFRBbgDJfCJPbMxo hYzt1nKxhm5g== X-IronPort-AV: E=McAfee;i="6200,9189,9958"; a="182428156" X-IronPort-AV: E=Sophos;i="5.82,233,1613462400"; d="scan'208";a="182428156" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 02:28:47 -0700 IronPort-SDR: Ch7dura5xwZAlVhhghG0kPWJ28br1zjjqT5nakYhDTe9s/EHDCJVGCjadrlkTQnAD/5mzy96/d vAVEVQISHtQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,233,1613462400"; d="scan'208";a="452086912" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by FMSMGA003.fm.intel.com with ESMTP; 19 Apr 2021 02:28:47 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 19 Apr 2021 02:28:46 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Mon, 19 Apr 2021 02:28:46 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Mon, 19 Apr 2021 02:28:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fgoICVQKd1jHK3BAiO7k9elSseqV7BDO8ZRGTIGGVwOJBaElN1yIugEHhmrbACGuouEL4WSlSGpXZtcHHa45AgV6Ch+1rNR+FuCiRYX9D3t8CWVT8wnkBlPE/SaEIg1LDHt7TErFhNuB1tXDwxLJsH6D4pVTU/45x0gBTBZR8OseYXNP7Ou3Kt9SDzFvOd/qGp7bV1QVL3xnuLI5Je4vK2k7JONczHQnp+udVGrQ2fkcsSXPPWS8WtebSrF9ifeJEuWtJwM+tfZbVImMMmBF/ZATt6zv94jpRZdjmEgMLF1FZ+Enq7UxHnZ9D2QurbmvY7ymfEel70xBpKJ6IauevQ== 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-SenderADCheck; bh=QqMtR4I2V6aP6XINuB8ZuaEG6nwOlTHj67u22GUouwc=; b=CrztCvV7uUjuAuALvbVkGNK6n+ieEZCs8kIwkdcYqhxCUwzY43/LCL+bZRLKiTAXQYA/E3OsIfsQXHMhNwDVbI+e9wuWfW91DQQ40EQLWCab/XIp/C24NhWrzgIWZzMWJ+117y66H9SUEX+SZTuiw7nUdGH9tDjB6MEPRUHUDnG2p6uQDAQ6XRnc192ok8cQT2FG+u6QmA2j6jk0qf9mvfHFdC3ewgkuSopth7UyXDQrvmWG0xLVwbxfqV6X0vB9qdlDmBbcUrKQ59c82nESSPUg973L6GGe095G0+XNyhKtDkoaAbKqsUESrTmMa4AGs1Kbkk3staiqiQGsyw8mjA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqMtR4I2V6aP6XINuB8ZuaEG6nwOlTHj67u22GUouwc=; b=I2UK/J+4SeuI9HVpppXXxuOnzeK0afajU9CKA/fnNKnpYEXVRiK6ronaIZJ7zerd49qxxT6BeOcOPDOmhqVLP80N8blY1LyELAoXQ912wOb27pW1tAdKX7Jfq6vz7zfoAXpIdq7wPZoBG241EI9GX6/Ic+L22TbURiWfQPDwltU= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM6PR11MB4074.namprd11.prod.outlook.com (2603:10b6:5:5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16; Mon, 19 Apr 2021 09:28:44 +0000 Received: from DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::cc64:a87c:5cf:5f18]) by DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::cc64:a87c:5cf:5f18%3]) with mapi id 15.20.4042.024; Mon, 19 Apr 2021 09:28:43 +0000 From: "Bob Feng" To: "Yeh, GregX" , "devel@edk2.groups.io" CC: Liming Gao Subject: Re: [PATCH] [edk2-staging] BaseTools/Fmmt: Fix rebuild FFS lost dependency section. Thread-Topic: [PATCH] [edk2-staging] BaseTools/Fmmt: Fix rebuild FFS lost dependency section. Thread-Index: AQHXIU76Q0jPlZ0A8E2Cz2bcY1PTDKq7ufpg Date: Mon, 19 Apr 2021 09:28:43 +0000 Message-ID: References: <20210325081452.5104-1-gregx.yeh@intel.com> In-Reply-To: <20210325081452.5104-1-gregx.yeh@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.46.54] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a3322238-02d7-4e06-1df5-08d9031586c6 x-ms-traffictypediagnostic: DM6PR11MB4074: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HwbuAau/+fLXYZ5X1oEKHDAP461rDnCQ5s6FkUq01dHTxpnsMWxdwrFNHm8SebZV695WUjrrT2S7a17z/1bWRK52T535pmzL+Xm0KpXCRaGZPKOwrq9KxMrqJotEr4fcaNJG0ydYl2PQPEatzJNoml+5MNXvUqg43u41MlpN+HfwfSZViX6xemfBkfII+4Ck9GRwbEN4FFzidFTSz80S8RE0AmYjQd7l2PYoBDmx+skkjJZsZyPSoV3451KFnDj5/5OO4ms8xxoaP1KCwB8gYCfAqqffTZxXgODyLYqgQh0HV9U/+kzEa5LBL9UH1zHTnyP82Dk4HNg+aCoHCnt8KAu9cunARYpsekr/ZjF0YSyQ/tnA+xDLwXNJPcR13MYl2Uo5rX5e9qUqaGGtcHtOz2sMzCx043hR4CbJAiJzCMqpQHcl/yF9jM6yYpjMAQY0uzpI2oGureKFIX1VoEXyapUriUn+VAwWddvqGT5LKSwVsuvHmMOQEZeXkRY6WAggejky8wR8djOb9MebZBTFSq/tAvo76TGcOudZE+sKuzFNZFEI7YATXpLCO5Zrggu+Pi5DYFxPU8q90nHpNqvjEAVSQ14bqUvxyylMBumf4Z2F2FgepPhslfnqgdVolu/sn6N1u0iQG4QXpPr8EHbaMiR3j5xDGI0LNX+sBNPMCyMDKwLVZRnZg+nwmw3oU79C x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4073.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(366004)(396003)(39860400002)(346002)(136003)(8676002)(38100700002)(966005)(86362001)(110136005)(8936002)(7696005)(33656002)(66476007)(316002)(83380400001)(66446008)(66946007)(2906002)(66556008)(76116006)(52536014)(478600001)(64756008)(6506007)(53546011)(4326008)(30864003)(26005)(5660300002)(55016002)(122000001)(71200400001)(186003)(9686003)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?ZrlnIWQD6uW1i9JbRgetvfM4iQzr11AWDLH6x/XzH0+8MPwILu3NJSAUM6Br?= =?us-ascii?Q?QqN3zCv+Pg6lYf/mRIL3TAW/8lIqQmPEvur0RZUKlb+xEdYeXRfznOADIUjZ?= =?us-ascii?Q?rj8cF7Gs+PmjipPGKF45+rEGCTm43Psird2Bj2r1g6Xvz5PvItjEijXX0IKo?= =?us-ascii?Q?X2dw8L2smKpfk4Y3i1FumMz891mOHPMvQRpiRWljCEYhGF7xLzV7/Y1mGWbs?= =?us-ascii?Q?95iIGgxguaebUwAuScy/nJOHz778Vf5JoMhq5AjL0b1lYB3cwhQv5rWx7n1V?= =?us-ascii?Q?KXcWWvZj4iXUPCybvg2DyQPuWPIxxQUXJORqjsBXo4kSssA/SnyYgRVXuEaf?= =?us-ascii?Q?wAKetEqyz4+CcuYto4DkFczQVoFTsFbY8PdKxrgmaGg9iQCe3lHo11UKRYG5?= =?us-ascii?Q?4BP+yGjrUTX3+gC91ZCZrYcOe7gmT9yJVwjeAgXarQX6qbN0EjgrXDJeBlnx?= =?us-ascii?Q?LUyHZkuaC93ceNmunyXRdSgPg8Z4twNuQMJ5Oi9SRsFSk2IqZFNS56PutHH4?= =?us-ascii?Q?8/a5EaNP8xiXNLL/spfFm9eLkyUJwEkNNOs+nthqQeYMImc9ZMdprTTJcqkQ?= =?us-ascii?Q?E+ajjSOmQCdeLQ/Y6ly4R1iuORVgeeKZKyzwYCrMKzMjPvSnXFm0aQ+B4XzO?= =?us-ascii?Q?UOrPqAkhQvuPJFc5ArWEB6yvsKqwaWkejNCkzAfeD/JLYuRvhP0jx6l6tydV?= =?us-ascii?Q?aDMtGDK8OuBZ0sSqCmXI5c6GLzsTTJBVVGHw0jpW0EpI54YPNDcS/ZE5Qb/b?= =?us-ascii?Q?mkAClHECBZ65KydDnEKtF7NY4hQ7iEc5fc5tcFm89fGsEQ1OsY/YTldtHP6g?= =?us-ascii?Q?qj8nOdSpaGwoX/BQ6P2ecwXhGYdAudoancMasyeTqwzhI33IW6gYFdB9pVOh?= =?us-ascii?Q?SpTtvWpbLnVNbdSsnJUqMbMhhs25RtdhFSRZSNkcUIaFw9IXr/CUPrAYZToU?= =?us-ascii?Q?7l/ntCM/soO7Uw56xxxK4lFL+slTJqKGqg8z6faEwkNHd3Mu9+VCE/8oFcNL?= =?us-ascii?Q?ZbYdvnm9V0UhF4VM1Sv05JdREIa5vTSzeGOzs1MtdaiOoFdpDNFs4iVSfoU5?= =?us-ascii?Q?YypWS+AnFJzLEXKdJFJ3FIPf89LVKACbTBXNxv9twbPeZ9zMeTB24wdIICQA?= =?us-ascii?Q?MbCh/suLDsuWXRVgulxaSH/v+aplxvDFsmi+BQ5cfLxvwM2OVc4op1f0OquO?= =?us-ascii?Q?XpONZWQbcg+UNwHOkrnNU1LsxvA+D7HFv6sUYXOsJImqlyTvRdx6BhSoVbNA?= =?us-ascii?Q?g2d0v6p8r8H3aW/mOIceHKY6tkAt9EskWxOM/eSTsWce9QBkp6EtMyIeMAWv?= =?us-ascii?Q?1fY=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4073.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3322238-02d7-4e06-1df5-08d9031586c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2021 09:28:43.9153 (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: U27WVJ5OJn/ANJ+ukAn7btJUZbmgxmQb5vxeFi3RUNX6HL92FSBjKQKNd85FdrZl/ZTEnHGrRquT9XiBnLdyjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4074 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 Thanks, Bob -----Original Message----- From: Yeh, GregX =20 Sent: Thursday, March 25, 2021 4:15 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Liming Gao Subject: [PATCH] [edk2-staging] BaseTools/Fmmt: Fix rebuild FFS lost depend= ency section. https://bugzilla.tianocore.org/show_bug.cgi?id=3D3261 Dependency section data lost when rebuild FFS. Add pei dxe smm dependency section to FFS and Encap_INFO_DATA structure. Restore dependency section when build FFS. Cc: Bob Feng Cc: Liming Gao Signed-off-by: GregX Yeh --- BaseTools/Source/C/FMMT/FirmwareModuleManagement.h | 28 +- BaseTools/Source/C/FMMT/FmmtLib.c | 443 +++++++++++++++--= ---- 2 files changed, 334 insertions(+), 137 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h b/BaseTools= /Source/C/FMMT/FirmwareModuleManagement.h index 9d09c9160a..84ccfaed1d 100644 --- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h +++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h @@ -2,7 +2,7 @@ =20 Structures and functions declaration. =20 - Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -195,7 +195,7 @@ typedef struct { // UI Name for this FFS file, if has. // CHAR16 UiName[_MAX_PATH]; - UINT32 UiNameSize; + UINT32 UiNameSize; // // Total section number in this FFS. // @@ -223,8 +223,12 @@ typedef struct { UINT32 Offset; UINT8 FvLevel; EFI_GUID GuidName; - UINT8 *Depex; - UINT32 DepexLen; + UINT8 *PeiDepex; + UINT32 PeiDepexLen; + UINT8 *DxeDepex; + UINT32 DxeDepexLen; + UINT8 *SmmDepex; + UINT32 SmmDepexLen; BOOLEAN IsHandle; BOOLEAN IsFvStart; BOOLEAN IsFvEnd; @@ -259,8 +263,12 @@ typedef struct __ENCAP_INFO_DATA{ =20 CHAR16 UiName[_MAX_PATH]; UINT32 UiNameSize; - UINT8 *Depex; - UINT32 DepexLen; + UINT8 *PeiDepex; + UINT32 PeiDepexLen; + UINT8 *DxeDepex; + UINT32 DxeDepexLen; + UINT8 *SmmDepex; + UINT32 SmmDepexLen; =20 // // Next node. @@ -281,8 +289,12 @@ typedef struct _FFS_INFOMATION{ BOOLEAN IsFFS; CHAR16 UiName[_MAX_PATH]; UINT32 UiNameSize; - UINT8 *Depex; - UINT32 DepexLen; + UINT8 *PeiDepex; + UINT32 PeiDepexLen; + UINT8 *DxeDepex; + UINT32 DxeDepexLen; + UINT8 *SmmDepex; + UINT32 SmmDepexLen; BOOLEAN FfsFoundFlag; struct _FFS_INFOMATION *Next; } FFS_INFORMATION; diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index 9a9ba8b56f..fa77ed7317 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -164,8 +164,12 @@ LibInitializeFvStruct ( Fv->FfsAttuibutes[Index].IsLeaf =3D TRUE; Fv->FfsAttuibutes[Index].Level =3D 0xFF; Fv->FfsAttuibutes[Index].TotalSectionNum =3D 0; - Fv->FfsAttuibutes[Index].Depex =3D NULL; - Fv->FfsAttuibutes[Index].DepexLen =3D 0; + Fv->FfsAttuibutes[Index].PeiDepex =3D NULL; + Fv->FfsAttuibutes[Index].PeiDepexLen =3D 0; + Fv->FfsAttuibutes[Index].DxeDepex =3D NULL; + Fv->FfsAttuibutes[Index].DxeDepexLen =3D 0; + Fv->FfsAttuibutes[Index].SmmDepex =3D NULL; + Fv->FfsAttuibutes[Index].SmmDepexLen =3D 0; Fv->FfsAttuibutes[Index].IsHandle =3D FALSE; Fv->FfsAttuibutes[Index].IsFvStart =3D FALSE; Fv->FfsAttuibutes[Index].IsFvEnd =3D FALSE; @@ -835,6 +839,7 @@ LibParseSection ( CHAR8 *ToolOutputFileName; BOOLEAN HasUiSection; BOOLEAN FirstInFlag; + UINT32 KeepFfsCount; =20 DataOffset =3D 0; GuidAttr =3D 0; @@ -871,6 +876,7 @@ LibParseSection ( LargeHeaderOffset =3D 0; HasUiSection =3D FALSE; FirstInFlag =3D TRUE; + KeepFfsCount =3D *FfsCount; =20 =20 while (ParsedLength < BufferLength) { @@ -945,9 +951,13 @@ LibParseSecti= on ( LocalEncapData->Data =3D NULL; LocalEncapData->FvExtHeader =3D NULL; LocalEncapData->NextNode =3D NULL; - LocalEncapData->RightNode =3D NULL; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->RightNode =3D NULL; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; } @@ -972,13 +982,19 @@ LibParseSection ( if ((memcmp(&CurrentFv->FfsAttuibutes[*FfsCount - 1].G= uidName, &(LocalEncapDataTemp->FvExtHeader->FvName), sizeof(EFI_GUID)) =3D= =3D 0)) { memcpy(LocalEncapDataTemp->UiName, CurrentFv->FfsA= ttuibutes[*FfsCount - 1].UiName, _MAX_PATH); LocalEncapDataTemp->UiNameSize =3D CurrentFv->FfsA= ttuibutes[*FfsCount - 1].UiNameSize; - LocalEncapDataTemp->DepexLen =3D CurrentFv->FfsAtt= uibutes[*FfsCount - 1].DepexLen; - LocalEncapDataTemp->Depex =3D malloc (LocalEncapDa= taTemp->DepexLen); - if (LocalEncapDataTemp->Depex =3D=3D NULL) { + LocalEncapDataTemp->PeiDepexLen =3D CurrentFv->Ffs= Attuibutes[*FfsCount - 1].PeiDepexLen; + LocalEncapDataTemp->PeiDepex =3D malloc (LocalEnca= pDataTemp->PeiDepexLen); + LocalEncapDataTemp->DxeDepexLen =3D CurrentFv->Ffs= Attuibutes[*FfsCount - 1].DxeDepexLen; + LocalEncapDataTemp->DxeDepex =3D malloc (LocalEnca= pDataTemp->DxeDepexLen); + LocalEncapDataTemp->SmmDepexLen =3D CurrentFv->Ffs= Attuibutes[*FfsCount - 1].SmmDepexLen; + LocalEncapDataTemp->SmmDepex =3D malloc (LocalEnca= pDataTemp->SmmDepexLen); + if ((LocalEncapDataTemp->SmmDepex =3D=3D NULL) ||= =20 + (LocalEncapDataTemp->SmmDepex =3D=3D NULL) ||=20 + (LocalEncapDataTemp->SmmDepex =3D=3D NULL)){ Error(NULL, 0, 4001, "Resource: Memory can't b= e allocated", NULL); return EFI_ABORTED; } - memcpy(LocalEncapDataTemp->Depex, CurrentFv->FfsAt= tuibutes[*FfsCount - 1].Depex, LocalEncapDataTemp->DepexLen); + memcpy(LocalEncapDataTemp->PeiDepex, CurrentFv->Ff= sAttuibutes[*FfsCount - 1].PeiDepex, LocalEncapDataTemp->PeiDepexLen); + memcpy(LocalEncapDataTemp->DxeDepex, CurrentFv->Ff= sAttuibutes[*FfsCount - 1].DxeDepex, LocalEncapDataTemp->DxeDepexLen); + memcpy(LocalEncapDataTemp->SmmDepex,=20 + CurrentFv->FfsAttuibutes[*FfsCount - 1].SmmDepex,=20 + LocalEncapDataTemp->SmmDepexLen); } } } @@ -1257,8 +1273,12 @@ LibParseSection ( =20 LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_GUIDED_SECTION; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; // @@ -1290,8 +1310,12 @@ LibParseSection ( LocalEncapData =3D LocalEncapData->RightNode; LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_GUIDED_SECTION; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; // @@ -1608,25 +1632,25 @@ LibParseSection ( NumberOfSections ++; CurrentFv->FfsAttuibutes[*FfsCount].Level =3D Level; HasDepexSection =3D TRUE; - CurrentFv->FfsAttuibutes[*FfsCount].Depex =3D malloc (SectionLength)= ; - memcpy(CurrentFv->FfsAttuibutes[*FfsCount].Depex, Ptr, SectionLength= ); - CurrentFv->FfsAttuibutes[*FfsCount].DepexLen =3D SectionLength; + CurrentFv->FfsAttuibutes[*FfsCount].PeiDepex =3D malloc (SectionLeng= th); + memcpy(CurrentFv->FfsAttuibutes[*FfsCount].PeiDepex, Ptr, SectionLen= gth); + CurrentFv->FfsAttuibutes[*FfsCount].PeiDepexLen =3D SectionLength; break; case EFI_SECTION_DXE_DEPEX: NumberOfSections ++; CurrentFv->FfsAttuibutes[*FfsCount].Level =3D Level; HasDepexSection =3D TRUE; - CurrentFv->FfsAttuibutes[*FfsCount].Depex =3D malloc (SectionLength)= ; - memcpy(CurrentFv->FfsAttuibutes[*FfsCount].Depex, Ptr, SectionLength= ); - CurrentFv->FfsAttuibutes[*FfsCount].DepexLen =3D SectionLength; + CurrentFv->FfsAttuibutes[*FfsCount].DxeDepex =3D malloc (SectionLeng= th); + memcpy(CurrentFv->FfsAttuibutes[*FfsCount].DxeDepex, Ptr, SectionLen= gth); + CurrentFv->FfsAttuibutes[*FfsCount].DxeDepexLen =3D SectionLength; break; case EFI_SECTION_SMM_DEPEX: NumberOfSections ++; CurrentFv->FfsAttuibutes[*FfsCount].Level =3D Level; HasDepexSection =3D TRUE; - CurrentFv->FfsAttuibutes[*FfsCount].Depex =3D malloc (SectionLength)= ; - memcpy(CurrentFv->FfsAttuibutes[*FfsCount].Depex, Ptr, SectionLength= ); - CurrentFv->FfsAttuibutes[*FfsCount].DepexLen =3D SectionLength; + CurrentFv->FfsAttuibutes[*FfsCount].SmmDepex =3D malloc (SectionLeng= th); + memcpy(CurrentFv->FfsAttuibutes[*FfsCount].SmmDepex, Ptr, SectionLen= gth); + CurrentFv->FfsAttuibutes[*FfsCount].SmmDepexLen =3D SectionLength; break; =20 case EFI_SECTION_USER_INTERFACE: @@ -1686,6 +1710,10 @@ LibParseSection ( CurrentFv->FfsAttuibutes[*FfsCount].UiNameSize =3D UINameSize; } =20 + if (IsFfs) { + memcpy (CurrentFv->FfsAttuibutes[KeepFfsCount].UiName, UIName, UIN= ameSize); + CurrentFv->FfsAttuibutes[KeepFfsCount].UiNameSize =3D UINameSize; + } HasDepexSection =3D FALSE; free(UIName); UINameSize =3D 0; @@ -1983,8 +2011,12 @@ LibGetFileInfo ( LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_FFS; LocalEncapData->FvExtHeader =3D NULL; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; // @@ -2031,8 +2063,12 @@ LibGetFileInfo ( LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_FFS; LocalEncapData->FvExtHeader =3D NULL; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; // @@ -2235,8 +2271,12 @@ LibGetFvInfo ( } =20 CurrentFv->EncapData->FvExtHeader =3D NULL; - CurrentFv->EncapData->Depex =3D NULL; - CurrentFv->EncapData->DepexLen =3D 0; + CurrentFv->EncapData->PeiDepex =3D NULL; + CurrentFv->EncapData->PeiDepexLen =3D 0; + CurrentFv->EncapData->DxeDepex =3D NULL; + CurrentFv->EncapData->DxeDepexLen =3D 0; + CurrentFv->EncapData->SmmDepex =3D NULL; + CurrentFv->EncapData->SmmDepexLen =3D 0; CurrentFv->EncapData->UiNameSize =3D 0; CurrentFv->EncapData->Level =3D Level; CurrentFv->EncapData->Type =3D FMMT_ENCAP_TREE_FV; @@ -2292,8 +2332,1= 2 @@ LibGetFvInfo ( LocalEncapData->Type =3D FMMT_ENCAP_TREE_FV; LocalEncapData->Data =3D (EFI_FIRMWARE_VOLUME_HEADER *) malloc (siz= eof (EFI_FIRMWARE_VOLUME_HEADER)); LocalEncapData->FvExtHeader =3D NULL; - LocalEncapData->Depex =3D NULL; - LocalEncapData->DepexLen =3D 0; + LocalEncapData->PeiDepex =3D NULL; + LocalEncapData->PeiDepexLen =3D 0; + LocalEncapData->DxeDepex =3D NULL; + LocalEncapData->DxeDepexLen =3D 0; + LocalEncapData->SmmDepex =3D NULL; + LocalEncapData->SmmDepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; LocalEncapData->FvId =3D *FvCount; if (LocalEncapData->Data =3D=3D NULL) { @@ -4255,8 +4299,12 @@ LibEn= capNewFvFile( OutputFileNameList->ParentLevel =3D 0; OutputFileNameList->Next =3D NULL; OutputFileNameList->UiNameSize =3D 0; - OutputFileNameList->Depex =3D NULL; - OutputFileNameList->DepexLen =3D 0; + OutputFileNameList->PeiDepex =3D NULL; + OutputFileNameList->PeiDepexLen =3D 0; + OutputFileNameList->DxeDepex =3D NULL; + OutputFileNameList->DxeDepexLen =3D 0; + OutputFileNameList->SmmDepex =3D NULL; + OutputFileNameList->SmmDepexLen =3D 0; OutputFileNameList->FfsFoundFlag =3D FALSE; =20 ChildFileNameList =3D (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION))= ; @@ -4270,8 +4318,12 @@ LibEncapNewFvFile( ChildFileNameList->Next =3D NULL; ChildFileNameList->IsFFS =3D FALSE; ChildFileNameList->UiNameSize =3D 0; - ChildFileNameList->Depex =3D NULL; - ChildFileNameList->DepexLen =3D 0; + ChildFileNameList->PeiDepex =3D NULL; + ChildFileNameList->PeiDepexLen =3D 0; + ChildFileNameList->DxeDepex =3D NULL; + ChildFileNameList->DxeDepexLen =3D 0; + ChildFileNameList->SmmDepex =3D NULL; + ChildFileNameList->SmmDepexLen =3D 0; ChildFileNameList->FfsFoundFlag =3D FALSE; // // Encapsulate from the lowest FFS file level. @@ -4663,8 +4715,12 @@ LibEncapNewFvFile( if (EncapFvIndex > 0) { memcpy(OutputFileNameList->UiName,FvInFd->FfsAttuibutes[EncapF= vIndex - 1].UiName, FvInFd->FfsAttuibutes[EncapFvIndex - 1].UiNameSize); OutputFileNameList->UiNameSize =3D FvInFd->FfsAttuibutes[Encap= FvIndex - 1].UiNameSize; - OutputFileNameList->Depex =3D FvInFd->FfsAttuibutes[EncapFvInd= ex - 1].Depex; - OutputFileNameList->DepexLen =3D FvInFd->FfsAttuibutes[EncapFv= Index - 1].DepexLen; + OutputFileNameList->PeiDepex =3D FvInFd->FfsAttuibutes[EncapFv= Index - 1].PeiDepex; + OutputFileNameList->PeiDepexLen =3D FvInFd->FfsAttuibutes[Enca= pFvIndex - 1].PeiDepexLen; + OutputFileNameList->DxeDepex =3D FvInFd->FfsAttuibutes[EncapFv= Index - 1].DxeDepex; + OutputFileNameList->DxeDepexLen =3D FvInFd->FfsAttuibutes[Enca= pFvIndex - 1].DxeDepexLen; + OutputFileNameList->SmmDepex =3D FvInFd->FfsAttuibutes[EncapFv= Index - 1].SmmDepex; + OutputFileNameList->SmmDepexLen =3D=20 + FvInFd->FfsAttuibutes[EncapFvIndex - 1].SmmDepexLen; OutputFileNameList->FfsFoundFlag =3D FfsFoundFlag; OutputFileNameList->FvId =3D FvInFd->FfsAttuibutes[EncapFvInde= x - 1].FvId; OutputFileNameList->ParentLevel =3D ParentLevel - 1; @@ -4683,= 13 +4739,13 @@ LibEncapNewFvFile( } while (LocalEncapData->NextNode !=3D NULL) { if (LocalEncapData->Level =3D=3D ParentLevel) { - for(;LocalEncapData->NextNode !=3D NULL;) { - if(LocalEncapData->FvExtHeader !=3D NULL) { - break; - } - LocalEncapData =3D LocalEncapData->NextNode; - } - break; + for(;LocalEncapData->NextNode !=3D NULL;) { + if(LocalEncapData->FvExtHeader !=3D NULL) { + break; + } + LocalEncapData =3D LocalEncapData->NextNode; + } + break; } LocalEncapData =3D LocalEncapData->NextNode; } @@ -4701,100 +4757,225 @@ LibEncapNewFvFile( return EFI_ABORTED; } =20 - if (OutputFileNameList->UiNameSize > 0) { - TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (= ), OS_SEP), TemDir, "tmp"); - TmpFile =3D fopen(TmpFileName, "wb+"); - if (TmpFile =3D=3D NULL) { - Error("FMMT", 0, 0004, "Could not open tmp file %s to sto= re UI section information! \n", ""); - free (OutputFileNameList); - free (ChildFileNameList); - return EFI_ABORTED; + for (Id =3D 0; Id <=3D FvInFd->FfsNumbers; Id++) { + if ((memcmp(&FvInFd->FfsAttuibutes[Id].GuidName, &(LocalEncapD= ata->FvExtHeader->FvName), sizeof(EFI_GUID)) =3D=3D 0)){ + if (&FvInFd->FfsAttuibutes[Id].UiNameSize > 0){ + OutputFileNameList->UiNameSize =3D FvInFd->FfsAttuibutes[I= d].UiNameSize; + memcpy(OutputFileNameList->UiName,=20 + FvInFd->FfsAttuibutes[Id].UiName,=20 + FvInFd->FfsAttuibutes[Id].UiNameSize); } - header =3D (OutputFileNameList->UiNameSize+4) | (EFI_SECTION_= USER_INTERFACE << 24); - Index =3D 0; - while (header) { - SectionHeader[Index] =3D header % 0x100; - header /=3D 0x100; - Index ++; - } - InputFile =3D fopen(InputFileName, "rb+"); - if (InputFile =3D=3D NULL) { - Error("FMMT", 0, 0004, "Could not open input file %s! \n", = ""); - fclose(TmpFile); - free (OutputFileNameList); - free (ChildFileNameList); - return EFI_ABORTED; - } - fseek(InputFile, 0, SEEK_SET); - fseek(InputFile, 0, SEEK_END); - InputFileSize =3D ftell(InputFile); - fseek(InputFile, 0, SEEK_SET); - - Buffer =3D malloc(InputFileSize+OutputFileNameList->UiNameSiz= e+4); - memcpy(Buffer, (CHAR16 *)SectionHeader, 4); - memcpy(Buffer + 4, (CHAR16 *)(OutputFileNameList->UiName), Ou= tputFileNameList->UiNameSize); - if (fread(Buffer+4+OutputFileNameList->UiNameSize, 1, InputFi= leSize, InputFile) !=3D InputFileSize) { - Error("FMMT", 0, 0004, "Could not open sec file %s to add U= I section information! \n", ""); - fclose(TmpFile); - fclose(InputFile); - free(Buffer); - free (OutputFileNameList); - free (ChildFileNameList); - return EFI_ABORTED; - } - fwrite(Buffer, 1, InputFileSize + OutputFileNameList->UiNameS= ize + 4, TmpFile); - free(Buffer); - fclose(TmpFile); - fclose(InputFile); - InputFileName =3D TmpFileName; + if (&FvInFd->FfsAttuibutes[Id].PeiDepexLen > 0){ + OutputFileNameList->PeiDepexLen =3D FvInFd->FfsAttuibutes[= Id].PeiDepexLen; + OutputFileNameList->PeiDepex =3D FvInFd->FfsAttuibutes[= Id].PeiDepex; + } + if (&FvInFd->FfsAttuibutes[Id].DxeDepexLen > 0){ + OutputFileNameList->DxeDepexLen =3D FvInFd->FfsAttuibutes[= Id].DxeDepexLen; + OutputFileNameList->DxeDepex =3D FvInFd->FfsAttuibutes[= Id].DxeDepex; + } + if (&FvInFd->FfsAttuibutes[Id].SmmDepexLen > 0){ + OutputFileNameList->SmmDepexLen =3D FvInFd->FfsAttuibutes[= Id].SmmDepexLen; + OutputFileNameList->SmmDepex =3D FvInFd->FfsAttuibutes[= Id].SmmDepex; + } + } } - if (OutputFileNameList->DepexLen > 0) { - TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (= ), OS_SEP), TemDir, "tmp"); - TmpFile =3D fopen(TmpFileName, "wb+"); - if (TmpFile =3D=3D NULL) { - Error("FMMT", 0, 0004, "Could not open tmp file %s to st= ore Depex section information! \n", ""); - free (OutputFileNameList); - free (ChildFileNameList); - return EFI_ABORTED; + + if (OutputFileNameList->UiNameSize > 0) { + TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (),= OS_SEP), TemDir, "tmp"); + TmpFile =3D fopen(TmpFileName, "wb+"); + if (TmpFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open tmp file %s to store = UI section information! \n", ""); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + header =3D (OutputFileNameList->UiNameSize+4) | (EFI_SECTION_U= SER_INTERFACE << 24); + Index =3D 0; + while (header) { + SectionHeader[Index] =3D header % 0x100; + header /=3D 0x100; + Index ++; + } + InputFile =3D fopen(InputFileName, "rb+"); + if (InputFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open input file %s! \n", "= "); + fclose(TmpFile); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fseek(InputFile, 0, SEEK_SET); + fseek(InputFile, 0, SEEK_END); + InputFileSize =3D ftell(InputFile); + fseek(InputFile, 0, SEEK_SET); + + if (InputFileSize % 4 !=3D 0) { + AlignN =3D 4 - InputFileSize % 4; + } + + Buffer =3D malloc(InputFileSize + AlignN + OutputFileNameList-= >UiNameSize + 4); + memcpy(Buffer + InputFileSize + AlignN , (CHAR16 *)SectionHead= er, 4); + memcpy(Buffer + InputFileSize + AlignN + 4, (CHAR16 *)(OutputF= ileNameList->UiName), OutputFileNameList->UiNameSize); + if (fread(Buffer, 1, InputFileSize, InputFile) !=3D InputFileS= ize) { + Error("FMMT", 0, 0004, "Could not open sec file %s to add UI= section information! \n", ""); + fclose(TmpFile); + fclose(InputFile); + free(Buffer); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fwrite(Buffer, 1, InputFileSize + AlignN + OutputFileNameList-= >UiNameSize + 4, TmpFile); + free(Buffer); + fclose(TmpFile); + fclose(InputFile); + InputFileName =3D TmpFileName; + } + + if (OutputFileNameList->DxeDepexLen > 0) { + TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (),= OS_SEP), TemDir, "tmp"); + TmpFile =3D fopen(TmpFileName, "wb+"); + if (TmpFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open tmp file %s to store = Depex section information! \n", ""); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + InputFile =3D fopen(InputFileName, "rb+"); + if (InputFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open input file %s! \n", "= "); + fclose(TmpFile); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fseek(InputFile, 0, SEEK_SET); + fseek(InputFile, 0, SEEK_END); + InputFileSize =3D ftell(InputFile); + fseek(InputFile, 0, SEEK_SET); + // + // make sure the section is 4 byte align + // + if (OutputFileNameList->DxeDepexLen % 4 !=3D 0) { + AlignN =3D 4 - OutputFileNameList->DxeDepexLen % 4; + } + Buffer =3D malloc(InputFileSize + OutputFileNameList->DxeDepex= Len + AlignN); + memcpy(Buffer, OutputFileNameList->DxeDepex, OutputFileNameLis= t->DxeDepexLen); + if (AlignN !=3D 0) { + for (Index =3D 0; Index < AlignN; Index ++) { + memcpy(Buffer + OutputFileNameList->DxeDepexLen +=20 + Index, AlignV, 1); } - InputFile =3D fopen(InputFileName, "rb+"); - if (InputFile =3D=3D NULL) { - Error("FMMT", 0, 0004, "Could not open input file %s! \n",= ""); - fclose(TmpFile); + } + if (fread(Buffer + OutputFileNameList->DxeDepexLen + AlignN, 1= , InputFileSize, InputFile) !=3D InputFileSize) { + Error("FMMT", 0, 0004, "Could not open sec file %s to add De= pex section information! \n", ""); + fclose(TmpFile); + fclose(InputFile); + free(Buffer); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fwrite(Buffer, 1, InputFileSize + OutputFileNameList->DxeDepex= Len + AlignN, TmpFile); + free(Buffer); + fclose(TmpFile); + fclose(InputFile); + InputFileName =3D TmpFileName; + } + + if (OutputFileNameList->PeiDepexLen > 0) { + TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (),= OS_SEP), TemDir, "tmp"); + TmpFile =3D fopen(TmpFileName, "wb+"); + if (TmpFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open tmp file %s to=20 + store Depex section information! \n", ""); free (OutputFileNameList); free (ChildFileNameList); return EFI_ABORTED; + } + InputFile =3D fopen(InputFileName, "rb+"); + if (InputFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open input file %s! \n", "= "); + fclose(TmpFile); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fseek(InputFile, 0, SEEK_SET); + fseek(InputFile, 0, SEEK_END); + InputFileSize =3D ftell(InputFile); + fseek(InputFile, 0, SEEK_SET); + // make sure the section is 4 byte align + if (OutputFileNameList->PeiDepexLen % 4 !=3D 0) { + AlignN =3D 4 - OutputFileNameList->PeiDepexLen % 4; + } + Buffer =3D malloc(InputFileSize + OutputFileNameList->PeiDepex= Len + AlignN); + memcpy(Buffer, OutputFileNameList->PeiDepex, OutputFileNameLis= t->PeiDepexLen); + if (AlignN !=3D 0) { + for (Index =3D 0; Index < AlignN; Index ++) { + memcpy(Buffer + OutputFileNameList->PeiDepexLen +=20 + Index, AlignV, 1); } - fseek(InputFile, 0, SEEK_SET); - fseek(InputFile, 0, SEEK_END); - InputFileSize =3D ftell(InputFile); - fseek(InputFile, 0, SEEK_SET); - // make sure the section is 4 byte align - if (OutputFileNameList->DepexLen % 4 !=3D 0) { - AlignN =3D 4 - OutputFileNameList->DepexLen % 4; - } - Buffer =3D malloc(InputFileSize + OutputFileNameList->DepexL= en + AlignN); - memcpy(Buffer, OutputFileNameList->Depex, OutputFileNameList= ->DepexLen); - if (AlignN !=3D 0) { - for (Index =3D 0; Index < AlignN; Index ++) { - memcpy(Buffer + OutputFileNameList->DepexLen + Index= , AlignV, 1); - } - } - if (fread(Buffer + OutputFileNameList->DepexLen + AlignN, 1,= InputFileSize, InputFile) !=3D InputFileSize) { - Error("FMMT", 0, 0004, "Could not open sec file %s to ad= d Depex section information! \n", ""); - fclose(TmpFile); - fclose(InputFile); - free(Buffer); - free (OutputFileNameList); - free (ChildFileNameList); - return EFI_ABORTED; - } - fwrite(Buffer, 1, InputFileSize + OutputFileNameList->DepexL= en + AlignN, TmpFile); + } + if (fread(Buffer + OutputFileNameList->PeiDepexLen + AlignN, 1= , InputFileSize, InputFile) !=3D InputFileSize) { + Error("FMMT", 0, 0004, "Could not open sec file %s to add De= pex section information! \n", ""); + fclose(TmpFile); + fclose(InputFile); free(Buffer); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fwrite(Buffer, 1, InputFileSize + OutputFileNameList->PeiDepex= Len + AlignN, TmpFile); + free(Buffer); + fclose(TmpFile); + fclose(InputFile); + InputFileName =3D TmpFileName; + } + + if (OutputFileNameList->SmmDepexLen > 0) { + TmpFileName =3D LibFilenameStrExtended(strrchr(GenTempFile (),= OS_SEP), TemDir, "tmp"); + TmpFile =3D fopen(TmpFileName, "wb+"); + if (TmpFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open tmp file %s to store = Depex section information! \n", ""); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + InputFile =3D fopen(InputFileName, "rb+"); + if (InputFile =3D=3D NULL) { + Error("FMMT", 0, 0004, "Could not open input file %s! \n", "= "); + fclose(TmpFile); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fseek(InputFile, 0, SEEK_SET); + fseek(InputFile, 0, SEEK_END); + InputFileSize =3D ftell(InputFile); + fseek(InputFile, 0, SEEK_SET); + // make sure the section is 4 byte align + if (OutputFileNameList->SmmDepexLen % 4 !=3D 0) { + AlignN =3D 4 - OutputFileNameList->SmmDepexLen % 4; + } + Buffer =3D malloc(InputFileSize + OutputFileNameList->SmmDepex= Len + AlignN); + memcpy(Buffer, OutputFileNameList->SmmDepex, OutputFileNameLis= t->SmmDepexLen); + if (AlignN !=3D 0) { + for (Index =3D 0; Index < AlignN; Index ++) { + memcpy(Buffer + OutputFileNameList->SmmDepexLen + Index, A= lignV, 1); + } + } + if (fread(Buffer + OutputFileNameList->SmmDepexLen + AlignN, 1= , InputFileSize, InputFile) !=3D InputFileSize) { + Error("FMMT", 0, 0004, "Could not open sec file %s to add=20 + Depex section information! \n", ""); fclose(TmpFile); fclose(InputFile); - InputFileName =3D TmpFileName; - } + free(Buffer); + free (OutputFileNameList); + free (ChildFileNameList); + return EFI_ABORTED; + } + fwrite(Buffer, 1, InputFileSize + OutputFileNameList->SmmDepex= Len + AlignN, TmpFile); + free(Buffer); + fclose(TmpFile); + fclose(InputFile); + InputFileName =3D TmpFileName; + } + for (Id =3D FvInFd->FfsNumbers; Id <=3D FvInFd->FfsNumbers; Id--)= { if ((memcmp(&FvInFd->FfsAttuibutes[Id].GuidName, &(LocalEncap= Data->FvExtHeader->FvName), sizeof(EFI_GUID)) =3D=3D 0)){ if (access(FvInFd->FfsAttuibutes[Id].FfsName, 0) !=3D -1)= { @@ -5083,8 +5264,12 @@ LibEncapNewFvFile( memcpy(OutputFileNameList->UiName, FvInFd->FfsAttuibutes[I= d].UiName, FvInFd->FfsAttuibutes[Id].UiNameSize); OutputFileNameList->UiNameSize =3D FvInFd->FfsAttuibutes[I= d].UiNameSize; OutputFileNameList->FFSName =3D FvInFd->FfsAttuibutes[Id].= FfsName; - OutputFileNameList->Depex =3D FvInFd->FfsAttuibutes[Id].De= pex; - OutputFileNameList->DepexLen =3D FvInFd->FfsAttuibutes[Id]= .DepexLen; + OutputFileNameList->PeiDepex =3D FvInFd->FfsAttuibutes[Id]= .PeiDepex; + OutputFileNameList->PeiDepexLen =3D FvInFd->FfsAttuibutes[= Id].PeiDepexLen; + OutputFileNameList->DxeDepex =3D FvInFd->FfsAttuibutes[Id]= .DxeDepex; + OutputFileNameList->DxeDepexLen =3D FvInFd->FfsAttuibutes[= Id].DxeDepexLen; + OutputFileNameList->SmmDepex =3D FvInFd->FfsAttuibutes[Id]= .SmmDepex; + OutputFileNameList->SmmDepexLen =3D=20 + FvInFd->FfsAttuibutes[Id].SmmDepexLen; OutputFileNameList->FfsFoundFlag =3D TRUE; OutputFileNameList->IsFFS =3D TRUE; OutputFileNameList->InFvId =3D Id; -- 2.16.2.windows.1