]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Fix function comment to follows doxygen format.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
... / ...
CommitLineData
1/** @file\r
2 Pei Core Main Entry Point\r
3 \r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PeiMain.h>\r
16\r
17STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
18 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
19 &gEfiPeiMemoryDiscoveredPpiGuid,\r
20 NULL\r
21};\r
22\r
23//\r
24// Pei Core Module Variables\r
25//\r
26//\r
27STATIC EFI_PEI_SERVICES gPs = {\r
28 {\r
29 PEI_SERVICES_SIGNATURE,\r
30 PEI_SERVICES_REVISION,\r
31 sizeof (EFI_PEI_SERVICES),\r
32 0,\r
33 0\r
34 },\r
35 PeiInstallPpi,\r
36 PeiReInstallPpi,\r
37 PeiLocatePpi,\r
38 PeiNotifyPpi,\r
39\r
40 PeiGetBootMode,\r
41 PeiSetBootMode,\r
42\r
43 PeiGetHobList,\r
44 PeiCreateHob,\r
45\r
46 PeiFvFindNextVolume,\r
47 PeiFfsFindNextFile,\r
48 PeiFfsFindSectionData,\r
49\r
50 PeiInstallPeiMemory, \r
51 PeiAllocatePages,\r
52 PeiAllocatePool,\r
53 (EFI_PEI_COPY_MEM)CopyMem,\r
54 (EFI_PEI_SET_MEM)SetMem,\r
55\r
56 PeiReportStatusCode,\r
57 PeiResetSystem,\r
58\r
59 NULL,\r
60 NULL,\r
61\r
62 PeiFfsFindFileByName,\r
63 PeiFfsGetFileInfo,\r
64 PeiFfsGetVolumeInfo,\r
65 PeiRegisterForShadow\r
66};\r
67\r
68/**\r
69\r
70 The entry routine to Pei Core, invoked by PeiMain during transition\r
71 from SEC to PEI. After switching stack in the PEI core, it will restart\r
72 with the old core data.\r
73\r
74\r
75 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
76 environment, such as the size and location of temporary RAM, the stack location and\r
77 the BFV location.\r
78 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
79 An empty PPI list consists of a single descriptor with the end-tag\r
80 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
81 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
82 that both the PEI Foundation and any modules can leverage the associated service\r
83 calls and/or code in these early PPIs\r
84 @param Data Pointer to old core data that is used to initialize the\r
85 core's data areas.\r
86\r
87 @retval EFI_NOT_FOUND Never reach\r
88\r
89**/\r
90EFI_STATUS\r
91EFIAPI\r
92PeiCore (\r
93 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
94 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
95 IN VOID *Data\r
96 )\r
97{\r
98 PEI_CORE_INSTANCE PrivateData;\r
99 EFI_STATUS Status;\r
100 PEI_CORE_TEMP_POINTERS TempPtr;\r
101 UINT64 mTick;\r
102 PEI_CORE_INSTANCE *OldCoreData;\r
103 EFI_PEI_CPU_IO_PPI *CpuIo;\r
104 EFI_PEI_PCI_CFG2_PPI *PciCfg;\r
105 PEI_CORE_ENTRY_POINT ShadowedPeiCore;\r
106\r
107 mTick = 0;\r
108 OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
109\r
110 if (PerformanceMeasurementEnabled()) {\r
111 if (OldCoreData == NULL) {\r
112 mTick = GetPerformanceCounter ();\r
113 }\r
114 }\r
115\r
116 if (OldCoreData != NULL) {\r
117 ShadowedPeiCore = (PEI_CORE_ENTRY_POINT) (UINTN) OldCoreData->ShadowedPeiCore;\r
118 if (ShadowedPeiCore != NULL) {\r
119 OldCoreData->ShadowedPeiCore = NULL;\r
120 ShadowedPeiCore (\r
121 SecCoreData,\r
122 PpiList,\r
123 OldCoreData\r
124 );\r
125 }\r
126\r
127 CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));\r
128 \r
129 CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r
130 PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r
131 \r
132 CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
133 \r
134 PrivateData.ServiceTableShadow.CpuIo = CpuIo;\r
135 PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
136 } else {\r
137 ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
138 PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
139 CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
140 }\r
141\r
142 PrivateData.PS = &PrivateData.ServiceTableShadow;\r
143\r
144 //\r
145 // Initialize libraries that the PeiCore is linked against\r
146 // BUGBUG: The FileHandle is passed in as NULL. Do we look it up or remove it from the lib init?\r
147 //\r
148 ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
149\r
150 InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r
151\r
152 InitializePpiServices (&PrivateData, OldCoreData);\r
153\r
154 //\r
155 // Save PeiServicePointer so that it can be retrieved anywhere.\r
156 //\r
157 SetPeiServicesTablePointer(&PrivateData.PS);\r
158 \r
159 if (OldCoreData != NULL) {\r
160\r
161 PERF_END (NULL,"PreMem", NULL, 0);\r
162 PERF_START (NULL,"PostMem", NULL, 0);\r
163\r
164 //\r
165 // Alert any listeners that there is permanent memory available\r
166 //\r
167 \r
168 PERF_START (NULL,"DisMem", NULL, 0);\r
169 Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r
170 PERF_END (NULL,"DisMem", NULL, 0);\r
171\r
172 } else {\r
173\r
174 //\r
175 // Report Status Code EFI_SW_PC_INIT\r
176 //\r
177 REPORT_STATUS_CODE (\r
178 EFI_PROGRESS_CODE,\r
179 FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r
180 );\r
181\r
182 PERF_START (NULL,"PEI", NULL, mTick);\r
183 //\r
184 // If first pass, start performance measurement.\r
185 //\r
186 PERF_START (NULL,"PreMem", NULL, mTick);\r
187\r
188 //\r
189 // If SEC provided any PPI services to PEI, install them.\r
190 //\r
191 if (PpiList != NULL) {\r
192 Status = PeiServicesInstallPpi (PpiList);\r
193 ASSERT_EFI_ERROR (Status);\r
194 }\r
195 }\r
196\r
197 InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
198\r
199 InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r
200\r
201 //\r
202 // Install Pei Load File PPI. \r
203 //\r
204 InitializeImageServices (&PrivateData, OldCoreData);\r
205\r
206 //\r
207 // Call PEIM dispatcher\r
208 //\r
209 PeiDispatcher (SecCoreData, &PrivateData);\r
210\r
211 //\r
212 // Check if InstallPeiMemory service was called.\r
213 //\r
214 ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
215\r
216 PERF_END (NULL, "PostMem", NULL, 0);\r
217\r
218 Status = PeiServicesLocatePpi (\r
219 &gEfiDxeIplPpiGuid,\r
220 0,\r
221 NULL,\r
222 (VOID **)&TempPtr.DxeIpl\r
223 );\r
224 ASSERT_EFI_ERROR (Status);\r
225\r
226 DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
227 Status = TempPtr.DxeIpl->Entry (\r
228 TempPtr.DxeIpl,\r
229 &PrivateData.PS,\r
230 PrivateData.HobList\r
231 );\r
232\r
233 ASSERT_EFI_ERROR (Status);\r
234\r
235 return EFI_NOT_FOUND;\r
236}\r
237\r
238\r