]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2WrapperPkg: Add FSP 2.4 MultiPhase interface.
authorChasel Chiu <chasel.chiu@intel.com>
Wed, 10 Aug 2022 00:31:52 +0000 (17:31 -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 wrapper support library.

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>
IntelFsp2WrapperPkg/Include/Library/FspWrapperMultiPhaseProcessLib.h [new file with mode: 0644]
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/BaseFspWrapperPlatformMultiPhaseLibSample.inf [new file with mode: 0644]
IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/FspWrapperPlatformMultiPhaseLibSample.c [new file with mode: 0644]
IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf [new file with mode: 0644]
IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c [new file with mode: 0644]

diff --git a/IntelFsp2WrapperPkg/Include/Library/FspWrapperMultiPhaseProcessLib.h b/IntelFsp2WrapperPkg/Include/Library/FspWrapperMultiPhaseProcessLib.h
new file mode 100644 (file)
index 0000000..65a5db2
--- /dev/null
@@ -0,0 +1,62 @@
+/** @file\r
+  Provide FSP wrapper MultiPhase handling functions.\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_WRAPPER_MULTI_PHASE_PROCESS_LIB_H__\r
+#define __FSP_WRAPPER_MULTI_PHASE_PROCESS_LIB_H__\r
+\r
+/**\r
+  FSP Wrapper Platform MultiPhase Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+  @param[in] PhaseIndex           - Indicates current execution phase of FSP MultiPhase initialization.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FspWrapperPlatformMultiPhaseHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex,\r
+  IN UINT32    PhaseIndex\r
+  );\r
+\r
+/**\r
+  FSP Wrapper Variable Request Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+\r
+  @retval EFI_UNSUPPORTED   FSP Wrapper cannot support the specific variable request\r
+  @retval EFI_STATUS        Return FSP returned status\r
+\r
+**/EFI_STATUS\r
+EFIAPI\r
+FspWrapperVariableRequestHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex\r
+  );\r
+\r
+/**\r
+  FSP Wrapper MultiPhase Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspWrapperMultiPhaseHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex\r
+  );\r
+\r
+#endif\r
index c43b0c2267a7615c43c2b4d8b46d24386c9c712f..d96037b63b521633817f42883cb94c97387ed864 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Provides drivers and definitions to support fsp in EDKII bios.\r
 #\r
-# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 \r
   ##  @libraryclass  Provide FSP TPM measurement related function.\r
   FspMeasurementLib|Include/Library/FspMeasurementLib.h\r
+\r
+  ##  @libraryclass  Provide MultiPhase handling related functions.\r
+  FspWrapperMultiPhaseProcessLib|Include/Library/FspWrapperMultiPhaseProcessLib.h\r
+\r
+  ##  @libraryclass  Provide MultiPhase platform actions related functions.\r
+  FspWrapperPlatformMultiPhaseLib|Include/Library/FspWrapperMultiPhaseProcessLib.h\r
+\r
+\r
 [Guids]\r
   #\r
   # GUID defined in package\r
index 21e089000eaf9e62f4bfbf828b4460d34c4cb7a3..79a5c7f13dc3705fc1c6b638e1c4b60d3856abc5 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Provides drivers and definitions to support fsp in EDKII bios.\r
 #\r
-# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -48,6 +48,8 @@
   FspWrapperApiLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/BaseFspWrapperApiLib.inf\r
   FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperApiTestLibNull/BaseFspWrapperApiTestLibNull.inf\r
   FspMeasurementLib|IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf\r
+  FspWrapperPlatformMultiPhaseLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/BaseFspWrapperPlatformMultiPhaseLibSample.inf\r
+  FspWrapperMultiPhaseProcessLib|IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf\r
 \r
   # FSP platform sample\r
   FspWrapperPlatformLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformLibSample/BaseFspWrapperPlatformLibSample.inf\r
@@ -91,6 +93,8 @@
   IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/BaseFspWrapperApiLib.inf\r
   IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformLibSample/BaseFspWrapperPlatformLibSample.inf\r
   IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.inf\r
+  IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/BaseFspWrapperPlatformMultiPhaseLibSample.inf\r
+  IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf\r
 \r
 [PcdsFixedAtBuild.common]\r
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f\r
diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/BaseFspWrapperPlatformMultiPhaseLibSample.inf b/IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/BaseFspWrapperPlatformMultiPhaseLibSample.inf
new file mode 100644 (file)
index 0000000..607ad41
--- /dev/null
@@ -0,0 +1,37 @@
+## @file\r
+#  FSP Wrapper to handle platform specific actions for\r
+#  FSP MultiPhase (SeparatePhase) Initialization.\r
+#\r
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseFspWrapperPlatformMultiPhaseLibSample\r
+  FILE_GUID                      = DB63E5AA-21C6-40BB-879A-CD1762C8427B\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = FspWrapperPlatformMultiPhaseLib\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
+[Sources]\r
+  FspWrapperPlatformMultiPhaseLibSample.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFsp2Pkg/IntelFsp2Pkg.dec\r
+  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseLib\r
+  PcdLib\r
+  PeiServicesLib\r
diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/FspWrapperPlatformMultiPhaseLibSample.c b/IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformMultiPhaseLibSample/FspWrapperPlatformMultiPhaseLibSample.c
new file mode 100644 (file)
index 0000000..b4bc3d8
--- /dev/null
@@ -0,0 +1,50 @@
+/** @file\r
+  FSP Wrapper to handle platform specific actions for\r
+  FSP MultiPhase (SeparatePhase) Initialization.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+/**\r
+  FSP Wrapper Platform MultiPhase Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+  @param[in] PhaseIndex           - Indicates current execution phase of FSP MultiPhase initialization.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FspWrapperPlatformMultiPhaseHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex,\r
+  IN UINT32    PhaseIndex\r
+  )\r
+{\r
+  /* Example platform actions as below\r
+  switch (ComponentIndex) {\r
+  case FspMultiPhaseMemInitApiIndex:\r
+    switch (PhaseIndex) {\r
+      case 1:\r
+        PlatformAction1 ();\r
+      break;\r
+    }\r
+    break;\r
+  case FspMultiPhaseSiInitApiIndex:\r
+    switch (PhaseIndex) {\r
+      case 1:\r
+        PlatformAction2 ();\r
+      break;\r
+    }\r
+    break;\r
+  }\r
+  */\r
+}\r
diff --git a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf
new file mode 100644 (file)
index 0000000..e76a746
--- /dev/null
@@ -0,0 +1,48 @@
+## @file\r
+#  FSP wrapper to handle FSP MultiPhase (SeparatePhase) Initialization.\r
+#\r
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = FspWrapperMultiPhaseProcessLib\r
+  FILE_GUID                      = 11E657B7-C3D8-405B-94C5-516840E67B75\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = FspWrapperMultiPhaseProcessLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32\r
+#\r
+\r
+[Sources]\r
+  PeiFspWrapperMultiPhaseProcessLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFsp2Pkg/IntelFsp2Pkg.dec\r
+  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  DebugLib\r
+  BaseLib\r
+  PcdLib\r
+  FspWrapperPlatformLib\r
+  PeiServicesLib\r
+  FspWrapperPlatformMultiPhaseLib\r
+\r
+[Ppis]\r
+  gEfiPeiReadOnlyVariable2PpiGuid\r
+  gEdkiiPeiVariablePpiGuid\r
+\r
+[Pcd]\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress       ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress       ## CONSUMES\r
diff --git a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c
new file mode 100644 (file)
index 0000000..3ddc076
--- /dev/null
@@ -0,0 +1,355 @@
+/** @file\r
+  Support FSP Wrapper MultiPhase process.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/FspWrapperApiLib.h>\r
+#include <Library/FspWrapperPlatformLib.h>\r
+#include <FspEas.h>\r
+#include <FspGlobalData.h>\r
+#include <Ppi/ReadOnlyVariable2.h>\r
+#include <Ppi/Variable.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/FspWrapperMultiPhaseProcessLib.h>\r
+\r
+/**\r
+  Execute 32-bit FSP API entry code.\r
+\r
+  @param[in] Function     The 32bit code entry to be executed.\r
+  @param[in] Param1       The first parameter to pass to 32bit code.\r
+  @param[in] Param2       The second parameter to pass to 32bit code.\r
+\r
+  @return EFI_STATUS.\r
+**/\r
+EFI_STATUS\r
+Execute32BitCode (\r
+  IN UINT64  Function,\r
+  IN UINT64  Param1,\r
+  IN UINT64  Param2\r
+  );\r
+\r
+/**\r
+  Execute 64-bit FSP API entry code.\r
+\r
+  @param[in] Function     The 64bit code entry to be executed.\r
+  @param[in] Param1       The first parameter to pass to 64bit code.\r
+  @param[in] Param2       The second parameter to pass to 64bit code.\r
+\r
+  @return EFI_STATUS.\r
+**/\r
+EFI_STATUS\r
+Execute64BitCode (\r
+  IN UINT64  Function,\r
+  IN UINT64  Param1,\r
+  IN UINT64  Param2\r
+  );\r
+\r
+/**\r
+  Call FspsMultiPhase API.\r
+\r
+  @param[in] FspsMultiPhaseParams - Parameters for MultiPhase API.\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+\r
+  @return EFI_UNSUPPORTED  - the requested FspsMultiPhase API is not supported.\r
+  @return EFI_DEVICE_ERROR - the FSP header was not found.\r
+  @return EFI status returned by FspsMultiPhase API.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CallFspMultiPhaseEntry (\r
+  IN VOID      *FspMultiPhaseParams,\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex\r
+  )\r
+{\r
+  FSP_INFO_HEADER  *FspHeader;\r
+  //\r
+  // FSP_MULTI_PHASE_INIT and FSP_MULTI_PHASE_SI_INIT API functions having same prototype.\r
+  //\r
+  UINTN       FspMultiPhaseApiEntry;\r
+  UINTN       FspMultiPhaseApiOffset;\r
+  EFI_STATUS  Status;\r
+  BOOLEAN     InterruptState;\r
+\r
+  if (ComponentIndex == FspMultiPhaseMemInitApiIndex) {\r
+    FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
+    if (FspHeader == NULL) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    FspMultiPhaseApiOffset = FspHeader->FspMultiPhaseMemInitEntryOffset;\r
+  } else if (ComponentIndex == FspMultiPhaseSiInitApiIndex) {\r
+    FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));\r
+    if (FspHeader == NULL) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    FspMultiPhaseApiOffset = FspHeader->FspMultiPhaseSiInitEntryOffset;\r
+  }\r
+\r
+  if (FspMultiPhaseApiOffset == 0) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  FspMultiPhaseApiEntry = FspHeader->ImageBase + FspMultiPhaseApiOffset;\r
+  InterruptState        = SaveAndDisableInterrupts ();\r
+  if ((FspHeader->ImageAttribute & BIT2) == 0) {\r
+    // BIT2: IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT\r
+    Status = Execute32BitCode ((UINTN)FspMultiPhaseApiEntry, (UINTN)FspMultiPhaseParams, (UINTN)NULL);\r
+  } else {\r
+    Status = Execute64BitCode ((UINTN)FspMultiPhaseApiEntry, (UINTN)FspMultiPhaseParams, (UINTN)NULL);\r
+  }\r
+\r
+  SetInterruptState (InterruptState);\r
+\r
+  DEBUG ((DEBUG_ERROR, "CallFspMultiPhaseEntry return Status %r \n", Status));\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  FSP Wrapper Variable Request Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+\r
+  @retval EFI_UNSUPPORTED   FSP Wrapper cannot support the specific variable request\r
+  @retval EFI_STATUS        Return FSP returned status\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspWrapperVariableRequestHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex\r
+  )\r
+{\r
+  EFI_STATUS                                        Status;\r
+  FSP_MULTI_PHASE_PARAMS                            FspMultiPhaseParams;\r
+  FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS      *FspVariableRequestParams;\r
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI                   *ReadOnlyVariablePpi;\r
+  EDKII_PEI_VARIABLE_PPI                            *VariablePpi;\r
+  BOOLEAN                                           WriteVariableSupport;\r
+  FSP_MULTI_PHASE_COMPLETE_VARIABLE_REQUEST_PARAMS  CompleteVariableRequestParams;\r
+\r
+  WriteVariableSupport = TRUE;\r
+  Status               = PeiServicesLocatePpi (\r
+                           &gEdkiiPeiVariablePpiGuid,\r
+                           0,\r
+                           NULL,\r
+                           (VOID **)&VariablePpi\r
+                           );\r
+  if (EFI_ERROR (Status)) {\r
+    WriteVariableSupport = FALSE;\r
+    Status               = PeiServicesLocatePpi (\r
+                             &gEfiPeiReadOnlyVariable2PpiGuid,\r
+                             0,\r
+                             NULL,\r
+                             (VOID **)&ReadOnlyVariablePpi\r
+                             );\r
+    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  Status = FSP_STATUS_VARIABLE_REQUEST;\r
+  while (Status == FSP_STATUS_VARIABLE_REQUEST) {\r
+    //\r
+    // Get the variable request information from FSP.\r
+    //\r
+    FspMultiPhaseParams.MultiPhaseAction = EnumMultiPhaseGetVariableRequestInfo;\r
+    FspMultiPhaseParams.PhaseIndex       = 0;\r
+    Status                               = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+    ASSERT_EFI_ERROR (Status);\r
+    //\r
+    // FSP should output this pointer for variable request information.\r
+    //\r
+    FspVariableRequestParams = (FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS *)FspMultiPhaseParams.MultiPhaseParamPtr;\r
+    switch (FspVariableRequestParams->VariableRequest) {\r
+      case EnumFspVariableRequestGetVariable:\r
+        if (WriteVariableSupport) {\r
+          Status = VariablePpi->GetVariable (\r
+                                  VariablePpi,\r
+                                  FspVariableRequestParams->VariableName,\r
+                                  FspVariableRequestParams->VariableGuid,\r
+                                  FspVariableRequestParams->Attributes,\r
+                                  (UINTN *)FspVariableRequestParams->DataSize,\r
+                                  FspVariableRequestParams->Data\r
+                                  );\r
+        } else {\r
+          Status = ReadOnlyVariablePpi->GetVariable (\r
+                                          ReadOnlyVariablePpi,\r
+                                          FspVariableRequestParams->VariableName,\r
+                                          FspVariableRequestParams->VariableGuid,\r
+                                          FspVariableRequestParams->Attributes,\r
+                                          (UINTN *)FspVariableRequestParams->DataSize,\r
+                                          FspVariableRequestParams->Data\r
+                                          );\r
+        }\r
+\r
+        CompleteVariableRequestParams.VariableRequestStatus = Status;\r
+        FspMultiPhaseParams.MultiPhaseParamPtr              = (VOID *)&CompleteVariableRequestParams;\r
+        FspMultiPhaseParams.MultiPhaseAction                = EnumMultiPhaseCompleteVariableRequest;\r
+        Status                                              = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+        break;\r
+\r
+      case EnumFspVariableRequestSetVariable:\r
+        if (WriteVariableSupport) {\r
+          Status = VariablePpi->SetVariable (\r
+                                  VariablePpi,\r
+                                  FspVariableRequestParams->VariableName,\r
+                                  FspVariableRequestParams->VariableGuid,\r
+                                  *FspVariableRequestParams->Attributes,\r
+                                  (UINTN)*FspVariableRequestParams->DataSize,\r
+                                  FspVariableRequestParams->Data\r
+                                  );\r
+        } else {\r
+          Status = EFI_UNSUPPORTED;\r
+        }\r
+\r
+        CompleteVariableRequestParams.VariableRequestStatus = Status;\r
+        FspMultiPhaseParams.MultiPhaseParamPtr              = (VOID *)&CompleteVariableRequestParams;\r
+        FspMultiPhaseParams.MultiPhaseAction                = EnumMultiPhaseCompleteVariableRequest;\r
+        Status                                              = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+        break;\r
+\r
+      case EnumFspVariableRequestGetNextVariableName:\r
+        if (WriteVariableSupport) {\r
+          Status = VariablePpi->GetNextVariableName (\r
+                                  VariablePpi,\r
+                                  (UINTN *)FspVariableRequestParams->VariableNameSize,\r
+                                  FspVariableRequestParams->VariableName,\r
+                                  FspVariableRequestParams->VariableGuid\r
+                                  );\r
+        } else {\r
+          Status = ReadOnlyVariablePpi->NextVariableName (\r
+                                          ReadOnlyVariablePpi,\r
+                                          (UINTN *)FspVariableRequestParams->VariableNameSize,\r
+                                          FspVariableRequestParams->VariableName,\r
+                                          FspVariableRequestParams->VariableGuid\r
+                                          );\r
+        }\r
+\r
+        CompleteVariableRequestParams.VariableRequestStatus = Status;\r
+        FspMultiPhaseParams.MultiPhaseParamPtr              = (VOID *)&CompleteVariableRequestParams;\r
+        FspMultiPhaseParams.MultiPhaseAction                = EnumMultiPhaseCompleteVariableRequest;\r
+        Status                                              = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+        break;\r
+\r
+      case EnumFspVariableRequestQueryVariableInfo:\r
+        if (WriteVariableSupport) {\r
+          Status = VariablePpi->QueryVariableInfo (\r
+                                  VariablePpi,\r
+                                  *FspVariableRequestParams->Attributes,\r
+                                  FspVariableRequestParams->MaximumVariableStorageSize,\r
+                                  FspVariableRequestParams->RemainingVariableStorageSize,\r
+                                  FspVariableRequestParams->MaximumVariableSize\r
+                                  );\r
+        } else {\r
+          Status = EFI_UNSUPPORTED;\r
+        }\r
+\r
+        CompleteVariableRequestParams.VariableRequestStatus = Status;\r
+        FspMultiPhaseParams.MultiPhaseParamPtr              = (VOID *)&CompleteVariableRequestParams;\r
+        FspMultiPhaseParams.MultiPhaseAction                = EnumMultiPhaseCompleteVariableRequest;\r
+        Status                                              = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+        break;\r
+\r
+      default:\r
+        DEBUG ((DEBUG_ERROR, "Unknown VariableRequest type!\n"));\r
+        Status = EFI_UNSUPPORTED;\r
+        break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
+  //\r
+  if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
+    DEBUG ((DEBUG_INFO, "FspMultiPhaseApi-0x%x requested reset %r\n", ComponentIndex, Status));\r
+    CallFspWrapperResetSystem ((UINTN)Status);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  FSP Wrapper MultiPhase Handler\r
+\r
+  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspWrapperMultiPhaseHandler (\r
+  IN OUT VOID  **FspHobListPtr,\r
+  IN UINT8     ComponentIndex\r
+  )\r
+{\r
+  EFI_STATUS                                   Status;\r
+  FSP_MULTI_PHASE_PARAMS                       FspMultiPhaseParams;\r
+  FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS  FspMultiPhaseGetNumber;\r
+  UINT32                                       Index;\r
+  UINT32                                       NumOfPhases;\r
+\r
+  //\r
+  // Query FSP for the number of phases supported.\r
+  //\r
+  FspMultiPhaseParams.MultiPhaseAction   = EnumMultiPhaseGetNumberOfPhases;\r
+  FspMultiPhaseParams.PhaseIndex         = 0;\r
+  FspMultiPhaseParams.MultiPhaseParamPtr = (VOID *)&FspMultiPhaseGetNumber;\r
+  Status                                 = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    //\r
+    // MultiPhase API was not supported\r
+    //\r
+    return Status;\r
+  } else {\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  NumOfPhases = FspMultiPhaseGetNumber.NumberOfPhases;\r
+\r
+  for (Index = 1; Index <= NumOfPhases; Index++) {\r
+    DEBUG ((DEBUG_ERROR, "MultiPhase Index/NumOfPhases = %d of %d\n", Index, NumOfPhases));\r
+    //\r
+    // Platform actions can be added in below function for each component and phase before returning control back to FSP.\r
+    //\r
+    FspWrapperPlatformMultiPhaseHandler (FspHobListPtr, ComponentIndex, Index);\r
+\r
+    FspMultiPhaseParams.MultiPhaseAction   = EnumMultiPhaseExecutePhase;\r
+    FspMultiPhaseParams.PhaseIndex         = Index;\r
+    FspMultiPhaseParams.MultiPhaseParamPtr = NULL;\r
+    Status                                 = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex);\r
+\r
+    if (Status == FSP_STATUS_VARIABLE_REQUEST) {\r
+      //\r
+      // call to Variable request handler\r
+      //\r
+      FspWrapperVariableRequestHandler (FspHobListPtr, ComponentIndex);\r
+    }\r
+\r
+    //\r
+    // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
+    //\r
+    if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
+      DEBUG ((DEBUG_INFO, "FspMultiPhaseApi-0x%x requested reset %r\n", ComponentIndex, Status));\r
+      CallFspWrapperResetSystem ((UINTN)Status);\r
+    }\r
+\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r