2 This driver will register two callbacks to call fsp's notifies.
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/PciEnumerationComplete.h>
19 #include <Library/UefiDriverEntryPoint.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/UefiLib.h>
24 #include <Library/FspApiLib.h>
26 FSP_INFO_HEADER
*mFspHeader
= NULL
;
29 PciEnumerationComplete Protocol notification event handler.
31 @param[in] Event Event whose notification function is being invoked.
32 @param[in] Context Pointer to the notification function's context.
36 OnPciEnumerationComplete (
41 NOTIFY_PHASE_PARAMS NotifyPhaseParams
;
47 // Try to locate it because gEfiPciEnumerationCompleteProtocolGuid will trigger it once when registration.
48 // Just return if it is not found.
50 Status
= gBS
->LocateProtocol (
51 &gEfiPciEnumerationCompleteProtocolGuid
,
55 if (EFI_ERROR (Status
)) {
59 NotifyPhaseParams
.Phase
= EnumInitPhaseAfterPciEnumeration
;
60 FspStatus
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
61 if (FspStatus
!= FSP_SUCCESS
) {
62 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", FspStatus
));
64 DEBUG((DEBUG_INFO
, "FSP NotifyPhase AfterPciEnumeration Success.\n"));
69 Notification function of EVT_GROUP_READY_TO_BOOT event group.
71 This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.
72 When the Boot Manager is about to load and execute a boot option, it reclaims variable
73 storage if free size is below the threshold.
75 @param[in] Event Event whose notification function is being invoked.
76 @param[in] Context Pointer to the notification function's context.
86 NOTIFY_PHASE_PARAMS NotifyPhaseParams
;
89 gBS
->CloseEvent (Event
);
91 NotifyPhaseParams
.Phase
= EnumInitPhaseReadyToBoot
;
92 FspStatus
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
93 if (FspStatus
!= FSP_SUCCESS
) {
94 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", FspStatus
));
96 DEBUG((DEBUG_INFO
, "FSP NotifyPhase ReadyToBoot Success.\n"));
101 Main entry for the FSP DXE module.
103 This routine registers two callbacks to call fsp's notifies.
105 @param[in] ImageHandle The firmware allocated handle for the EFI image.
106 @param[in] SystemTable A pointer to the EFI System Table.
108 @retval EFI_SUCCESS The entry point is executed successfully.
109 @retval other Some error occurs when executing this entry point.
115 IN EFI_HANDLE ImageHandle
,
116 IN EFI_SYSTEM_TABLE
*SystemTable
120 EFI_EVENT ReadyToBootEvent
;
122 EFI_EVENT ProtocolNotifyEvent
;
124 mFspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
125 DEBUG ((DEBUG_INFO
, "FspHeader - 0x%x\n", mFspHeader
));
126 if (mFspHeader
== NULL
) {
127 return EFI_DEVICE_ERROR
;
130 ProtocolNotifyEvent
= EfiCreateProtocolNotifyEvent (
131 &gEfiPciEnumerationCompleteProtocolGuid
,
133 OnPciEnumerationComplete
,
137 ASSERT (ProtocolNotifyEvent
!= NULL
);
139 Status
= EfiCreateEventReadyToBootEx (
145 ASSERT_EFI_ERROR (Status
);