[PATCH] Add support for FuSA ACM in FitGen tool


Agrawal, Sachin
 

REF https://bugzilla.tianocore.org/show_bug.cgi?id=2200

FitGen Tool is responsible for creating FIT table in UEFI BIOS.
A new FIT entry type (FIT Type 0x3) has been allocated for FuSa ACM.
FitGen tool is updated to add support for this FuSa ACM.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>

Signed-off-by: Sachin Agrawal <sachin.agrawal@intel.com>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 82 +++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index faf9880060..1ebce40505 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -217,6 +217,7 @@ typedef struct {
#define FIT_TABLE_TYPE_HEADER 0
#define FIT_TABLE_TYPE_MICROCODE 1
#define FIT_TABLE_TYPE_STARTUP_ACM 2
+#define FIT_TABLE_TYPE_FUSA_ACM 3
#define FIT_TABLE_TYPE_BIOS_MODULE 7
#define FIT_TABLE_TYPE_TPM_POLICY 8
#define FIT_TABLE_TYPE_BIOS_POLICY 9
@@ -246,6 +247,8 @@ typedef struct {
UINT32 FitHeaderVersion;
FIT_TABLE_CONTEXT_ENTRY StartupAcm;
UINT32 StartupAcmVersion;
+ FIT_TABLE_CONTEXT_ENTRY FusaAcm;
+ UINT32 FusaAcmVersion;
FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];
UINT32 BiosModuleVersion;
FIT_TABLE_CONTEXT_ENTRY Microcode[MAX_MICROCODE_ENTRY];
@@ -317,6 +320,7 @@ Returns:
"\t[-CLEAR]\n"
"\t[-I <BiosInfoGuid>]\n"
"\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-V <StartupAcmVersion>]\n"
+ "\t[-F <FusaAcmAddress FusaAcmSize>|<FusaAcmGuid>] [-V <FusaAcmVersion>]\n"
"\t[-B <BiosModuleAddress BiosModuleSize>] [-B ...] [-V <BiosModuleVersion>]\n"
"\t[-M <MicrocodeAddress MicrocodeSize>] [-M ...]|[-U <MicrocodeFv MicrocodeBase>|<MicrocodeRegionOffset MicrocodeRegionSize>|<MicrocodeGuid>] [-V <MicrocodeVersion>]\n"
"\t[-O RecordType <RecordDataAddress RecordDataSize>|<RESERVE RecordDataSize>|<RecordDataGuid>|<RecordBinFile> [-V <RecordVersion>]] [-O ... [-V ...]]\n"
@@ -331,6 +335,9 @@ Returns:
printf ("\tStartupAcmAddress - Address of StartupAcm.\n");
printf ("\tStartupAcmSize - Size of StartupAcm.\n");
printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if StartupAcm is in a BiosModule, it will be excluded form that.\n");
+ printf ("\tFusaAcmAddress - Address of FusaAcm.\n");
+ printf ("\tFusaAcmSize - Size of FusaAcm.\n");
+ printf ("\tFusaAcmGuid - Guid of FusaAcm Module, if FusaAcm is in a BiosModule, it will be excluded from that.\n");
printf ("\tBiosModuleAddress - Address of BiosModule. User should ensure there is no overlap.\n");
printf ("\tBiosModuleSize - Size of BiosModule.\n");
printf ("\tMicrocodeAddress - Address of Microcode.\n");
@@ -349,6 +356,7 @@ Returns:
printf ("\tFitEntryDefaultVersion - The default version for all FIT table entries. 0x%04x is used if this is not specified.\n", DEFAULT_FIT_ENTRY_VERSION);
printf ("\tFitHeaderVersion - The version for FIT header. (Override default version)\n");
printf ("\tStartupAcmVersion - The version for StartupAcm. (Override default version)\n");
+ printf ("\tFusaAcmVersion - The version for FusaAcm. (Override default version)\n");
printf ("\tBiosModuleVersion - The version for BiosModule. (Override default version)\n");
printf ("\tMicrocodeVersion - The version for Microcode. (Override default version)\n");
printf ("\tRecordVersion - The version for Record. (Override default version)\n");
@@ -953,6 +961,17 @@ Returns:
gFitTableContext.StartupAcmVersion = BiosInfoStruct[BiosInfoIndex].Version;
gFitTableContext.FitEntryNumber ++;
break;
+ case FIT_TABLE_TYPE_FUSA_ACM:
+ if (gFitTableContext.FusaAcm.Type != 0) {
+ Error (NULL, 0, 0, "-I Parameter incorrect, Duplicated FusaAcm!", NULL);
+ return 0;
+ }
+ gFitTableContext.FusaAcm.Type = FIT_TABLE_TYPE_FUSA_ACM;
+ gFitTableContext.FusaAcm.Address = (UINT32)BiosInfoStruct[BiosInfoIndex].Address;
+ gFitTableContext.FusaAcm.Size = (UINT32)BiosInfoStruct[BiosInfoIndex].Size;
+ gFitTableContext.FusaAcmVersion = BiosInfoStruct[BiosInfoIndex].Version;
+ gFitTableContext.FitEntryNumber ++;
+ break;
case FIT_TABLE_TYPE_BIOS_MODULE:
if ((BiosInfoStruct[BiosInfoIndex].Attributes & BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB) != 0) {
continue;
@@ -1148,6 +1167,52 @@ Returns:
} while (FALSE);

//
+ // 1.5. FusaAcm
+ //
+ do {
+ if ((Index + 1 >= argc) ||
+ ((strcmp (argv[Index], "-F") != 0) &&
+ (strcmp (argv[Index], "-f") != 0)) ) {
+ if (BiosInfoExist && (gFitTableContext.FusaAcm.Type == FIT_TABLE_TYPE_FUSA_ACM)) {
+ break;
+ }
+ break;
+ }
+ if (IsGuidData (argv[Index + 1], &Guid)) {
+ FileBuffer = FindFileFromFvByGuid (FdBuffer, FdSize, &Guid, &FileSize);
+ if (FileBuffer == NULL) {
+ Error (NULL, 0, 0, "-F Parameter incorrect, GUID not found!", "%s", argv[Index + 1]);
+ return 0;
+ }
+ FileBuffer = (UINT8 *)MEMORY_TO_FLASH (FileBuffer, FdBuffer, FdSize);
+ Index += 2;
+ } else {
+ if (Index + 2 >= argc) {
+ Error (NULL, 0, 0, "-F Parameter incorrect, expect Address Size!", NULL);
+ return 0;
+ }
+ FileBuffer = (UINT8 *) (UINTN) xtoi (argv[Index + 1]);
+ FileSize = xtoi (argv[Index + 2]);
+ Index += 3;
+ }
+ if (gFitTableContext.FusaAcm.Type != 0) {
+ Error (NULL, 0, 0, "-F Parameter incorrect, Duplicated FusaAcm!", NULL);
+ return 0;
+ }
+ gFitTableContext.FusaAcm.Type = FIT_TABLE_TYPE_FUSA_ACM;
+ gFitTableContext.FusaAcm.Address = (UINT32) (UINTN) FileBuffer;
+ gFitTableContext.FusaAcm.Size = FileSize;
+ gFitTableContext.FitEntryNumber ++;
+ if ((Index + 1 >= argc) ||
+ ((strcmp (argv[Index], "-V") != 0) &&
+ (strcmp (argv[Index], "-v") != 0)) ) {
+ gFitTableContext.FusaAcmVersion = gFitTableContext.GlobalVersion;
+ } else {
+ gFitTableContext.FusaAcmVersion = xtoi (argv[Index + 1]);
+ Index += 2;
+ }
+ } while (FALSE);
+
// 2. BiosModule
//
do {
@@ -1555,6 +1620,7 @@ Returns:
// Final: Check StartupAcm in BiosModule.
//
CheckOverlap (gFitTableContext.StartupAcm.Address, gFitTableContext.StartupAcm.Size);
+ CheckOverlap (gFitTableContext.FusaAcm.Address, gFitTableContext.FusaAcm.Size);
FitEntryNumber = gFitTableContext.FitEntryNumber;
for (Index = 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; Index++) {
if ((gFitTableContext.OptionalModule[Index].Type == FIT_TABLE_TYPE_BIOS_POLICY) ||
@@ -1821,6 +1887,9 @@ Returns:
if (gFitTableContext.StartupAcm.Address != 0) {
printf ("StartupAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.StartupAcm.Address, gFitTableContext.StartupAcm.Size, gFitTableContext.StartupAcmVersion);
}
+ if (gFitTableContext.FusaAcm.Address != 0) {
+ printf ("FusaAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.FusaAcm.Address, gFitTableContext.FusaAcm.Size, gFitTableContext.FusaAcmVersion);
+ }
for (Index = 0; Index < gFitTableContext.BiosModuleNumber; Index++) {
printf ("BiosModule[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTableContext.BiosModule[Index].Address, gFitTableContext.BiosModule[Index].Size, gFitTableContext.BiosModuleVersion);
}
@@ -1845,6 +1914,7 @@ CHAR8 *mFitTypeStr[] = {
" ",
"MICROCODE ",
"STARTUP_ACM",
+ "FUSA_ACM ",
" ",
" ",
" ",
@@ -2413,6 +2483,18 @@ Returns:
FitIndex++;
}

+ //
+ // 4.5. FuSaAcm
+ //
+ if (gFitTableContext.FusaAcm.Address != 0) {
+ FitEntry[FitIndex].Address = gFitTableContext.FusaAcm.Address;
+ *(UINT32 *)&FitEntry[FitIndex].Size[0] = 0;
+ FitEntry[FitIndex].Version = (UINT16)gFitTableContext.FusaAcmVersion;
+ FitEntry[FitIndex].Type = FIT_TABLE_TYPE_FUSA_ACM;
+ FitEntry[FitIndex].C_V = 0;
+ FitEntry[FitIndex].Checksum = 0;
+ FitIndex++;
+ }
//
// 5. BiosModule
//
--
2.14.3.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.