2 This driver will register two callbacks to call fsp's notifies.
4 Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Protocol/PciEnumerationComplete.h>
13 #include <Library/UefiDriverEntryPoint.h>
14 #include <Library/UefiBootServicesTableLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/UefiLib.h>
18 #include <Library/FspApiLib.h>
21 Relocate this image under 4G memory.
23 @param ImageHandle Handle of driver image.
24 @param SystemTable Pointer to system table.
26 @retval EFI_SUCCESS Image successfully relocated.
27 @retval EFI_ABORTED Failed to relocate image.
31 RelocateImageUnder4GIfNeeded (
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
36 FSP_INFO_HEADER
*mFspHeader
= NULL
;
39 PciEnumerationComplete Protocol notification event handler.
41 @param[in] Event Event whose notification function is being invoked.
42 @param[in] Context Pointer to the notification function's context.
46 OnPciEnumerationComplete (
51 NOTIFY_PHASE_PARAMS NotifyPhaseParams
;
56 // Try to locate it because gEfiPciEnumerationCompleteProtocolGuid will trigger it once when registration.
57 // Just return if it is not found.
59 Status
= gBS
->LocateProtocol (
60 &gEfiPciEnumerationCompleteProtocolGuid
,
64 if (EFI_ERROR (Status
)) {
68 NotifyPhaseParams
.Phase
= EnumInitPhaseAfterPciEnumeration
;
69 Status
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
70 if (Status
!= EFI_SUCCESS
) {
71 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", Status
));
73 DEBUG((DEBUG_INFO
, "FSP NotifyPhase AfterPciEnumeration Success.\n"));
78 Notification function of EVT_GROUP_READY_TO_BOOT event group.
80 This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.
81 When the Boot Manager is about to load and execute a boot option, it reclaims variable
82 storage if free size is below the threshold.
84 @param[in] Event Event whose notification function is being invoked.
85 @param[in] Context Pointer to the notification function's context.
95 NOTIFY_PHASE_PARAMS NotifyPhaseParams
;
98 gBS
->CloseEvent (Event
);
100 NotifyPhaseParams
.Phase
= EnumInitPhaseReadyToBoot
;
101 Status
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
102 if (Status
!= EFI_SUCCESS
) {
103 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", Status
));
105 DEBUG((DEBUG_INFO
, "FSP NotifyPhase ReadyToBoot Success.\n"));
110 Main entry for the FSP DXE module.
112 This routine registers two callbacks to call fsp's notifies.
114 @param[in] ImageHandle The firmware allocated handle for the EFI image.
115 @param[in] SystemTable A pointer to the EFI System Table.
117 @retval EFI_SUCCESS The entry point is executed successfully.
118 @retval other Some error occurs when executing this entry point.
124 IN EFI_HANDLE ImageHandle
,
125 IN EFI_SYSTEM_TABLE
*SystemTable
129 EFI_EVENT ReadyToBootEvent
;
131 EFI_EVENT ProtocolNotifyEvent
;
134 // Load this driver's image to memory
136 Status
= RelocateImageUnder4GIfNeeded (ImageHandle
, SystemTable
);
137 if (EFI_ERROR (Status
)) {
141 if (PcdGet32 (PcdFlashFvSecondFspBase
) == 0) {
142 mFspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
144 mFspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvSecondFspBase
));
146 DEBUG ((DEBUG_INFO
, "FspHeader - 0x%x\n", mFspHeader
));
147 if (mFspHeader
== NULL
) {
148 return EFI_DEVICE_ERROR
;
151 ProtocolNotifyEvent
= EfiCreateProtocolNotifyEvent (
152 &gEfiPciEnumerationCompleteProtocolGuid
,
154 OnPciEnumerationComplete
,
158 ASSERT (ProtocolNotifyEvent
!= NULL
);
160 Status
= EfiCreateEventReadyToBootEx (
166 ASSERT_EFI_ERROR (Status
);