+++ /dev/null
-/** @file\r
- This driver will register two callbacks to call fsp's notifies.\r
-\r
- Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/PciEnumerationComplete.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\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
- PciEnumerationComplete Protocol notification event handler.\r
-\r
- @param[in] Event Event whose notification function is being invoked.\r
- @param[in] Context Pointer to the notification function's context.\r
-**/\r
-VOID\r
-EFIAPI\r
-OnPciEnumerationComplete (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
- EFI_STATUS Status;\r
- VOID *Interface;\r
-\r
- //\r
- // Try to locate it because gEfiPciEnumerationCompleteProtocolGuid will trigger it once when registration.\r
- // Just return if it is not found.\r
- //\r
- Status = gBS->LocateProtocol (\r
- &gEfiPciEnumerationCompleteProtocolGuid,\r
- NULL,\r
- &Interface\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;\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
-}\r
-\r
-/**\r
- Notification function of EVT_GROUP_READY_TO_BOOT event group.\r
-\r
- This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.\r
- When the Boot Manager is about to load and execute a boot option, it reclaims variable\r
- storage if free size is below the threshold.\r
-\r
- @param[in] Event Event whose notification function is being invoked.\r
- @param[in] Context Pointer to the notification function's context.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-OnReadyToBoot (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
- EFI_STATUS Status;\r
-\r
- gBS->CloseEvent (Event);\r
-\r
- NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;\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
-}\r
-\r
-/**\r
- Main entry for the FSP DXE module.\r
-\r
- This routine registers two callbacks to call fsp's notifies.\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
- @param[in] SystemTable A pointer to the EFI System Table.\r
-\r
- @retval EFI_SUCCESS The entry point is executed successfully.\r
- @retval other Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FspDxeEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_EVENT ReadyToBootEvent;\r
- VOID *Registration;\r
- EFI_EVENT ProtocolNotifyEvent;\r
-\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
- }\r
-\r
- ProtocolNotifyEvent = EfiCreateProtocolNotifyEvent (\r
- &gEfiPciEnumerationCompleteProtocolGuid,\r
- TPL_CALLBACK,\r
- OnPciEnumerationComplete,\r
- NULL,\r
- &Registration\r
- );\r
- ASSERT (ProtocolNotifyEvent != NULL);\r
-\r
- Status = EfiCreateEventReadyToBootEx (\r
- TPL_CALLBACK,\r
- OnReadyToBoot,\r
- NULL,\r
- &ReadyToBootEvent\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r