From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.25609.1605001416633705165 for ; Tue, 10 Nov 2020 01:43:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=oKgYa8H6; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: bob.c.feng@intel.com) IronPort-SDR: cG/Wx229TlVilNJsMa00ces24JuwfKfDWvbL/JVYvahO04Uj1AS0yKZfLi729ZjlDQ+PtHX9ou CjEvuKWXx3kQ== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149795892" X-IronPort-AV: E=Sophos;i="5.77,466,1596524400"; d="scan'208";a="149795892" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2020 01:43:35 -0800 IronPort-SDR: jwlYl2SiWMuOM//1KSHdKKcnZZjVzMtsIvlH7s7ovv9P/j2H27Pf6Kf+J/aCzbEJtE3xg+JGXM CIFOUWY6obhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,466,1596524400"; d="scan'208";a="360045504" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga002.fm.intel.com with ESMTP; 10 Nov 2020 01:43:35 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 10 Nov 2020 01:43:35 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 10 Nov 2020 01:43:34 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 10 Nov 2020 01:43:34 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) 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.1713.5; Tue, 10 Nov 2020 01:43:34 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mfX9xcDY/DcCTz4KexSNafzxhfhuM84r9DNclPKHPadm8cp3z3bGHgKA/Fdx1jKXM+IrsvOBCUXZDF/nOF2ZbpJbQklg7duTz8i65Fuj5qiJR4oYLXtbwpRJH8WTbgxF/tkcwmZgUMKxlCx/o2E/ESSAMGwJwHU3wH6mmNumRFVBf7TDDu0BOcaSHlA/d1eDOJbx/8leNrQfzD2i4FU3edwgD/LqwDGS04pMq8HkBjXqgyYtOscQbeiah2kzDtjw2v1E77X5Owk1LRTsJwo+MKaWEc2o1KOMtOHgjAM/YhPH1GfwF+DKTnqu0PKvQ2oXYZ9mfY7JUnZbIrMtnQYFNw== 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=/jyL7kybXBzCDz2qkH0KJJIzgD6zUm3vnLeemHRvJt8=; b=Uk67jwc71vJU4b+lbr7DDGH1LBLBd+nMFOgPTVeFHvTZR2269mD2me+xKBNWSq+5B3klXmy/9MGGwezsMQrWKOmzLF3qCgzf19RbutPwaHWcu1OK4gatZI4QrXmEkAK1ssOAlh2vVCxipe6KUWZ2Wiw3FM6ICGey9CiFRZDtpXcD3rVtmWFeHGw3vKx8XBKV5bMBlI1Q7JLIa2G1+P6LQsPmVvx84wXkem0DcbIq9q+pai7ac3n4P0tYP1vvboU3F/mPzQ4vvgsk5u8jvwgdPSUoJqoYAd2Zn/KZarkAHYGD/QR+CGsvKGsJ3m5biWloNiXcQlp0000hia+hJDTDyQ== 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=/jyL7kybXBzCDz2qkH0KJJIzgD6zUm3vnLeemHRvJt8=; b=oKgYa8H68Rlb7JRrgu1GNvIQ9hq3vv6J9vs/sgRwGRS9mSb+bOhRh/cvCXOBvKTAeXeDOnbg0egIAtJKszn0og3G4kT1T/2/o+fT4zt6E9jxhrgtEa4DXK0MvhaIf8f7tDT8FoGCM/Al1CDAraIVIJsOzrR2AW3A3yh9wpeBF1c= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM6PR11MB2539.namprd11.prod.outlook.com (2603:10b6:5:bf::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21; Tue, 10 Nov 2020 09:43:33 +0000 Received: from DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::c9f:47ea:6321:5ccb]) by DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::c9f:47ea:6321:5ccb%3]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 09:43:33 +0000 From: "Bob Feng" To: "Yeh, GregX" , "devel@edk2.groups.io" CC: Liming Gao , fengyunhua Subject: Re: [PATCH] BaseTools/FMMT: Replace file failure when FV level over 2 Thread-Topic: [PATCH] BaseTools/FMMT: Replace file failure when FV level over 2 Thread-Index: AQHWsaTV7DshF1jLrUWutdeVEFzn06m2HWiggAEYyVCACfE0AA== Date: Tue, 10 Nov 2020 09:43:32 +0000 Message-ID: References: <20201103054711.22836-1-gregx.yeh@intel.com> In-Reply-To: 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.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 543434a4-687c-426e-aa88-08d8855d16aa x-ms-traffictypediagnostic: DM6PR11MB2539: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6LRy19kh3nQTA615jrydignmBI87XMm9H73EkyDm9V1DdvUG2NKxTdaDqwAWsX5pK6KiaDwHl/ax1c4wwrrmjRBEPlq+YzBsZj++LcFnLeoJd2fAwHWNTOX7QJfnN0IJIP0+2NQvASCKdOZ8R/YxoXiwbdmvS6AecOevUzXRkLqDcg9alyo5JvChmzb5IEHHrtYB5pOcZdJ2IH9bhHNHGYnab4zIfzXuN03TPHVM8VQCcJt69Zl0Yr3dozVbCvuhqTwGPZSzSu/Z0l75WmTucVlJoPPwzX8GGtg1Vm44gzW5BtZ73Fmoy1pb554g07/twrUV68scMsmoT3+GR9OdnQ== 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:(4636009)(39860400002)(366004)(376002)(346002)(396003)(136003)(186003)(26005)(478600001)(6506007)(4326008)(71200400001)(9686003)(83380400001)(55016002)(2906002)(5660300002)(7696005)(316002)(110136005)(66446008)(64756008)(66556008)(66476007)(76116006)(66946007)(33656002)(53546011)(8676002)(8936002)(30864003)(52536014)(86362001)(54906003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 8HzNSZtjYQc1HITTh4pLnE7neuNbBZktm2U+bnHB8rf93Ewd5itLXHIL1vAc9tHMtlEDMzCNHqLEtjRG0nojTLZx0qinuu99dh3q24Z494BHVQugo8qe6VFDt5f/SbdywXO5sGmmYfYHBNo4AGoCGW479+/zhPunJEtPTXSc2/fdkMlRNIKa3c73IeW9wixIw46TjhDwP1mUaAW9Xfvj2CV+02m+e7RZDPZsfIoJjam7926ltOqw3+IXjVy9eP+pewq0Jo9xVDayDMToA9ZB/1Bjja6f0P0po8kHHLf4OlPVIIqOT3JO//cu8CP+lQKczrApCkpPPK442O8QVnxU110C0jeOFO48iP3YoWq5aiCCgaUjYldOz9GVnEqnlnxiaWJ9rLRPPLI5rl8/AdCwsMbSlzypI9GNaTPEuKjgL8MKcMZjFUWm5bzoLC8EEvP0oi11mO1s/A5/V3ROGgpNiPhDr9DMnfVLYW6RG3mKkYpTAn8aCzcqfeMfykMeh+30Bgc9+ua5tfjjw1e+c4afgQlg2tHtYH7SGGSm3CZVgAlW3ZC5uzYKkNnQoDEVPDNs6Zuz3X6Ur4ovHkM30UImDKQ/0EyEPZsOtvgOVKwDbwuKcMZB0Waq/yCQLYBweou0lwI51uKfcV/F6diyXJDVIS+9lNVYrbtw5NoCCVB/SGHr8QoxzSTiVsbWZ/ip2IXJGzj3CElk/aUOGRtDYg+B2idx4/NBw31iiNkTRORDppDJY5tiENqxFbdWJFB6xvsIqRqI+jKi2m/KHtPIuU3CmNmgXUZu7Vwgbw9YOjOWPHgzevypdTAwNg8eNBUNK4F3rK6Un4CAMYXBwE+CTxe4R7i7/HcyVgiWR8VEKUqWP4t/ogUKywjWd8wlF9SolHwpiepSOU+DJS8Kkb7pe4x9Tw== 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: 543434a4-687c-426e-aa88-08d8855d16aa X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2020 09:43:33.0292 (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: oTjH2w0t2K3pHuFJdQVD/kb0MOGelyk58cUTD7xarQ1SRbJNJwBD1Z4npF0snONBTeMUVMRyrikasiuwC0t2xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2539 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 Greg, I found there is a regression issue after applying this patch. It happens w= hen the FMMT delete a ffs file from an FV which is in a multiple level FV l= ayout image. Thanks, Bob -----Original Message----- From: Yeh, GregX =20 Sent: Wednesday, November 4, 2020 10:07 AM To: Feng, Bob C ; devel@edk2.groups.io Cc: Liming Gao Subject: RE: [PATCH] BaseTools/FMMT: Replace file failure when FV level ove= r 2 Hi Bob, This problem can be reproduced on APL. We want to replace new BT FW by FMM= T. BT FW is located at FV level 3 FvOptional (level1) |--FvCnvUnCompact(Level2) |--FvBlueToothDxeUnCompact(level3) |--BT FW We can replace BT FW successfully when BT FW at FV level 2. But fail when BT FW at FV level 3. Thanks! Greg -----Original Message----- From: Feng, Bob C Sent: Tuesday, November 3, 2020 5:10 PM To: Yeh, GregX ; devel@edk2.groups.io Cc: Liming Gao Subject: RE: [PATCH] BaseTools/FMMT: Replace file failure when FV level ove= r 2 Hi Greg, Could you provide more details about problems that this patch fix? It would= be great if you can share the test case. FMMT tool is in the edk2-staging repo, so the patch title for FMMT should a= dd [edk2-staging] tag. Thanks, Bob -----Original Message----- From: Yeh, GregX Sent: Tuesday, November 3, 2020 1:47 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Liming Gao Subject: [PATCH] BaseTools/FMMT: Replace file failure when FV level over 2 Fixed replace file failure when FFS in multi level FV and FV level over 2. Signed-off-by: GregX Yeh Cc: Bob Feng Cc: Liming Gao --- BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 2 +- BaseTools/Source/C/FMMT/FirmwareModuleManagement.h | 3 +- BaseTools/Source/C/FMMT/FmmtLib.c | 171 ++++++++++++++---= ---- 3 files changed, 118 insertions(+), 58 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools= /Source/C/FMMT/FirmwareModuleManagement.c index 38056153fb..dfad02838b 100644 --- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c +++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c @@ -615,7 +615,7 @@ static UINT32 FindFile(FV_INFORMATION *FvInFd, UINT8 Fv= Level, CHAR8 *File, UINT3 return 0; } LibAscii2Unicode(File, UIName); - for (Index =3D 0; Index <=3D FvInFd->FfsNumbers; Index++) { + for (Index =3D 0; Index < FvInFd->FfsNumbers; Index++) { // // Compare the New File Name with UI Name of FFS // NOTE: The UI Name is Unicode, but the New File Name is Ascii. diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h b/BaseTools= /Source/C/FMMT/FirmwareModuleManagement.h index 9d09c9160a..da9eb1a4b9 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 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -284,6 +284,7 @@ typedef struct _FFS_INFOMATION{ UINT8 *Depex; UINT32 DepexLen; BOOLEAN FfsFoundFlag; + UINT8 FvLevel; struct _FFS_INFOMATION *Next; } FFS_INFORMATION; =20 diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index b945e9b63d..9bccd634bb 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -523,7 +523,7 @@ LibReadFvHeader ( FvExtHeader->FvName.Data4[6], FvExtHeader->FvName.Data4[7]); LibExtractFvUiName(FvExtHeader, &FvUiName); - if (FvUiName !=3D NULL && FvLevel =3D=3D 1) { + if (FvUiName !=3D NULL && (FvLevel - 1) !=3D 0) { printf("%sFV UI Name: %s\n\n", BlankSpace, FvUiName); } free(FvUiName); @@ -709,10 +709,10 @@ LibGenFfsFile ( free(FfsFileName); FfsFileName =3D NULL; =20 - CurrentFv->FfsNumbers =3D *FfsCount; - *FfsCount +=3D 1; =20 + CurrentFv->FfsNumbers =3D *FfsCount; + if (ErasePolarity) { CurrentFile->State =3D (UINT8)~(CurrentFile->State); } @@ -789,7 +789,8 @@ LibParseSection ( UINT8 *FvCount, BOOLEAN ViewFlag, BOOLEAN ErasePolarity, - BOOLEAN *IsFfsGenerated + BOOLEAN *IsFfsGenerated, + UINT32 *FfsIndex ) { UINT32 ParsedLength; @@ -1147,19 +1148,21 @@ LibParseSection ( return EFI_SECTION_ERROR; } =20 - Status =3D LibParseSection ( UncompressedBuffer, - UncompressedLength, - CurrentFv, - FvName, - CurrentFile, - Level, - &LocalEncapData, - FfsLevel, - FfsCount, - FvCount, - ViewFlag, - ErasePolarity, - IsFfsGenerated); + Status =3D LibParseSection (UncompressedBuffer, + UncompressedLength, + CurrentFv, + FvName, + CurrentFile, + Level, + &LocalEncapData, + FfsLevel, + FfsCount, + FvCount, + ViewFlag, + ErasePolarity, + IsFfsGenerated, + FfsIndex + ); =20 if (CompressionType =3D=3D EFI_STANDARD_COMPRESSION) { // @@ -1216,7 +1219,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FfsIndex ); if (EFI_ERROR(Status)) { Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", N= ULL); @@ -1471,7 +1475,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FfsIndex ); if (EFI_ERROR (Status)) { Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", = NULL); @@ -1491,7 +1496,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FfsIndex ); if (ExtractionTool !=3D NULL) { free (ExtractionTool); @@ -1527,6 +1533,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } =20 @@ -1538,6 +1545,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } =20 @@ -1549,6 +1557,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } =20 @@ -1560,6 +1569,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } break; @@ -1571,6 +1581,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } break; @@ -1582,6 +1593,7 @@ LibParseSection ( if (!*IsFfsGenerated) { LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); *IsFfsGenerated =3D TRUE; + *FfsIndex =3D *FfsCount; } } break; @@ -1665,11 +1677,11 @@ LibParseSection ( // If Ffs file has been generated, then the FfsCount should decrease= 1. // if (*IsFfsGenerated) { - memcpy (CurrentFv->FfsAttuibutes[*FfsCount -1].UiName, UIName, UIN= ameSize); - CurrentFv->FfsAttuibutes[*FfsCount -1].UiNameSize =3D UINameSize; + memcpy (CurrentFv->FfsAttuibutes[*FfsIndex - 1].UiName, UIName, UI= NameSize); + CurrentFv->FfsAttuibutes[*FfsIndex - 1].UiNameSize =3D=20 + UINameSize; } else { - memcpy (CurrentFv->FfsAttuibutes[*FfsCount].UiName, UIName, UIName= Size); - CurrentFv->FfsAttuibutes[*FfsCount].UiNameSize =3D UINameSize; + memcpy (CurrentFv->FfsAttuibutes[*FfsIndex].UiName, UIName, UIName= Size); + CurrentFv->FfsAttuibutes[*FfsIndex].UiNameSize =3D UINameSize; } =20 HasDepexSection =3D FALSE; @@ -1682,7 +1694,9 @@ LibParseSection ( } =20 ParsedLength +=3D SectionLength; - FirstInFlag =3D FALSE; + if (Type !=3D EFI_SECTION_PEI_DEPEX && Type !=3D EFI_SECTION_DXE_DEPEX= ) { + FirstInFlag =3D FALSE; + } // // We make then next section begin on a 4-byte boundary // @@ -1872,12 +1886,14 @@ LibGetFileInfo ( BOOLEAN IsGeneratedFfs; UINT32 FfsFileHeaderSize; CHAR8 *BlankChar; + UINT32 FfsIndex; =20 Status =3D EFI_SUCCESS; =20 LocalEncapData =3D NULL; EncapDataNeedUpdateFlag =3D TRUE; IsGeneratedFfs =3D FALSE; + FfsIndex =3D 0xFFFFFFFF; BlankChar =3D NULL; =20 FfsFileHeaderSize =3D GetFfsHeaderLength ((EFI_FFS_FILE_HEADER *) Curre= ntFile); @@ -2083,24 +2099,25 @@ LibGetFileInfo ( } else if( CurrentFile->Type =3D=3D EFI_FV_FILETYPE_FFS_PAD){ //EFI_FV_FILETYPE_FFS_PAD } else { - // - // All other files have sections - // - Status =3D LibParseSection ( - (UINT8 *) ((UINTN) CurrentFile + FfsFileHeaderSize), - FileLength - FfsFileHeaderSize, - CurrentFv, - FvName, - CurrentFile, - Level, - &LocalEncapData, - Level, - FfsCount, - FvCount, - ViewFlag, - ErasePolarity, - &IsGeneratedFfs - ); + // + // All other files have sections + // + Status =3D LibParseSection ( + (UINT8 *) ((UINTN) CurrentFile + FfsFileHeaderSize), + FileLength - FfsFileHeaderSize, + CurrentFv, + FvName, + CurrentFile, + Level, + &LocalEncapData, + Level, + FfsCount, + FvCount, + ViewFlag, + ErasePolarity, + &IsGeneratedFfs, + &FfsIndex + ); } if (EFI_ERROR (Status)) { printf ("ERROR: Parsing the FFS file.\n"); @@ -2144,6 +2161,7 @@ Lib= GetFvInfo ( EFI_FIRMWARE_VOLUME_EXT_HEADER *ExtHdrPtr; EFI_FIRMWARE_VOLUME_HEADER *FvHdr; UINT8 PreFvId; + UINT8 GuidBuffer[PRINTED_GUID_BUFFER_SIZE]; =20 NumberOfFiles =3D 0; Key =3D 0; @@ -2344,9 +2362,10 @@ LibGetFvInfo ( =20 CurrentFv->FfsAttuibutes[*FfsCount].FvLevel =3D CurrentFv->FvLevel; CurrentFv->FfsAttuibutes[*FfsCount].FvId =3D PreFvId; - if (CurrentFv->FvLevel > CurrentFv->MulFvLevel) { + if (CurrentFv->FvLevel > CurrentFv->MulFvLevel) { CurrentFv->MulFvLevel =3D CurrentFv->FvLevel; - } + } + PrintGuidToBuffer (&(CurrentFile->Name), GuidBuffer,=20 + PRINTED_GUID_BUFFER_SIZE, FALSE); // // Display info about this file // @@ -4198,10 +4217,13 @@ LibEncapNewFvFile( UINT32 header; UINT8 AlignN; UINT8 AlignV[1] =3D {0xFF}; + UINT32 EntryFvId; + AlignN =3D 0; Id =3D 0; InputFileSize =3D 0; TmpFileSize =3D 0; + AlignmentFileSize =3D 0; EncapFvIndex =3D 0; Index =3D 0; OuterIndex =3D 0; @@ -4224,7 +4246,7 @@ LibEncapNewFvFile( IsLargeFile =3D FALSE; OutputFileSize =3D 0; LargeFileSize =3D 0x1000000; - + EntryFvId =3D 0; =20 OutputFileNameList =3D (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION)= ); if (OutputFileNameList =3D=3D NULL) { @@ -4240,6 +4262,7 @@ LibEncapNewFvFile( OutputFileNameList->Depex =3D NULL; OutputFileNameList->DepexLen =3D 0; OutputFileNameList->FfsFoundFlag =3D FALSE; + OutputFileNameList->FvLevel =3D 0; =20 ChildFileNameList =3D (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION))= ; if (ChildFileNameList =3D=3D NULL) { @@ -4258,12 +4281,16 @@ LibEncapNewFvFile( // // Encapsulate from the lowest FFS file level. // - LocalEncapData =3D CurrentEncapData; - if (LocalEncapData =3D=3D NULL) { - LocalEncapData =3D FvInFd->EncapData; - } - Level =3D LocalEncapData->Level; - Type =3D LocalEncapData->Type; + LocalEncapData =3D CurrentEncapData; + if (LocalEncapData =3D=3D NULL) { + LocalEncapData =3D FvInFd->EncapData; + EntryFvId =3D 0xFFFFFFFF; + } else { + EntryFvId =3D LocalEncapData->FvId; + } + + Level =3D LocalEncapData->Level; + Type =3D LocalEncapData->Type; =20 if (CurrentEncapData =3D=3D NULL) { LocalEncapData =3D FvInFd->EncapData; @@ -4278,6 +4305,7 @@ LibEncapNe= wFvFile( ChildFileNameList->ParentLevel =3D LocalEncapDataTemp->Lev= el -1; if (FvInFd->ChildFvFFS =3D=3D NULL) { FvInFd->ChildFvFFS =3D ChildFileNameList; + NewFileNameList =3D FvInFd->ChildFvFFS; } else { NewFileNameList =3D FvInFd->ChildFvFFS; while (NewFileNameList->Next !=3D NULL) { @@ -4325,6 += 4353,12 @@ LibEncapNewFvFile( Type =3D LocalEncapData->Type; } LocalEncapData =3D LocalEncapData->NextNode; + if (LocalEncapData =3D=3D NULL) { + if (Type =3D=3D FMMT_ENCAP_TREE_FV) { + ParentLevel =3D Level; + ParentType =3D Type; + } + } } } else { LocalEncapData =3D CurrentEncapData; @@ -4349,6 +4383,28 @@ LibEncapNewFvFile( LocalEncapDataTemp =3D LocalEncapDataTemp->RightNode; } } + + if (LocalEncapData->FvId > EntryFvId && LocalEncapData->Type =3D=3D = FMMT_ENCAP_TREE_FFS) { + LocalEncapDataTemp =3D LocalEncapData->RightNode; + + while (LocalEncapDataTemp !=3D NULL) { + LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; + if (LocalEncapDataNext !=3D NULL && LocalEncapDataNext->NextNode= !=3D NULL) { + LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, LocalEnc= apDataTemp->Level - 1, &ChildFileNameList); + if (FvInFd->ChildFvFFS =3D=3D NULL) { + FvInFd->ChildFvFFS =3D ChildFileNameList; + } else { + NewFileNameList =3D FvInFd->ChildFvFFS; + while (NewFileNameList->Next !=3D NULL) { + NewFileNameList =3D NewFileNameList->Next; + } + NewFileNameList->Next =3D ChildFileNameList; + } + } + LocalEncapDataTemp =3D LocalEncapDataTemp->RightNode; + } + } + if (LocalEncapData->Level > Level) { if (LocalEncapData->Type =3D=3D FMMT_ENCAP_TREE_FFS) { ParentLevel =3D Level; @@ -4485,12 +4541,12 @@ LibEncapNewFvFile( // FfsFoundFlag =3D FALSE; IsRootFv =3D FALSE; - for (Index=3D0; Index <=3D FvInFd->FfsNumbers; Index++) { + for (Index=3D0; Index < FvInFd->FfsNumbers; Index++) { if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSNam= e !=3D NULL && OutputFileNameList->IsFFS =3D=3D FALSE){ break; } if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSNam= e !=3D NULL && OutputFileNameList->IsFFS =3D=3D TRUE){ - if (Index =3D=3D EncapFvIndex) { + if (Index =3D=3D EncapFvStart) { if (FirstInFlag) { Status =3D LibAddFfsFileToFvInf (OutputFileNam= eList->FFSName, InfFile, TRUE); FirstInFlag =3D FALSE; @@ -4601,7 +4657,7 @@ L= ibEncapNewFvFile( } } // The Fv may has multiple level (> 2), when it is in the FvLevel = =3D=3D 2, we set the IsLastLevelFfs Flag - if (Index <=3DFvInFd->FfsNumbers && FvInFd->FfsAttuibutes[Index].Fv= Level <=3D FvInFd->MulFvLevel) { + if (Index < FvInFd->FfsNumbers && + FvInFd->FfsAttuibutes[Index].FvLevel <=3D FvInFd->MulFvLevel) { if (FvInFd->FfsAttuibutes[Index].FvLevel =3D=3D 2) { IsLastLevelFfs =3D FALSE; } @@ -4777,6 +4833,7 @@ LibEncapNewFvFile( 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)= { + OutputFileNameList->FvLevel =3D + FvInFd->FfsAttuibutes[Id].FvLevel; Status =3D LibFmmtDeleteFile(FvInFd->FfsAttuibutes[Id= ].FfsName); if (EFI_ERROR(Status)) { Error("FMMT", 0, 0004, "error while encapsulate F= D Image", "Delete the specified file failed!"); @@ -5079,7 +5136,9 @@ LibEn= capNewFvFile( } else { if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSName != =3D NULL && OutputFileNameList->IsFFS =3D=3D TRUE) { *OutputFile =3D OutputFileNameList; - return EFI_SUCCESS; + if (OutputFileNameList->FvLevel < 2) { + return EFI_SUCCESS; + } } LocalEncapData =3D CurrentEncapData; } -- 2.16.2.windows.1