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....@intel.com> 
Sent: Monday, November 7, 2022 2:14 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.c...@intel.com>; Desimone, Nathaniel L 
<nathaniel.l.desim...@intel.com>; Zeng, Star <star.z...@intel.com>; S, Ashraf 
Ali <ashraf.al...@intel.com>; Duggapu, Chinni B <chinni.b.dugg...@intel.com>; 
Chan, Amy <amy.c...@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.c...@intel.com>
Cc: Nate DeSimone <nathaniel.l.desim...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Ashraf Ali S <ashraf.al...@intel.com>
Cc: Chinni B Duggapu <chinni.b.dugg...@intel.com>
Cc: Amy Chan <amy.c...@intel.com>
Signed-off-by: Ted Kuo <ted....@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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96025): https://edk2.groups.io/g/devel/message/96025
Mute This Topic: https://groups.io/mt/94862155/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to