* [edk2-platform] FitGen: Support FV with the extension header
@ 2020-02-05 14:32 Liming Gao
2020-02-07 3:12 ` Bob Feng
0 siblings, 1 reply; 2+ messages in thread
From: Liming Gao @ 2020-02-05 14:32 UTC (permalink / raw)
To: devel; +Cc: Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2086
To find Microcode FILE in FV image, need to skip FV header and
FV extension header, then find the first RAW FFS file.
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 40 +++++++++++++++++++++++++++++++------
Silicon/Intel/Tools/FitGen/FitGen.h | 2 +-
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index 9f1db32a15..5f5638dc8b 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -747,6 +747,37 @@ CheckOverlap (
}
}
+UINT8 *
+GetMicrocodeBufferFromFv (
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+{
+ UINT8 *MicrocodeBuffer;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+
+ MicrocodeBuffer = NULL;
+ //
+ // Skip FV header + FV extension header + FFS header
+ //
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *) FvHeader + FvHeader->HeaderLength);
+ while ((UINT8 *) FfsHeader < (UINT8 *) FvHeader + FvHeader->FvLength) {
+ if (FfsHeader->Type == EFI_FV_FILETYPE_RAW) {
+ //
+ // Find the first RAW ffs file as Microcode Buffer
+ //
+ MicrocodeBuffer = (UINT8 *)(FfsHeader + 1);
+ break;
+ }
+ if (GetFfsFileLength (FfsHeader) == 0xFFFFFF) {
+ // spare space is found, and exit
+ break;
+ }
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + ((GetFfsFileLength (FfsHeader)+7)&~7));
+ }
+
+ return MicrocodeBuffer;
+}
+
UINT32
GetFitEntryNumber (
IN INTN argc,
@@ -1047,8 +1078,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
@@ -1388,8 +1418,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
@@ -1401,8 +1430,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h
index ecb5822d32..4d0a2dc6f8 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 57
+#define UTILITY_MINOR_VERSION 58
#define UTILITY_DATE __DATE__
//
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-platform] FitGen: Support FV with the extension header
2020-02-05 14:32 [edk2-platform] FitGen: Support FV with the extension header Liming Gao
@ 2020-02-07 3:12 ` Bob Feng
0 siblings, 0 replies; 2+ messages in thread
From: Bob Feng @ 2020-02-07 3:12 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Gao, Liming <liming.gao@intel.com>
Sent: Wednesday, February 5, 2020 10:32 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>
Subject: [edk2-platform] FitGen: Support FV with the extension header
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2086
To find Microcode FILE in FV image, need to skip FV header and FV extension header, then find the first RAW FFS file.
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 40 +++++++++++++++++++++++++++++++------
Silicon/Intel/Tools/FitGen/FitGen.h | 2 +-
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index 9f1db32a15..5f5638dc8b 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -747,6 +747,37 @@ CheckOverlap (
}
}
+UINT8 *
+GetMicrocodeBufferFromFv (
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+{
+ UINT8 *MicrocodeBuffer;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+
+ MicrocodeBuffer = NULL;
+ //
+ // Skip FV header + FV extension header + FFS header // FfsHeader =
+ (EFI_FFS_FILE_HEADER *)((UINT8 *) FvHeader + FvHeader->HeaderLength);
+ while ((UINT8 *) FfsHeader < (UINT8 *) FvHeader + FvHeader->FvLength) {
+ if (FfsHeader->Type == EFI_FV_FILETYPE_RAW) {
+ //
+ // Find the first RAW ffs file as Microcode Buffer
+ //
+ MicrocodeBuffer = (UINT8 *)(FfsHeader + 1);
+ break;
+ }
+ if (GetFfsFileLength (FfsHeader) == 0xFFFFFF) {
+ // spare space is found, and exit
+ break;
+ }
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader +
+ ((GetFfsFileLength (FfsHeader)+7)&~7)); }
+
+ return MicrocodeBuffer;
+}
+
UINT32
GetFitEntryNumber (
IN INTN argc,
@@ -1047,8 +1078,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
@@ -1388,8 +1418,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
@@ -1401,8 +1430,7 @@ Returns:
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer;
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
- // Skip FV header + FFS header
- MicrocodeBuffer = MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER);
+ MicrocodeBuffer = GetMicrocodeBufferFromFv (FvHeader);
} else {
MicrocodeBuffer = MicrocodeFileBuffer;
}
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h
index ecb5822d32..4d0a2dc6f8 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information // #define UTILITY_MAJOR_VERSION 0 -#define UTILITY_MINOR_VERSION 57
+#define UTILITY_MINOR_VERSION 58
#define UTILITY_DATE __DATE__
//
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-07 3:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-05 14:32 [edk2-platform] FitGen: Support FV with the extension header Liming Gao
2020-02-07 3:12 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox