public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] IntelFsp2Pkg: Changes to return FSP API error return status
@ 2016-10-21  7:23 Satya Yarlagadda
  0 siblings, 0 replies; only message in thread
From: Satya Yarlagadda @ 2016-10-21  7:23 UTC (permalink / raw)
  To: edk2-devel; +Cc: Maurice Ma, Jiewen Yao, Giri P Mudusuru

Changed the FSPMemoryInitDone, FspSiliconInitDone and FspTempRamInitDone
functions to return FSP API error status instead of always returning
success.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Satya Yarlagadda <satya.p.yarlagadda@intel.com>
---
 IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c   |   2 +-
 IntelFsp2Pkg/Include/Library/FspPlatformLib.h      |  12 +--
 .../Library/BaseFspPlatformLib/FspPlatformNotify.c | 108 ++++++++++++++++-----
 3 files changed, 93 insertions(+), 29 deletions(-)

diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
index 6acdeb3..113b819 100644
--- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
+++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
@@ -81,7 +81,7 @@ WaitForNotify (
   // Give control back to BootLoader after FspSiliconInit
   //
   DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));
-  FspSiliconInitDone ();
+  FspSiliconInitDone (EFI_SUCCESS);
 
   //
   // BootLoader called FSP again through NotifyPhase
diff --git a/IntelFsp2Pkg/Include/Library/FspPlatformLib.h b/IntelFsp2Pkg/Include/Library/FspPlatformLib.h
index 61e77bd..90222a2 100644
--- a/IntelFsp2Pkg/Include/Library/FspPlatformLib.h
+++ b/IntelFsp2Pkg/Include/Library/FspPlatformLib.h
@@ -51,33 +51,33 @@ FspSetNewStackFrame (
 
 /**
   This function transfer control back to BootLoader after FspSiliconInit.
-
+  @param[in] Status return status for the FspSiliconInit.
 **/
 VOID
 EFIAPI
 FspSiliconInitDone (
-  VOID
+  IN EFI_STATUS Status
   );
 
 /**
   This function returns control to BootLoader after MemoryInitApi.
 
-  @param[in,out] HobListPtr The address of HobList pointer.
+  @param[in] Status return status for the MemoryInitApi.
 **/
 VOID
 EFIAPI
 FspMemoryInitDone (
-  IN OUT VOID   **HobListPtr
+  IN EFI_STATUS Status
   );
 
 /**
   This function returns control to BootLoader after TempRamExitApi.
-
+  @param[in] Status return status for the TempRamExitApi.
 **/
 VOID
 EFIAPI
 FspTempRamExitDone (
-  VOID
+  IN EFI_STATUS Status
   );
 
 /**
diff --git a/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c b/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c
index 66b6cdb..f1ff52e 100644
--- a/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c
+++ b/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c
@@ -108,58 +108,99 @@ FspNotificationHandler (
 /**
   This function transfer control back to BootLoader after FspSiliconInit.
 
+  @param[in] Status return status for the FspSiliconInit.
+
 **/
 VOID
 EFIAPI
 FspSiliconInitDone (
-  VOID
+  IN EFI_STATUS Status
   )
 {
   //
+  // Convert to FSP EAS defined API return codes
+  //
+  switch (Status) {
+    case EFI_SUCCESS:
+    case EFI_INVALID_PARAMETER:
+    case EFI_UNSUPPORTED:
+    case EFI_DEVICE_ERROR:
+      break;
+    default:
+      DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() Invalid Error - [Status: 0x%08X]\n", Status));
+      Status = EFI_DEVICE_ERROR;  // Force to known error.
+      break;
+  }
+  //
   // This is the end of the FspSiliconInit API
   // Give control back to the boot loader
   //
   SetFspMeasurePoint (FSP_PERF_ID_API_FSP_SILICON_INIT_EXIT);
-  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - End\n"));
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - [Status: 0x%08X] - End\n", Status));
 
   PERF_END_EX (&gFspPerformanceDataGuid, "EventRec", NULL, 0, 0x907F);
 
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
-  SetFspApiReturnStatus (EFI_SUCCESS);
-
-  Pei2LoaderSwitchStack();
-
-  PERF_START_EX (&gFspPerformanceDataGuid, "EventRec", NULL, 0, 0x6000);
+  do {
+    SetFspApiReturnStatus (Status);
+    Pei2LoaderSwitchStack ();
+    if (Status != EFI_SUCCESS) {
+      DEBUG ((DEBUG_ERROR, "!!!ERROR: FspSiliconInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));
+    }
+  } while (Status != EFI_SUCCESS);
 }
 
 /**
   This function returns control to BootLoader after MemoryInitApi.
 
-  @param[in,out] HobListPtr The address of HobList pointer.
+  @param[in] Status return status for the MemoryInitApi.
+
 **/
 VOID
 EFIAPI
 FspMemoryInitDone (
-  IN OUT VOID   **HobListPtr
+  IN EFI_STATUS Status
   )
 {
+  VOID **HobListPtr;
+
   //
   // Calling use FspMemoryInit API
   // Update HOB and return the control directly
   //
+  HobListPtr = (VOID **)GetFspApiParameter2 ();
   if (HobListPtr != NULL) {
     *HobListPtr = (VOID *) GetHobList ();
   }
-
+  //
+  // Convert to FSP EAS defined API return codes
+  //
+  switch (Status) {
+    case EFI_SUCCESS:
+    case EFI_INVALID_PARAMETER:
+    case EFI_UNSUPPORTED:
+    case EFI_DEVICE_ERROR:
+    case EFI_OUT_OF_RESOURCES:
+      break;
+    default:
+      DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() Invalid Error [Status: 0x%08X]\n", Status));
+      Status = EFI_DEVICE_ERROR;  // Force to known error.
+      break;
+  }
   //
   // This is the end of the FspMemoryInit API
   // Give control back to the boot loader
   //
   SetFspMeasurePoint (FSP_PERF_ID_API_FSP_MEMORY_INIT_EXIT);
-  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() - End\n"));
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() - [Status: 0x%08X] - End\n", Status));
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
-  SetFspApiReturnStatus (EFI_SUCCESS);
-  Pei2LoaderSwitchStack ();
+  do {
+    SetFspApiReturnStatus (Status);
+    Pei2LoaderSwitchStack ();
+    if (Status != EFI_SUCCESS) {
+      DEBUG ((DEBUG_ERROR, "!!!ERROR: FspMemoryInitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));
+    }
+  } while (Status != EFI_SUCCESS);
 
   //
   // The TempRamExitApi is called
@@ -180,24 +221,43 @@ FspMemoryInitDone (
 /**
   This function returns control to BootLoader after TempRamExitApi.
 
+  @param[in] Status return status for the TempRamExitApi.
+
 **/
 VOID
 EFIAPI
 FspTempRamExitDone (
-  VOID
+  IN EFI_STATUS Status
   )
 {
-
+  //
+  // Convert to FSP EAS defined API return codes
+  //
+  switch (Status) {
+    case EFI_SUCCESS:
+    case EFI_INVALID_PARAMETER:
+    case EFI_UNSUPPORTED:
+    case EFI_DEVICE_ERROR:
+      break;
+    default:
+      DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() Invalid Error - [Status: 0x%08X]\n", Status));
+      Status = EFI_DEVICE_ERROR;  // Force to known error.
+      break;
+  }
   //
   // This is the end of the TempRamExit API
   // Give control back to the boot loader
   //
   SetFspMeasurePoint (FSP_PERF_ID_API_TEMP_RAM_EXIT_EXIT);
-  DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() - End\n"));
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() - [Status: 0x%08X] - End\n", Status));
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_TEMP_RAM_EXIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
-  SetFspApiReturnStatus (EFI_SUCCESS);
-  Pei2LoaderSwitchStack ();
-
+  do {
+    SetFspApiReturnStatus (Status);
+    Pei2LoaderSwitchStack ();
+    if (Status != EFI_SUCCESS) {
+      DEBUG ((DEBUG_ERROR, "!!!ERROR: TempRamExitApi() - [Status: 0x%08X] - Error encountered during previous API and cannot proceed further\n", Status));
+    }
+  } while (Status != EFI_SUCCESS);
   SetPhaseStatusCode (FSP_STATUS_CODE_SILICON_INIT);
   SetFspMeasurePoint (FSP_PERF_ID_API_FSP_SILICON_INIT_ENTRY);
   DEBUG ((DEBUG_INFO | DEBUG_INIT, "SiliconInitApi() - Begin\n"));
@@ -256,9 +316,7 @@ FspWaitForNotify (
       }
     }
 
-    SetFspApiReturnStatus(Status);
     DEBUG ((DEBUG_INFO | DEBUG_INIT, "NotifyPhaseApi() - End  [Status: 0x%08X]\n", Status));
-
     SetFspMeasurePoint (FSP_PERF_ID_API_NOTIFY_POST_PCI_EXIT + Count);
 
     if ((NotificationCount - 1) == 0) {
@@ -268,7 +326,13 @@ FspWaitForNotify (
     } else if ((NotificationCount - 1) == 2) {
       REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
     }
-    Pei2LoaderSwitchStack();
+    do {
+      SetFspApiReturnStatus(Status);
+      Pei2LoaderSwitchStack();
+      if (Status != EFI_SUCCESS) {
+        DEBUG ((DEBUG_ERROR, "!!!ERROR: NotifyPhaseApi() [Phase: %08X] - Failed - [Status: 0x%08X]\n", NotificationValue, Status));
+      }
+    } while (Status != EFI_SUCCESS);
   }
 
   //
-- 
2.10.0.windows.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-21  7:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-21  7:23 [PATCH] IntelFsp2Pkg: Changes to return FSP API error return status Satya Yarlagadda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox