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