From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.7400.1604455701977427859 for ; Tue, 03 Nov 2020 18:08:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Jse9EryQ; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: gregx.yeh@intel.com) IronPort-SDR: 2PDDt1IFBjtfEiN+TVhAycAO429HYAAYF14O6iDlPb7I4IB+l9njL/ZA+ndIlc6kWoiAMRNvVC Zs8YAxpjniWA== X-IronPort-AV: E=McAfee;i="6000,8403,9794"; a="156930010" X-IronPort-AV: E=Sophos;i="5.77,449,1596524400"; d="scan'208";a="156930010" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 18:08:21 -0800 IronPort-SDR: 7CJNbAfkwUzdhQAHZui5CbgOfQDLGMjy3kb0TZuWb6RWm/tfIZNyhvI+Je0T2tPlcyy1cjkYwA +gemnDry/ijA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,449,1596524400"; d="scan'208";a="306238729" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga007.fm.intel.com with ESMTP; 03 Nov 2020 18:08:20 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 3 Nov 2020 18:08:20 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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.1713.5; Tue, 3 Nov 2020 18:08:19 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) 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, 3 Nov 2020 18:08:19 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.55) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 3 Nov 2020 18:06:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SMotZKHnhi5LE9jeDte0iEWdAKmJMoW+1vwmpw+0flDuo7yo5SLpNw4PggqHMXC1hxMYHj7VAV00cblknYGiRqb5J8IvlBpWM8CQjZFJy3p8UQ1+zJjajk4lHs9htuh3QnQRYVGLmJyfJS2krawIwAPyqjiZyof9An8Q4HQIS/KF5WsGvass4X5tn3aVlm8/8+xpLcpIHPVG9DKDm3hYaJLbbqkzallA1R203eccHyYmNSloDa0wmqV6vr4CedZH/q2fBp5ex7lCgwVjZ8dfUjiwiEFj5xsCy6cJQsSSVbj5B4giS5dPb+zyuQpOS5ltBTZtkOUv2/GVT8wWxy0FYw== 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=xYzvswXjj7Y9iOo9nMudVDfMBc19YJmvaumnzFRYfus=; b=AGPBqs4U7nSRB8Q5NQYWLxlZcNvoQEZdivNwIbcM15pFQZ8zpmCTT3G6RoLlpsNd+cb17dRAkUiD9T25djp8fbMQX6oVq+QdNszyoSpiC8CyAdXFykbqw8pYGwnZYBmOVmlnY2wb+duvT0QjeDezt883Uv1QsySmj6hyM2Tzzjqd8GWgXeLPkJhVdpckmGEjboOmrJ8FbcUBISr5lCcProSdsGFnGM7KSTio9OyFMlvvpI+b1HLUDHAMChBqdWNR2X8g0ktGZGhI6QVVfkQE1CFiXPuv2dbDzoLQr1J7EfSuernW02CTgbXZSblqfr8GLIQkYD0CA5Q7VKl769Ts9Q== 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=xYzvswXjj7Y9iOo9nMudVDfMBc19YJmvaumnzFRYfus=; b=Jse9EryQBIET0whHppo2hDhfIHJU46OlMsFvNmM9XxFpsCiGOpfyINLuLzpLSyUnbIRbvnJF3S0MOcQdajxa5kWH0RLOOg4bVj4r2Tmh/G57A+ymlp/V8wYp9Yfq+dukVcB9XLPxa8SBBq4qrwJ1t8SJWaKYKi5PzJEKTYZCkPY= Received: from BYAPR11MB3368.namprd11.prod.outlook.com (2603:10b6:a03:1b::13) by SJ0PR11MB4832.namprd11.prod.outlook.com (2603:10b6:a03:2dd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Wed, 4 Nov 2020 02:06:46 +0000 Received: from BYAPR11MB3368.namprd11.prod.outlook.com ([fe80::c5e7:38ef:aed7:8c31]) by BYAPR11MB3368.namprd11.prod.outlook.com ([fe80::c5e7:38ef:aed7:8c31%7]) with mapi id 15.20.3499.032; Wed, 4 Nov 2020 02:06:46 +0000 From: "GregX Yeh" To: "Feng, Bob C" , "devel@edk2.groups.io" CC: Liming Gao 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: AQHWsaTV7DshF1jLrUWutdeVEFzn06m2HWiggAEYyVA= Date: Wed, 4 Nov 2020 02:06:46 +0000 Message-ID: References: <20201103054711.22836-1-gregx.yeh@intel.com> In-Reply-To: Accept-Language: zh-TW, 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.52.220] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4745acbd-2ea1-4eaf-77de-08d8806648c4 x-ms-traffictypediagnostic: SJ0PR11MB4832: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ExsoK8lMuIp3AOzE/+GA+Ui2apsMyihu9TgVTqZ7QS9pKwprEEK9F4+dHwGi0nJN7VPRdWlFDDFIsZUowlUcYizqmaBjVRNKvOYKE+6DWCmy92F1HYN8dvTLgVqiCtZ6pJ7wfMqMr7FQ3httvjwg+QHtNAqWPb3q80C3z2ZaQJkyxa1pB9LQeMBl0QgMahxIpKygNMWFCfIj0aUlPl8CZDpOcI5zl22g7oQe0I75Uy0SZFbPwXbH5xnFSUHowbODHWfHvb4hNbx0clmlNleISAVbKPCXnGAyPcENRemBizvnuPFctebNCi/qmRntd+GeQTiMdzw1LyBqbLpskvjzUg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3368.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(30864003)(33656002)(86362001)(186003)(7696005)(4326008)(83380400001)(316002)(110136005)(52536014)(55016002)(478600001)(8676002)(66946007)(66446008)(76116006)(66556008)(64756008)(6506007)(53546011)(2906002)(5660300002)(71200400001)(26005)(9686003)(8936002)(66476007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: XvxVEdhDTmuKkf8rzxRSa2nFwQtT6g/CRnHOuD2Fi0utntKrq2c4Pfu+ojKnSE1zWsm6jbTJ54tf3qBm61nQHXpV3mIs6KwigVwmjd3Naib+aABthMfnl0vu9dWpH5R5Ro3l7DEbst62OTBVV+KpF4Au7t1J3gZukjqWDAF02zBoyIQNNOw/uP9I4ry+sFBcQs5FCfI6bZWfATzgTS7Or1b67Iqk/w1HwQuR3pA5ZwNtTAo38jfYWTcDWNuxrHNnj+bKh+Ns4Lx2qRca7Ituwur5V/CUXNq5MunAZpARTl9lZjnfzBPZ7UFLGyXV7VMn9ChbI4JcHeu+CcRh3cGOc1vozSy5fS7p1NHZLddyv5gow2xNsMhuTZVbEXXpLWs/0hJgFq2Nh1fyNtau9V1J/s2By/YuVsIVMbePwx02tLljy+ouoh8PqBeUK2Kk2pi7tCpaq79PWc/Fm/0gvDpTC4k0r+J0LuiAoBIfUIiEJk7Mzr9nw9QRTKf9rCsNW1qa4x+xHD70OjURpq5Gfkt8y3VOaQ2N2GWpgamfMqAJZJLcj0ubcO/gOa3n4kRKX8RfFrZxNfo6xd0Y+02l6t8pAfIborLMXJtQBt9WiLC36GGYBiWx/zKAAqJ8NJCjcUwNOvC2fBXrWQyQmvCKSGRU9Q== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3368.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4745acbd-2ea1-4eaf-77de-08d8806648c4 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Nov 2020 02:06:46.7167 (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: qq+Qp0KrrMpo17TN45y1aDmF1CUTW00ya+ILLFd3wk3alABGUWZkZ7mpOELz+ubgiNRn2r5XNVxZWIWYxdQU3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4832 Return-Path: gregx.yeh@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 =20 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