Re: [edk2-devel] [PATCH v2] IntelFsp2Pkg/FspSecCore: Add FSP-I API for SMM support.

2022-07-19 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Chiu, Chasel  
Sent: Tuesday, July 19, 2022 10:09 AM
To: devel@edk2.groups.io
Cc: Zhang, Hongbin1 ; Desimone, Nathaniel L 
; Zeng, Star ; Chiu, 
Chasel 
Subject: [PATCH v2] IntelFsp2Pkg/FspSecCore: Add FSP-I API for SMM support.

From: Hongbin1 Zhang 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3993
Add FSP-I API entry point for SMM support.
Also update 64bit API entry code to assign ApiIdx to RAX to avoid confusion.

Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Chasel Chiu 
Signed-off-by: Hongbin1 Zhang 
---
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c  | 13 +
 IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf | 54 
++
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm  | 44 

 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm |  8 
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryI.nasm   | 44 

 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm   |  4 ++--
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm   |  4 ++--
 IntelFsp2Pkg/Include/FspEas/FspApi.h| 57 
++---
 IntelFsp2Pkg/Include/FspGlobalData.h| 53 
-
 IntelFsp2Pkg/Include/Guid/FspHeaderFile.h   | 22 +++---
 IntelFsp2Pkg/IntelFsp2Pkg.dsc   |  1 +
 IntelFsp2Pkg/Tools/GenCfgOpt.py | 26 --
 IntelFsp2Pkg/Tools/SplitFspBin.py   |  6 +++---
 13 files changed, 264 insertions(+), 72 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c 
b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
index e22a88cc84..35d223a404 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
@@ -71,6 +71,19 @@ FspApiCallingCheck (
 Status = EFI_INVALID_PARAMETER;   } }+  } else if (ApiIdx == 
FspSmmInitApiIndex) {+//+// FspSmmInitApiIndex check+//+if 
((FspData == NULL) || ((UINTN)FspData == MAX_ADDRESS) || ((UINTN)FspData == 
MAX_UINT32)) {+  Status = EFI_UNSUPPORTED;+} else {+  if 
(FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {+Status = 
EFI_UNSUPPORTED;+  } else if (EFI_ERROR (FspUpdSignatureCheck 
(FspSmmInitApiIndex, ApiParam))) {+Status = EFI_INVALID_PARAMETER;+ 
 }+}   } else { Status = EFI_UNSUPPORTED;   }diff --git 
a/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf
new file mode 100644
index 00..d31576c00b
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf
@@ -0,0 +1,54 @@
+## @file+#  Sec Core for FSP+#+#  Copyright (c) 2022, Intel Corporation. All 
rights reserved.+#+#  SPDX-License-Identifier: 
BSD-2-Clause-Patent+#+##++[Defines]+  INF_VERSION= 
0x00010005+  BASE_NAME  = FspSecCoreI+  FILE_GUID   
   = 558782b5-782d-415e-ab9e-0ceb79dc3425+  MODULE_TYPE 
   = SEC+  VERSION_STRING = 1.0++#+# The following information 
is for reference only and not required by the build tools.+#+#  
VALID_ARCHITECTURES   = IA32 X64+#++[Sources]+  SecFspApiChk.c+  
SecFsp.h++[Sources.X64]+  X64/FspApiEntryI.nasm+  X64/FspApiEntryCommon.nasm+  
X64/FspHelper.nasm++[Sources.IA32]+  Ia32/FspApiEntryI.nasm+  
Ia32/FspApiEntryCommon.nasm+  Ia32/FspHelper.nasm++[Binaries.Ia32]+  
RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC++[Packages]+  MdePkg/MdePkg.dec+  
IntelFsp2Pkg/IntelFsp2Pkg.dec++[LibraryClasses]+  BaseMemoryLib+  DebugLib+  
BaseLib+  PciCf8Lib+  SerialPortLib+  FspSwitchStackLib+  FspCommonLib+  
FspSecPlatformLib++diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm
new file mode 100644
index 00..e9365d6832
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm
@@ -0,0 +1,44 @@
+;; @file+;  Provide FSP API entry points.+;+; Copyright (c) 2022, Intel 
Corporation. All rights reserved.+; SPDX-License-Identifier: 
BSD-2-Clause-Patent+;;++SECTION .text++;+; Following functions will be 
provided in C+;+extern 
ASM_PFX(FspApiCommon)++;+;
 FspApiCommonContinue API+;+; This is the FSP API common entry point to resume 
the FSP 
execution+;+;+global
 ASM_PFX(FspApiCommonContinue)+ASM_PFX(FspApiCommonContinue):+  jmp 
$++;+;
 FspSmmInit API+;+; This FSP API will notify the FSP about the different phases 
in the boot+; 
process+;+;+global
 ASM_PFX(FspSmmInitApi)+ASM_PFX(FspSmmInitApi):+  moveax,  7 ; 

[edk2-devel] [PATCH v2] IntelFsp2Pkg/FspSecCore: Add FSP-I API for SMM support.

2022-07-19 Thread Chiu, Chasel
From: Hongbin1 Zhang 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3993
Add FSP-I API entry point for SMM support.
Also update 64bit API entry code to assign ApiIdx to RAX
to avoid confusion.

Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Chasel Chiu 
Signed-off-by: Hongbin1 Zhang 
---
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c  | 13 +
 IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf | 54 
++
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm  | 44 

 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm |  8 
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryI.nasm   | 44 

 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm   |  4 ++--
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm   |  4 ++--
 IntelFsp2Pkg/Include/FspEas/FspApi.h| 57 
++---
 IntelFsp2Pkg/Include/FspGlobalData.h| 53 
-
 IntelFsp2Pkg/Include/Guid/FspHeaderFile.h   | 22 +++---
 IntelFsp2Pkg/IntelFsp2Pkg.dsc   |  1 +
 IntelFsp2Pkg/Tools/GenCfgOpt.py | 26 --
 IntelFsp2Pkg/Tools/SplitFspBin.py   |  6 +++---
 13 files changed, 264 insertions(+), 72 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c 
b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
index e22a88cc84..35d223a404 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
@@ -71,6 +71,19 @@ FspApiCallingCheck (
 Status = EFI_INVALID_PARAMETER;
   }
 }
