From nobody Mon May 6 06:04:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72603+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72603+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615341942; cv=none; d=zohomail.com; s=zohoarc; b=gSOXW5rpYHVRP4IGZft9GWZf46/JLlorN2srG+9QOpRVxq1YYFAAEUME9JWuH/MeMWIpFrzXcmss4k1HburuuvN7aphP5eKenLKIWGwrqD2qgtcTBcLIL95guYTt/O4VX54r9fkgBG16f3+DsoNootVaefXqqswdcC/KsdsBsKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615341942; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=BPO2rY+cmEu5KtFlzDEvj884DzsSudNXnUIHqJ+LXZ0=; b=daONhGGrGOxv1lqFg8AQ/LoXJ6h1PTePGDWZvD8gEmf9Hec7ZFa6B8w9CrXwf7obJUrqbGG//FnD+ZWslhLOE7kzDWMXRaItHqFkPCi2f9SG7An++qAFFbM7WdGc+WIT+wKHB5fJmyVeOYJMZCrVfTf6SoWOkT2G6L5gKdrNszY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72603+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1615341942608671.7664843330068; Tue, 9 Mar 2021 18:05:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id A2WdYY1788612xYzDBoC38wR; Tue, 09 Mar 2021 18:05:37 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.3200.1615341936729040701 for ; Tue, 09 Mar 2021 18:05:36 -0800 IronPort-SDR: ab50UyPm7tiZEk/E6YchSsfGL5IfhW3A92Mby6TIrbnzWmtX948imxYoCY8XDH40jpCkylVyJ5 6GNVQFPO1mlA== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="167637099" X-IronPort-AV: E=Sophos;i="5.81,236,1610438400"; d="scan'208";a="167637099" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 18:05:34 -0800 IronPort-SDR: 1g5N9umrNTQxOUmZ8HraUWdhjsZBx9upcXVwkjLkLBzmZUlq6igzFrTYKUDEki8P/X9pkj7Glv Xp7nQ/F6pG8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,236,1610438400"; d="scan'208";a="588650894" X-Received: from chinghux-desk1.gar.corp.intel.com ([10.5.215.141]) by orsmga005.jf.intel.com with ESMTP; 09 Mar 2021 18:05:33 -0800 From: "GregX Yeh" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 Date: Wed, 10 Mar 2021 10:05:28 +0800 Message-Id: <20210310020528.1924-1-gregx.yeh@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,gregx.yeh@intel.com X-Gm-Message-State: 6tmIDfF43IGHExzBJ9rdytM7x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615341937; bh=Qv+uKQdAbx/lG4P3GI0vx4cxXwX0b+zisp379faL97U=; h=Cc:Date:From:Reply-To:Subject:To; b=jdDXPrNP1aR1jCENa3yTpGSg5LiJYto18H8MPe2bSJxwLOlAmfuIrwzKjDWIe95bE+4 qTIc6dsfbYgBp3TXJAB2wZnaDca2P1cyvjOGCJCdKmKcsWjCgM6EQy+HZbZUO6IMYgXyC +gSCEb6MQFXkurjIaXWR7XABQmN1OwYFkOg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fixed replace file failure when FFS in multiple level FV and FV level over 2 Signed-off-by: GregX Yeh Cc: Bob Feng Cc: Liming Gao --- BaseTools/Source/C/FMMT/FmmtLib.c | 56 ++++++++++++++++++++++++++---------= ---- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index b945e9b63d..26df0181c7 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -494,7 +494,7 @@ LibReadFvHeader ( if ((FvLevel -1) =3D=3D 0) { printf ("\n%s :\n", FvName); } else { - printf ("%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName= ); + printf ("\n%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvNa= me); } } =20 @@ -502,7 +502,7 @@ LibReadFvHeader ( // Print FV header information // if (ViewFlag) { - printf ("\n%sAttributes: %X\n", BlankSpace, (unsigned) Volu= meHeader->Attributes); + printf ("%sAttributes: %X\n", BlankSpace, (unsigned) Volume= Header->Attributes); printf ("%sTotal Volume Size: 0x%08X\n", BlankSpace, (unsigned) Vo= lumeHeader->FvLength); printf ("%sFree Volume Size: 0x%08X\n", BlankSpace, (unsigned) (V= olumeHeader->FvLength - GetFreeOffset(InputFv))); } @@ -789,7 +789,8 @@ LibParseSection ( UINT8 *FvCount, BOOLEAN ViewFlag, BOOLEAN ErasePolarity, - BOOLEAN *IsFfsGenerated + BOOLEAN *IsFfsGenerated, + BOOLEAN IsFfs ) { UINT32 ParsedLength; @@ -997,8 +998,12 @@ LibParseSection ( break; =20 case EFI_SECTION_COMPRESSION: - if (FirstInFlag) { - Level ++; + if (IsFfs){ + Level ++; + } else { + if (FirstInFlag) { + Level ++; + } } NumberOfSections ++; =20 @@ -1159,7 +1164,9 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated); + IsFfsGenerated, + FALSE + ); =20 if (CompressionType =3D=3D EFI_STANDARD_COMPRESSION) { // @@ -1181,8 +1188,12 @@ LibParseSection ( // looks up the appropriate tool to use for extracting // a GUID defined FV section. // - if (FirstInFlag) { + if (IsFfs) { Level ++; + } else { + if (FirstInFlag) { + Level ++; + } } NumberOfSections++; EncapDataNeedUpdata =3D TRUE; @@ -1216,7 +1227,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (EFI_ERROR(Status)) { Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", N= ULL); @@ -1471,7 +1483,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (EFI_ERROR (Status)) { Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", = NULL); @@ -1491,7 +1504,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (ExtractionTool !=3D NULL) { free (ExtractionTool); @@ -2016,7 +2030,7 @@ LibGetFileInfo ( =20 LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_FFS; - LocalEncapData->FvExtHeader =3D NULL; + LocalEncapData->FvExtHeader =3D NULL; LocalEncapData->Depex =3D NULL; LocalEncapData->DepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; @@ -2099,7 +2113,8 @@ LibGetFileInfo ( FvCount, ViewFlag, ErasePolarity, - &IsGeneratedFfs + &IsGeneratedFfs, + TRUE ); } if (EFI_ERROR (Status)) { @@ -4198,10 +4213,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 +4242,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) { @@ -4261,6 +4279,9 @@ LibEncapNewFvFile( 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; @@ -4274,7 +4295,7 @@ LibEncapNewFvFile( LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; if (LocalEncapDataNext !=3D NULL && LocalEncapDataNext->NextNo= de !=3D NULL) { =20 - LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &= ChildFileNameList); + LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp,Local= EncapDataTemp->Level - 1, &ChildFileNameList); ChildFileNameList->ParentLevel =3D LocalEncapDataTemp->Lev= el -1; if (FvInFd->ChildFvFFS =3D=3D NULL) { FvInFd->ChildFvFFS =3D ChildFileNameList; @@ -4329,7 +4350,7 @@ LibEncapNewFvFile( } else { LocalEncapData =3D CurrentEncapData; while (LocalEncapData !=3D NULL) { - if (Level_Break > 1 && LocalEncapData->Type =3D=3D FMMT_ENCAP_TREE_F= FS) { + if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type =3D= =3D FMMT_ENCAP_TREE_FFS)) { LocalEncapDataTemp =3D LocalEncapData->RightNode; while (LocalEncapDataTemp !=3D NULL) { LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; @@ -4818,6 +4839,7 @@ LibEncapNewFvFile( memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, = strlen(OutputFileName)+1); OutputFileNameList->IsFFS =3D TRUE; OutputFileNameList->ParentLevel =3D ParentLevel - 1; + OutputFileNameList->InFvId =3D Id; if (OutputFileNameList->Next =3D=3D NULL){ break; } @@ -5077,10 +5099,6 @@ LibEncapNewFvFile( if (CurrentEncapData =3D=3D NULL) { LocalEncapData =3D FvInFd->EncapData; } else { - if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSName != =3D NULL && OutputFileNameList->IsFFS =3D=3D TRUE) { - *OutputFile =3D OutputFileNameList; - return EFI_SUCCESS; - } LocalEncapData =3D CurrentEncapData; } ParentLevel -=3D 1; --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72603): https://edk2.groups.io/g/devel/message/72603 Mute This Topic: https://groups.io/mt/81218233/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-