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.web08.1226.1667810639235532695 for ; Mon, 07 Nov 2022 00:43:59 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=iMllxTxU; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ted.kuo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667810639; x=1699346639; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bw7tSS+OU++nEiRHevON5ApCmBKdgiwjLDpeYM3ik4k=; b=iMllxTxU6xlxDgqOoa+cwBXlcIlGewMs2y8O/pi1kHndUlZmoAR7sKvH dle0cg8GIT1jeYmadz/FZCjIESyl/6BR0AH66dAGtcj8MGaTNzFYE3Vkj vYSxw/mvq196YxcrVOuybzSUyEbjT+eqDsfNPO1xLgj2Ix+y+so1VKwWL 7UAev4R2jMHlwVJXHmyTEMbEuI2mJY+8YdN69lp6FOdI6HmuRE8jGv+c+ ZBalPDBkCKN/p73Z58S1iEIzV1vnQ6Rh6Xk/LSTMSIpw/rRR8xcGIjeYG f/2W8L4bdw2rp5e/GW1X4ZrHt1qAUtQ7DdItboAefnIPU1ryjFHadSSd/ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="374612396" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="374612396" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 00:43:58 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="778406228" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="778406228" Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 00:43:56 -0800 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S , Chinni B Duggapu , Amy Chan Subject: [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib Date: Mon, 7 Nov 2022 16:43:30 +0800 Message-Id: <28da0d3ce6289e39e542990fdabd3002a4c665a2.1667810598.git.ted.kuo@intel.com> X-Mailer: git-send-email 2.35.3.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D4128 Adding FspHelperLib for platform code to consume. There will be another patch raised later for FspSecCore to consume FspHelperLib. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Cc: Chinni B Duggapu Cc: Amy Chan Signed-off-by: Ted Kuo --- IntelFsp2Pkg/FspSecCore/SecFsp.h | 25 +--------- IntelFsp2Pkg/Include/Library/FspHelperLib.h | 35 +++++++++++++ IntelFsp2Pkg/IntelFsp2Pkg.dsc | 2 + .../BaseFspHelperLib/BaseFspHelperLib.inf | 50 +++++++++++++++++++ .../BaseFspHelperLib/Ia32/FspHelper.nasm | 35 +++++++++++++ .../BaseFspHelperLib/X64/FspHelper.nasm | 34 +++++++++++++ 6 files changed, 157 insertions(+), 24 deletions(-) create mode 100644 IntelFsp2Pkg/Include/Library/FspHelperLib.h create mode 100644 IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.= inf create mode 100644 IntelFsp2Pkg/Library/BaseFspHelperLib/Ia32/FspHelper.na= sm create mode 100644 IntelFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.h index d7a5976c12..f12769890f 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h @@ -17,6 +17,7 @@ #include =0D #include =0D #include =0D +#include =0D =0D #define FSP_MCUD_SIGNATURE SIGNATURE_32 ('M', 'C', 'U', 'D')=0D #define FSP_PER0_SIGNATURE SIGNATURE_32 ('P', 'E', 'R', '0')=0D @@ -64,28 +65,4 @@ FspDataPointerFixUp ( IN UINTN OffsetGap=0D );=0D =0D -/**=0D - This interface returns the base address of FSP binary.=0D -=0D - @return FSP binary base address.=0D -=0D -**/=0D -UINTN=0D -EFIAPI=0D -AsmGetFspBaseAddress (=0D - VOID=0D - );=0D -=0D -/**=0D - This interface gets FspInfoHeader pointer=0D -=0D - @return FSP binary base address.=0D -=0D -**/=0D -UINTN=0D -EFIAPI=0D -AsmGetFspInfoHeader (=0D - VOID=0D - );=0D -=0D #endif=0D diff --git a/IntelFsp2Pkg/Include/Library/FspHelperLib.h b/IntelFsp2Pkg/Inc= lude/Library/FspHelperLib.h new file mode 100644 index 0000000000..84b74fa7aa --- /dev/null +++ b/IntelFsp2Pkg/Include/Library/FspHelperLib.h @@ -0,0 +1,35 @@ +/** @file=0D + Header file for FSP Helper Library.=0D +=0D + Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _FSP_HELPER_LIB_H_=0D +#define _FSP_HELPER_LIB_H_=0D +=0D +/**=0D + This interface returns the base address of FSP binary.=0D +=0D + @return FSP binary base address.=0D +=0D +**/=0D +UINTN=0D +EFIAPI=0D +AsmGetFspBaseAddress (=0D + VOID=0D + );=0D +=0D +/**=0D + This interface gets FspInfoHeader pointer=0D +=0D + @return FSP info header.=0D +**/=0D +UINTN=0D +EFIAPI=0D +AsmGetFspInfoHeader (=0D + VOID=0D + );=0D +=0D +#endif // _FSP_HELPER_LIB_H_=0D diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc index 0713f0028d..09893d70e8 100644 --- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc @@ -46,6 +46,7 @@ FspSwitchStackLib|IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwit= chStackLib.inf=0D FspSecPlatformLib|IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSe= cPlatformLibNull.inf=0D FspMultiPhaseLib|IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiP= haseLib.inf=0D + FspHelperLib|IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf= =0D =0D [LibraryClasses.common.PEIM]=0D PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf=0D @@ -66,6 +67,7 @@ IntelFsp2Pkg/Library/BaseDebugDeviceLibNull/BaseDebugDeviceLibNull.inf=0D IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.i= nf=0D IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf=0D + IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf=0D =0D IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf=0D IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf=0D diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf b/I= ntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf new file mode 100644 index 0000000000..318ad65330 --- /dev/null +++ b/IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf @@ -0,0 +1,50 @@ +## @file=0D +# FSP Helper Library.=0D +#=0D +# Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +##########################################################################= ######=0D +#=0D +# Defines Section - statements that will be processed to create a Makefile= .=0D +#=0D +##########################################################################= ######=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D FspHelperLib=0D + FILE_GUID =3D 65746991-8a41-4b89-b0f4-eb4e24b5b471= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D FspHelperLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +##########################################################################= ######=0D +#=0D +# Sources Section - list of files that are required for the build to succe= ed.=0D +#=0D +##########################################################################= ######=0D +=0D +[Sources.IA32]=0D + Ia32/FspHelper.nasm=0D +=0D +[Sources.X64]=0D + X64/FspHelper.nasm=0D +=0D +##########################################################################= ######=0D +#=0D +# Package Dependency Section - list of Package files that are required for= =0D +# this module.=0D +#=0D +##########################################################################= ######=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/Ia32/FspHelper.nasm b/In= telFsp2Pkg/Library/BaseFspHelperLib/Ia32/FspHelper.nasm new file mode 100644 index 0000000000..e3e1945473 --- /dev/null +++ b/IntelFsp2Pkg/Library/BaseFspHelperLib/Ia32/FspHelper.nasm @@ -0,0 +1,35 @@ +;; @file=0D +; Provide FSP helper function.=0D +;=0D +; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +;;=0D +=0D + SECTION .text=0D +=0D +global ASM_PFX(FspInfoHeaderRelativeOff)=0D +ASM_PFX(FspInfoHeaderRelativeOff):=0D + DD 0x12345678 ; This value must be patched by the buil= d script=0D +=0D +global ASM_PFX(AsmGetFspBaseAddress)=0D +ASM_PFX(AsmGetFspBaseAddress):=0D + call ASM_PFX(AsmGetFspInfoHeader)=0D + add eax, 0x1C=0D + mov eax, dword [eax]=0D + ret=0D +=0D +global ASM_PFX(AsmGetFspInfoHeader)=0D +ASM_PFX(AsmGetFspInfoHeader):=0D + call ASM_PFX(NextInstruction)=0D +ASM_PFX(NextInstruction):=0D + pop eax=0D + sub eax, ASM_PFX(NextInstruction)=0D + add eax, ASM_PFX(AsmGetFspInfoHeader)=0D + sub eax, dword [eax - ASM_PFX(AsmGetFspInfoHeader) + ASM_PFX(FspInfoH= eaderRelativeOff)]=0D + ret=0D +=0D +global ASM_PFX(AsmGetFspInfoHeaderNoStack)=0D +ASM_PFX(AsmGetFspInfoHeaderNoStack):=0D + mov eax, ASM_PFX(AsmGetFspInfoHeader)=0D + sub eax, dword [ASM_PFX(FspInfoHeaderRelativeOff)]=0D + jmp edi=0D diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm b/Int= elFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm new file mode 100644 index 0000000000..122fa1d174 --- /dev/null +++ b/IntelFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm @@ -0,0 +1,34 @@ +;; @file=0D +; Provide FSP helper function.=0D +;=0D +; Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +;;=0D + DEFAULT REL=0D + SECTION .text=0D +=0D +global ASM_PFX(AsmGetFspBaseAddress)=0D +ASM_PFX(AsmGetFspBaseAddress):=0D + call ASM_PFX(AsmGetFspInfoHeader)=0D + add rax, 0x1C=0D + mov eax, [rax]=0D + ret=0D +=0D +global ASM_PFX(AsmGetFspInfoHeader)=0D +ASM_PFX(AsmGetFspInfoHeader):=0D + lea rax, [ASM_PFX(AsmGetFspInfoHeader)]=0D + DB 0x48, 0x2d ; sub rax, 0x????????=0D +global ASM_PFX(FspInfoHeaderRelativeOff)=0D +ASM_PFX(FspInfoHeaderRelativeOff):=0D + DD 0x12345678 ; This value must be patched by the buil= d script=0D + and rax, 0xffffffff=0D + ret=0D +=0D +global ASM_PFX(AsmGetFspInfoHeaderNoStack)=0D +ASM_PFX(AsmGetFspInfoHeaderNoStack):=0D + lea rax, [ASM_PFX(AsmGetFspInfoHeader)]=0D + lea rcx, [ASM_PFX(FspInfoHeaderRelativeOff)]=0D + mov ecx, [rcx]=0D + sub rax, rcx=0D + and rax, 0xffffffff=0D + jmp rdi=0D --=20 2.35.3.windows.1