]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspWrapperPkg/FspNotifyDxe/FspNotifyDxe.c
FatBinPkg: Update EBC/IA32/X64/IPF binaries
[mirror_edk2.git] / IntelFspWrapperPkg / FspNotifyDxe / FspNotifyDxe.c
index 7beedc458ae04481886c3c62a435c0b802cc219d..1a1e4e625890e809fcde69a699a5f44532d7af32 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This driver will register two callbacks to call fsp's notifies.\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
 #include <Library/UefiLib.h>\r
 #include <Library/FspApiLib.h>\r
 \r
+/**\r
+  Relocate this image under 4G memory.\r
+\r
+  @param  ImageHandle  Handle of driver image.\r
+  @param  SystemTable  Pointer to system table.\r
+\r
+  @retval EFI_SUCCESS  Image successfully relocated.\r
+  @retval EFI_ABORTED  Failed to relocate image.\r
+\r
+**/\r
+EFI_STATUS\r
+RelocateImageUnder4GIfNeeded (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  );\r
+\r
 FSP_INFO_HEADER *mFspHeader = NULL;\r
 \r
 /**\r
@@ -40,7 +56,6 @@ OnPciEnumerationComplete (
 {\r
   NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
   EFI_STATUS          Status;\r
-  FSP_STATUS          FspStatus;\r
   VOID                *Interface;\r
 \r
   //\r
@@ -57,9 +72,9 @@ OnPciEnumerationComplete (
   }\r
 \r
   NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;\r
-  FspStatus = CallFspNotifyPhase (mFspHeader, &NotifyPhaseParams);\r
-  if (FspStatus != FSP_SUCCESS) {\r
-    DEBUG((DEBUG_ERROR, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", FspStatus));\r
+  Status = CallFspNotifyPhase (mFspHeader, &NotifyPhaseParams);\r
+  if (Status != EFI_SUCCESS) {\r
+    DEBUG((DEBUG_ERROR, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", Status));\r
   } else {\r
     DEBUG((DEBUG_INFO, "FSP NotifyPhase AfterPciEnumeration Success.\n"));\r
   }\r
@@ -84,14 +99,14 @@ OnReadyToBoot (
   )\r
 {\r
   NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
-  FSP_STATUS          FspStatus;\r
+  EFI_STATUS          Status;\r
 \r
   gBS->CloseEvent (Event);\r
 \r
   NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;\r
-  FspStatus = CallFspNotifyPhase (mFspHeader, &NotifyPhaseParams);\r
-  if (FspStatus != FSP_SUCCESS) {\r
-    DEBUG((DEBUG_ERROR, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", FspStatus));\r
+  Status = CallFspNotifyPhase (mFspHeader, &NotifyPhaseParams);\r
+  if (Status != EFI_SUCCESS) {\r
+    DEBUG((DEBUG_ERROR, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", Status));\r
   } else {\r
     DEBUG((DEBUG_INFO, "FSP NotifyPhase ReadyToBoot Success.\n"));\r
   }\r
@@ -121,7 +136,19 @@ FspDxeEntryPoint (
   VOID       *Registration;\r
   EFI_EVENT  ProtocolNotifyEvent;\r
 \r
-  mFspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));\r
+  //\r
+  // Load this driver's image to memory\r
+  //\r
+  Status = RelocateImageUnder4GIfNeeded (ImageHandle, SystemTable);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (PcdGet32 (PcdFlashFvSecondFspBase) == 0) {\r
+    mFspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));\r
+  } else {\r
+    mFspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvSecondFspBase));\r
+  }\r
   DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", mFspHeader));\r
   if (mFspHeader == NULL) {\r
     return EFI_DEVICE_ERROR;\r