From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web09.39992.1656688211066291732 for ; Fri, 01 Jul 2022 08:10:15 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=kM9xcevi; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: jason1.lin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656688214; x=1688224214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4hg7v38NqS/ZFXweh7CaEilzTri3Yg/W2vkGZs1K7k8=; b=kM9xceviHsrUVQ/MlNCGrFVCm6VQuVKlhCN7XnhWtgGm4FITxjZUQhJ+ Fr13i8yDs5NmC69KsUJD8Oul1LSJm7UPtC/bktTjG21fkzz/Z4CyRhuom BrmrG7GrimpQOVCfyzAja9RHr1SQMMUV8LzF9uwH18Bfl22cdxGCvu3Yj qSCOb2Q2Xvi7u4yI29sjYWHPXxaCqyCOHeX3NmTDPv9VzQf63OhsHXPSW xOuiQwhTrHbWhlsjisONBkvAH15QjI5D3UFSTl06Vma0n9bShHR/xjYO1 HCbu0fb0KjVTCaVHC3zi4PXbw8DMW95XY0o7ituT4gGRtuEkGDuwVUhQi g==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="346658199" X-IronPort-AV: E=Sophos;i="5.92,237,1650956400"; d="scan'208";a="346658199" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2022 08:10:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,237,1650956400"; d="scan'208";a="918502042" Received: from linjaso1-desk1.gar.corp.intel.com ([10.5.215.41]) by fmsmga005.fm.intel.com with ESMTP; 01 Jul 2022 08:10:12 -0700 From: "Lin, Jason1" To: devel@edk2.groups.io Cc: Jason1 Lin , Bob Feng , Liming Gao , Yuwei Chen , Isaac W Oram , Rangasai V Chaganty , Dakota Chiang Subject: [PATCH v3 3/3] [edk2-platforms] Silicon/Intel/FitGen: Support Startup ACM entries (Type 2) 0x200 Version Date: Fri, 1 Jul 2022 23:10:05 +0800 Message-Id: <20220701151005.189-3-jason1.lin@intel.com> X-Mailer: git-send-email 2.37.0.windows.1 In-Reply-To: <20220701151005.189-1-jason1.lin@intel.com> References: <20220701151005.189-1-jason1.lin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jason1 Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3959 As per FIT BIOS Specification 1.2 Rules, the size bytes (3 bytes) / reserved byte (1 byte) / CheckSum byte (1 byte) in type 2 are must-be-zero (MBZ). These bytes could be override for the other usages. This change is used to support the Type 02 (ACM) Ver. 0x200. Command: [-S |] [-I ] [-V ] Signed-off-by: Jason1 Lin Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Cc: Isaac W Oram Cc: Rangasai V Chaganty Cc: Dakota Chiang --- Silicon/Intel/Tools/FitGen/FitGen.c | 183 ++++++++++++++++++-- Silicon/Intel/Tools/FitGen/FitGen.h | 2 +- 2 files changed, 165 insertions(+), 20 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG= en/FitGen.c index 01b4f82518..577ce48b10 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -55,6 +55,7 @@ typedef struct { #define ACM_MODULE_FLAG_PREPRODUCTION 0x4000=0D #define ACM_MODULE_FLAG_DEBUG_SIGN 0x8000=0D =0D +#define NIBBLES_TO_BYTE(A, B) (UINT8)(((A & (0x0F)) << 4) | (B & 0x0F))=0D =0D typedef struct {=0D UINT16 ModuleType;=0D @@ -149,6 +150,20 @@ typedef struct { ACM_PROCESSOR_ID ProcessorID[1];=0D } PROCESSOR_ID_LIST;=0D =0D +typedef union {=0D + struct {=0D + UINT32 Stepping : 4;=0D + UINT32 Model : 4;=0D + UINT32 Family : 4;=0D + UINT32 Type : 2;=0D + UINT32 Reserved1 : 2;=0D + UINT32 ExtendedModel : 4;=0D + UINT32 ExtendedFamily: 8;=0D + UINT32 Reserved2 : 4;=0D + } Bits;=0D + UINT32 Uint32;=0D +} PROCESSOR_ID;=0D +=0D #pragma pack ()=0D =0D =0D @@ -210,6 +225,7 @@ typedef struct { =0D #define DEFAULT_FIT_TABLE_POINTER_OFFSET 0x40=0D #define DEFAULT_FIT_ENTRY_VERSION 0x0100=0D +#define STARTUP_ACM_FIT_ENTRY_200_VERSION 0x0200=0D =0D #define TOP_FLASH_ADDRESS (gFitTableContext.TopFlashAddressRemapValue)=0D =0D @@ -247,6 +263,8 @@ typedef struct { UINT8 *Buffer; // Used by OptionalModule only=0D UINT32 Size;=0D UINT32 Version; // Used by OptionalModule and PortModule only=0D + UINT32 FMS; // Used by Entry Type 02 (ACM) Ver. 0x200 only=0D + UINT32 FMSMask; // Used by Entry Type 02 (ACM) Ver. 0x200 only=0D } FIT_TABLE_CONTEXT_ENTRY;=0D =0D typedef struct {=0D @@ -262,7 +280,7 @@ typedef struct { UINT32 GlobalVersion;=0D UINT32 FitHeaderVersion;=0D FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D - UINT32 StartupAcmVersion;=0D + UINT32 StartupAcmVersion[MAX_STARTUP_ACM_ENTRY];=0D FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D UINT32 DiagnstAcmVersion;=0D FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];=0D @@ -341,7 +359,7 @@ Returns: "\t[-L ]\n"=0D "\t[-LF ]\n"=0D "\t[-I ]\n"=0D - "\t[-S |] [-V = ]\n"=0D + "\t[-S |] [-I = ] [-V ]\n"=0D "\t[-U |]\n"=0D "\t[-B ] [-B ...] [-V ]\n"=0D "\t[-M ] [-M ...]|[-U ||] [-V ]\n"=0D @@ -356,8 +374,11 @@ Returns: printf ("\tFitTablePointerOffset - FIT table pointer offset. 0x%x as de= fault. 0x18 for current soon to be obsoleted CPUs. User can set both.\n", D= EFAULT_FIT_TABLE_POINTER_OFFSET);=0D printf ("\tBiosInfoGuid - Guid of BiosInfo Module. If this mod= ule exists, StartupAcm/Bios/Microcode can be optional.\n");=0D printf ("\tStartupAcmAddress - Address of StartupAcm.\n");=0D - printf ("\tStartupAcmSize - Size of StartupAcm.\n");=0D + printf ("\tStartupAcmSize - The maximum size value that could pl= ace the StartupAcm in.\n");=0D printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if Startu= pAcm is in a BiosModule, it will be excluded form that.\n");=0D + printf ("\tStartupAcmFMS - Value of PROCESSOR ID (Family/Model/= Stepping value called \"FMS\") - see detail on FIT spec (1.3).\n");=0D + printf ("\tStartupAcmFMSMask - Value use for uCode (if it recognize= s 0x200 Type2 entry) to do bitmask logic operation with CPU processor ID.\n= ");=0D + printf ("\t If the result match to StartupAcmFMS= , corresponding ACM will be loaded - see detail on FIT spec (1.3).\n");=0D printf ("\tDiagnstAcmAddress - Address of DiagnstAcm.\n");=0D printf ("\tDiagnstAcmGuid - Guid of DiagnstAcm Module, if Diagns= tAcm is in a BiosModule, it will be excluded from that.\n");=0D printf ("\tBiosModuleAddress - Address of BiosModule. User should e= nsure there is no overlap.\n");=0D @@ -1155,6 +1176,9 @@ Returns: Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc= m!", NULL);=0D return 0;=0D }=0D + //=0D + // NOTE: BIOS INFO structure only support the default FIT entry = format.=0D + //=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T= ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A= ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S= ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D @@ -1392,7 +1416,37 @@ Returns: gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = =3D FileSize;=0D =0D //=0D - // 1.1 StartupAcm version=0D + // 1.1 Support 0x200 StartupAcm Information=0D + // With the -I parameter should assign the type 2 entry with 0x200= version format=0D + //=0D + if ((Index + 1 >=3D argc) ||=0D + ((strcmp (argv[Index], "-I") !=3D 0) &&=0D + (strcmp (argv[Index], "-i") !=3D 0)) ) {=0D + //=0D + // Bypass=0D + //=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D gFitTableContext.GlobalVersion;=0D + } else {=0D + if (Index + 2 >=3D argc) {=0D + //=0D + // Should get two input value, but not sufficient=0D + //=0D + Error (NULL, 0, 0, "-I Parameter incorrect, Require two inputs val= ue!", NULL);=0D + return 0;=0D + } else {=0D + //=0D + // With the -I parameter should assign the type 2 entry version as= 0x200 format=0D + //=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumb= er] =3D STARTUP_ACM_FIT_ENTRY_200_VERSION;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].FMS= =3D (UINT32)xtoi (argv[Index + 1]);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].FMS= Mask =3D (UINT32)xtoi (argv[Index + 2]);=0D +=0D + Index +=3D 3;=0D + }=0D + }=0D +=0D + //=0D + // 1.2 StartupAcm version=0D //=0D if ((Index + 1 >=3D argc) ||=0D ((strcmp (argv[Index], "-V") !=3D 0) &&=0D @@ -1400,18 +1454,17 @@ Returns: //=0D // Bypass=0D //=0D - gFitTableContext.StartupAcmVersion =3D gFitTableContext.GlobalVersio= n;=0D } else {=0D //=0D // Get offset from parameter=0D //=0D - gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D xtoi (argv[Index + 1]);=0D Index +=3D 2;=0D }=0D =0D gFitTableContext.StartupAcmNumber ++;=0D gFitTableContext.FitEntryNumber ++;=0D - }=0D + };=0D =0D //=0D // 1.5. DiagnosticsAcm=0D @@ -2185,7 +2238,7 @@ Returns: printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe= r);=0D printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion= );=0D for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {= =0D - printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl= eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size= , gFitTableContext.StartupAcmVersion);=0D + printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl= eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size= , gFitTableContext.StartupAcmVersion[Index]);=0D }=0D if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext= .DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia= gnstAcmVersion);=0D @@ -2774,6 +2827,8 @@ Returns: UINTN SubIndex;=0D FIT_TABLE_CONTEXT_ENTRY TempContextEntry;=0D FIRMWARE_INTERFACE_TABLE_ENTRY TempTableEntry;=0D + PROCESSOR_ID FMS;=0D + PROCESSOR_ID FMSMask;=0D =0D //=0D // 1. FitPointer=0D @@ -2825,16 +2880,30 @@ Returns: // 4. StartupAcm=0D //=0D for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {= =0D - FitEntrySizeValue =3D 0; // gFitTableContext.StartupAcm.Size= / 16=0D - FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm[Index].Add= ress;=0D - FitEntry[FitIndex].Size[0] =3D (UINT8)FitEntrySizeValue;=0D - FitEntry[FitIndex].Size[1] =3D (UINT8)(FitEntrySizeValue >> 8);=0D - FitEntry[FitIndex].Size[2] =3D (UINT8)(FitEntrySizeValue >> 16);=0D - FitEntry[FitIndex].Rsvd =3D 0;=0D - FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.StartupAcmVer= sion;=0D - FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D - FitEntry[FitIndex].C_V =3D 0;=0D - FitEntry[FitIndex].Checksum =3D 0;=0D + if (gFitTableContext.StartupAcmVersion[Index] =3D=3D STARTUP_ACM_FIT_E= NTRY_200_VERSION) {=0D + FMS.Uint32 =3D gFitTableContext.StartupAcm[Index].FMS;=0D + FMSMask.Uint32 =3D gFitTableContext.StartupAcm[Index].FMSMask;=0D + FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm[Index].A= ddress;=0D + FitEntry[FitIndex].Size[0] =3D NIBBLES_TO_BYTE (FMS.Bits.Family, FM= S.Bits.Model);=0D + FitEntry[FitIndex].Size[1] =3D NIBBLES_TO_BYTE (FMS.Bits.ExtendedMo= del, FMS.Bits.Type);=0D + FitEntry[FitIndex].Size[2] =3D NIBBLES_TO_BYTE (FMSMask.Bits.Family= , FMSMask.Bits.Model);=0D + FitEntry[FitIndex].Rsvd =3D NIBBLES_TO_BYTE (FMSMask.Bits.Extend= edModel, FMSMask.Bits.Type);=0D + FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.StartupAcmV= ersion[Index];=0D + FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D + FitEntry[FitIndex].C_V =3D 0;=0D + FitEntry[FitIndex].Checksum =3D NIBBLES_TO_BYTE (FMSMask.Bits.Extend= edFamily, FMS.Bits.ExtendedFamily);=0D + } else {=0D + FitEntrySizeValue =3D 0; // gFitTableContext.StartupAcm.Si= ze / 16=0D + FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm[Index].A= ddress;=0D + FitEntry[FitIndex].Size[0] =3D (UINT8)FitEntrySizeValue;=0D + FitEntry[FitIndex].Size[1] =3D (UINT8)(FitEntrySizeValue >> 8);=0D + FitEntry[FitIndex].Size[2] =3D (UINT8)(FitEntrySizeValue >> 16);=0D + FitEntry[FitIndex].Rsvd =3D 0;=0D + FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.StartupAcmV= ersion[Index];=0D + FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D + FitEntry[FitIndex].C_V =3D 0;=0D + FitEntry[FitIndex].Checksum =3D 0;=0D + }=0D FitIndex++;=0D }=0D =0D @@ -3135,6 +3204,69 @@ Returns: return FvRecoveryFileSize;=0D }=0D =0D +void=0D +GetFMSFromFitEntry (=0D + IN FIRMWARE_INTERFACE_TABLE_ENTRY FitEntry,=0D + IN OUT PROCESSOR_ID *FMS,=0D + IN OUT PROCESSOR_ID *FMSMask=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Get FMS information from FIT Entry.=0D +=0D + Note: Since FIT entry not record all the processor ID information.=0D + The value would not the same as the real value.=0D +=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Byte | 15 | 14 | 13:= 12 | 11 |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + |Bit Fields| [7:4] | [3:0] | [7:7] | [6:0] | [7:4] |= [3:0] | [7:4] | [3:0] |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Ver. 100 | Checksum | C_V | Type | Vers= ion | Reserved |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Ver. 200 | FMSMask | FMS | C_V | Type | Vers= ion | FMSMask | FMSMask |=0D + | | ExtFamily | ExtFamily | | | = | ExtModel | Type |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D +=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Byte | 10 | 9 | 8= | 7:0 |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + |Bit Fields| [7:4] | [3:0] | [7:4] | [3:0] | [7:4] |= [3:0] | [7:4] | [3:0] |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Ver. 100 | Size[2] | Size[1] | Size= [0] | Address |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D + | Ver. 200 | FMSMask | FMSMask | FMS | FMS | FMS |= FMS | Address |=0D + | | Family | Model | ExtModel | Type | Family |= Model | |=0D + +----------+-----------------------+-----------------------+------------= -----------+-----------------------+=0D +=0D +=0D +Arguments:=0D +=0D + FitEntry - FIT entry information.=0D + FMS - Processor ID information.=0D + FMSMask - Processor ID mask information.=0D +=0D +Returns:=0D + None=0D +=0D +--*/=0D +{=0D +=0D + FMS->Bits.Family =3D (FitEntry.Size[0] & 0xF0) >> 4;=0D + FMS->Bits.Model =3D (FitEntry.Size[0] & 0x0F);=0D + FMS->Bits.ExtendedModel =3D (FitEntry.Size[1] & 0xF0) >> 4;=0D + FMS->Bits.Type =3D (FitEntry.Size[1] & 0x0F);=0D + FMS->Bits.ExtendedFamily =3D (FitEntry.Checksum & 0x0F);=0D +=0D + FMSMask->Bits.Family =3D (FitEntry.Size[2] & 0xF0) >> 4;=0D + FMSMask->Bits.Model =3D (FitEntry.Size[2] & 0x0F);=0D + FMSMask->Bits.ExtendedModel =3D (FitEntry.Rsvd & 0xF0) >> 4;=0D + FMSMask->Bits.Type =3D (FitEntry.Rsvd & 0x0F);=0D + FMSMask->Bits.ExtendedFamily =3D (FitEntry.Checksum & 0xF0) >> 4;=0D +}=0D +=0D UINT32=0D GetFitEntryInfo (=0D IN UINT8 *FvBuffer,=0D @@ -3161,6 +3293,11 @@ Returns: UINT32 FitEntrySizeValue;=0D UINT32 FitIndex;=0D UINT32 FitTableOffset;=0D + PROCESSOR_ID FMS;=0D + PROCESSOR_ID FMSMask;=0D +=0D + FMS.Uint32 =3D 0;=0D + FMSMask.Uint32 =3D 0;=0D =0D //=0D // 1. FitPointer=0D @@ -3202,7 +3339,15 @@ Returns: break;=0D case FIT_TABLE_TYPE_STARTUP_ACM:=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre= ss =3D (UINT32)FitEntry[FitIndex].Address;=0D - gFitTableContext.StartupAcmVersion = =3D FitEntry[FitIndex].Version;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = =3D FitEntrySizeValue;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = =3D FitEntry[FitIndex].Type;=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D FitEntry[FitIndex].Version;=0D + if (gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNu= mber] =3D=3D STARTUP_ACM_FIT_ENTRY_200_VERSION) {=0D + GetFMSFromFitEntry (FitEntry[FitIndex], &FMS, &FMSMask);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].FMS= =3D FMS.Uint32;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].FMS= Mask =3D FMSMask.Uint32;=0D + }=0D + gFitTableContext.StartupAcmNumber++;=0D break;=0D case FIT_TABLE_TYPE_BIOS_MODULE:=0D gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre= ss =3D (UINT32)FitEntry[FitIndex].Address;=0D diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/FitGen.h index b7de0a6b2d..80a1423ceb 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=0D //=0D #define UTILITY_MAJOR_VERSION 0=0D -#define UTILITY_MINOR_VERSION 65=0D +#define UTILITY_MINOR_VERSION 66=0D #define UTILITY_DATE __DATE__=0D =0D //=0D --=20 2.37.0.windows.1