public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* 回复: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
  2021-01-04  3:11 GregX Yeh
@ 2021-01-04 10:43 ` fengyunhua
  0 siblings, 0 replies; 6+ messages in thread
From: fengyunhua @ 2021-01-04 10:43 UTC (permalink / raw)
  To: devel, gregx.yeh; +Cc: 'Bob Feng', 'Liming Gao'

Hi Greg,
  I hope to know which cases have you tested?
Except your case, have you try other FDs, or Delete FFS or Add FFS in FD. 

Thanks,
Yunhua

-----邮件原件-----
发件人: bounce+27952+69530+5049190+8953120@groups.io
<bounce+27952+69530+5049190+8953120@groups.io> 代表 GregX Yeh
发送时间: 2021年1月4日 11:11
收件人: devel@edk2.groups.io
抄送: Bob Feng <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
主题: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file
failure when FV level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over
2.

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 BaseTools/Source/C/FMMT/FmmtLib.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c
b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..60bd47e5bb 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -709,10 +709,10 @@ LibGenFfsFile (
   free(FfsFileName);
   FfsFileName = NULL;
 
-  CurrentFv->FfsNumbers  = *FfsCount;
-
   *FfsCount += 1;
 
+  CurrentFv->FfsNumbers  = *FfsCount;
+
   if (ErasePolarity) {
     CurrentFile->State = (UINT8)~(CurrentFile->State);
   }
@@ -833,7 +833,6 @@ LibParseSection (
   CHAR8               *ToolInputFileName;
   CHAR8               *ToolOutputFileName;
   BOOLEAN              HasUiSection;
-  BOOLEAN              FirstInFlag;
 
   DataOffset                 = 0;
   GuidAttr                   = 0;
@@ -869,7 +868,6 @@ LibParseSection (
   EncapDataNeedUpdata        = TRUE;
   LargeHeaderOffset          = 0;
   HasUiSection               = FALSE;
-  FirstInFlag                = TRUE;
 
 
   while (ParsedLength < BufferLength) {
@@ -997,9 +995,7 @@ LibParseSection (
       break;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
-      }
+      Level ++;
       NumberOfSections ++;
 
       EncapDataNeedUpdata = TRUE;
@@ -1181,9 +1177,7 @@ LibParseSection (
       // looks up the appropriate tool to use for extracting
       // a GUID defined FV section.
       //
-      if (FirstInFlag) {
-        Level ++;
-      }
+      Level ++;
       NumberOfSections++;
       EncapDataNeedUpdata = TRUE;
       HasUiSection = TRUE;
@@ -1682,7 +1676,6 @@ LibParseSection (
     }
 
     ParsedLength += SectionLength;
-    FirstInFlag  = FALSE;
     //
     // We make then next section begin on a 4-byte boundary
     //
@@ -4198,10 +4191,13 @@ LibEncapNewFvFile(
   UINT32                      header;
   UINT8                       AlignN;
   UINT8                       AlignV[1] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4220,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4257,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4273,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode
!= NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1,
&ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir,
LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level
-1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList;
@@ -4329,7 +4328,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type ==
FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
@@ -4473,7 +4472,7 @@ LibEncapNewFvFile(
           while (LocalEncapData->Level != ParentLevel) {
             LocalEncapData = LocalEncapData->NextNode;
           }
-            for (Index = 0; Index <= FvInFd->FfsNumbers; Index++) {
+            for (Index = 0; Index < FvInFd->FfsNumbers; Index++) {
                 if ((memcmp(&FvInFd->FfsAttuibutes[Index].GuidName,
&(LocalEncapData->FvExtHeader->FvName), sizeof(EFI_GUID)) == 0)) {
                     SubFvId = Index;
                     break;
@@ -4485,7 +4484,7 @@ LibEncapNewFvFile(
         //
         FfsFoundFlag = FALSE;
         IsRootFv = FALSE;
-        for (Index=0; Index <= FvInFd->FfsNumbers; Index++) {
+        for (Index=0; Index < FvInFd->FfsNumbers; Index++) {
             if (OutputFileNameList != NULL && OutputFileNameList->FFSName
!= NULL && OutputFileNameList->IsFFS == FALSE){
                 break;
             }
@@ -4818,6 +4817,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName,
strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5077,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName !=
NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
-- 
2.16.2.windows.1









^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
@ 2021-03-10  2:05 GregX Yeh
  2021-03-15  4:34 ` Bob Feng
  0 siblings, 1 reply; 6+ messages in thread
