]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: Support FSP Dispatch mode
authorChasel, Chiu <chasel.chiu@intel.com>
Thu, 11 Oct 2018 13:22:12 +0000 (21:22 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Fri, 19 Oct 2018 07:01:00 +0000 (15:01 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1241

Add support for both API (original mode) and DISPATCH mode:
1. Add FspMode field from reserved byte of Global
   Data Structure to tell which mode is selected by boot
   loader. If boot loader invoking FSP-M API this field
   will remain as default 0 (API mode), otherwise platform
   FSP should set this field to 1 (Dispatch mode) when
   initializing Global Data Structure.
2. gFspInApiModePpiGuid will be instaled when FSP running in API
   mode and modules only for API mode should have this in depex.
3. If it is DISPATCH mode, FSP will return to PEI dispatcher,
   not directly return to boot loader.
4. DISPATCH mode supports DXE NotifyPhase drivers so FSP
   will not wait for PEI NotifyPhase callbacks, instead it
   will install gFspReadyForNotifyPhasePpiGuid PPI for
   platform to complete late initialization before transferring
   to DXE.

Test: Verified FSP API and DISPATCH modes on 2 internal
      platforms and both boot successfully.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
IntelFsp2Pkg/FspSecCore/SecMain.c
IntelFsp2Pkg/Include/FspGlobalData.h
IntelFsp2Pkg/IntelFsp2Pkg.dec
IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c

index 52435fa0b2d82715d76f733ca6d50933bfbcf50a..cbea3a7eaa8ff1a5349fa18f1345c40b70666a43 100644 (file)
@@ -48,6 +48,12 @@ CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {
   NULL\r
 };\r
 \r
+CONST EFI_PEI_PPI_DESCRIPTOR gFspReadyForNotifyPhasePpi = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gFspReadyForNotifyPhasePpiGuid,\r
+  NULL\r
+};\r
+\r
 /**\r
 \r
    This function waits for FSP notify.\r
@@ -88,13 +94,15 @@ WaitForNotify (
   //\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
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\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
 \r
   return EFI_SUCCESS;\r
@@ -121,22 +129,27 @@ FspNotifyPhasePeimEntryPoint (
 \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
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\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
+  } else {\r
+    Status = PeiServicesInstallPpi (&gFspReadyForNotifyPhasePpi);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r
index a0bc37580d3bb09bc651290531addf91d9cd4afe..b0f6768cfaaa8589f8304b677bb304021b0aca16 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Component information file for the FSP notify phase PEI module.\r
 #\r
-#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.\r
+#  Copyright (c) 2016 - 2018, 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
@@ -37,6 +37,7 @@
 [Ppis]\r
   gEfiDxeIplPpiGuid                       ## PRODUCES\r
   gEfiEndOfPeiSignalPpiGuid               ## PRODUCES\r
+  gFspReadyForNotifyPhasePpiGuid          ## PRODUCES\r
 \r
 [Protocols]\r
   gEfiPciEnumerationCompleteProtocolGuid  ## PRODUCES\r
index c657862debadcd0e286abc916a105cf92430f941..c61af10b8ad64ea858008a93cec6fc0ae99dbf74 100644 (file)
@@ -65,4 +65,4 @@
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid                              ## PRODUCES\r
-\r
+  gFspInApiModePpiGuid                                        ## PRODUCES\r
index 5a43ba1967143e2fc8849424bf8af32deaef1eff..37fd4dfdeb0d311608452d99f66f315840921c8c 100644 (file)
@@ -19,6 +19,11 @@ EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI gSecTemporaryRamSupportPpi = {
 };\r
 \r
 EFI_PEI_PPI_DESCRIPTOR            mPeiSecPlatformInformationPpi[] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gFspInApiModePpiGuid,\r
+    NULL\r
+  },\r
   {\r
     (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
     &gEfiTemporaryRamSupportPpiGuid,\r
index 7de26606a7fbca49e5d203ba057bbb260d2cd4ce..2a03129f4a19851cb80937ae2de819ba0d7f15e2 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2018, 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
@@ -16,6 +16,9 @@
 \r
 #include <FspEas.h>\r
 \r
+#define FSP_IN_API_MODE      0\r
+#define FSP_IN_DISPATCH_MODE 1\r
+\r
 #pragma pack(1)\r
 \r
 typedef enum {\r
@@ -54,7 +57,8 @@ typedef struct  {
    VOID               *MemoryInitUpdPtr;\r
    VOID               *SiliconInitUpdPtr;\r
    UINT8              ApiIdx;\r
-   UINT8              Reserved3[31];\r
+   UINT8              FspMode; // 0: FSP in API mode; 1: FSP in DISPATCH mode\r
+   UINT8              Reserved3[30];\r
    UINT32             PerfSig;\r
    UINT16             PerfLen;\r
    UINT16             Reserved4;\r
index b2ee4b6ef5e8a9b17f901f0dbe84a7d6cc021599..5b037d65e23284c44b1d149d94d899770073e033 100644 (file)
   ##  @libraryclass  Provides FSP platform sec related actions.\r
   FspSecPlatformLib|Include/Library/FspSecPlatformLib.h\r
 \r
+[Ppis]\r
+  #\r
+  # PPI to indicate FSP is ready to enter notify phase\r
+  # This provides flexibility for any late initialization that must be done right before entering notify phase.\r
+  #\r
+  gFspReadyForNotifyPhasePpiGuid        = { 0xcd167c1e, 0x6e0b, 0x42b3, { 0x82, 0xf6, 0xe3, 0xe9, 0x6, 0x19, 0x98, 0x10}}\r
+\r
+  #\r
+  # PPI as dependency on some modules which only required for API mode\r
+  #\r
+  gFspInApiModePpiGuid                  = { 0xa1eeab87, 0xc859, 0x479d, {0x89, 0xb5, 0x14, 0x61, 0xf4, 0x06, 0x1a, 0x3e}}\r
+\r
 [Guids]\r
   #\r
   # GUID defined in package\r
index d0128304e6bafdaffe38e70d9674a6b5aea801df..64ffba1d16789f8a5f1fe62f2a2e24fc6e4bf170 100644 (file)
@@ -519,14 +519,16 @@ FspApiReturnStatusReset (
 \r
   LoopUntilReset = TRUE;\r
   DEBUG ((DEBUG_INFO, "FSP returning control to Bootloader with reset required return status %x\n",FspResetType));\r
-  ///\r
-  /// Below code is not an infinite loop.The control will go back to API calling function in BootLoader each time BootLoader\r
-  /// calls the FSP API without honoring the reset request by FSP\r
-  ///\r
-  do {\r
-    SetFspApiReturnStatus ((EFI_STATUS)FspResetType);\r
-    Pei2LoaderSwitchStack ();\r
-    DEBUG ((DEBUG_ERROR, "!!!ERROR: FSP has requested BootLoader for reset. But BootLoader has not honored the reset\n"));\r
-    DEBUG ((DEBUG_ERROR, "!!!ERROR: Please add support in BootLoader to honor the reset request from FSP\n"));\r
-  } while (LoopUntilReset);\r
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
+    ///\r
+    /// Below code is not an infinite loop.The control will go back to API calling function in BootLoader each time BootLoader\r
+    /// calls the FSP API without honoring the reset request by FSP\r
+    ///\r
+    do {\r
+      SetFspApiReturnStatus ((EFI_STATUS)FspResetType);\r
+      Pei2LoaderSwitchStack ();\r
+      DEBUG ((DEBUG_ERROR, "!!!ERROR: FSP has requested BootLoader for reset. But BootLoader has not honored the reset\n"));\r
+      DEBUG ((DEBUG_ERROR, "!!!ERROR: Please add support in BootLoader to honor the reset request from FSP\n"));\r
+    } while (LoopUntilReset);\r
+  }\r
 }\r
index ac1fc1ac0b37cec6045d044cc132ff4d6a262a07..cbc3b472c6e7425587b73cdfe054be780129dd40 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2018, 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
@@ -117,6 +117,9 @@ FspSiliconInitDone2 (
   IN EFI_STATUS Status\r
   )\r
 {\r
+  volatile EFI_STATUS FspStatus;\r
+\r
+  FspStatus = Status;\r
   //\r
   // Convert to FSP EAS defined API return codes\r
   //\r
@@ -139,13 +142,15 @@ FspSiliconInitDone2 (
   DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - [Status: 0x%08X] - End\n", Status));\r
   PERF_END_EX (&gFspPerformanceDataGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
-  do {\r
-    SetFspApiReturnStatus (Status);\r
-    Pei2LoaderSwitchStack ();\r
-    if (Status != EFI_SUCCESS) {\r
-      DEBUG ((DEBUG_ERROR, "!!!ERROR: FspSiliconInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
-    }\r
-  } while (Status != EFI_SUCCESS);\r
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
+    do {\r
+      SetFspApiReturnStatus (Status);\r
+      Pei2LoaderSwitchStack ();\r
+      if (Status != EFI_SUCCESS) {\r
+        DEBUG ((DEBUG_ERROR, "!!!ERROR: FspSiliconInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
+      }\r
+    } while (FspStatus != EFI_SUCCESS);\r
+  }\r
 }\r
 \r
 /**\r
@@ -162,6 +167,9 @@ FspMemoryInitDone2 (
   )\r
 {\r
   FSP_GLOBAL_DATA   *FspData;\r
+  volatile EFI_STATUS FspStatus;\r
+\r
+  FspStatus = Status;\r
   //\r
   // Calling use FspMemoryInit API\r
   // Update HOB and return the control directly\r
@@ -199,13 +207,15 @@ FspMemoryInitDone2 (
   PERF_START_EX(&gFspPerformanceDataGuid, "EventRec", NULL, (FspData->PerfData[2] & FSP_PERFORMANCE_DATA_TIMER_MASK), FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
   PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
-  do {\r
-    SetFspApiReturnStatus (Status);\r
-    Pei2LoaderSwitchStack ();\r
-    if (Status != EFI_SUCCESS) {\r
-      DEBUG ((DEBUG_ERROR, "!!!ERROR: FspMemoryInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
-    }\r
-  } while (Status != EFI_SUCCESS);\r
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
+    do {\r
+      SetFspApiReturnStatus (Status);\r
+      Pei2LoaderSwitchStack ();\r
+      if (Status != EFI_SUCCESS) {\r
+        DEBUG ((DEBUG_ERROR, "!!!ERROR: FspMemoryInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
+      }\r
+    } while (FspStatus != EFI_SUCCESS);\r
+  }\r
 \r
   //\r
   // The TempRamExitApi is called\r
@@ -238,6 +248,9 @@ FspTempRamExitDone2 (
   )\r
 {\r
   //\r
+  volatile EFI_STATUS FspStatus;\r
+\r
+  FspStatus = Status;\r
   // Convert to FSP EAS defined API return codes\r
   //\r
   switch (Status) {\r
@@ -259,13 +272,15 @@ FspTempRamExitDone2 (
   SetFspMeasurePoint (FSP_PERF_ID_API_TEMP_RAM_EXIT_EXIT);\r
   PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_TEMP_RAM_EXIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_TEMP_RAM_EXIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
-  do {\r
-    SetFspApiReturnStatus (Status);\r
-    Pei2LoaderSwitchStack ();\r
-    if (Status != EFI_SUCCESS) {\r
-      DEBUG ((DEBUG_ERROR, "!!!ERROR: TempRamExitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
-    }\r
-  } while (Status != EFI_SUCCESS);\r
+  if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
+    do {\r
+      SetFspApiReturnStatus (Status);\r
+      Pei2LoaderSwitchStack ();\r
+      if (Status != EFI_SUCCESS) {\r
+        DEBUG ((DEBUG_ERROR, "!!!ERROR: TempRamExitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));\r
+      }\r
+    } while (FspStatus != EFI_SUCCESS);\r
+  }\r
   SetPhaseStatusCode (FSP_STATUS_CODE_SILICON_INIT);\r
   SetFspMeasurePoint (FSP_PERF_ID_API_FSP_SILICON_INIT_ENTRY);\r
   PERF_START_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
@@ -289,6 +304,7 @@ FspWaitForNotify (
   UINT32                     NotificationValue;\r
   UINT32                     NotificationCount;\r
   UINT8                      Count;\r
+  volatile EFI_STATUS        FspStatus;\r
 \r
   NotificationCount = 0;\r
   while (NotificationCount < sizeof(mFspNotifySequence) / sizeof(UINT32)) {\r
@@ -341,15 +357,17 @@ FspWaitForNotify (
       PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
       REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
     }\r
-    do {\r
-      SetFspApiReturnStatus(Status);\r
-      Pei2LoaderSwitchStack();\r
-      if (Status != EFI_SUCCESS) {\r
-        DEBUG ((DEBUG_ERROR, "!!!ERROR: NotifyPhaseApi() [Phase: %08X] - Failed - [Status: 0x%08X]\n", NotificationValue, Status));\r
-      }\r
-    } while (Status != EFI_SUCCESS);\r
+    if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
+      FspStatus = Status;\r
+      do {\r
+        SetFspApiReturnStatus(Status);\r
+        Pei2LoaderSwitchStack();\r
+        if (Status != EFI_SUCCESS) {\r
+          DEBUG ((DEBUG_ERROR, "!!!ERROR: NotifyPhaseApi() [Phase: %08X] - Failed - [Status: 0x%08X]\n", NotificationValue, Status));\r
+        }\r
+      } while (FspStatus != EFI_SUCCESS);\r
+    }\r
   }\r
-\r
   //\r
   // Control goes back to the PEI Core and it dispatches further PEIMs.\r
   // DXEIPL is the final one to transfer control back to the boot loader.\r