]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
UefiPayloadPkg: Enhance UEFI payload for coreboot and Slim Bootloader
[mirror_edk2.git] / IntelFsp2Pkg / FspNotifyPhase / FspNotifyPhasePeim.c
CommitLineData
cf1d4549
JY
1/** @file\r
2 Source file for FSP notify phase PEI module\r
3\r
e37bb20c 4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.\r
9672cd30 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
cf1d4549
JY
6**/\r
7\r
8#include "FspNotifyPhasePeim.h"\r
9\r
10/**\r
11\r
12 This function waits for FSP notify.\r
e37bb20c 13\r
cf1d4549
JY
14 @param This Entry point for DXE IPL PPI.\r
15 @param PeiServices General purpose services available to every PEIM.\r
16 @param HobList Address to the Pei HOB list.\r
e37bb20c 17\r
cf1d4549
JY
18 @return EFI_SUCCESS This function never returns.\r
19\r
20**/\r
21EFI_STATUS\r
22EFIAPI\r
23WaitForNotify (\r
24 IN CONST EFI_DXE_IPL_PPI *This,\r
25 IN EFI_PEI_SERVICES **PeiServices,\r
26 IN EFI_PEI_HOB_POINTERS HobList\r
27 );\r
28\r
29CONST EFI_DXE_IPL_PPI mDxeIplPpi = {\r
30 WaitForNotify\r
31};\r
32\r
33CONST EFI_PEI_PPI_DESCRIPTOR mInstallDxeIplPpi = {\r
34 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
35 &gEfiDxeIplPpiGuid,\r
36 (VOID *) &mDxeIplPpi\r
37};\r
38\r
39CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
40 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
41 &gEfiEndOfPeiSignalPpiGuid,\r
42 NULL\r
43};\r
44\r
a2e61f34
CC
45CONST EFI_PEI_PPI_DESCRIPTOR gFspReadyForNotifyPhasePpi = {\r
46 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
47 &gFspReadyForNotifyPhasePpiGuid,\r
48 NULL\r
49};\r
50\r
cf1d4549
JY
51/**\r
52\r
53 This function waits for FSP notify.\r
e37bb20c 54\r
cf1d4549
JY
55 @param This Entry point for DXE IPL PPI.\r
56 @param PeiServices General purpose services available to every PEIM.\r
57 @param HobList Address to the Pei HOB list.\r
e37bb20c 58\r
cf1d4549
JY
59 @return EFI_SUCCESS This function never returns.\r
60\r
61**/\r
62EFI_STATUS\r
63EFIAPI\r
64WaitForNotify (\r
65 IN CONST EFI_DXE_IPL_PPI *This,\r
66 IN EFI_PEI_SERVICES **PeiServices,\r
67 IN EFI_PEI_HOB_POINTERS HobList\r
68 )\r
69{\r
70 EFI_STATUS Status;\r
71\r
72 DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP HOB is located at 0x%08X\n", HobList));\r
73\r
74 //\r
75 // End of PEI phase signal\r
76 //\r
77 Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);\r
78 ASSERT_EFI_ERROR (Status);\r
79\r
80 //\r
81 // Give control back to BootLoader after FspSiliconInit\r
82 //\r
83 DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));\r
0e3f9ee1 84 FspSiliconInitDone2 (EFI_SUCCESS);\r
cf1d4549
JY
85\r
86 //\r
87 // BootLoader called FSP again through NotifyPhase\r
88 //\r
89 FspWaitForNotify ();\r
90\r
a2e61f34
CC
91 if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
92 //\r
93 // Should not come here\r
94 //\r
95 while (TRUE) {\r
96 DEBUG ((DEBUG_ERROR, "No FSP API should be called after FSP is DONE!\n"));\r
97 SetFspApiReturnStatus (EFI_UNSUPPORTED);\r
98 Pei2LoaderSwitchStack ();\r
99 }\r
cf1d4549
JY
100 }\r
101\r
102 return EFI_SUCCESS;\r
103}\r
104\r
105/**\r
106 FSP notify phase PEI module entry point\r
107\r
108 @param[in] FileHandle Not used.\r
109 @param[in] PeiServices General purpose services available to every PEIM.\r
110\r
111 @retval EFI_SUCCESS The function completes successfully\r
112 @retval EFI_OUT_OF_RESOURCES Insufficient resources to create database\r
113**/\r
114EFI_STATUS\r
115FspNotifyPhasePeimEntryPoint (\r
116 IN EFI_PEI_FILE_HANDLE FileHandle,\r
117 IN CONST EFI_PEI_SERVICES **PeiServices\r
118 )\r
119{\r
120 EFI_STATUS Status;\r
121 VOID *OldDxeIplPpi;\r
122 EFI_PEI_PPI_DESCRIPTOR *OldDescriptor;\r
123\r
124 DEBUG ((DEBUG_INFO | DEBUG_INIT, "The entry of FspNotificationPeim\n"));\r
125\r
a2e61f34
CC
126 if (GetFspGlobalDataPointer ()->FspMode == FSP_IN_API_MODE) {\r
127 //\r
128 // Locate old DXE IPL PPI\r
129 //\r
130 Status = PeiServicesLocatePpi (\r
131 &gEfiDxeIplPpiGuid,\r
132 0,\r
133 &OldDescriptor,\r
134 &OldDxeIplPpi\r
135 );\r
136 ASSERT_EFI_ERROR (Status);\r
137\r
138 //\r
139 // Re-install the DXE IPL PPI to wait for notify\r
140 //\r
141 Status = PeiServicesReInstallPpi (OldDescriptor, &mInstallDxeIplPpi);\r
142 ASSERT_EFI_ERROR (Status);\r
143 } else {\r
144 Status = PeiServicesInstallPpi (&gFspReadyForNotifyPhasePpi);\r
145 ASSERT_EFI_ERROR (Status);\r
146 }\r
cf1d4549
JY
147\r
148 return EFI_SUCCESS;\r
149}\r