From: GregX Yeh @ 2021-03-10  2:05 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 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/FmmtLib.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) == 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, FvName);
     }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-    printf ("\n%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
+    printf ("%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
     printf ("%sTotal Volume Size:     0x%08X\n", BlankSpace, (unsigned) VolumeHeader->FvLength);
     printf ("%sFree Volume Size:      0x%08X\n", BlankSpace, (unsigned) (VolumeHeader->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;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
+    	if (IsFfs){
+    	  Level ++;
+    	} else {
+        if (FirstInFlag) {
+          Level ++;
+        }
       }
       NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
                                   FvCount,
                                   ViewFlag,
                                   ErasePolarity,
-                                  IsFfsGenerated);
+                                  IsFfsGenerated,
+                                  FALSE
+                                  );
 
       if (CompressionType == 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 = 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", NULL);
@@ -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 != NULL) {
             free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
       LocalEncapData->Level = Level;
       LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-    LocalEncapData->FvExtHeader = NULL;
+      LocalEncapData->FvExtHeader = NULL;
       LocalEncapData->Depex = NULL;
       LocalEncapData->DepexLen = 0;
       LocalEncapData->UiNameSize = 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] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4279,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4295,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level -1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList;
@@ -4329,7 +4350,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type == FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
@@ -4818,6 +4839,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5099,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
-- 
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
  2021-03-10  2:05 [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 GregX Yeh
@ 2021-03-15  4:34 ` Bob Feng
  2021-03-16  1:13   ` 回复: [edk2-devel] " fengyunhua
  2021-03-16  1:54   ` GregX Yeh
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Feng @ 2021-03-15  4:34 UTC (permalink / raw)
  To: Yeh, GregX, devel@edk2.groups.io, Yunhua Feng; +Cc: Liming Gao

Hi Greg,

Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are some lines code format invalid.
The logic looks good to me.

Yunhua, could you please double check, I remember you have concerns about the previous version of this patch.

Thanks,
Bob

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com> 
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 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/FmmtLib.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) == 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, 
+ FvName);
     }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-    printf ("\n%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
+    printf ("%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
     printf ("%sTotal Volume Size:     0x%08X\n", BlankSpace, (unsigned) VolumeHeader->FvLength);
     printf ("%sFree Volume Size:      0x%08X\n", BlankSpace, (unsigned) (VolumeHeader->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;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
+    	if (IsFfs){
+    	  Level ++;
+    	} else {
+        if (FirstInFlag) {
+          Level ++;
+        }
       }
       NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
                                   FvCount,
                                   ViewFlag,
                                   ErasePolarity,
-                                  IsFfsGenerated);
+                                  IsFfsGenerated,
+                                  FALSE
+                                  );
 
       if (CompressionType == 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 = 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", NULL); @@ -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 != NULL) {
             free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
       LocalEncapData->Level = Level;
       LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-    LocalEncapData->FvExtHeader = NULL;
+      LocalEncapData->FvExtHeader = NULL;
       LocalEncapData->Depex = NULL;
       LocalEncapData->DepexLen = 0;
       LocalEncapData->UiNameSize = 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] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4279,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4295,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir, 
+ LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level -1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList; @@ -4329,7 +4350,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type 
+ == FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode; @@ -4818,6 +4839,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5099,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
--
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* 回复: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
  2021-03-15  4:34 ` Bob Feng
@ 2021-03-16  1:13   ` fengyunhua
  2021-03-16  1:54   ` GregX Yeh
  1 sibling, 0 replies; 6+ messages in thread
From: fengyunhua @ 2021-03-16  1:13 UTC (permalink / raw)
  To: devel, bob.c.feng, 'Yeh, GregX'; +Cc: 'Liming Gao'

Hi Bob,
  I have no concern about this patch.

Thanks,
Yunhua

-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Bob Feng
发送时间: 2021年3月15日 12:35
收件人: Yeh, GregX <gregx.yeh@intel.com>; devel@edk2.groups.io; Yunhua Feng
<fengyunhua@byosoft.com.cn>
抄送: Liming Gao <gaoliming@byosoft.com.cn>
主题: Re: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file
failure when FV level over 2

Hi Greg,

Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are
some lines code format invalid.
The logic looks good to me.

Yunhua, could you please double check, I remember you have concerns about
the previous version of this patch.

Thanks,
Bob

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com> 
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao
<gaoliming@byosoft.com.cn>
Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV
level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 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/FmmtLib.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) == 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, 
+ FvName);
     }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-    printf ("\n%sAttributes:            %X\n", BlankSpace, (unsigned)
VolumeHeader->Attributes);
+    printf ("%sAttributes:            %X\n", BlankSpace, (unsigned)
VolumeHeader->Attributes);
     printf ("%sTotal Volume Size:     0x%08X\n", BlankSpace, (unsigned)
VolumeHeader->FvLength);
     printf ("%sFree Volume Size:      0x%08X\n", BlankSpace, (unsigned)
(VolumeHeader->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;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
+    	if (IsFfs){
+    	  Level ++;
+    	} else {
+        if (FirstInFlag) {
+          Level ++;
+        }
       }
       NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
                                   FvCount,
                                   ViewFlag,
                                   ErasePolarity,
-                                  IsFfsGenerated);
+                                  IsFfsGenerated,
+                                  FALSE
+                                  );
 
       if (CompressionType == 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 = 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",
NULL); @@ -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 != NULL) {
             free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
       LocalEncapData->Level = Level;
       LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-    LocalEncapData->FvExtHeader = NULL;
+      LocalEncapData->FvExtHeader = NULL;
       LocalEncapData->Depex = NULL;
       LocalEncapData->DepexLen = 0;
       LocalEncapData->UiNameSize = 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] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4279,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4295,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode
!= NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1,
&ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir, 
+ LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level
-1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList; @@ -4329,7
+4350,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type 
+ == FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode; @@ -4818,6
+4839,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName,
strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5099,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName !=
NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
--
2.16.2.windows.1









^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
  2021-03-15  4:34 ` Bob Feng
  2021-03-16  1:13   ` 回复: [edk2-devel] " fengyunhua
@ 2021-03-16  1:54   ` GregX Yeh
  2021-03-17  6:57     ` Bob Feng
  1 sibling, 1 reply; 6+ messages in thread
From: GregX Yeh @ 2021-03-16  1:54 UTC (permalink / raw)
  To: Feng, Bob C, devel@edk2.groups.io, Yunhua Feng; +Cc: Liming Gao

Hi Bob,

I have created new patch file. PatchCheck is pass.
Using Git send-email  send to edk2.group.io 

Thanks,
Greg

-----Original Message-----
From: Feng, Bob C <bob.c.feng@intel.com> 
Sent: Monday, March 15, 2021 12:35 PM
To: Yeh, GregX <gregx.yeh@intel.com>; devel@edk2.groups.io; Yunhua Feng <fengyunhua@byosoft.com.cn>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Subject: RE: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Hi Greg,

Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are some lines code format invalid.
The logic looks good to me.

Yunhua, could you please double check, I remember you have concerns about the previous version of this patch.

