From: "GregX Yeh" <gregx.yeh@intel.com>
To: devel@edk2.groups.io
Cc: Bob Feng <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
Date: Fri, 4 Dec 2020 17:04:44 +0800 [thread overview]
Message-ID: <20201204090444.16056-1-gregx.yeh@intel.com> (raw)
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 | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..bfb3b57d4a 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;
@@ -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
next reply other threads:[~2020-12-04 9:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 9:04 GregX Yeh [this message]
-- strict thread matches above, loose matches on Subject: below --
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:54 ` GregX Yeh
2021-03-17 6:57 ` Bob Feng
2021-01-04 3:11 GregX Yeh
2020-12-08 7:32 GregX Yeh
2020-12-08 8:30 ` Bob Feng
2020-12-08 8:33 ` GregX Yeh
2020-12-18 9:33 ` Bob Feng
2020-12-23 8:00 ` GregX Yeh
2021-01-04 2:54 ` Bob Feng
2020-12-01 7:43 GregX Yeh
2020-11-27 2:16 GregX Yeh
2020-11-27 1:38 GregX Yeh
2020-11-27 2:08 ` Bob Feng
2020-11-26 7:07 GregX Yeh
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=20201204090444.16056-1-gregx.yeh@intel.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