2 This driver will register two callbacks to call fsp's notifies.
4 Copyright (c) 2014 - 2015, 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
;
46 // Try to locate it because gEfiPciEnumerationCompleteProtocolGuid will trigger it once when registration.
47 // Just return if it is not found.
49 Status
= gBS
->LocateProtocol (
50 &gEfiPciEnumerationCompleteProtocolGuid
,
54 if (EFI_ERROR (Status
)) {
58 NotifyPhaseParams
.Phase
= EnumInitPhaseAfterPciEnumeration
;
59 Status
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
60 if (Status
!= EFI_SUCCESS
) {
61 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", Status
));
63 DEBUG((DEBUG_INFO
, "FSP NotifyPhase AfterPciEnumeration Success.\n"));
68 Notification function of EVT_GROUP_READY_TO_BOOT event group.
70 This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.
71 When the Boot Manager is about to load and execute a boot option, it reclaims variable
72 storage if free size is below the threshold.
74 @param[in] Event Event whose notification function is being invoked.
75 @param[in] Context Pointer to the notification function's context.
85 NOTIFY_PHASE_PARAMS NotifyPhaseParams
;
88 gBS
->CloseEvent (Event
);
90 NotifyPhaseParams
.Phase
= EnumInitPhaseReadyToBoot
;
91 Status
= CallFspNotifyPhase (mFspHeader
, &NotifyPhaseParams
);
92 if (Status
!= EFI_SUCCESS
) {
93 DEBUG((DEBUG_ERROR
, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", Status
));
95 DEBUG((DEBUG_INFO
, "FSP NotifyPhase ReadyToBoot Success.\n"));
100 Main entry for the FSP DXE module.
102 This routine registers two callbacks to call fsp's notifies.
104 @param[in] ImageHandle The firmware allocated handle for the EFI image.
105 @param[in] SystemTable A pointer to the EFI System Table.
107 @retval EFI_SUCCESS The entry point is executed successfully.
108 @retval other Some error occurs when executing this entry point.
114 IN EFI_HANDLE ImageHandle
,
115 IN EFI_SYSTEM_TABLE
*SystemTable
119 EFI_EVENT ReadyToBootEvent
;
121 EFI_EVENT ProtocolNotifyEvent
;
123 mFspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
124 DEBUG ((DEBUG_INFO
, "FspHeader - 0x%x\n", mFspHeader
));
125 if (mFspHeader
== NULL
) {
126 return EFI_DEVICE_ERROR
;
129 ProtocolNotifyEvent
= EfiCreateProtocolNotifyEvent (
130 &gEfiPciEnumerationCompleteProtocolGuid
,
132 OnPciEnumerationComplete
,
136 ASSERT (ProtocolNotifyEvent
!= NULL
);
138 Status
= EfiCreateEventReadyToBootEx (
144 ASSERT_EFI_ERROR (Status
);