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