]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
IntelFsp2Pkg: Support FSP Dispatch mode
[mirror_edk2.git] / IntelFsp2Pkg / Library / BaseFspCommonLib / FspCommonLib.c
index 151b1893433d726316586dd91ddae38a4c8e2899..64ffba1d16789f8a5f1fe62f2a2e24fc6e4bf170 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
@@ -17,7 +17,7 @@
 #include <Library/PcdLib.h>\r
 #include <FspGlobalData.h>\r
 #include <FspEas.h>\r
-#include <FspDataTable.h>\r
+#include <Library/FspSwitchStackLib.h>\r
 \r
 #pragma pack(1)\r
 \r
@@ -57,7 +57,7 @@ typedef struct {
 /**\r
   This function sets the FSP global data pointer.\r
 \r
-  @param[in] FspData       Fsp global data pointer.\r
+  @param[in] FspData       FSP global data pointer.\r
 \r
 **/\r
 VOID\r
@@ -190,7 +190,7 @@ SetFspCoreStackPointer (
 /**\r
   This function sets the platform specific data pointer.\r
 \r
-  @param[in] PlatformData       Fsp platform specific data pointer.\r
+  @param[in] PlatformData       FSP platform specific data pointer.\r
 \r
 **/\r
 VOID\r
@@ -209,7 +209,7 @@ SetFspPlatformDataPointer (
 /**\r
   This function gets the platform specific data pointer.\r
 \r
-   @param[in] PlatformData       Fsp platform specific data pointer.\r
+   @param[in] PlatformData       FSP platform specific data pointer.\r
 \r
 **/\r
 VOID *\r
@@ -239,7 +239,7 @@ SetFspUpdDataPointer (
   FSP_GLOBAL_DATA  *FspData;\r
 \r
   //\r
-  // Get the Fsp Global Data Pointer\r
+  // Get the FSP Global Data Pointer\r
   //\r
   FspData  = GetFspGlobalDataPointer ();\r
 \r
@@ -268,9 +268,9 @@ GetFspUpdDataPointer (
 \r
 \r
 /**\r
-  This function sets the memory init UPD data pointer.\r
+  This function sets the FspMemoryInit UPD data pointer.\r
 \r
-  @param[in] MemoryInitUpdPtr   memory init UPD data pointer.\r
+  @param[in] MemoryInitUpdPtr   FspMemoryInit UPD data pointer.\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -281,20 +281,20 @@ SetFspMemoryInitUpdDataPointer (
   FSP_GLOBAL_DATA  *FspData;\r
 \r
   //\r
-  // Get the Fsp Global Data Pointer\r
+  // Get the FSP Global Data Pointer\r
   //\r
   FspData  = GetFspGlobalDataPointer ();\r
 \r
   //\r
-  // Set the memory init UPD pointer.\r
+  // Set the FspMemoryInit UPD pointer.\r
   //\r
   FspData->MemoryInitUpdPtr = MemoryInitUpdPtr;\r
 }\r
 \r
 /**\r
-  This function gets the memory init UPD data pointer.\r
+  This function gets the FspMemoryInit UPD data pointer.\r
 \r
-  @return memory init UPD data pointer.\r
+  @return FspMemoryInit UPD data pointer.\r
 **/\r
 VOID *\r
 EFIAPI\r
@@ -310,9 +310,9 @@ GetFspMemoryInitUpdDataPointer (
 \r
 \r
 /**\r
-  This function sets the silicon init UPD data pointer.\r
+  This function sets the FspSiliconInit UPD data pointer.\r
 \r
-  @param[in] SiliconInitUpdPtr   silicon init UPD data pointer.\r
+  @param[in] SiliconInitUpdPtr   FspSiliconInit UPD data pointer.\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -323,20 +323,20 @@ SetFspSiliconInitUpdDataPointer (
   FSP_GLOBAL_DATA  *FspData;\r
 \r
   //\r
-  // Get the Fsp Global Data Pointer\r
+  // Get the FSP Global Data Pointer\r
   //\r
   FspData  = GetFspGlobalDataPointer ();\r
 \r
   //\r
-  // Set the silicon init UPD data pointer.\r
+  // Set the FspSiliconInit UPD data pointer.\r
   //\r
   FspData->SiliconInitUpdPtr = SiliconInitUpdPtr;\r
 }\r
 \r
 /**\r
-  This function gets the silicon init UPD data pointer.\r
+  This function gets the FspSiliconInit UPD data pointer.\r
 \r
-  @return silicon init UPD data pointer.\r
+  @return FspSiliconInit UPD data pointer.\r
 **/\r
 VOID *\r
 EFIAPI\r
@@ -504,43 +504,31 @@ SetPhaseStatusCode (
 }\r
 \r
 /**\r
-  This function gets FSP CAR base.\r
+  This function updates the return status of the FSP API with requested reset type and returns to Boot Loader.\r
 \r
-**/\r
-UINT32\r
-EFIAPI\r
-GetFspCarBase (\r
-  VOID\r
-  )\r
-{\r
-  FSP_GLOBAL_DATA  *FspData;\r
-  UINT32           CarBase;\r
-\r
-  FspData  = GetFspGlobalDataPointer ();\r
-  CarBase = FspData->PlatformData.CarBase;\r
-  if (CarBase == 0) {\r
-    CarBase = PcdGet32(PcdTemporaryRamBase);\r
-  }\r
-  return CarBase;\r
-}\r
-\r
-/**\r
-  This function gets FSP CAR size.\r
+  @param[in] FspResetType     Reset type that needs to returned as API return status\r
 \r
 **/\r
-UINT32\r
+VOID\r
 EFIAPI\r
-GetFspCarSize (\r
-  VOID\r
+FspApiReturnStatusReset (\r
+  IN UINT32   FspResetType\r
   )\r
 {\r
-  FSP_GLOBAL_DATA  *FspData;\r
-  UINT32           CarSize;\r
-\r
-  FspData  = GetFspGlobalDataPointer ();\r
-  CarSize = FspData->PlatformData.CarSize;\r
-  if (FspData->PlatformData.CarBase == 0) {\r
-    CarSize = PcdGet32(PcdTemporaryRamSize);\r
+  volatile BOOLEAN  LoopUntilReset;\r
+\r
+  LoopUntilReset = TRUE;\r
+  DEBUG ((DEBUG_INFO, "FSP returning control to Bootloader with reset required return status %x\n",FspResetType));\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
-  return CarSize;\r
 }\r