public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ashraf Ali S" <ashraf.ali.s@intel.com>
To: "Kuo, Ted" <ted.kuo@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Chiu, Chasel" <chasel.chiu@intel.com>,
	"Desimone, Nathaniel L" <nathaniel.l.desimone@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>,
	"Duggapu, Chinni B" <chinni.b.duggapu@intel.com>,
	"Chan, Amy" <amy.chan@intel.com>,
	"Chaganty, Rangasai V" <rangasai.v.chaganty@intel.com>
Subject: Re: [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib
Date: Mon, 7 Nov 2022 09:31:51 +0000	[thread overview]
Message-ID: <DM4PR11MB52803F3206CE16B3F5D8A462D73C9@DM4PR11MB5280.namprd11.prod.outlook.com> (raw)
In-Reply-To: <28da0d3ce6289e39e542990fdabd3002a4c665a2.1667810598.git.ted.kuo@intel.com>

Hi.,

Instead of Hardcoded FSP ImageBase as 0x1C in FspHelper.nasm, can we have struct from there we can get it. So that in future if the Header is changing assembly code will not get impacted.

Regards,
Ashraf Ali S
Intel Technology India Pvt. Ltd. 

-----Original Message-----
From: Kuo, Ted <ted.kuo@intel.com> 
Sent: Monday, November 7, 2022 2:14 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; S, Ashraf Ali <ashraf.ali.s@intel.com>; Duggapu, Chinni B <chinni.b.duggapu@intel.com>; Chan, Amy <amy.chan@intel.com>
Subject: [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib

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-  );- #endifdiff --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.infdiff --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.decdiff --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   edidiff --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


      reply	other threads:[~2022-11-07  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07  8:43 [edk2-devel][PATCH v1] IntelFsp2Pkg: Adding FspHelperLib Kuo, Ted
2022-11-07  9:31 ` Ashraf Ali S [this message]

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=DM4PR11MB52803F3206CE16B3F5D8A462D73C9@DM4PR11MB5280.namprd11.prod.outlook.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