]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
IntelFsp2Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFsp2Pkg / Library / BaseFspCommonLib / FspCommonLib.c
index efd55f464c03a4c4cb43266b5bedb592d27a9c74..0a5bc76aa72d0697116b42597e71a1dc427142b0 100644 (file)
@@ -1,13 +1,7 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2016, 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
@@ -17,7 +11,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 +51,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
@@ -87,9 +81,9 @@ GetFspGlobalDataPointer (
 }\r
 \r
 /**\r
-  This function gets back the FSP API first parameter passed by the bootlaoder.\r
+  This function gets back the FSP API first parameter passed by the bootloader.\r
 \r
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.\r
+  @retval ApiParameter FSP API first parameter passed by the bootloader.\r
 **/\r
 UINT32\r
 EFIAPI\r
@@ -104,9 +98,26 @@ GetFspApiParameter (
 }\r
 \r
 /**\r
-  This function gets back the FSP API second parameter passed by the bootlaoder.\r
+  This function returns the FSP entry stack pointer from address of the first API parameter.\r
+\r
+  @retval FSP entry stack pointer.\r
+**/\r
+VOID*\r
+EFIAPI\r
+GetFspEntryStack (\r
+  VOID\r
+  )\r
+{\r
+  FSP_GLOBAL_DATA  *FspData;\r
+\r
+  FspData  = GetFspGlobalDataPointer ();\r
+  return (VOID*)(FspData->CoreStack + CONTEXT_STACK_OFFSET(ApiParam[0]));\r
+}\r
+\r
+/**\r
+  This function gets back the FSP API second parameter passed by the bootloader.\r
 \r
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.\r
+  @retval ApiParameter FSP API second parameter passed by the bootloader.\r
 **/\r
 UINT32\r
 EFIAPI\r
@@ -190,7 +201,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 +220,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 +250,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 +279,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 +292,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 +321,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 +334,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
@@ -425,13 +436,13 @@ GetFspInfoHeaderFromApiContext (
 }\r
 \r
 /**\r
-  This function gets the VPD data pointer.\r
+  This function gets the CfgRegion data pointer.\r
 \r
-  @return VpdDataRgnPtr   VPD data pointer.\r
+  @return CfgRegion data pointer.\r
 **/\r
 VOID *\r
 EFIAPI\r
-GetFspVpdDataPointer (\r
+GetFspCfgRegionDataPointer (\r
   VOID\r
   )\r
 {\r
@@ -504,43 +515,31 @@ SetPhaseStatusCode (
 }\r
 \r
 /**\r
-  This function gets FSP CAR base.\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
+  This function updates the return status of the FSP API with requested reset type and returns to Boot Loader.\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