public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Feng, YunhuaX" <yunhuax.feng@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Feng, Bob C" <bob.c.feng@intel.com>
Subject: [edk2-staging][PATCH] BaseTools/Fmmt: Fix regression issue by b41fac8e
Date: Mon, 20 Jul 2020 07:26:51 +0000	[thread overview]
Message-ID: <BN8PR11MB3793EDF4C9127CD49C1B33BC8D7B0@BN8PR11MB3793.namprd11.prod.outlook.com> (raw)

Fix regression issue by b41fac8e

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 .../Source/C/FMMT/FirmwareModuleManagement.c  |  1 +
 BaseTools/Source/C/FMMT/FmmtLib.c             | 20 +++++++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
index c8a53d3def..20663ba163 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
@@ -1212,10 +1212,11 @@ FmmtImageAdd(
                 FvInFd->FfsAttuibutes[EndId].FfsName[_MAX_PATH - 1] = 0;
                 FvInFd->FfsAttuibutes[EndId].Level = NewAddedFfsLevel;
                 memset (&FvInFd->FfsAttuibutes[EndId].GuidName, '\0', sizeof(EFI_GUID));
                 if (EndId > 0) {
                     FvInFd->FfsAttuibutes[EndId].FvLevel = FvInFd->FfsAttuibutes[EndId - 1].FvLevel;
+                    FvInFd->FfsAttuibutes[EndId].FvId    = FvInFd->FfsAttuibutes[EndId - 1].FvId;
                     FvInFd->FfsAttuibutes[EndId - 1].IsFvEnd = 0;
                 }
                 FvInFd->FfsAttuibutes[EndId].IsFvEnd = 1;
                 FvInFd->FfsAttuibutes[EndId].IsFvStart = 0;
                 NewFileNode = NewFileNode->Next;
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c
index 2c3529680e..b945e9b63d 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -1,10 +1,10 @@
 /** @file

  Library to parse and generate FV image.

- Copyright (c)  2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c)  2019 - 2020, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

 **/

 #include "FirmwareModuleManagement.h"
@@ -900,13 +900,11 @@ LibParseSection (
     case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:

       EncapDataNeedUpdata = TRUE;
       HasUiSection = TRUE;

-      if (FirstInFlag) {
-        Level ++;
-      }
+      Level ++;
       NumberOfSections ++;

       CurrentFv->FfsAttuibutes[*FfsCount].IsLeaf = FALSE;
       CurrentFv->FfsAttuibutes[*FfsCount].IsFvStart = TRUE;
       //
@@ -1193,13 +1191,10 @@ LibParseSection (
       // Put in encapsulate data information.
       //
       LocalEncapData = *CurrentFvEncapData;
       if (LocalEncapData->NextNode != NULL) {
         EncapDataNeedUpdata = FALSE;
-        while (Level != LocalEncapData->Level) {
-          LocalEncapData = LocalEncapData->NextNode;
-        }
         while (LocalEncapData->RightNode != NULL) {
           LocalEncapData = LocalEncapData->RightNode;
         }
       }
       GuidAttr = ((EFI_GUID_DEFINED_SECTION *)(Ptr + LargeHeaderOffset))->Attributes;
@@ -1524,13 +1519,10 @@ LibParseSection (

     //
     //Leaf sections
     //
     case EFI_SECTION_RAW:
-      if (FirstInFlag) {
-        Level++;
-      }
       NumberOfSections ++;
       CurrentFv->FfsAttuibutes[*FfsCount].Level = Level;
       if (!ViewFlag) {
         if (!*IsFfsGenerated) {
           LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, ErasePolarity);
@@ -2149,10 +2141,11 @@ LibGetFvInfo (
   EFI_FFS_FILE_HEADER2        *CurrentFile;
   UINTN                       Key;
   ENCAP_INFO_DATA             *LocalEncapData;
   EFI_FIRMWARE_VOLUME_EXT_HEADER *ExtHdrPtr;
   EFI_FIRMWARE_VOLUME_HEADER *FvHdr;
+  UINT8                      PreFvId;

   NumberOfFiles  = 0;
   Key            = 0;
   LocalEncapData = NULL;
   CurrentFile    = NULL;
@@ -2324,10 +2317,11 @@ LibGetFvInfo (
     CurrentFile = NULL;
   } else if (EFI_ERROR (Status)) {
     Error ("FMMT", 0, 0003, "error parsing FV image", "cannot find the first file in the FV image");
     return Status;
   }
+  PreFvId = *FvCount;

   while (CurrentFile != NULL) {

     //
     // Increment the number of files counter
@@ -2347,11 +2341,11 @@ LibGetFvInfo (
     CurrentFv->FfsHeader[*FfsCount].Type             = CurrentFile->Type;
     CurrentFv->FfsHeader[*FfsCount].ExtendedSize     = CurrentFile->ExtendedSize;
     CurrentFv->FfsAttuibutes[*FfsCount].Offset = Key - GetFfsFileLength ((EFI_FFS_FILE_HEADER *) CurrentFile);

     CurrentFv->FfsAttuibutes[*FfsCount].FvLevel = CurrentFv->FvLevel;
-    CurrentFv->FfsAttuibutes[*FfsCount].FvId    = *FvCount;
+    CurrentFv->FfsAttuibutes[*FfsCount].FvId    = PreFvId;
      if (CurrentFv->FvLevel > CurrentFv->MulFvLevel) {
       CurrentFv->MulFvLevel = CurrentFv->FvLevel;
    }
     //
     // Display info about this file
@@ -4333,11 +4327,11 @@ LibEncapNewFvFile(
       LocalEncapData = LocalEncapData->NextNode;
     }
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) {
                 LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, LocalEncapDataTemp->Level-1, &ChildFileNameList);
@@ -4513,11 +4507,11 @@ LibEncapNewFvFile(
                 }
             }

             NewFileNameList = FvInFd->ChildFvFFS;
             while (NewFileNameList != NULL && NewFileNameList -> FFSName != NULL) {
-                if (NewFileNameList->FvId == LocalEncapData->FvId && NewFileNameList -> ParentLevel == ParentLevel && Index == NewFileNameList->InFvId && NewFileNameList->FfsFoundFlag==TRUE) {
+                if (NewFileNameList -> ParentLevel == ParentLevel && Index == NewFileNameList->InFvId && NewFileNameList->FfsFoundFlag==TRUE) {
                     if (FirstInFlag) {
                         Status = LibAddFfsFileToFvInf (NewFileNameList->FFSName, InfFile, TRUE);
                         FirstInFlag = FALSE;
                     } else {
                         Status = LibAddFfsFileToFvInf (NewFileNameList->FFSName, InfFile, FALSE);
--
2.27.0.windows.1


             reply	other threads:[~2020-07-20  7:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  7:26 Feng, YunhuaX [this message]
2020-07-20 14:30 ` [edk2-staging][PATCH] BaseTools/Fmmt: Fix regression issue by b41fac8e Liming Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN8PR11MB3793EDF4C9127CD49C1B33BC8D7B0@BN8PR11MB3793.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox