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