From: "Kuo, Ted" <ted.kuo@intel.com>
To: devel@edk2.groups.io
Cc: Chasel Chiu <chasel.chiu@intel.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Star Zeng <star.zeng@intel.com>,
Ashraf Ali S <ashraf.ali.s@intel.com>,
Chinni B Duggapu <chinni.b.duggapu@intel.com>,
Amy Chan <amy.chan@intel.com>
Subject: [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib
Date: Mon, 7 Nov 2022 16:43:30 +0800 [thread overview]
Message-ID: <28da0d3ce6289e39e542990fdabd3002a4c665a2.1667810598.git.ted.kuo@intel.com> (raw)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4128
Adding FspHelperLib for platform code to consume. There will be
another patch raised later for FspSecCore to consume FspHelperLib.
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
---
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.nasm
create mode 100644 IntelFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm
diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h b/IntelFsp2Pkg/FspSecCore/SecFsp.h
index d7a5976c12..f12769890f 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFsp.h
+++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h
@@ -17,6 +17,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/FspCommonLib.h>
#include <Library/FspSecPlatformLib.h>
+#include <Library/FspHelperLib.h>
#define FSP_MCUD_SIGNATURE SIGNATURE_32 ('M', 'C', 'U', 'D')
#define FSP_PER0_SIGNATURE SIGNATURE_32 ('P', 'E', 'R', '0')
@@ -64,28 +65,4 @@ FspDataPointerFixUp (
IN UINTN OffsetGap
);
-/**
- This interface returns the base address of FSP binary.
-
- @return FSP binary base address.
-
-**/
-UINTN
-EFIAPI
-AsmGetFspBaseAddress (
- VOID
- );
-
-/**
- This interface gets FspInfoHeader pointer
-
- @return FSP binary base address.
-
-**/
-UINTN
-EFIAPI
-AsmGetFspInfoHeader (
- VOID
- );
-
#endif
diff --git a/IntelFsp2Pkg/Include/Library/FspHelperLib.h b/IntelFsp2Pkg/Include/Library/FspHelperLib.h
new file mode 100644
index 0000000000..84b74fa7aa
--- /dev/null
+++ b/IntelFsp2Pkg/Include/Library/FspHelperLib.h
@@ -0,0 +1,35 @@
+/** @file
+ Header file for FSP Helper Library.
+
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FSP_HELPER_LIB_H_
+#define _FSP_HELPER_LIB_H_
+
+/**
+ This interface returns the base address of FSP binary.
+
+ @return FSP binary base address.
+
+**/
+UINTN
+EFIAPI
+AsmGetFspBaseAddress (
+ VOID
+ );
+
+/**
+ This interface gets FspInfoHeader pointer
+
+ @return FSP info header.
+**/
+UINTN
+EFIAPI
+AsmGetFspInfoHeader (
+ VOID
+ );
+
+#endif // _FSP_HELPER_LIB_H_
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/BaseFspSwitchStackLib.inf
FspSecPlatformLib|IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
FspMultiPhaseLib|IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf
+ FspHelperLib|IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf
[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
@@ -66,6 +67,7 @@
IntelFsp2Pkg/Library/BaseDebugDeviceLibNull/BaseDebugDeviceLibNull.inf
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf
+ IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf b/IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf
new file mode 100644
index 0000000000..318ad65330
--- /dev/null
+++ b/IntelFsp2Pkg/Library/BaseFspHelperLib/BaseFspHelperLib.inf
@@ -0,0 +1,50 @@
+## @file
+# FSP Helper Library.
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = FspHelperLib
+ FILE_GUID = 65746991-8a41-4b89-b0f4-eb4e24b5b471
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = FspHelperLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+
+[Sources.IA32]
+ Ia32/FspHelper.nasm
+
+[Sources.X64]
+ X64/FspHelper.nasm
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+
+[Packages]
+ MdePkg/MdePkg.dec
diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/Ia32/FspHelper.nasm b/IntelFsp2Pkg/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
+; Provide FSP helper function.
+;
+; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+
+ SECTION .text
+
+global ASM_PFX(FspInfoHeaderRelativeOff)
+ASM_PFX(FspInfoHeaderRelativeOff):
+ DD 0x12345678 ; This value must be patched by the build script
+
+global ASM_PFX(AsmGetFspBaseAddress)
+ASM_PFX(AsmGetFspBaseAddress):
+ call ASM_PFX(AsmGetFspInfoHeader)
+ add eax, 0x1C
+ mov eax, dword [eax]
+ ret
+
+global ASM_PFX(AsmGetFspInfoHeader)
+ASM_PFX(AsmGetFspInfoHeader):
+ call ASM_PFX(NextInstruction)
+ASM_PFX(NextInstruction):
+ pop eax
+ sub eax, ASM_PFX(NextInstruction)
+ add eax, ASM_PFX(AsmGetFspInfoHeader)
+ sub eax, dword [eax - ASM_PFX(AsmGetFspInfoHeader) + ASM_PFX(FspInfoHeaderRelativeOff)]
+ ret
+
+global ASM_PFX(AsmGetFspInfoHeaderNoStack)
+ASM_PFX(AsmGetFspInfoHeaderNoStack):
+ mov eax, ASM_PFX(AsmGetFspInfoHeader)
+ sub eax, dword [ASM_PFX(FspInfoHeaderRelativeOff)]
+ jmp edi
diff --git a/IntelFsp2Pkg/Library/BaseFspHelperLib/X64/FspHelper.nasm b/IntelFsp2Pkg/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
+; Provide FSP helper function.
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+ DEFAULT REL
+ SECTION .text
+
+global ASM_PFX(AsmGetFspBaseAddress)
+ASM_PFX(AsmGetFspBaseAddress):
+ call ASM_PFX(AsmGetFspInfoHeader)
+ add rax, 0x1C
+ mov eax, [rax]
+ ret
+
+global ASM_PFX(AsmGetFspInfoHeader)
+ASM_PFX(AsmGetFspInfoHeader):
+ lea rax, [ASM_PFX(AsmGetFspInfoHeader)]
+ DB 0x48, 0x2d ; sub rax, 0x????????
+global ASM_PFX(FspInfoHeaderRelativeOff)
+ASM_PFX(FspInfoHeaderRelativeOff):
+ DD 0x12345678 ; This value must be patched by the build script
+ and rax, 0xffffffff
+ ret
+
+global ASM_PFX(AsmGetFspInfoHeaderNoStack)
+ASM_PFX(AsmGetFspInfoHeaderNoStack):
+ lea rax, [ASM_PFX(AsmGetFspInfoHeader)]
+ lea rcx, [ASM_PFX(FspInfoHeaderRelativeOff)]
+ mov ecx, [rcx]
+ sub rax, rcx
+ and rax, 0xffffffff
+ jmp rdi
--
2.35.3.windows.1
next reply other threads:[~2022-11-07 8:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 8:43 Kuo, Ted [this message]
2022-11-07 9:31 ` [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib Ashraf Ali S
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28da0d3ce6289e39e542990fdabd3002a4c665a2.1667810598.git.ted.kuo@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox