]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Updated EFI_MANAGED_NETWORK_PROTOCOL_GUID value according to UEFI 2.1b.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
CommitLineData
192f6d4c 1/*++\r
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
22--*/\r
23\r
192f6d4c 24#include <PeiMain.h>\r
25\r
26//\r
27//CAR is filled with this initial value during SEC phase\r
28//\r
29#define INIT_CAR_VALUE 0x5AA55AA5\r
30\r
31static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
32 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
33 &gEfiPeiMemoryDiscoveredPpiGuid,\r
34 NULL\r
35};\r
36\r
37//\r
38// Pei Core Module Variables\r
39//\r
40//\r
41static EFI_PEI_SERVICES mPS = {\r
42 {\r
43 PEI_SERVICES_SIGNATURE,\r
44 PEI_SERVICES_REVISION,\r
45 sizeof (EFI_PEI_SERVICES),\r
46 0,\r
47 0\r
48 },\r
49 PeiInstallPpi,\r
50 PeiReInstallPpi,\r
51 PeiLocatePpi,\r
52 PeiNotifyPpi,\r
53\r
54 PeiGetBootMode,\r
55 PeiSetBootMode,\r
56\r
57 PeiGetHobList,\r
58 PeiCreateHob,\r
59\r
60 PeiFvFindNextVolume,\r
61 PeiFfsFindNextFile,\r
62 PeiFfsFindSectionData,\r
63\r
64 PeiInstallPeiMemory,\r
65 PeiAllocatePages,\r
66 PeiAllocatePool,\r
67 (EFI_PEI_COPY_MEM)CopyMem,\r
68 (EFI_PEI_SET_MEM)SetMem,\r
69\r
70 PeiReportStatusCode,\r
71\r
14e8823a 72 PeiResetSystem,\r
73 NULL,\r
74 NULL,\r
75 NULL,\r
76 NULL,\r
77 NULL,\r
78 PeiRegisterForShadow\r
192f6d4c 79};\r
80\r
81EFI_STATUS\r
82EFIAPI\r
83PeiCore (\r
5aae0aa7 84 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
d074a8e1 85 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
5aae0aa7 86 IN VOID *Data\r
192f6d4c 87 )\r
88/*++\r
89\r
90Routine Description:\r
91\r
92 The entry routine to Pei Core, invoked by PeiMain during transition\r
93 from SEC to PEI. After switching stack in the PEI core, it will restart\r
94 with the old core data.\r
95\r
96Arguments:\r
97\r
5aae0aa7 98 SecCoreData - Points to a data structure containing information about the PEI core's operating\r
99 environment, such as the size and location of temporary RAM, the stack location and\r
100 the BFV location.\r
101 PpiList - Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
102 An empty PPI list consists of a single descriptor with the end-tag\r
103 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
104 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
105 that both the PEI Foundation and any modules can leverage the associated service\r
106 calls and/or code in these early PPIs\r
107 Data - Pointer to old core data that is used to initialize the\r
192f6d4c 108 core's data areas.\r
109\r
110Returns:\r
111\r
112 This function never returns\r
113 EFI_NOT_FOUND - Never reach\r
114\r
115--*/\r
116{\r
117 PEI_CORE_INSTANCE PrivateData;\r
118 EFI_STATUS Status;\r
119 PEI_CORE_TEMP_POINTERS TempPtr;\r
120 PEI_CORE_DISPATCH_DATA *DispatchData;\r
121 UINT64 mTick;\r
122 PEI_CORE_INSTANCE *OldCoreData;\r
123\r
124 mTick = 0;\r
125 OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
126\r
127 if (PerformanceMeasurementEnabled()) {\r
128 if (OldCoreData == NULL) {\r
129 mTick = GetPerformanceCounter ();\r
130 }\r
131 }\r
132\r
133 //\r
134 // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory()\r
135 // the 63-bit of address is set to 1.\r
136 //\r
137 SWITCH_TO_CACHE_MODE (OldCoreData);\r
138\r
139 if (OldCoreData != NULL) {\r
140 CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));\r
141 } else {\r
142 ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
143 }\r
144\r
145 PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
146 PrivateData.PS = &mPS;\r
147\r
148 //\r
149 // Initialize libraries that the PeiCore is linked against\r
150 // BUGBUG: The FfsHeader is passed in as NULL. Do we look it up or remove it from the lib init?\r
151 //\r
152 ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
153\r
5aae0aa7 154 InitializeMemoryServices (&PrivateData.PS, SecCoreData, OldCoreData);\r
192f6d4c 155\r
156 InitializePpiServices (&PrivateData.PS, OldCoreData);\r
157\r
158 InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
159\r
5aae0aa7 160 InitializeDispatcherData (&PrivateData.PS, OldCoreData, SecCoreData);\r
192f6d4c 161\r
162 if (OldCoreData != NULL) {\r
163\r
164 PERF_END (NULL,"PreMem", NULL, 0);\r
165 PERF_START (NULL,"PostMem", NULL, 0);\r
166\r
167 //\r
168 // The following code dumps out interesting cache as RAM usage information\r
169 // so we can keep tabs on how the cache as RAM is being utilized. The\r
170 // DEBUG_CODE_BEGIN macro is used to prevent this code from being compiled\r
171 // on a debug build.\r
172 //\r
173 DEBUG_CODE_BEGIN ();\r
174 UINTN *StackPointer;\r
175 UINTN StackValue;\r
176\r
177 StackValue = INIT_CAR_VALUE;\r
178 for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap;\r
179 ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam))\r
180 && StackValue == INIT_CAR_VALUE;\r
181 StackPointer++) {\r
182 StackValue = *StackPointer;\r
183 }\r
184\r
185 DEBUG ((EFI_D_INFO, "Total Cache as RAM: %d bytes.\n", OldCoreData->SizeOfCacheAsRam));\r
186 DEBUG ((EFI_D_INFO, " CAR stack ever used: %d bytes.\n",\r
187 ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer)\r
188 ));\r
189 DEBUG ((EFI_D_INFO, " CAR heap used: %d bytes.\n",\r
190 ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -\r
191 (UINTN) OldCoreData->HobList.Raw)\r
192 ));\r
193 DEBUG_CODE_END ();\r
194\r
195 //\r
196 // Alert any listeners that there is permanent memory available\r
197 //\r
198 \r
199 PERF_START (NULL,"DisMem", NULL, 0);\r
200 Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r
201 PERF_END (NULL,"DisMem", NULL, 0);\r
202\r
203 } else {\r
204\r
205 //\r
206 // Report Status Code EFI_SW_PC_INIT\r
207 //\r
208 REPORT_STATUS_CODE (\r
209 EFI_PROGRESS_CODE,\r
210 EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT\r
211 );\r
212\r
213 PERF_START (NULL,"PEI", NULL, mTick);\r
214 //\r
215 // If first pass, start performance measurement.\r
216 //\r
217 PERF_START (NULL,"PreMem", NULL, mTick);\r
218\r
219 //\r
220 // If SEC provided any PPI services to PEI, install them.\r
221 //\r
d074a8e1 222 if (PpiList != NULL) {\r
223 Status = PeiServicesInstallPpi (PpiList);\r
192f6d4c 224 ASSERT_EFI_ERROR (Status);\r
225 }\r
226 }\r
227\r
228 DispatchData = &PrivateData.DispatchData;\r
229\r
230 //\r
231 // Call PEIM dispatcher\r
232 //\r
5aae0aa7 233 PeiDispatcher (SecCoreData, &PrivateData, DispatchData);\r
192f6d4c 234\r
235 //\r
236 // Check if InstallPeiMemory service was called.\r
237 //\r
238 ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
239\r
240 PERF_END (NULL, "PostMem", NULL, 0);\r
241\r
242 Status = PeiServicesLocatePpi (\r
243 &gEfiDxeIplPpiGuid,\r
244 0,\r
245 NULL,\r
246 (VOID **)&TempPtr.DxeIpl\r
247 );\r
248 ASSERT_EFI_ERROR (Status);\r
249\r
250 DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
251 Status = TempPtr.DxeIpl->Entry (\r
252 TempPtr.DxeIpl,\r
253 &PrivateData.PS,\r
254 PrivateData.HobList\r
255 );\r
256\r
257 ASSERT_EFI_ERROR (Status);\r
258\r
259 return EFI_NOT_FOUND;\r
260}\r
261\r