Thanks,
Bob

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com>
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 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/FmmtLib.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) == 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, 
+ FvName);
     }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-    printf ("\n%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
+    printf ("%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
     printf ("%sTotal Volume Size:     0x%08X\n", BlankSpace, (unsigned) VolumeHeader->FvLength);
     printf ("%sFree Volume Size:      0x%08X\n", BlankSpace, (unsigned) (VolumeHeader->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;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
+    	if (IsFfs){
+    	  Level ++;
+    	} else {
+        if (FirstInFlag) {
+          Level ++;
+        }
       }
       NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
                                   FvCount,
                                   ViewFlag,
                                   ErasePolarity,
-                                  IsFfsGenerated);
+                                  IsFfsGenerated,
+                                  FALSE
+                                  );
 
       if (CompressionType == 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 = 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", NULL); @@ -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 != NULL) {
             free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
       LocalEncapData->Level = Level;
       LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-    LocalEncapData->FvExtHeader = NULL;
+      LocalEncapData->FvExtHeader = NULL;
       LocalEncapData->Depex = NULL;
       LocalEncapData->DepexLen = 0;
       LocalEncapData->UiNameSize = 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] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4279,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4295,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir, 
+ LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level -1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList; @@ -4329,7 +4350,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type 
+ == FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode; @@ -4818,6 +4839,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5099,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
--
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2
  2021-03-16  1:54   ` GregX Yeh
@ 2021-03-17  6:57     ` Bob Feng
  0 siblings, 0 replies; 6+ messages in thread
From: Bob Feng @ 2021-03-17  6:57 UTC (permalink / raw)
  To: Yeh, GregX, devel@edk2.groups.io, Yunhua Feng; +Cc: Liming Gao

Pushed. 4bfc77a87b820cd585ba10ca28aa957ae315c3dc

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com> 
Sent: Tuesday, March 16, 2021 9:55 AM
To: Feng, Bob C <bob.c.feng@intel.com>; devel@edk2.groups.io; Yunhua Feng <fengyunhua@byosoft.com.cn>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Subject: RE: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Hi Bob,

I have created new patch file. PatchCheck is pass.
Using Git send-email  send to edk2.group.io 

Thanks,
Greg

-----Original Message-----
From: Feng, Bob C <bob.c.feng@intel.com>
Sent: Monday, March 15, 2021 12:35 PM
To: Yeh, GregX <gregx.yeh@intel.com>; devel@edk2.groups.io; Yunhua Feng <fengyunhua@byosoft.com.cn>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Subject: RE: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Hi Greg,

Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are some lines code format invalid.
The logic looks good to me.

Yunhua, could you please double check, I remember you have concerns about the previous version of this patch.

Thanks,
Bob

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com>
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 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/FmmtLib.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) == 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, 
+ FvName);
     }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-    printf ("\n%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
+    printf ("%sAttributes:            %X\n", BlankSpace, (unsigned) VolumeHeader->Attributes);
     printf ("%sTotal Volume Size:     0x%08X\n", BlankSpace, (unsigned) VolumeHeader->FvLength);
     printf ("%sFree Volume Size:      0x%08X\n", BlankSpace, (unsigned) (VolumeHeader->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;
 
     case EFI_SECTION_COMPRESSION:
-      if (FirstInFlag) {
-        Level ++;
+    	if (IsFfs){
+    	  Level ++;
+    	} else {
+        if (FirstInFlag) {
+          Level ++;
+        }
       }
       NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
                                   FvCount,
                                   ViewFlag,
                                   ErasePolarity,
-                                  IsFfsGenerated);
+                                  IsFfsGenerated,
+                                  FALSE
+                                  );
 
       if (CompressionType == 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 = 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", NULL); @@ -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 != NULL) {
             free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
       LocalEncapData->Level = Level;
       LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-    LocalEncapData->FvExtHeader = NULL;
+      LocalEncapData->FvExtHeader = NULL;
       LocalEncapData->Depex = NULL;
       LocalEncapData->DepexLen = 0;
       LocalEncapData->UiNameSize = 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] = {0xFF};
+  UINT32                      EntryFvId;
+
   AlignN                      = 0;
   Id                          = 0;
   InputFileSize               = 0;
   TmpFileSize                 = 0;
+  AlignmentFileSize           = 0;
   EncapFvIndex                = 0;
   Index                       = 0;
   OuterIndex                  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile                 = FALSE;
   OutputFileSize              = 0;
   LargeFileSize               = 0x1000000;
-
+  EntryFvId                   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@ -4261,6 +4279,9 @@ LibEncapNewFvFile(
     LocalEncapData = CurrentEncapData;
     if (LocalEncapData == NULL) {
         LocalEncapData = FvInFd->EncapData;
+        EntryFvId = 0xFFFFFFFF;
+    } else {
+      EntryFvId = LocalEncapData->FvId;
     }
     Level = LocalEncapData->Level;
     Type = LocalEncapData->Type;
@@ -4274,7 +4295,7 @@ LibEncapNewFvFile(
             LocalEncapDataNext = LocalEncapDataTemp->NextNode;
             if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) {
 
-                LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &ChildFileNameList);
+                LibEncapNewFvFile(FvInFd, TemDir, 
+ LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList);
                 ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level -1;
                 if (FvInFd->ChildFvFFS == NULL) {
                     FvInFd->ChildFvFFS = ChildFileNameList; @@ -4329,7 +4350,7 @@ LibEncapNewFvFile(
   } else {
     LocalEncapData = CurrentEncapData;
     while (LocalEncapData != NULL) {
-      if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) {
+      if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type 
+ == FMMT_ENCAP_TREE_FFS)) {
         LocalEncapDataTemp = LocalEncapData->RightNode;
         while (LocalEncapDataTemp != NULL) {
             LocalEncapDataNext = LocalEncapDataTemp->NextNode; @@ -4818,6 +4839,7 @@ LibEncapNewFvFile(
       memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, strlen(OutputFileName)+1);
       OutputFileNameList->IsFFS = TRUE;
       OutputFileNameList->ParentLevel = ParentLevel - 1;
+      OutputFileNameList->InFvId = Id;
       if (OutputFileNameList->Next == NULL){
           break;
       }
@@ -5077,10 +5099,6 @@ LibEncapNewFvFile(
     if (CurrentEncapData == NULL) {
        LocalEncapData = FvInFd->EncapData;
     } else {
-        if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == TRUE) {
-          *OutputFile = OutputFileNameList;
-          return EFI_SUCCESS;
-        }
         LocalEncapData = CurrentEncapData;
     }
     ParentLevel -= 1;
--
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-17  6:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-10  2:05 [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 GregX Yeh
2021-03-15  4:34 ` Bob Feng
2021-03-16  1:13   ` 回复: [edk2-devel] " fengyunhua
2021-03-16  1:54   ` GregX Yeh
2021-03-17  6:57     ` Bob Feng
  -- strict thread matches above, loose matches on Subject: below --
2021-01-04  3:11 GregX Yeh
2021-01-04 10:43 ` 回复: [edk2-devel] " fengyunhua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox