Add IntelFsp2Pkg and IntelFsp2WrapperPkg.
[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
4 Copyright (c) 2016, Intel Corporation. All rights reserved.\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13\r
14#include "FspNotifyPhasePeim.h"\r
15\r
16/**\r
17\r
18 This function waits for FSP notify.\r
19 \r
20 @param This Entry point for DXE IPL PPI.\r
21 @param PeiServices General purpose services available to every PEIM.\r
22 @param HobList Address to the Pei HOB list.\r
23 \r
24 @return EFI_SUCCESS This function never returns.\r
25\r
26**/\r
27EFI_STATUS\r
28EFIAPI\r
29WaitForNotify (\r
30 IN CONST EFI_DXE_IPL_PPI *This,\r
31 IN EFI_PEI_SERVICES **PeiServices,\r
32 IN EFI_PEI_HOB_POINTERS HobList\r
33 );\r
34\r
35CONST EFI_DXE_IPL_PPI mDxeIplPpi = {\r
36 WaitForNotify\r
37};\r
38\r
39CONST EFI_PEI_PPI_DESCRIPTOR mInstallDxeIplPpi = {\r
40 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
41 &gEfiDxeIplPpiGuid,\r
42 (VOID *) &mDxeIplPpi\r
43};\r
44\r
45CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
46 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
47 &gEfiEndOfPeiSignalPpiGuid,\r
48 NULL\r
49};\r
50\r
51/**\r
52\r
53 This function waits for FSP notify.\r
54 \r
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
58 \r
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
84 FspSiliconInitDone ();\r
85\r
86 //\r
87 // BootLoader called FSP again through NotifyPhase\r
88 //\r
89 FspWaitForNotify ();\r
90\r
91 //\r
92 // Should not come here\r
93 //\r
94 while (TRUE) {\r
95 DEBUG ((DEBUG_ERROR, "No FSP API should be called after FSP is DONE!\n"));\r
96 SetFspApiReturnStatus (EFI_UNSUPPORTED);\r
97 Pei2LoaderSwitchStack ();\r
98 }\r
99\r
100 return EFI_SUCCESS;\r
101}\r
102\r
103/**\r
104 FSP notify phase PEI module entry point\r
105\r
106 @param[in] FileHandle Not used.\r
107 @param[in] PeiServices General purpose services available to every PEIM.\r
108\r
109 @retval EFI_SUCCESS The function completes successfully\r
110 @retval EFI_OUT_OF_RESOURCES Insufficient resources to create database\r
111**/\r
112EFI_STATUS\r
113FspNotifyPhasePeimEntryPoint (\r
114 IN EFI_PEI_FILE_HANDLE FileHandle,\r
115 IN CONST EFI_PEI_SERVICES **PeiServices\r
116 )\r
117{\r
118 EFI_STATUS Status;\r
119 VOID *OldDxeIplPpi;\r
120 EFI_PEI_PPI_DESCRIPTOR *OldDescriptor;\r
121\r
122 DEBUG ((DEBUG_INFO | DEBUG_INIT, "The entry of FspNotificationPeim\n"));\r
123\r
124 //\r
125 // Locate old DXE IPL PPI\r
126 //\r
127 Status = PeiServicesLocatePpi (\r
128 &gEfiDxeIplPpiGuid,\r
129 0,\r
130 &OldDescriptor,\r
131 &OldDxeIplPpi\r
132 );\r
133 ASSERT_EFI_ERROR (Status);\r
134\r
135 //\r
136 // Re-install the DXE IPL PPI to wait for notify\r
137 //\r
138 Status = PeiServicesReInstallPpi (OldDescriptor, &mInstallDxeIplPpi);\r
139 ASSERT_EFI_ERROR (Status);\r
140\r
141 return EFI_SUCCESS;\r
142}\r