]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: Add FSP 2.4 MultiPhase interface.
authorChasel Chiu <chasel.chiu@intel.com>
Mon, 25 Jul 2022 19:03:51 +0000 (12:03 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 31 Aug 2022 16:48:07 +0000 (16:48 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3916

Provide FSP 2.4 MultiPhase interface and scripts
support.

Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2Pkg/Include/FspEas/FspApi.h
IntelFsp2Pkg/Include/FspGlobalData.h
IntelFsp2Pkg/Include/Library/FspMultiPhaseLib.h [new file with mode: 0644]
IntelFsp2Pkg/Include/Library/FspSecPlatformLib.h
IntelFsp2Pkg/IntelFsp2Pkg.dec
IntelFsp2Pkg/IntelFsp2Pkg.dsc
IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf [new file with mode: 0644]
IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c [new file with mode: 0644]
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c
IntelFsp2Pkg/Tools/SplitFspBin.py

index 361e916b5fa33736b883a960c4595a94931f83a4..40e063e9440a78717136c079cf7075bee43984ca 100644 (file)
@@ -487,10 +487,38 @@ typedef struct {
 /// Action definition for FspMultiPhaseSiInit API\r
 ///\r
 typedef enum {\r
-  EnumMultiPhaseGetNumberOfPhases = 0x0,\r
-  EnumMultiPhaseExecutePhase      = 0x1\r
+  EnumMultiPhaseGetNumberOfPhases       = 0x0,\r
+  EnumMultiPhaseExecutePhase            = 0x1,\r
+  EnumMultiPhaseGetVariableRequestInfo  = 0x2,\r
+  EnumMultiPhaseCompleteVariableRequest = 0x3\r
 } FSP_MULTI_PHASE_ACTION;\r
 \r
+typedef enum {\r
+  EnumFspVariableRequestGetVariable         = 0x0,\r
+  EnumFspVariableRequestGetNextVariableName = 0x1,\r
+  EnumFspVariableRequestSetVariable         = 0x2,\r
+  EnumFspVariableRequestQueryVariableInfo   = 0x3\r
+} FSP_VARIABLE_REQUEST_TYPE;\r
+\r
+#pragma pack(16)\r
+typedef struct {\r
+  IN     FSP_VARIABLE_REQUEST_TYPE    VariableRequest;\r
+  IN OUT CHAR16                       *VariableName;\r
+  IN OUT UINT64                       *VariableNameSize;\r
+  IN OUT EFI_GUID                     *VariableGuid;\r
+  IN OUT UINT32                       *Attributes;\r
+  IN OUT UINT64                       *DataSize;\r
+  IN OUT VOID                         *Data;\r
+  OUT    UINT64                       *MaximumVariableStorageSize;\r
+  OUT    UINT64                       *RemainingVariableStorageSize;\r
+  OUT    UINT64                       *MaximumVariableSize;\r
+} FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS;\r
+\r
+typedef struct {\r
+  EFI_STATUS    VariableRequestStatus;\r
+} FSP_MULTI_PHASE_COMPLETE_VARIABLE_REQUEST_PARAMS;\r
+#pragma pack()\r
+\r
 ///\r
 /// Data structure returned by FSP when bootloader calling\r
 /// FspMultiPhaseSiInit API with action 0 (EnumMultiPhaseGetNumberOfPhases)\r
@@ -594,7 +622,7 @@ EFI_STATUS
   @retval EFI_UNSUPPORTED             The FSP calling conditions were not met.\r
   @retval EFI_DEVICE_ERROR            FSP initialization failed.\r
   @retval EFI_OUT_OF_RESOURCES        Stack range requested by FSP is not met.\r
-  @retval FSP_STATUS_RESET_REQUIREDx  A reset is reuired. These status codes will not be returned during S3.\r
+  @retval FSP_STATUS_RESET_REQUIREDx  A reset is required. These status codes will not be returned during S3.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -690,4 +718,34 @@ EFI_STATUS
   IN VOID          *FspiUpdDataPtr\r
   );\r
 \r
+/**\r
+  This FSP API provides multi-phase memory and silicon initialization, which brings greater modularity to the existing\r
+  FspMemoryInit() and FspSiliconInit() API. Increased modularity is achieved by adding an extra API to FSP-M and FSP-S.\r
+  This allows the bootloader to add board specific initialization steps throughout the MemoryInit and SiliconInit flows as needed.\r
+  The FspMemoryInit() API is always called before FspMultiPhaseMemInit(); it is the first phase of memory initialization. Similarly,\r
+  the FspSiliconInit() API is always called before FspMultiPhaseSiInit(); it is the first phase of silicon initialization.\r
+  After the first phase, subsequent phases are invoked by calling the FspMultiPhaseMem/SiInit() API.\r
+  The FspMultiPhaseMemInit() API may only be called after the FspMemoryInit() API and before the FspSiliconInit() API;\r
+  or in the case that FSP-T is being used, before the TempRamExit() API. The FspMultiPhaseSiInit() API may only be called after\r
+  the FspSiliconInit() API and before NotifyPhase() API; or in the case that FSP-I is being used, before the FspSmmInit() API.\r
+  The multi-phase APIs may not be called at any other time.\r
+\r
+  @param[in,out] FSP_MULTI_PHASE_PARAMS   For action - EnumMultiPhaseGetNumberOfPhases:\r
+                                            FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr will contain\r
+                                            how many phases supported by FSP.\r
+                                          For action - EnumMultiPhaseExecutePhase:\r
+                                            FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr shall be NULL.\r
+  @retval EFI_SUCCESS                     FSP execution environment was initialized successfully.\r
+  @retval EFI_INVALID_PARAMETER           Input parameters are invalid.\r
+  @retval EFI_UNSUPPORTED                 The FSP calling conditions were not met.\r
+  @retval EFI_DEVICE_ERROR                FSP initialization failed.\r
+  @retval FSP_STATUS_RESET_REQUIRED_*     A reset is required. These status codes will not be returned during S3.\r
+  @retval FSP_STATUS_VARIABLE_REQUEST     A variable request has been made by FSP that needs boot loader handling.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FSP_MULTI_PHASE_INIT)(\r
+  IN FSP_MULTI_PHASE_PARAMS     *MultiPhaseInitParamPtr\r
+  );\r
+\r
 #endif\r
index 32c6d460e472aebf1c465e23010a3d93fa704517..81813df3ce66412a6732041cba9c6da1d3d2a1c0 100644 (file)
@@ -12,7 +12,7 @@
 \r
 #define FSP_IN_API_MODE          0\r
 #define FSP_IN_DISPATCH_MODE     1\r
-#define FSP_GLOBAL_DATA_VERSION  0x2\r
+#define FSP_GLOBAL_DATA_VERSION  0x3\r
 \r
 #pragma pack(1)\r
 \r
@@ -25,6 +25,7 @@ typedef enum {
   FspSiliconInitApiIndex,\r
   FspMultiPhaseSiInitApiIndex,\r
   FspSmmInitApiIndex,\r
+  FspMultiPhaseMemInitApiIndex,\r
   FspApiIndexMax\r
 } FSP_API_INDEX;\r
 \r
@@ -82,6 +83,8 @@ typedef struct  {
   VOID               *FunctionParameterPtr;\r
   FSP_INFO_HEADER    *FspInfoHeader;\r
   VOID               *UpdDataPtr;\r
+  VOID               *FspHobListPtr;\r
+  VOID               *VariableRequestParameterPtr;\r
   ///\r
   /// End of UINTN and pointer section\r
   /// At this point, next field offset must be either *0h or *8h to\r
diff --git a/IntelFsp2Pkg/Include/Library/FspMultiPhaseLib.h b/IntelFsp2Pkg/Include/Library/FspMultiPhaseLib.h
new file mode 100644 (file)
index 0000000..9c6973c
--- /dev/null
@@ -0,0 +1,55 @@
+/** @file\r
+  FSP MultiPhase Library.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef _FSP_MULTIPHASE_LIB_H_\r
+#define _FSP_MULTIPHASE_LIB_H_\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseSwitchStack (\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FspVariableRequestSwitchStack (\r
+  IN FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS  *FspVariableRequestParams\r
+  );\r
+\r
+/**\r
+  This function handles FspMultiPhaseMemInitApi.\r
+\r
+  @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
+\r
+  @retval EFI_SUCCESS                 FSP execution was successful.\r
+  @retval EFI_INVALID_PARAMETER       Input parameters are invalid.\r
+  @retval EFI_UNSUPPORTED             The FSP calling conditions were not met.\r
+  @retval EFI_DEVICE_ERROR            FSP initialization failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseMemInitApiHandler (\r
+  IN UINT32  ApiIdx,\r
+  IN VOID    *ApiParam\r
+  );\r
+\r
+/**\r
+  This function handles FspMultiPhaseSiInitApi.\r
+\r
+  @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseSiInitApiHandlerV2 (\r
+  IN UINT32  ApiIdx,\r
+  IN VOID    *ApiParam\r
+  );\r
+\r
+#endif\r
index 920115e90ef8090d552865a4a7c4bf7ea1a66bca..c91ea4a78ff1ebb17252430319dc64fce3153add 100644 (file)
@@ -81,6 +81,7 @@ FspUpdSignatureCheck (
 \r
 /**\r
   This function handles FspMultiPhaseSiInitApi.\r
+  Starting from FSP 2.4 this function is obsolete and FspMultiPhaseSiInitApiHandlerV2 is the replacement.\r
 \r
   @param[in]  ApiIdx           Internal index of the FSP API.\r
   @param[in]  ApiParam         Parameter of the FSP API.\r
@@ -93,4 +94,26 @@ FspMultiPhaseSiInitApiHandler (
   IN VOID    *ApiParam\r
   );\r
 \r
+/**\r
+  FSP MultiPhase Platform Get Number Of Phases Function.\r
+\r
+  Allows an FSP binary to dynamically update the number of phases at runtime.\r
+  For example, UPD settings could negate the need to enter the multi-phase flow\r
+  in certain scenarios. If this function returns FALSE, the default number of phases\r
+  provided by PcdMultiPhaseNumberOfPhases will be returned to the bootloader instead.\r
+\r
+  @param[in] ApiIdx                  - Internal index of the FSP API.\r
+  @param[in] NumberOfPhasesSupported - How many phases are supported by current FSP Component.\r
+\r
+  @retval  TRUE  - NumberOfPhases are modified by Platform during runtime.\r
+  @retval  FALSE - The Default build time NumberOfPhases should be used.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FspMultiPhasePlatformGetNumberOfPhases (\r
+  IN     UINTN   ApiIdx,\r
+  IN OUT UINT32  *NumberOfPhasesSupported\r
+  );\r
+\r
 #endif\r
index 2d3eb708b93fec76c9688a804abd9006d27ec2d4..d1c3d3ee7b90bf83c86ff21c9a7a0c58883cd537 100644 (file)
@@ -37,6 +37,9 @@
   ##  @libraryclass  Provides FSP platform sec related actions.\r
   FspSecPlatformLib|Include/Library/FspSecPlatformLib.h\r
 \r
+  ## @libraryclass  Provides FSP MultiPhase service functions.\r
+  FspMultiPhaseLib|Include/Library/FspMultiPhaseLib.h\r
+\r
 [Ppis]\r
   #\r
   # PPI to indicate FSP is ready to enter notify phase\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspPrivateTemporaryRamSize |0x00000000|UINT32|0x10000006\r
 \r
 [PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx]\r
-  gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000\r
-  gIntelFsp2PkgTokenSpaceGuid.PcdBootLoaderEntry         |0xFFFFFFE4|UINT32|0x46530100\r
+  gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength  |0x00100000|UINT32|0x46530000\r
+  gIntelFsp2PkgTokenSpaceGuid.PcdBootLoaderEntry          |0xFFFFFFE4|UINT32|0x46530100\r
+  #\r
+  # Different FSP Components may have different NumberOfPhases which can be defined\r
+  # by each FspSecCore module from DSC.\r
+  #\r
+  gIntelFsp2PkgTokenSpaceGuid.PcdMultiPhaseNumberOfPhases |0x00000000|UINT32|0x46530101\r
index b2d786788007f3bc1131a7b157766dbc5bd04ce8..0713f0028dd5b9cfc09ea526ec1c50ae81ef2443 100644 (file)
@@ -45,6 +45,7 @@
   FspPlatformLib|IntelFsp2Pkg/Library/BaseFspPlatformLib/BaseFspPlatformLib.inf\r
   FspSwitchStackLib|IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf\r
   FspSecPlatformLib|IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf\r
+  FspMultiPhaseLib|IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf\r
 \r
 [LibraryClasses.common.PEIM]\r
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
   IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf\r
   IntelFsp2Pkg/Library/BaseDebugDeviceLibNull/BaseDebugDeviceLibNull.inf\r
   IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf\r
+  IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf\r
 \r
   IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf\r
   IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf\r
+  IntelFsp2Pkg/FspSecCore/Fsp24SecCoreM.inf\r
   IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf\r
   IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf\r
   IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf\r
+  IntelFsp2Pkg/FspSecCore/Fsp24SecCoreS.inf\r
   IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.inf\r
 \r
 [PcdsFixedAtBuild.common]\r
diff --git a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf
new file mode 100644 (file)
index 0000000..a79f6ae
--- /dev/null
@@ -0,0 +1,50 @@
+## @file\r
+#  FSP MultiPhase Lib.\r
+#\r
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseFspMultiPhaseLib\r
+  FILE_GUID                      = C128CADC-623E-4E41-97CB-A7138E627460\r
+  MODULE_TYPE                    = SEC\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = FspMultiPhaseLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources]\r
+  FspMultiPhaseLib.c\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFsp2Pkg/IntelFsp2Pkg.dec\r
+\r
+[Pcd]\r
+ gIntelFsp2PkgTokenSpaceGuid.PcdMultiPhaseNumberOfPhases # CONSUMES\r
diff --git a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
new file mode 100644 (file)
index 0000000..3786da9
--- /dev/null
@@ -0,0 +1,184 @@
+/** @file\r
+  FSP MultiPhase library.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/FspCommonLib.h>\r
+#include <Library/FspSwitchStackLib.h>\r
+#include <Library/FspSecPlatformLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <FspEas/FspApi.h>\r
+#include <FspGlobalData.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseSwitchStack (\r
+  )\r
+{\r
+  SetFspApiReturnStatus (EFI_SUCCESS);\r
+  Pei2LoaderSwitchStack ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FspVariableRequestSwitchStack (\r
+  IN FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS  *FspVariableRequestParams\r
+  )\r
+{\r
+  FSP_GLOBAL_DATA  *FspData;\r
+\r
+  FspData = GetFspGlobalDataPointer ();\r
+  if (((UINTN)FspData == 0) || ((UINTN)FspData == 0xFFFFFFFF)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  FspData->VariableRequestParameterPtr = (VOID *)FspVariableRequestParams;\r
+  SetFspApiReturnStatus (FSP_STATUS_VARIABLE_REQUEST);\r
+  Pei2LoaderSwitchStack ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function supports FspMultiPhase implementation.\r
+\r
+  @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
+\r
+  @retval EFI_SUCCESS                 FSP execution was successful.\r
+  @retval EFI_INVALID_PARAMETER       Input parameters are invalid.\r
+  @retval EFI_UNSUPPORTED             The FSP calling conditions were not met.\r
+  @retval EFI_DEVICE_ERROR            FSP initialization failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseWorker (\r
+  IN UINT32  ApiIdx,\r
+  IN VOID    *ApiParam\r
+  )\r
+{\r
+  FSP_MULTI_PHASE_PARAMS                       *FspMultiPhaseParams;\r
+  FSP_GLOBAL_DATA                              *FspData;\r
+  FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS  *FspMultiPhaseGetNumber;\r
+  BOOLEAN                                      FspDataValid;\r
+  UINT32                                       NumberOfPhasesSupported;\r
+\r
+  FspDataValid = TRUE;\r
+  FspData      = GetFspGlobalDataPointer ();\r
+  if (((UINTN)FspData == 0) || ((UINTN)FspData == 0xFFFFFFFF)) {\r
+    FspDataValid = FALSE;\r
+  }\r
+\r
+  //\r
+  // It is required that FspData->NumberOfPhases to be reset to 0 after\r
+  // current FSP component finished.\r
+  // The next component FspData->NumberOfPhases will only be re-initialized when FspData->NumberOfPhases = 0\r
+  //\r
+  if ((FspDataValid == TRUE) && (FspData->NumberOfPhases == 0)) {\r
+    FspData->NumberOfPhases = PcdGet32 (PcdMultiPhaseNumberOfPhases);\r
+    FspData->PhasesExecuted = 0;\r
+    if (FspMultiPhasePlatformGetNumberOfPhases (ApiIdx, &NumberOfPhasesSupported) == TRUE) {\r
+      //\r
+      // Platform has implemented runtime controlling for NumberOfPhasesSupported\r
+      //\r
+      FspData->NumberOfPhases = NumberOfPhasesSupported;\r
+    }\r
+  }\r
+\r
+  FspMultiPhaseParams = (FSP_MULTI_PHASE_PARAMS *)ApiParam;\r
+\r
+  if (FspDataValid == FALSE) {\r
+    return EFI_DEVICE_ERROR;\r
+  } else {\r
+    switch (FspMultiPhaseParams->MultiPhaseAction) {\r
+      case EnumMultiPhaseGetNumberOfPhases:\r
+        if ((FspMultiPhaseParams->MultiPhaseParamPtr == NULL) || (FspMultiPhaseParams->PhaseIndex != 0)) {\r
+          return EFI_INVALID_PARAMETER;\r
+        }\r
+\r
+        FspMultiPhaseGetNumber                 = (FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS *)FspMultiPhaseParams->MultiPhaseParamPtr;\r
+        FspMultiPhaseGetNumber->NumberOfPhases = FspData->NumberOfPhases;\r
+        FspMultiPhaseGetNumber->PhasesExecuted = FspData->PhasesExecuted;\r
+        break;\r
+\r
+      case EnumMultiPhaseExecutePhase:\r
+        if ((FspMultiPhaseParams->PhaseIndex > FspData->PhasesExecuted) && (FspMultiPhaseParams->PhaseIndex <= FspData->NumberOfPhases)) {\r
+          FspData->PhasesExecuted = FspMultiPhaseParams->PhaseIndex;\r
+          return Loader2PeiSwitchStack ();\r
+        } else {\r
+          return EFI_INVALID_PARAMETER;\r
+        }\r
+\r
+        break;\r
+\r
+      case EnumMultiPhaseGetVariableRequestInfo:\r
+        //\r
+        // return variable request info\r
+        //\r
+        FspMultiPhaseParams->MultiPhaseParamPtr = FspData->VariableRequestParameterPtr;\r
+        break;\r
+\r
+      case EnumMultiPhaseCompleteVariableRequest:\r
+        //\r
+        // retrieve complete variable request params\r
+        //\r
+        FspData->VariableRequestParameterPtr = FspMultiPhaseParams->MultiPhaseParamPtr;\r
+        return Loader2PeiSwitchStack ();\r
+        break;\r
+\r
+      default:\r
+        return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function handles FspMultiPhaseMemInitApi.\r
+\r
+  @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
+\r
+  @retval EFI_SUCCESS                 FSP execution was successful.\r
+  @retval EFI_INVALID_PARAMETER       Input parameters are invalid.\r
+  @retval EFI_UNSUPPORTED             The FSP calling conditions were not met.\r
+  @retval EFI_DEVICE_ERROR            FSP initialization failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseMemInitApiHandler (\r
+  IN UINT32  ApiIdx,\r
+  IN VOID    *ApiParam\r
+  )\r
+{\r
+  return FspMultiPhaseWorker (ApiIdx, ApiParam);\r
+}\r
+\r
+/**\r
+  This function handles FspMultiPhaseSiInitApi.\r
+\r
+  @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
+\r
+  @retval EFI_SUCCESS                 FSP execution was successful.\r
+  @retval EFI_INVALID_PARAMETER       Input parameters are invalid.\r
+  @retval EFI_UNSUPPORTED             The FSP calling conditions were not met.\r
+  @retval EFI_DEVICE_ERROR            FSP initialization failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspMultiPhaseSiInitApiHandlerV2 (\r
+  IN UINT32  ApiIdx,\r
+  IN VOID    *ApiParam\r
+  )\r
+{\r
+  return FspMultiPhaseWorker (ApiIdx, ApiParam);\r
+}\r
index a6f3892ed8d8112fb931276a4d726c2a5c3c9dee..9c1b5b32e931257958ddb3e2338ff95d3a67ea77 100644 (file)
@@ -28,6 +28,7 @@ FspUpdSignatureCheck (
 \r
 /**\r
   This function handles FspMultiPhaseSiInitApi.\r
+  Starting from FSP 2.4 this function is obsolete and FspMultiPhaseSiInitApiHandlerV2 is the replacement.\r
 \r
   @param[in]  ApiIdx           Internal index of the FSP API.\r
   @param[in]  ApiParam         Parameter of the FSP API.\r
@@ -42,3 +43,36 @@ FspMultiPhaseSiInitApiHandler (
 {\r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  FSP MultiPhase Platform Get Number Of Phases Function.\r
+\r
+  Allows an FSP binary to dynamically update the number of phases at runtime.\r
+  For example, UPD settings could negate the need to enter the multi-phase flow\r
+  in certain scenarios. If this function returns FALSE, the default number of phases\r
+  provided by PcdMultiPhaseNumberOfPhases will be returned to the bootloader instead.\r
+\r
+  @param[in] ApiIdx                  - Internal index of the FSP API.\r
+  @param[in] NumberOfPhasesSupported - How many phases are supported by current FSP Component.\r
+\r
+  @retval  TRUE  - NumberOfPhases are modified by Platform during runtime.\r
+  @retval  FALSE - The Default build time NumberOfPhases should be used.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FspMultiPhasePlatformGetNumberOfPhases (\r
+  IN     UINT8   ApiIdx,\r
+  IN OUT UINT32  *NumberOfPhasesSupported\r
+  )\r
+{\r
+  /* Example for platform runtime controlling\r
+  if ((ApiIdx == FspMultiPhaseSiInitApiIndex) && (Feature1Enable == FALSE)) {\r
+    *NumberOfPhasesSupported = 0;\r
+    return TRUE;\r
+  }\r
+  return FALSE\r
+  */\r
+\r
+  return FALSE;\r
+}\r
index ddabab7d8cb091e3a37a5d586860f0fea9bf9dc7..419e5ba9850ef42057c43dfa549fa59d434c2b1c 100644 (file)
@@ -103,29 +103,31 @@ class FSP_COMMON_HEADER(Structure):
 \r
 class FSP_INFORMATION_HEADER(Structure):\r
      _fields_ = [\r
-        ('Signature',                      ARRAY(c_char, 4)),\r
-        ('HeaderLength',                   c_uint32),\r
-        ('Reserved1',                      c_uint16),\r
-        ('SpecVersion',                    c_uint8),\r
-        ('HeaderRevision',                 c_uint8),\r
-        ('ImageRevision',                  c_uint32),\r
-        ('ImageId',                        ARRAY(c_char, 8)),\r
-        ('ImageSize',                      c_uint32),\r
-        ('ImageBase',                      c_uint32),\r
-        ('ImageAttribute',                 c_uint16),\r
-        ('ComponentAttribute',             c_uint16),\r
-        ('CfgRegionOffset',                c_uint32),\r
-        ('CfgRegionSize',                  c_uint32),\r
-        ('Reserved2',                      c_uint32),\r
-        ('TempRamInitEntryOffset',         c_uint32),\r
-        ('Reserved3',                      c_uint32),\r
-        ('NotifyPhaseEntryOffset',         c_uint32),\r
-        ('FspMemoryInitEntryOffset',       c_uint32),\r
-        ('TempRamExitEntryOffset',         c_uint32),\r
-        ('FspSiliconInitEntryOffset',      c_uint32),\r
-        ('FspMultiPhaseSiInitEntryOffset', c_uint32),\r
-        ('ExtendedImageRevision',          c_uint16),\r
-        ('Reserved4',                      c_uint16)\r
+        ('Signature',                       ARRAY(c_char, 4)),\r
+        ('HeaderLength',                    c_uint32),\r
+        ('Reserved1',                       c_uint16),\r
+        ('SpecVersion',                     c_uint8),\r
+        ('HeaderRevision',                  c_uint8),\r
+        ('ImageRevision',                   c_uint32),\r
+        ('ImageId',                         ARRAY(c_char, 8)),\r
+        ('ImageSize',                       c_uint32),\r
+        ('ImageBase',                       c_uint32),\r
+        ('ImageAttribute',                  c_uint16),\r
+        ('ComponentAttribute',              c_uint16),\r
+        ('CfgRegionOffset',                 c_uint32),\r
+        ('CfgRegionSize',                   c_uint32),\r
+        ('Reserved2',                       c_uint32),\r
+        ('TempRamInitEntryOffset',          c_uint32),\r
+        ('Reserved3',                       c_uint32),\r
+        ('NotifyPhaseEntryOffset',          c_uint32),\r
+        ('FspMemoryInitEntryOffset',        c_uint32),\r
+        ('TempRamExitEntryOffset',          c_uint32),\r
+        ('FspSiliconInitEntryOffset',       c_uint32),\r
+        ('FspMultiPhaseSiInitEntryOffset',  c_uint32),\r
+        ('ExtendedImageRevision',           c_uint16),\r
+        ('Reserved4',                       c_uint16),\r
+        ('FspMultiPhaseMemInitEntryOffset', c_uint32),\r
+        ('FspSmmInitEntryOffset',           c_uint32)\r
     ]\r
 \r
 class FSP_PATCH_TABLE(Structure):\r