Re: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-17 Thread Bob Feng
Pushed. 4bfc77a87b820cd585ba10ca28aa957ae315c3dc

-Original Message-
From: Yeh, GregX  
Sent: Tuesday, March 16, 2021 9:55 AM
To: Feng, Bob C ; devel@edk2.groups.io; Yunhua Feng 

Cc: Liming Gao 
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 
Sent: Monday, March 15, 2021 12:35 PM
To: Yeh, GregX ; devel@edk2.groups.io; Yunhua Feng 

Cc: Liming Gao 
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 
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Liming Gao 
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 
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/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,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   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;
-

Re: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-15 Thread GregX Yeh
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  
Sent: Monday, March 15, 2021 12:35 PM
To: Yeh, GregX ; devel@edk2.groups.io; Yunhua Feng 

Cc: Liming Gao 
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 
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Liming Gao 
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 
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/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,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   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,
-  
+  ,
+

回复: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-15 Thread fengyunhua
Hi Bob,
  I have no concern about this patch.

Thanks,
Yunhua

-邮件原件-
发件人: devel@edk2.groups.io  代表 Bob Feng
发送时间: 2021年3月15日 12:35
收件人: Yeh, GregX ; devel@edk2.groups.io; Yunhua Feng

抄送: Liming Gao 
主题: 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  
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Liming Gao

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 
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/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,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   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,

Re: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-14 Thread Bob Feng
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  
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Liming Gao 
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 
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/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,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   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,
-  
+  ,
+  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  

[edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-09 Thread GregX Yeh
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/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,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   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,
-  
+  ,
+  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   = 0x100;
-
+  EntryFvId   = 0;
 
   OutputFileNameList = (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION));
   if (OutputFileNameList == NULL) {
@@