+  } else if (ApiIdx == FspSmmInitApiIndex) {
+//
+// FspSmmInitApiIndex check
+//
+if ((FspData == NULL) || ((UINTN)FspData == MAX_ADDRESS) || 
((UINTN)FspData == MAX_UINT32)) {
+  Status = EFI_UNSUPPORTED;
+} else {
+  if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
+Status = EFI_UNSUPPORTED;
+  } else if (EFI_ERROR (FspUpdSignatureCheck (FspSmmInitApiIndex, 
ApiParam))) {
+Status = EFI_INVALID_PARAMETER;
+  }
+}
   } else {
 Status = EFI_UNSUPPORTED;
   }
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf
new file mode 100644
index 00..d31576c00b
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf
@@ -0,0 +1,54 @@
+## @file
+#  Sec Core for FSP
+#
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = FspSecCoreI
+  FILE_GUID  = 558782b5-782d-415e-ab9e-0ceb79dc3425
+  MODULE_TYPE= SEC
+  VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  SecFspApiChk.c
+  SecFsp.h
+
+[Sources.X64]
+  X64/FspApiEntryI.nasm
+  X64/FspApiEntryCommon.nasm
+  X64/FspHelper.nasm
+
+[Sources.IA32]
+  Ia32/FspApiEntryI.nasm
+  Ia32/FspApiEntryCommon.nasm
+  Ia32/FspHelper.nasm
+
+[Binaries.Ia32]
+  RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
+
+[Packages]
+  MdePkg/MdePkg.dec
+  IntelFsp2Pkg/IntelFsp2Pkg.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  BaseLib
+  PciCf8Lib
+  SerialPortLib
+  FspSwitchStackLib
+  FspCommonLib
+  FspSecPlatformLib
+
+
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm
new file mode 100644
index 00..e9365d6832
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryI.nasm
@@ -0,0 +1,44 @@
+;; @file
+;  Provide FSP API entry points.
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+
+SECTION .text
+
+;
+; Following functions will be provided in C
+;
+extern ASM_PFX(FspApiCommon)
+
+;
+; FspApiCommonContinue API
+;
+; This is the FSP API common entry point to resume the FSP execution
+;
+;
+global ASM_PFX(FspApiCommonContinue)
+ASM_PFX(FspApiCommonContinue):
+  jmp $
+
+;
+; FspSmmInit API
+;
+; This FSP API will notify the FSP about the different phases in the boot
+; process
+;
+;
+global ASM_PFX(FspSmmInitApi)
+ASM_PFX(FspSmmInitApi):
+  moveax,  7 ; FSP_API_INDEX.FspSmmInitApiIndex
+  jmpASM_PFX(FspApiCommon)
+
+;
+; Module Entrypoint API