]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
IntelFsp2WrapperPkg/FspsWrapperPeim: Fix coding style.
[mirror_edk2.git] / IntelFsp2WrapperPkg / FspsWrapperPeim / FspsWrapperPeim.c
index 70dac7a4142dc62c1ba8b549599fe17b097d8eea..0f8cd69a0e6eba93a70265a1965d130cea25a7a9 100644 (file)
@@ -3,14 +3,8 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi\r
   notify to call FspSiliconInit API.\r
 \r
-  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -44,7 +38,7 @@ extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc;
 extern EFI_GUID                  gFspHobGuid;\r
 \r
 /**\r
-  This function handles S3 resume task at the end of PEI\r
+  This function handles S3 resume task at the end of PEI.\r
 \r
   @param[in] PeiServices    Pointer to PEI Services Table.\r
   @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
@@ -68,7 +62,7 @@ EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = {
 };\r
 \r
 /**\r
-  This function handles S3 resume task at the end of PEI\r
+  This function handles S3 resume task at the end of PEI.\r
 \r
   @param[in] PeiServices    Pointer to PEI Services Table.\r
   @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
@@ -136,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
@@ -163,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
@@ -184,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
@@ -302,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
@@ -333,7 +370,36 @@ FspsWrapperInit (
 }\r
 \r
 /**\r
-  This is the entrypoint of PEIM\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
   @param[in] FileHandle  Handle of the file being invoked.\r
   @param[in] PeiServices Describes the list of possible PEI Services.\r
@@ -349,7 +415,11 @@ FspsWrapperPeimEntryPoint (
 {\r
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
 \r
-  FspsWrapperInit ();\r
+  if (PcdGet8 (PcdFspModeSelection) == 1) {\r
+    FspsWrapperInitApiMode ();\r
+  } else {\r
+    FspsWrapperInitDispatchMode ();\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r