]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2WrapperPkg: Perform post FSP-S process.
authorChasel, Chiu <chasel.chiu@intel.com>
Fri, 12 Apr 2019 08:54:47 +0000 (16:54 +0800)
committerChasel Chiu <chasel.chiu@intel.com>
Tue, 16 Apr 2019 04:46:58 +0000 (12:46 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1716

In API mode FSP wrapper will perform some post
FSP-S process but such process was skipped in Dispatch
mode which may impact some of the boot loaders.
To align behavior between API and Dispatch, an
End-of-Pei callback is introduced to perform same process
in Dispatch mode.

Note: If boot loader implemented its own
      PostFspsHobProcess (), it has to check
      PcdFspModeSelection and support each mode
      properly.

Test: Verified on internal platform and both
      FSP API and Dispatch modes booted successfully.

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: Star Zeng <star.zeng@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
IntelFsp2WrapperPkg/Library/PeiFspWrapperHobProcessLibSample/FspWrapperHobProcessLibSample.c
IntelFsp2WrapperPkg/Library/PeiFspWrapperHobProcessLibSample/PeiFspWrapperHobProcessLibSample.inf

index bb126797ae3aafffd480638d39fd2cbf64d33668..9f8ce16023b9108a49c833d3f9ab1bc067ee9855 100644 (file)
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi\r
   notify to call FspSiliconInit API.\r
 \r
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -130,7 +130,7 @@ S3EndOfPeiNotify(
   @param[in]  This         The pointer to this instance of this PPI.\r
   @param[out] FspHobList   The pointer to Hob list produced by FSP.\r
 \r
-  @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
+  @return EFI_SUCCESS      Return Hob list produced by FSP successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -157,7 +157,7 @@ EFI_PEI_PPI_DESCRIPTOR            mPeiFspSiliconInitDonePpi = {
   @param[in]  This         The pointer to this instance of this PPI.\r
   @param[out] FspHobList   The pointer to Hob list produced by FSP.\r
 \r
-  @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
+  @return EFI_SUCCESS      Return Hob list produced by FSP successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -178,6 +178,49 @@ FspSiliconInitDoneGetFspHobList (
   }\r
 }\r
 \r
+/**\r
+  This function is for FSP dispatch mode to perform post FSP-S process.\r
+\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
+\r
+  @retval EFI_STATUS        Status returned by PeiServicesInstallPpi ()\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FspsWrapperEndOfPeiNotify (\r
+  IN EFI_PEI_SERVICES          **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
+  IN VOID                      *Ppi\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // This step may include platform specific process in some boot loaders so\r
+  // aligning the same behavior between API and Dispatch modes.\r
+  // Note: In Dispatch mode no FspHobList so passing NULL to function and\r
+  //       expecting function will handle it.\r
+  //\r
+  PostFspsHobProcess (NULL);\r
+\r
+  //\r
+  // Install FspSiliconInitDonePpi so that any other driver can consume this info.\r
+  //\r
+  Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_PEI_NOTIFY_DESCRIPTOR mFspsWrapperEndOfPeiNotifyDesc = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiEndOfPeiSignalPpiGuid,\r
+  FspsWrapperEndOfPeiNotify\r
+};\r
+\r
 /**\r
   This function is called after PEI core discover memory and finish migration.\r
 \r
@@ -296,12 +339,12 @@ PeiMemoryDiscoveredNotify (
 }\r
 \r
 /**\r
-  Do FSP initialization.\r
+  Do FSP initialization in API mode\r
 \r
-  @return FSP initialization status.\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
 **/\r
 EFI_STATUS\r
-FspsWrapperInit (\r
+FspsWrapperInitApiMode (\r
   VOID\r
   )\r
 {\r
@@ -326,6 +369,35 @@ FspsWrapperInit (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Do FSP initialization in Dispatch mode\r
+\r
+  @retval FSP initialization status.\r
+**/\r
+EFI_STATUS\r
+FspsWrapperInitDispatchMode (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS           Status;\r
+  //\r
+  // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.\r
+  //\r
+  PeiServicesInstallFvInfoPpi (\r
+    NULL,\r
+    (VOID *)(UINTN) PcdGet32 (PcdFspsBaseAddress),\r
+    (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength,\r
+    NULL,\r
+    NULL\r
+    );\r
+  //\r
+  // Register EndOfPei Nofity to run post FSP-S process.\r
+  //\r
+  Status = PeiServicesNotifyPpi (&mFspsWrapperEndOfPeiNotifyDesc);\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
 /**\r
   This is the entrypoint of PEIM\r
 \r
@@ -344,15 +416,9 @@ FspsWrapperPeimEntryPoint (
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
 \r
   if (PcdGet8 (PcdFspModeSelection) == 1) {\r
-    FspsWrapperInit ();\r
+    FspsWrapperInitApiMode ();\r
   } else {\r
-    PeiServicesInstallFvInfoPpi (\r
-      NULL,\r
-      (VOID *)(UINTN) PcdGet32 (PcdFspsBaseAddress),\r
-      (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength,\r
-      NULL,\r
-      NULL\r
-      );\r
+    FspsWrapperInitDispatchMode ();\r
   }\r
 \r
   return EFI_SUCCESS;\r
index 1c7f661c477320e1862ca8c41b803266cb0e9d52..54cebe127c8feea1306e36e1a307fa3628dbe94e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Sample to provide FSP wrapper hob process related function.\r
 \r
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -378,7 +378,19 @@ PostFspsHobProcess (
   IN VOID                 *FspHobList\r
   )\r
 {\r
-  ProcessFspHobList (FspHobList);\r
-\r
+  //\r
+  // PostFspsHobProcess () will be called in both FSP API and Dispatch modes to\r
+  // align the same behavior and support a variety of boot loader implementations.\r
+  // Boot loader provided library function is recommended to support both API and\r
+  // Dispatch modes by checking PcdFspModeSelection.\r
+  //\r
+  if (PcdGet8 (PcdFspModeSelection) == 1) {\r
+    //\r
+    // Only in FSP API mode the wrapper has to build hobs basing on FSP output data.\r
+    // In this case FspHobList cannot be NULL.\r
+    //\r
+    ASSERT (FspHobList != NULL);\r
+    ProcessFspHobList (FspHobList);\r
+  }\r
   return EFI_SUCCESS;\r
 }\r
index 938ffae494a2547402b87f68cacad59a336c6ebc..6d9e3063134f62792e28c5b0473e0df1c771b462 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Sample to provide FSP wrapper hob process related function.\r
 #\r
-#  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -61,6 +61,7 @@
 [Pcd]\r
   gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize          ## CONSUMES\r
   gIntelFsp2WrapperTokenSpaceGuid.PcdPeiRecoveryMinMemSize  ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection       ## CONSUMES\r
 \r
 [Guids]\r
   gFspReservedMemoryResourceHobGuid                       ## CONSUMES ## HOB\r