]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
Add IntelFsp2Pkg and IntelFsp2WrapperPkg.
[mirror_edk2.git] / IntelFsp2Pkg / FspNotifyPhase / FspNotifyPhasePeim.c
diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
new file mode 100644 (file)
index 0000000..6acdeb3
--- /dev/null
@@ -0,0 +1,142 @@
+/** @file\r
+  Source file for FSP notify phase PEI module\r
+\r
+  Copyright (c) 2016, Intel Corporation. All rights reserved.\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
+**/\r
+\r
+#include "FspNotifyPhasePeim.h"\r
+\r
+/**\r
+\r
+   This function waits for FSP notify.\r
+    \r
+   @param This          Entry point for DXE IPL PPI.\r
+   @param PeiServices   General purpose services available to every PEIM.\r
+   @param HobList       Address to the Pei HOB list.\r
+   \r
+   @return EFI_SUCCESS              This function never returns.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WaitForNotify (\r
+  IN CONST EFI_DXE_IPL_PPI *This,\r
+  IN EFI_PEI_SERVICES      **PeiServices,\r
+  IN EFI_PEI_HOB_POINTERS  HobList\r
+  );\r
+\r
+CONST EFI_DXE_IPL_PPI mDxeIplPpi = {\r
+  WaitForNotify\r
+};\r
+\r
+CONST EFI_PEI_PPI_DESCRIPTOR mInstallDxeIplPpi = {\r
+  EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+  &gEfiDxeIplPpiGuid,\r
+  (VOID *) &mDxeIplPpi\r
+};\r
+\r
+CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiEndOfPeiSignalPpiGuid,\r
+  NULL\r
+};\r
+\r
+/**\r
+\r
+   This function waits for FSP notify.\r
+    \r
+   @param This          Entry point for DXE IPL PPI.\r
+   @param PeiServices   General purpose services available to every PEIM.\r
+   @param HobList       Address to the Pei HOB list.\r
+   \r
+   @return EFI_SUCCESS              This function never returns.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WaitForNotify (\r
+  IN CONST EFI_DXE_IPL_PPI *This,\r
+  IN EFI_PEI_SERVICES      **PeiServices,\r
+  IN EFI_PEI_HOB_POINTERS  HobList\r
+  )\r
+{\r
+  EFI_STATUS   Status;\r
+\r
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP HOB is located at 0x%08X\n", HobList));\r
+\r
+  //\r
+  // End of PEI phase signal\r
+  //\r
+  Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Give control back to BootLoader after FspSiliconInit\r
+  //\r
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));\r
+  FspSiliconInitDone ();\r
+\r
+  //\r
+  // BootLoader called FSP again through NotifyPhase\r
+  //\r
+  FspWaitForNotify ();\r
+\r
+  //\r
+  // Should not come here\r
+  //\r
+  while (TRUE) {\r
+    DEBUG ((DEBUG_ERROR, "No FSP API should be called after FSP is DONE!\n"));\r
+    SetFspApiReturnStatus (EFI_UNSUPPORTED);\r
+    Pei2LoaderSwitchStack ();\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  FSP notify phase PEI module entry point\r
+\r
+  @param[in]  FileHandle           Not used.\r
+  @param[in]  PeiServices          General purpose services available to every PEIM.\r
+\r
+  @retval     EFI_SUCCESS          The function completes successfully\r
+  @retval     EFI_OUT_OF_RESOURCES Insufficient resources to create database\r
+**/\r
+EFI_STATUS\r
+FspNotifyPhasePeimEntryPoint (\r
+  IN       EFI_PEI_FILE_HANDLE    FileHandle,\r
+  IN CONST EFI_PEI_SERVICES       **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  VOID                            *OldDxeIplPpi;\r
+  EFI_PEI_PPI_DESCRIPTOR          *OldDescriptor;\r
+\r
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "The entry of FspNotificationPeim\n"));\r
+\r
+  //\r
+  // Locate old DXE IPL PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+            &gEfiDxeIplPpiGuid,\r
+            0,\r
+            &OldDescriptor,\r
+            &OldDxeIplPpi\r
+            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Re-install the DXE IPL PPI to wait for notify\r
+  //\r
+  Status = PeiServicesReInstallPpi (OldDescriptor, &mInstallDxeIplPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r