]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformNotify.c
Update IntelFspPkg to support FSP1.1
[mirror_edk2.git] / IntelFspPkg / Library / BaseFspPlatformLib / FspPlatformNotify.c
index 3488fbc61c7ad403644418df807f51722d0db3e5..e6f5fe8f5bc30c7bbb0af7064e69a99187b735ba 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, 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
@@ -38,7 +38,7 @@ EFI_PEI_PPI_DESCRIPTOR      mPeiReadyToBootPpi = {
 };\r
 \r
 \r
-UINT32  mFspNotfifySequence[] = {\r
+UINT32  mFspNotifySequence[] = {\r
   EnumInitPhaseAfterPciEnumeration,\r
   EnumInitPhaseReadyToBoot\r
 };\r
@@ -46,23 +46,23 @@ UINT32  mFspNotfifySequence[] = {
 /**\r
   Install FSP notification.\r
 \r
-  @param[in] NotificatonCode  FSP notification code\r
+  @param[in] NotificationCode  FSP notification code\r
 \r
   @retval EFI_SUCCESS            Notify FSP successfully\r
-  @retval EFI_INVALID_PARAMETER  NotificatonCode is invalid\r
+  @retval EFI_INVALID_PARAMETER  NotificationCode is invalid\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 FspNotificationHandler (\r
-  IN  UINT32     NotificatonCode\r
+  IN  UINT32     NotificationCode\r
   )\r
 {\r
   EFI_STATUS                Status;\r
 \r
   Status   = EFI_SUCCESS;\r
 \r
-  switch (NotificatonCode) {\r
+  switch (NotificationCode) {\r
   case EnumInitPhaseAfterPciEnumeration:\r
     //\r
     // Do POST PCI initialization if needed\r
@@ -89,7 +89,7 @@ FspNotificationHandler (
 \r
 /**\r
   This function transfer control to the ContinuationFunc passed in by the\r
-  bootloader.\r
+  BootLoader.\r
 \r
 **/\r
 VOID\r
@@ -98,32 +98,49 @@ FspInitDone (
   VOID\r
   )\r
 {\r
-  FSP_INIT_PARAMS           *FspInitParams;\r
+  FSP_INIT_PARAMS        *FspInitParams;\r
 \r
-  FspInitParams   = (FSP_INIT_PARAMS *)GetFspApiParameter ();\r
-\r
-  //\r
-  // Modify the parameters for ContinuationFunc\r
-  //\r
-  SetFspContinuationFuncParameter(EFI_SUCCESS, 0);\r
-  SetFspContinuationFuncParameter((UINT32)GetHobList(), 1);\r
+  if (GetFspApiCallingMode() == 0) {\r
+    //\r
+    // FspInit API is used, so jump into the ContinuationFunc\r
+    //\r
+    FspInitParams   = (FSP_INIT_PARAMS *)GetFspApiParameter ();\r
+  \r
+    //\r
+    // Modify the parameters for ContinuationFunc\r
+    //\r
+    SetFspContinuationFuncParameter(EFI_SUCCESS, 0);\r
+    SetFspContinuationFuncParameter((UINT32)GetHobList(), 1);\r
+  \r
+    //\r
+    // Modify the return address to ContinuationFunc\r
+    //\r
+    SetFspApiReturnAddress((UINT32)FspInitParams->ContinuationFunc);\r
+  \r
+    //\r
+    // Give control back to the boot loader framework caller after FspInit is done\r
+    // It is done throught the continuation function\r
+    //\r
+    SetFspMeasurePoint (FSP_PERF_ID_API_FSPINIT_EXIT);\r
+  } else {\r
+    //\r
+    // FspMemoryInit API is used, so return directly\r
+    //\r
 \r
-  //\r
-  // Modify the return address to ContinuationFunc\r
-  //\r
-  SetFspApiReturnAddress((UINT32)FspInitParams->ContinuationFunc);\r
+    //\r
+    // This is the end of the FspSiliconInit API\r
+    // Give control back to the boot loader\r
+    //\r
+    DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - End\n"));\r
+    SetFspApiReturnStatus (EFI_SUCCESS);\r
+  }\r
 \r
-  //\r
-  // Give control back to the boot loader framework caller after FspInit is done\r
-  // It is done throught the continuation function\r
-  //\r
-  SetFspMeasurePoint (FSP_PERF_ID_API_FSPINIT_EXIT);\r
   Pei2LoaderSwitchStack();\r
 }\r
 \r
 /**\r
-  This function handle NotifyPhase API call from the bootloader.\r
-  It gives control back to the bootloader after it is handled. If the\r
+  This function handle NotifyPhase API call from the BootLoader.\r
+  It gives control back to the BootLoader after it is handled. If the\r
   Notification code is a ReadyToBoot event, this function will return\r
   and FSP continues the remaining execution until it reaches the DxeIpl.\r
 \r
@@ -134,34 +151,36 @@ FspWaitForNotify (
   )\r
 {\r
   EFI_STATUS                 Status;\r
-  UINT32                     NotificatonValue;\r
-  UINT32                     NotificatonCount;\r
+  UINT32                     NotificationValue;\r
+  UINT32                     NotificationCount;\r
   UINT8                      Count;\r
 \r
-  NotificatonCount = 0;\r
-  while (NotificatonCount < sizeof(mFspNotfifySequence) / sizeof(UINT32)) {\r
+  NotificationCount = 0;\r
+  while (NotificationCount < sizeof(mFspNotifySequence) / sizeof(UINT32)) {\r
 \r
-    Count = (NotificatonCount << 1) & 0x07;\r
+    Count = (UINT8)((NotificationCount << 1) & 0x07);\r
     SetFspMeasurePoint (FSP_PERF_ID_API_NOTIFY_POSTPCI_ENTRY + Count);\r
 \r
-    NotificatonValue = ((NOTIFY_PHASE_PARAMS *)(UINTN)GetFspApiParameter ())->Phase;\r
-    DEBUG ((DEBUG_INFO, "FSP Got Notification. Notification Value : 0x%08X\n", NotificatonValue));\r
+    NotificationValue = ((NOTIFY_PHASE_PARAMS *)(UINTN)GetFspApiParameter ())->Phase;\r
+    DEBUG ((DEBUG_INFO, "FSP Got Notification. Notification Value : 0x%08X\n", NotificationValue));\r
 \r
-    if (mFspNotfifySequence[NotificatonCount] != NotificatonValue) {\r
+    if (mFspNotifySequence[NotificationCount] != NotificationValue) {\r
       //\r
       // Notify code does not follow the predefined order\r
       //\r
+      DEBUG ((DEBUG_INFO, "Unsupported FSP Notification Value\n"));\r
       SetFspApiReturnStatus(EFI_UNSUPPORTED);\r
     } else {\r
       //\r
       // Process Notification and Give control back to the boot loader framework caller\r
       //\r
-      Status = FspNotificationHandler (NotificatonValue);\r
+      Status = FspNotificationHandler (NotificationValue);\r
+      DEBUG ((DEBUG_INFO, "FSP Notification Handler Returns : 0x%08X\n", Status));\r
       SetFspApiReturnStatus(Status);\r
       if (!EFI_ERROR(Status)) {\r
-        NotificatonCount++;\r
+        NotificationCount++;\r
         SetFspApiReturnStatus(EFI_SUCCESS);\r
-        if (NotificatonValue == EnumInitPhaseReadyToBoot) {\r
+        if (NotificationValue == EnumInitPhaseReadyToBoot) {\r
           break;\r
         }\r
       }\r