From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.7678.1581045129864146127 for ; Thu, 06 Feb 2020 19:12:09 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: bob.c.feng@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2020 19:12:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,411,1574150400"; d="scan'208";a="225242214" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga008.jf.intel.com with ESMTP; 06 Feb 2020 19:12:09 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 6 Feb 2020 19:12:08 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX601.ccr.corp.intel.com (10.109.6.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 7 Feb 2020 11:12:07 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.1713.004; Fri, 7 Feb 2020 11:12:07 +0800 From: "Bob Feng" To: "Gao, Liming" , "devel@edk2.groups.io" Subject: Re: [edk2-platform] FitGen: Support FV with the extension header Thread-Topic: [edk2-platform] FitGen: Support FV with the extension header Thread-Index: AQHV3DEaaK0WnkHptUyKpCQMo777KKgPEE3w Date: Fri, 7 Feb 2020 03:12:06 +0000 Message-ID: References: <20200205143224.2038-1-liming.gao@intel.com> In-Reply-To: <20200205143224.2038-1-liming.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWJhZjQwODgtNWZjYy00MmIyLTk2NTktMDM3NTY5NDQyMzBlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQURKcjJpYXhGQzVZdW1pUnZvRlE0WXdpN1BSYjUrY2VDV1pOWEVxVUtrZTBBV29NTWNtMm5WWjZJNnNZeWZnQyJ9 dlp-version: 11.2.0.6 dlp-product: dlpe-windows x-ctpclassification: CTP_NT dlp-reaction: no-action x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Gao, Liming =20 Sent: Wednesday, February 5, 2020 10:32 PM To: devel@edk2.groups.io Cc: Feng, Bob C Subject: [edk2-platform] FitGen: Support FV with the extension header BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2086 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 Signed-off-by: Liming Gao --- 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/FitG= en/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 ( } } =20 +UINT8 * +GetMicrocodeBufferFromFv ( + EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ) +{ + UINT8 *MicrocodeBuffer; + EFI_FFS_FILE_HEADER *FfsHeader; + + MicrocodeBuffer =3D NULL; + // + // Skip FV header + FV extension header + FFS header // FfsHeader =3D= =20 + (EFI_FFS_FILE_HEADER *)((UINT8 *) FvHeader + FvHeader->HeaderLength); =20 + while ((UINT8 *) FfsHeader < (UINT8 *) FvHeader + FvHeader->FvLength) { + if (FfsHeader->Type =3D=3D EFI_FV_FILETYPE_RAW) { + // + // Find the first RAW ffs file as Microcode Buffer + // + MicrocodeBuffer =3D (UINT8 *)(FfsHeader + 1); + break; + } + if (GetFfsFileLength (FfsHeader) =3D=3D 0xFFFFFF) { + // spare space is found, and exit + break; + } + FfsHeader =3D (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader +=20 + ((GetFfsFileLength (FfsHeader)+7)&~7)); } + + return MicrocodeBuffer; +} + UINT32 GetFitEntryNumber ( IN INTN argc, @@ -1047,8 +1078,7 @@ Returns: =20 FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer= ; if (FvHeader->Signature =3D=3D EFI_FVH_SIGNATURE) { - // Skip FV header + FFS header - MicrocodeBuffer =3D MicrocodeFileBuffer + sizeof(EFI_FIRMWAR= E_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEA= DER); + MicrocodeBuffer =3D GetMicrocodeBufferFromFv (FvHeader); } else { MicrocodeBuffer =3D MicrocodeFileBuffer; } @@ -1388,8 +1418,7 @@ Returns: =20 FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer; if (FvHeader->Signature =3D=3D EFI_FVH_SIGNATURE) { - // Skip FV header + FFS header - MicrocodeBuffer =3D MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VO= LUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER)= ; + MicrocodeBuffer =3D GetMicrocodeBufferFromFv (FvHeader); } else { MicrocodeBuffer =3D MicrocodeFileBuffer; } @@ -1401,8 +1430,7 @@ Returns: =20 FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)MicrocodeFileBuffer; if (FvHeader->Signature =3D=3D EFI_FVH_SIGNATURE) { - // Skip FV header + FFS header - MicrocodeBuffer =3D MicrocodeFileBuffer + sizeof(EFI_FIRMWARE_VO= LUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(EFI_FFS_FILE_HEADER)= ; + MicrocodeBuffer =3D GetMicrocodeBufferFromFv (FvHeader); } else { MicrocodeBuffer =3D MicrocodeFileBuffer; } diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/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_M= INOR_VERSION 57 +#define UTILITY_MINOR_VERSION 58 #define UTILITY_DATE __DATE__ =20 // -- 2.13.0.windows.1