]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
Get entire variable data for efi varstore at first time.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Dispatcher / Dispatcher.c
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 EFI PEI Core dispatch services\r
3 \r
63e70348 4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
192f6d4c 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
615c6dd0 13**/\r
192f6d4c 14\r
0d516397 15#include "PeiMain.h"\r
192f6d4c 16\r
b1f6a7c6 17///\r
3d4d0c34 18/// temporary memory is filled with this initial value during SEC phase\r
b1f6a7c6 19///\r
a7715e73 20#define INIT_CAR_VALUE 0x5AA55AA5\r
21\r
797a9d67 22typedef struct {\r
23 EFI_STATUS_CODE_DATA DataHeader;\r
24 EFI_HANDLE Handle;\r
25} PEIM_FILE_HANDLE_EXTENDED_DATA;\r
26\r
b1f6a7c6 27/**\r
b0d803fe 28\r
29 Discover all Peims and optional Apriori file in one FV. There is at most one\r
30 Apriori file in one FV.\r
31\r
b0d803fe 32\r
3b428ade 33 @param Private Pointer to the private data passed in from caller\r
34 @param CoreFileHandle The instance of PEI_CORE_FV_HANDLE.\r
b0d803fe 35\r
b1f6a7c6 36**/\r
37VOID\r
38DiscoverPeimsAndOrderWithApriori (\r
39 IN PEI_CORE_INSTANCE *Private,\r
3b428ade 40 IN PEI_CORE_FV_HANDLE *CoreFileHandle\r
b1f6a7c6 41 )\r
b0d803fe 42{\r
43 EFI_STATUS Status;\r
890e5417 44 EFI_PEI_FILE_HANDLE FileHandle;\r
177aabe6 45 EFI_PEI_FILE_HANDLE AprioriFileHandle;\r
b0d803fe 46 EFI_GUID *Apriori;\r
47 UINTN Index;\r
48 UINTN Index2;\r
49 UINTN PeimIndex;\r
50 UINTN PeimCount;\r
51 EFI_GUID *Guid;\r
890e5417 52 EFI_PEI_FILE_HANDLE TempFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
177aabe6 53 EFI_GUID FileGuid[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
3b428ade 54 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
55 EFI_FV_FILE_INFO FileInfo;\r
56 \r
57 FvPpi = CoreFileHandle->FvPpi;\r
58 \r
b0d803fe 59 //\r
60 // Walk the FV and find all the PEIMs and the Apriori file.\r
61 //\r
62 AprioriFileHandle = NULL;\r
63 Private->CurrentFvFileHandles[0] = NULL;\r
64 Guid = NULL;\r
65 FileHandle = NULL;\r
66\r
67 //\r
68 // If the current Fv has been scanned, directly get its cachable record.\r
69 //\r
70 if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {\r
71 CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, sizeof (Private->CurrentFvFileHandles));\r
72 return;\r
73 }\r
74\r
75 //\r
76 // Go ahead to scan this Fv, and cache FileHandles within it.\r
77 //\r
4140a663 78 for (PeimCount = 0; PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv); PeimCount++) {\r
3b428ade 79 Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);\r
b0d803fe 80 if (Status != EFI_SUCCESS) {\r
81 break;\r
82 }\r
58dcdada 83\r
b0d803fe 84 Private->CurrentFvFileHandles[PeimCount] = FileHandle;\r
85 }\r
97b2c9b5
LG
86 \r
87 //\r
88 // Check whether the count of Peims exceeds the max support PEIMs in a FV image\r
89 // If more Peims are required in a FV image, PcdPeiCoreMaxPeimPerFv can be set to a larger value in DSC file.\r
90 //\r
4140a663 91 ASSERT (PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv));\r
b0d803fe 92\r
3b428ade 93 //\r
94 // Get Apriori File handle\r
95 //\r
58dcdada 96 Private->AprioriCount = 0;\r
3b428ade 97 Status = FvPpi->FindFileByName (FvPpi, &gPeiAprioriFileNameGuid, &CoreFileHandle->FvHandle, &AprioriFileHandle);\r
98 if (!EFI_ERROR(Status) && AprioriFileHandle != NULL) {\r
b0d803fe 99 //\r
100 // Read the Apriori file\r
101 //\r
3b428ade 102 Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);\r
b0d803fe 103 if (!EFI_ERROR (Status)) {\r
104 //\r
105 // Calculate the number of PEIMs in the A Priori list\r
106 //\r
3b428ade 107 Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);\r
108 ASSERT_EFI_ERROR (Status);\r
890e5417
SZ
109 Private->AprioriCount = FileInfo.BufferSize;\r
110 if (IS_SECTION2 (FileInfo.Buffer)) {\r
111 Private->AprioriCount -= sizeof (EFI_COMMON_SECTION_HEADER2);\r
112 } else {\r
113 Private->AprioriCount -= sizeof (EFI_COMMON_SECTION_HEADER);\r
114 }\r
b0d803fe 115 Private->AprioriCount /= sizeof (EFI_GUID);\r
58dcdada 116\r
82b8c8df 117 ZeroMem (FileGuid, sizeof (FileGuid));\r
b0d803fe 118 for (Index = 0; Index < PeimCount; Index++) {\r
119 //\r
120 // Make an array of file name guids that matches the FileHandle array so we can convert\r
121 // quickly from file name to file handle\r
122 //\r
3b428ade 123 Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index], &FileInfo);\r
124 CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));\r
b0d803fe 125 }\r
126\r
127 //\r
128 // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori file.\r
890e5417 129 // Add available PEIMs in Apriori file into TempFileHandles array at first.\r
b0d803fe 130 //\r
131 Index2 = 0;\r
132 for (Index = 0; Index2 < Private->AprioriCount; Index++) {\r
133 while (Index2 < Private->AprioriCount) {\r
134 Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2++]);\r
135 if (Guid != NULL) {\r
136 break;\r
137 }\r
138 }\r
139 if (Guid == NULL) {\r
58dcdada 140 break;\r
b0d803fe 141 }\r
142 PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);\r
143 TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];\r
144\r
145 //\r
146 // Since we have copied the file handle we can remove it from this list.\r
147 //\r
148 Private->CurrentFvFileHandles[PeimIndex] = NULL;\r
149 }\r
150\r
151 //\r
152 // Update valid Aprioricount\r
153 //\r
154 Private->AprioriCount = Index;\r
58dcdada 155\r
b0d803fe 156 //\r
157 // Add in any PEIMs not in the Apriori file\r
158 //\r
159 for (;Index < PeimCount; Index++) {\r
160 for (Index2 = 0; Index2 < PeimCount; Index2++) {\r
161 if (Private->CurrentFvFileHandles[Index2] != NULL) {\r
162 TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];\r
163 Private->CurrentFvFileHandles[Index2] = NULL;\r
164 break;\r
165 }\r
166 }\r
167 }\r
168 //\r
169 //Index the end of array contains re-range Pei moudle.\r
170 //\r
171 TempFileHandles[Index] = NULL;\r
58dcdada 172\r
b0d803fe 173 //\r
174 // Private->CurrentFvFileHandles is currently in PEIM in the FV order.\r
58dcdada 175 // We need to update it to start with files in the A Priori list and\r
176 // then the remaining files in PEIM order.\r
b0d803fe 177 //\r
178 CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof (Private->CurrentFvFileHandles));\r
179 }\r
180 }\r
181 //\r
182 // Cache the current Fv File Handle. So that we don't have to scan the Fv again.\r
183 // Instead, we can retrieve the file handles within this Fv from cachable data.\r
184 //\r
185 Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;\r
186 CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, Private->CurrentFvFileHandles, sizeof (Private->CurrentFvFileHandles));\r
58dcdada 187\r
188}\r
189\r
54ea99a7 190//\r
191// This is the minimum memory required by DxeCore initialization. When LMFA feature enabled,\r
192// This part of memory still need reserved on the very top of memory so that the DXE Core could \r
193// use these memory for data initialization. This macro should be sync with the same marco\r
194// defined in DXE Core.\r
195//\r
196#define MINIMUM_INITIAL_MEMORY_SIZE 0x10000\r
9bfb4940 197/**\r
198 This function is to test if the memory range described in resource HOB is available or not. \r
199 \r
200 This function should only be invoked when Loading Module at Fixed Address(LMFA) feature is enabled. Some platform may allocate the \r
201 memory before PeiLoadFixAddressHook in invoked. so this function is to test if the memory range described by the input resource HOB is\r
202 available or not.\r
203\r
204 @param PrivateData Pointer to the private data passed in from caller\r
205 @param ResourceHob Pointer to a resource HOB which described the memory range described by the input resource HOB\r
206**/\r
207BOOLEAN\r
208PeiLoadFixAddressIsMemoryRangeAvailable (\r
209 IN PEI_CORE_INSTANCE *PrivateData,\r
210 IN EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob\r
211 )\r
212{\r
213 EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
214 BOOLEAN IsAvailable;\r
215 EFI_PEI_HOB_POINTERS Hob;\r
216 \r
217 IsAvailable = TRUE;\r
218 if (PrivateData == NULL || ResourceHob == NULL) {\r
219 return FALSE;\r
220 }\r
221 //\r
222 // test if the memory range describe in the HOB is already allocated.\r
223 //\r
224 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
225 // \r
226 // See if this is a memory allocation HOB \r
227 //\r
228 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) { \r
229 MemoryHob = Hob.MemoryAllocation;\r
230 if(MemoryHob->AllocDescriptor.MemoryBaseAddress == ResourceHob->PhysicalStart && \r
231 MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength == ResourceHob->PhysicalStart + ResourceHob->ResourceLength) {\r
232 IsAvailable = FALSE;\r
233 break; \r
234 }\r
235 }\r
236 }\r
237 \r
238 return IsAvailable;\r
239 \r
240}\r
54ea99a7 241/**\r
242 Hook function for Loading Module at Fixed Address feature\r
243 \r
244 This function should only be invoked when Loading Module at Fixed Address(LMFA) feature is enabled. When feature is\r
245 configured as Load Modules at Fix Absolute Address, this function is to validate the top address assigned by user. When \r
246 feature is configured as Load Modules at Fixed Offset, the functino is to find the top address which is TOLM-TSEG in general. \r
247 And also the function will re-install PEI memory. \r
b0d803fe 248\r
54ea99a7 249 @param PrivateData Pointer to the private data passed in from caller\r
250\r
251**/\r
252VOID\r
253PeiLoadFixAddressHook(\r
254 IN PEI_CORE_INSTANCE *PrivateData\r
255 )\r
256{\r
257 EFI_PHYSICAL_ADDRESS TopLoadingAddress;\r
258 UINT64 PeiMemorySize;\r
259 UINT64 TotalReservedMemorySize;\r
260 UINT64 MemoryRangeEnd;\r
261 EFI_PHYSICAL_ADDRESS HighAddress; \r
262 EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;\r
263 EFI_HOB_RESOURCE_DESCRIPTOR *NextResourceHob;\r
264 EFI_HOB_RESOURCE_DESCRIPTOR *CurrentResourceHob;\r
265 EFI_PEI_HOB_POINTERS CurrentHob;\r
266 EFI_PEI_HOB_POINTERS Hob;\r
267 EFI_PEI_HOB_POINTERS NextHob;\r
9bfb4940 268 EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
54ea99a7 269 //\r
270 // Initialize Local Variables\r
271 //\r
272 CurrentResourceHob = NULL;\r
273 ResourceHob = NULL;\r
274 NextResourceHob = NULL;\r
54ea99a7 275 HighAddress = 0;\r
276 TopLoadingAddress = 0;\r
277 MemoryRangeEnd = 0;\r
278 CurrentHob.Raw = PrivateData->HobList.Raw;\r
279 PeiMemorySize = PrivateData->PhysicalMemoryLength;\r
280 //\r
281 // The top reserved memory include 3 parts: the topest range is for DXE core initialization with the size MINIMUM_INITIAL_MEMORY_SIZE\r
282 // then RuntimeCodePage range and Boot time code range.\r
283 // \r
e18fa167 284 TotalReservedMemorySize = MINIMUM_INITIAL_MEMORY_SIZE + EFI_PAGES_TO_SIZE(PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber));\r
285 TotalReservedMemorySize+= EFI_PAGES_TO_SIZE(PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber)) ; \r
54ea99a7 286 //\r
287 // PEI memory range lies below the top reserved memory\r
288 // \r
289 TotalReservedMemorySize += PeiMemorySize;\r
e18fa167 290 \r
852081fc 291 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressRuntimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber)));\r
292 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressBootTimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber)));\r
293 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressPeiCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressPeiCodePageNumber))); \r
294 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Total Reserved Memory Size = 0x%lx.\n", TotalReservedMemorySize));\r
54ea99a7 295 //\r
296 // Loop through the system memory typed hob to merge the adjacent memory range \r
297 //\r
298 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
299 // \r
300 // See if this is a resource descriptor HOB \r
301 //\r
302 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
303 \r
304 ResourceHob = Hob.ResourceDescriptor; \r
305 //\r
306 // If range described in this hob is not system memory or heigher than MAX_ADDRESS, ignored.\r
307 //\r
63e70348 308 if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY ||\r
54ea99a7 309 ResourceHob->PhysicalStart + ResourceHob->ResourceLength > MAX_ADDRESS) {\r
310 continue;\r
311 } \r
312 \r
313 for (NextHob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(NextHob); NextHob.Raw = GET_NEXT_HOB(NextHob)) { \r
314 if (NextHob.Raw == Hob.Raw){\r
315 continue;\r
316 } \r
317 //\r
318 // See if this is a resource descriptor HOB\r
319 //\r
320 if (GET_HOB_TYPE (NextHob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
321 \r
322 NextResourceHob = NextHob.ResourceDescriptor;\r
323 //\r
324 // test if range described in this NextResourceHob is system memory and have the same attribute.\r
325 // Note: Here is a assumption that system memory should always be healthy even without test.\r
326 // \r
327 if (NextResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
328 (((NextResourceHob->ResourceAttribute^ResourceHob->ResourceAttribute)&(~EFI_RESOURCE_ATTRIBUTE_TESTED)) == 0)){\r
329 \r
330 //\r
331 // See if the memory range described in ResourceHob and NextResourceHob is adjacent\r
332 //\r
333 if ((ResourceHob->PhysicalStart <= NextResourceHob->PhysicalStart && \r
334 ResourceHob->PhysicalStart + ResourceHob->ResourceLength >= NextResourceHob->PhysicalStart)|| \r
335 (ResourceHob->PhysicalStart >= NextResourceHob->PhysicalStart&&\r
336 ResourceHob->PhysicalStart <= NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength)) {\r
337 \r
338 MemoryRangeEnd = ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength)>(NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength)) ?\r
339 (ResourceHob->PhysicalStart + ResourceHob->ResourceLength):(NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength);\r
340 \r
341 ResourceHob->PhysicalStart = (ResourceHob->PhysicalStart < NextResourceHob->PhysicalStart) ? \r
342 ResourceHob->PhysicalStart : NextResourceHob->PhysicalStart;\r
343 \r
344 \r
345 ResourceHob->ResourceLength = (MemoryRangeEnd - ResourceHob->PhysicalStart);\r
346 \r
347 ResourceHob->ResourceAttribute = ResourceHob->ResourceAttribute & (~EFI_RESOURCE_ATTRIBUTE_TESTED);\r
348 //\r
349 // Delete the NextResourceHob by marking it as unused.\r
350 //\r
351 GET_HOB_TYPE (NextHob) = EFI_HOB_TYPE_UNUSED;\r
352 \r
353 }\r
354 }\r
355 } \r
356 }\r
357 } \r
358 }\r
9bfb4940 359 //\r
360 // Some platform is already allocated pages before the HOB re-org. Here to build dedicated resource HOB to describe\r
361 // the allocated memory range\r
362 //\r
363 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
364 // \r
365 // See if this is a memory allocation HOB \r
366 //\r
367 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
368 MemoryHob = Hob.MemoryAllocation;\r
369 for (NextHob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(NextHob); NextHob.Raw = GET_NEXT_HOB(NextHob)) {\r
370 //\r
371 // See if this is a resource descriptor HOB\r
372 //\r
373 if (GET_HOB_TYPE (NextHob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
374 NextResourceHob = NextHob.ResourceDescriptor;\r
375 //\r
376 // If range described in this hob is not system memory or heigher than MAX_ADDRESS, ignored.\r
377 //\r
63e70348 378 if (NextResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY || NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength > MAX_ADDRESS) {\r
9bfb4940 379 continue;\r
380 }\r
381 //\r
382 // If the range describe in memory allocation HOB belongs to the memroy range described by the resource hob\r
383 // \r
384 if (MemoryHob->AllocDescriptor.MemoryBaseAddress >= NextResourceHob->PhysicalStart && \r
385 MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength <= NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength) {\r
386 //\r
387 // Build seperate resource hob for this allocated range\r
388 // \r
389 if (MemoryHob->AllocDescriptor.MemoryBaseAddress > NextResourceHob->PhysicalStart) {\r
390 BuildResourceDescriptorHob (\r
391 EFI_RESOURCE_SYSTEM_MEMORY, \r
392 NextResourceHob->ResourceAttribute,\r
393 NextResourceHob->PhysicalStart, \r
394 (MemoryHob->AllocDescriptor.MemoryBaseAddress - NextResourceHob->PhysicalStart) \r
395 );\r
396 }\r
397 if (MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength < NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength) {\r
398 BuildResourceDescriptorHob (\r
399 EFI_RESOURCE_SYSTEM_MEMORY, \r
400 NextResourceHob->ResourceAttribute,\r
401 MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength, \r
402 (NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength -(MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength)) \r
403 );\r
404 }\r
405 NextResourceHob->PhysicalStart = MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
406 NextResourceHob->ResourceLength = MemoryHob->AllocDescriptor.MemoryLength;\r
407 break;\r
408 }\r
409 }\r
410 }\r
411 }\r
412 }\r
413\r
54ea99a7 414 //\r
415 // Try to find and validate the TOP address.\r
416 // \r
852081fc 417 if ((INT64)PcdGet64(PcdLoadModuleAtFixAddressEnable) > 0 ) {\r
54ea99a7 418 //\r
419 // The LMFA feature is enabled as load module at fixed absolute address.\r
420 //\r
852081fc 421 TopLoadingAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64(PcdLoadModuleAtFixAddressEnable);\r
54ea99a7 422 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Loading module at fixed absolute address.\n"));\r
423 //\r
424 // validate the Address. Loop the resource descriptor HOB to make sure the address is in valid memory range\r
425 //\r
426 if ((TopLoadingAddress & EFI_PAGE_MASK) != 0) {\r
852081fc 427 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid since top address should be page align. \n", TopLoadingAddress)); \r
54ea99a7 428 ASSERT (FALSE); \r
429 }\r
430 //\r
431 // Search for a memory region that is below MAX_ADDRESS and in which TopLoadingAddress lies \r
432 //\r
433 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
434 //\r
435 // See if this is a resource descriptor HOB\r
436 //\r
437 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
438\r
439 ResourceHob = Hob.ResourceDescriptor;\r
440 //\r
441 // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
442 // \r
443 if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
444 ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS) {\r
445 //\r
446 // See if Top address specified by user is valid.\r
447 //\r
448 if (ResourceHob->PhysicalStart + TotalReservedMemorySize < TopLoadingAddress && \r
9bfb4940 449 (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MINIMUM_INITIAL_MEMORY_SIZE) >= TopLoadingAddress && \r
450 PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
54ea99a7 451 CurrentResourceHob = ResourceHob; \r
452 CurrentHob = Hob;\r
453 break;\r
9bfb4940 454 }\r
54ea99a7 455 }\r
456 } \r
457 } \r
458 if (CurrentResourceHob != NULL) {\r
852081fc 459 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO:Top Address 0x%lx is valid \n", TopLoadingAddress));\r
54ea99a7 460 TopLoadingAddress += MINIMUM_INITIAL_MEMORY_SIZE; \r
461 } else {\r
852081fc 462 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid \n", TopLoadingAddress)); \r
54ea99a7 463 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The recommended Top Address for the platform is: \n")); \r
464 //\r
465 // Print the recomended Top address range.\r
466 // \r
467 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
468 //\r
469 // See if this is a resource descriptor HOB\r
470 //\r
471 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
472 \r
473 ResourceHob = Hob.ResourceDescriptor;\r
474 //\r
475 // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
476 // \r
477 if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
478 ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS) {\r
479 //\r
480 // See if Top address specified by user is valid.\r
481 //\r
9bfb4940 482 if (ResourceHob->ResourceLength > TotalReservedMemorySize && PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
852081fc 483 DEBUG ((EFI_D_INFO, "(0x%lx, 0x%lx)\n", \r
54ea99a7 484 (ResourceHob->PhysicalStart + TotalReservedMemorySize -MINIMUM_INITIAL_MEMORY_SIZE), \r
485 (ResourceHob->PhysicalStart + ResourceHob->ResourceLength -MINIMUM_INITIAL_MEMORY_SIZE) \r
486 )); \r
487 }\r
488 }\r
489 }\r
490 } \r
491 //\r
492 // Assert here \r
493 //\r
9bfb4940 494 ASSERT (FALSE); \r
495 return; \r
54ea99a7 496 } \r
497 } else {\r
498 //\r
499 // The LMFA feature is enabled as load module at fixed offset relative to TOLM\r
500 // Parse the Hob list to find the topest available memory. Generally it is (TOLM - TSEG)\r
501 //\r
502 //\r
503 // Search for a tested memory region that is below MAX_ADDRESS\r
504 //\r
505 for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
506 //\r
507 // See if this is a resource descriptor HOB \r
508 //\r
509 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
510 \r
511 ResourceHob = Hob.ResourceDescriptor; \r
512 //\r
513 // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
514 //\r
515 if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY && \r
516 ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS &&\r
9bfb4940 517 ResourceHob->ResourceLength > TotalReservedMemorySize && PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
54ea99a7 518 //\r
519 // See if this is the highest largest system memory region below MaxAddress\r
520 //\r
521 if (ResourceHob->PhysicalStart > HighAddress) {\r
522 CurrentResourceHob = ResourceHob;\r
523 CurrentHob = Hob;\r
524 HighAddress = CurrentResourceHob->PhysicalStart;\r
525 }\r
526 }\r
527 } \r
528 }\r
529 if (CurrentResourceHob == NULL) {\r
530 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The System Memory is too small\n")); \r
531 //\r
532 // Assert here \r
533 //\r
9bfb4940 534 ASSERT (FALSE);\r
535 return; \r
54ea99a7 536 } else {\r
537 TopLoadingAddress = CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength ; \r
538 } \r
539 }\r
540 \r
541 if (CurrentResourceHob != NULL) {\r
542 //\r
9bfb4940 543 // rebuild resource HOB for PEI memmory and reserved memory\r
54ea99a7 544 //\r
545 BuildResourceDescriptorHob (\r
9bfb4940 546 EFI_RESOURCE_SYSTEM_MEMORY, \r
54ea99a7 547 (\r
548 EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
549 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
550 EFI_RESOURCE_ATTRIBUTE_TESTED |\r
551 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
552 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
553 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
554 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
555 ),\r
9bfb4940 556 (TopLoadingAddress - TotalReservedMemorySize), \r
557 TotalReservedMemorySize \r
54ea99a7 558 );\r
559 //\r
9bfb4940 560 // rebuild resource for the remain memory if necessary\r
54ea99a7 561 //\r
562 if (CurrentResourceHob->PhysicalStart < TopLoadingAddress - TotalReservedMemorySize) {\r
563 BuildResourceDescriptorHob (\r
9bfb4940 564 EFI_RESOURCE_SYSTEM_MEMORY, \r
54ea99a7 565 (\r
566 EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
567 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
568 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
569 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
570 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
571 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
572 ),\r
9bfb4940 573 CurrentResourceHob->PhysicalStart, \r
574 (TopLoadingAddress - TotalReservedMemorySize - CurrentResourceHob->PhysicalStart) \r
54ea99a7 575 );\r
576 }\r
577 if (CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength > TopLoadingAddress ) {\r
578 BuildResourceDescriptorHob (\r
579 EFI_RESOURCE_SYSTEM_MEMORY, \r
580 (\r
581 EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
582 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
583 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
584 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
585 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
586 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
587 ),\r
588 TopLoadingAddress, \r
589 (CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength - TopLoadingAddress) \r
590 );\r
591 }\r
592 //\r
593 // Delete CurrentHob by marking it as unused since the the memory range described by is rebuilt.\r
594 //\r
595 GET_HOB_TYPE (CurrentHob) = EFI_HOB_TYPE_UNUSED; \r
596 }\r
597\r
598 //\r
599 // Cache the top address for Loading Module at Fixed Address feature\r
600 //\r
601 PrivateData->LoadModuleAtFixAddressTopAddress = TopLoadingAddress - MINIMUM_INITIAL_MEMORY_SIZE;\r
852081fc 602 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Top address = 0x%lx\n", PrivateData->LoadModuleAtFixAddressTopAddress)); \r
54ea99a7 603 //\r
604 // reinstall the PEI memory relative to TopLoadingAddress\r
605 //\r
606 PrivateData->PhysicalMemoryBegin = TopLoadingAddress - TotalReservedMemorySize;\r
607 PrivateData->FreePhysicalMemoryTop = PrivateData->PhysicalMemoryBegin + PeiMemorySize;\r
608}\r
0f9ebb32
LG
609\r
610/**\r
611 This routine is invoked in switch stack as PeiCore Entry.\r
612\r
613 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
614 environment, such as the size and location of temporary RAM, the stack location and\r
615 the BFV location.\r
616 @param Private Pointer to old core data that is used to initialize the\r
617 core's data areas.\r
618**/\r
619VOID\r
620EFIAPI\r
621PeiCoreEntry (\r
622 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
623 IN PEI_CORE_INSTANCE *Private\r
624 )\r
625{\r
626 //\r
627 // Entry PEI Phase 2\r
628 //\r
629 PeiCore (SecCoreData, NULL, Private);\r
630}\r
631\r
b1f6a7c6 632/**\r
192f6d4c 633 Conduct PEIM dispatch.\r
634\r
b1f6a7c6 635 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
5aae0aa7 636 environment, such as the size and location of temporary RAM, the stack location and\r
637 the BFV location.\r
b1f6a7c6 638 @param Private Pointer to the private data passed in from caller\r
192f6d4c 639\r
b1f6a7c6 640**/\r
641VOID\r
642PeiDispatcher (\r
643 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
644 IN PEI_CORE_INSTANCE *Private\r
645 )\r
192f6d4c 646{\r
b0d803fe 647 EFI_STATUS Status;\r
648 UINT32 Index1;\r
649 UINT32 Index2;\r
6c7a807a 650 CONST EFI_PEI_SERVICES **PeiServices;\r
b0d803fe 651 EFI_PEI_FILE_HANDLE PeimFileHandle;\r
652 UINTN FvCount;\r
653 UINTN PeimCount;\r
654 UINT32 AuthenticationState;\r
655 EFI_PHYSICAL_ADDRESS EntryPoint;\r
797a9d67 656 EFI_PEIM_ENTRY_POINT2 PeimEntryPoint;\r
b0d803fe 657 UINTN SaveCurrentPeimCount;\r
1053e0c5 658 UINTN SaveCurrentFvCount;\r
b0d803fe 659 EFI_PEI_FILE_HANDLE SaveCurrentFileHandle;\r
797a9d67 660 PEIM_FILE_HANDLE_EXTENDED_DATA ExtendedData;\r
d0a3ead2 661 EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;\r
ef05e063 662 UINT64 NewStackSize;\r
0f9ebb32 663 EFI_PHYSICAL_ADDRESS BaseOfNewHeap;\r
ef05e063 664 EFI_PHYSICAL_ADDRESS TopOfNewStack;\r
665 EFI_PHYSICAL_ADDRESS TopOfOldStack;\r
666 EFI_PHYSICAL_ADDRESS TemporaryRamBase;\r
667 UINTN TemporaryRamSize;\r
0f9ebb32
LG
668 UINTN TemporaryStackSize;\r
669 VOID *TemporaryStackBase;\r
670 UINTN PeiTemporaryRamSize;\r
671 VOID *PeiTemporaryRamBase;\r
ef05e063 672 UINTN StackOffset;\r
673 BOOLEAN StackOffsetPositive;\r
0f9ebb32
LG
674 EFI_PHYSICAL_ADDRESS HoleMemBase;\r
675 UINTN HoleMemSize;\r
288f9b38 676 EFI_FV_FILE_INFO FvFileInfo;\r
3b428ade 677 PEI_CORE_FV_HANDLE *CoreFvHandle;\r
54ea99a7 678 VOID *LoadFixPeiCodeBegin;\r
0f9ebb32
LG
679 EFI_PHYSICAL_ADDRESS TempBase1;\r
680 UINTN TempSize1;\r
681 EFI_PHYSICAL_ADDRESS TempBase2;\r
682 UINTN TempSize2;\r
683 UINTN Index;\r
684 \r
4140a663 685 PeiServices = (CONST EFI_PEI_SERVICES **) &Private->Ps;\r
b0d803fe 686 PeimEntryPoint = NULL;\r
687 PeimFileHandle = NULL;\r
288f9b38 688 EntryPoint = 0;\r
b0d803fe 689\r
5d7f3126 690 if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {\r
b0d803fe 691 //\r
692 // Once real memory is available, shadow the RegisterForShadow modules. And meanwhile\r
693 // update the modules' status from PEIM_STATE_REGISITER_FOR_SHADOW to PEIM_STATE_DONE.\r
694 //\r
695 SaveCurrentPeimCount = Private->CurrentPeimCount;\r
1053e0c5 696 SaveCurrentFvCount = Private->CurrentPeimFvCount;\r
b0d803fe 697 SaveCurrentFileHandle = Private->CurrentFileHandle;\r
698\r
1053e0c5 699 for (Index1 = 0; Index1 <= SaveCurrentFvCount; Index1++) {\r
4140a663 700 for (Index2 = 0; (Index2 < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {\r
b0d803fe 701 if (Private->Fv[Index1].PeimState[Index2] == PEIM_STATE_REGISITER_FOR_SHADOW) {\r
58dcdada 702 PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];\r
b0d803fe 703 Status = PeiLoadImage (\r
4140a663 704 (CONST EFI_PEI_SERVICES **) &Private->Ps,\r
58dcdada 705 PeimFileHandle,\r
341a658f 706 PEIM_STATE_REGISITER_FOR_SHADOW,\r
58dcdada 707 &EntryPoint,\r
b0d803fe 708 &AuthenticationState\r
709 );\r
710 if (Status == EFI_SUCCESS) {\r
711 //\r
712 // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE\r
713 //\r
714 Private->Fv[Index1].PeimState[Index2]++;\r
1053e0c5 715 Private->CurrentFileHandle = PeimFileHandle;\r
58dcdada 716 Private->CurrentPeimFvCount = Index1;\r
717 Private->CurrentPeimCount = Index2;\r
b0d803fe 718 //\r
719 // Call the PEIM entry point\r
720 //\r
797a9d67 721 PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint;\r
58dcdada 722\r
087e13cb 723 PERF_START (PeimFileHandle, "PEIM", NULL, 0);\r
4140a663 724 PeimEntryPoint(PeimFileHandle, (const EFI_PEI_SERVICES **) &Private->Ps);\r
087e13cb 725 PERF_END (PeimFileHandle, "PEIM", NULL, 0);\r
58dcdada 726 }\r
727\r
b0d803fe 728 //\r
729 // Process the Notify list and dispatch any notifies for\r
730 // newly installed PPIs.\r
731 //\r
732 ProcessNotifyList (Private);\r
733 }\r
734 }\r
735 }\r
58dcdada 736 Private->CurrentFileHandle = SaveCurrentFileHandle;\r
737 Private->CurrentPeimFvCount = SaveCurrentFvCount;\r
738 Private->CurrentPeimCount = SaveCurrentPeimCount;\r
b0d803fe 739 }\r
192f6d4c 740\r
741 //\r
742 // This is the main dispatch loop. It will search known FVs for PEIMs and\r
743 // attempt to dispatch them. If any PEIM gets dispatched through a single\r
744 // pass of the dispatcher, it will start over from the Bfv again to see\r
745 // if any new PEIMs dependencies got satisfied. With a well ordered\r
746 // FV where PEIMs are found in the order their dependencies are also\r
747 // satisfied, this dipatcher should run only once.\r
748 //\r
b0d803fe 749 do {\r
82b8c8df 750 //\r
751 // In case that reenter PeiCore happens, the last pass record is still available. \r
752 //\r
753 if (!Private->PeimDispatcherReenter) {\r
754 Private->PeimNeedingDispatch = FALSE;\r
755 Private->PeimDispatchOnThisPass = FALSE;\r
756 } else {\r
757 Private->PeimDispatcherReenter = FALSE;\r
758 }\r
759 \r
b0d803fe 760 for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
3b428ade 761 CoreFvHandle = FindNextCoreFvHandle (Private, FvCount);\r
762 ASSERT (CoreFvHandle != NULL);\r
763 \r
2a00326e 764 //\r
3b428ade 765 // If the FV has corresponding EFI_PEI_FIRMWARE_VOLUME_PPI instance, then dispatch it.\r
2a00326e 766 //\r
3b428ade 767 if (CoreFvHandle->FvPpi == NULL) {\r
768 continue;\r
769 }\r
770 \r
771 Private->CurrentPeimFvCount = FvCount;\r
192f6d4c 772\r
b0d803fe 773 if (Private->CurrentPeimCount == 0) {\r
774 //\r
775 // When going through each FV, at first, search Apriori file to\r
58dcdada 776 // reorder all PEIMs to ensure the PEIMs in Apriori file to get\r
b0d803fe 777 // dispatch at first.\r
778 //\r
3b428ade 779 DiscoverPeimsAndOrderWithApriori (Private, CoreFvHandle);\r
b0d803fe 780 }\r
192f6d4c 781\r
782 //\r
b0d803fe 783 // Start to dispatch all modules within the current Fv.\r
192f6d4c 784 //\r
58dcdada 785 for (PeimCount = Private->CurrentPeimCount;\r
4140a663 786 (PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->CurrentFvFileHandles[PeimCount] != NULL);\r
b0d803fe 787 PeimCount++) {\r
788 Private->CurrentPeimCount = PeimCount;\r
789 PeimFileHandle = Private->CurrentFileHandle = Private->CurrentFvFileHandles[PeimCount];\r
790\r
791 if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {\r
792 if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r
82b8c8df 793 Private->PeimNeedingDispatch = TRUE;\r
b0d803fe 794 } else {\r
3b428ade 795 Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, PeimFileHandle, &FvFileInfo);\r
288f9b38
LG
796 ASSERT_EFI_ERROR (Status);\r
797 if (FvFileInfo.FileType == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
798 //\r
799 // For Fv type file, Produce new FV PPI and FV hob\r
800 //\r
c7935105
SZ
801 Status = ProcessFvFile (Private, &Private->Fv[FvCount], PeimFileHandle);\r
802 if (Status == EFI_SUCCESS) {\r
803 //\r
804 // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED\r
805 //\r
806 Private->Fv[FvCount].PeimState[PeimCount]++;\r
807 Private->PeimDispatchOnThisPass = TRUE;\r
808 }\r
288f9b38
LG
809 } else {\r
810 //\r
811 // For PEIM driver, Load its entry point\r
812 //\r
813 Status = PeiLoadImage (\r
58dcdada 814 PeiServices,\r
815 PeimFileHandle,\r
341a658f 816 PEIM_STATE_NOT_DISPATCHED,\r
58dcdada 817 &EntryPoint,\r
288f9b38
LG
818 &AuthenticationState\r
819 );\r
c7935105 820 if (Status == EFI_SUCCESS) {\r
b0d803fe 821 //\r
c7935105
SZ
822 // The PEIM has its dependencies satisfied, and its entry point\r
823 // has been found, so invoke it.\r
b0d803fe 824 //\r
c7935105 825 PERF_START (PeimFileHandle, "PEIM", NULL, 0);\r
58dcdada 826\r
c7935105
SZ
827 ExtendedData.Handle = (EFI_HANDLE)PeimFileHandle;\r
828\r
829 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
830 EFI_PROGRESS_CODE,\r
831 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN),\r
832 (VOID *)(&ExtendedData),\r
833 sizeof (ExtendedData)\r
834 );\r
835\r
836 Status = VerifyPeim (Private, CoreFvHandle->FvHandle, PeimFileHandle, AuthenticationState);\r
837 if (Status != EFI_SECURITY_VIOLATION) {\r
838 //\r
839 // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED\r
840 //\r
841 Private->Fv[FvCount].PeimState[PeimCount]++;\r
288f9b38
LG
842 //\r
843 // Call the PEIM entry point for PEIM driver\r
844 //\r
797a9d67 845 PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint;\r
846 PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r
c7935105 847 Private->PeimDispatchOnThisPass = TRUE;\r
288f9b38 848 }\r
797a9d67 849\r
c7935105
SZ
850 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
851 EFI_PROGRESS_CODE,\r
852 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END),\r
853 (VOID *)(&ExtendedData),\r
854 sizeof (ExtendedData)\r
855 );\r
856 PERF_END (PeimFileHandle, "PEIM", NULL, 0);\r
b0d803fe 857\r
c7935105 858 }\r
58dcdada 859 }\r
860\r
861 if (Private->SwitchStackSignal) {\r
a7715e73 862 //\r
3d4d0c34 863 // Before switch stack from temporary memory to permenent memory, caculate the heap and stack\r
a7715e73 864 // usage in temporary memory for debuging.\r
865 //\r
866 DEBUG_CODE_BEGIN ();\r
96317468 867 UINT32 *StackPointer;\r
a7715e73 868 \r
96317468 869 for (StackPointer = (UINT32*)SecCoreData->StackBase;\r
870 (StackPointer < (UINT32*)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)) \\r
a7715e73 871 && (*StackPointer == INIT_CAR_VALUE);\r
872 StackPointer ++);\r
873 \r
ef05e063 874 DEBUG ((EFI_D_INFO, "Temp Stack : BaseAddress=0x%p Length=0x%X\n", SecCoreData->StackBase, (UINT32)SecCoreData->StackSize));\r
875 DEBUG ((EFI_D_INFO, "Temp Heap : BaseAddress=0x%p Length=0x%X\n", Private->HobList.Raw, (UINT32)((UINTN) Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom - (UINTN) Private->HobList.Raw)));\r
3d4d0c34 876 DEBUG ((EFI_D_INFO, "Total temporary memory: %d bytes.\n", (UINT32)SecCoreData->TemporaryRamSize));\r
877 DEBUG ((EFI_D_INFO, " temporary memory stack ever used: %d bytes.\n",\r
ef05e063 878 (UINT32)(SecCoreData->StackSize - ((UINTN) StackPointer - (UINTN)SecCoreData->StackBase))\r
a7715e73 879 ));\r
3d4d0c34 880 DEBUG ((EFI_D_INFO, " temporary memory heap used: %d bytes.\n",\r
ef05e063 881 (UINT32)((UINTN)Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom - (UINTN)Private->HobList.Raw)\r
a7715e73 882 ));\r
883 DEBUG_CODE_END ();\r
884 \r
f73b3df8 885 if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r
54ea99a7 886 //\r
887 // Loading Module at Fixed Address is enabled\r
888 //\r
ef05e063 889 PeiLoadFixAddressHook (Private);\r
890\r
4fb72076 891 //\r
ef05e063 892 // If Loading Module at Fixed Address is enabled, Allocating memory range for Pei code range.\r
4fb72076 893 //\r
894 LoadFixPeiCodeBegin = AllocatePages((UINTN)PcdGet32(PcdLoadFixAddressPeiCodePageNumber));\r
3978f5d9 895 DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PeiCodeBegin = 0x%lX, PeiCodeTop= 0x%lX\n", (UINT64)(UINTN)LoadFixPeiCodeBegin, (UINT64)((UINTN)LoadFixPeiCodeBegin + PcdGet32(PcdLoadFixAddressPeiCodePageNumber) * EFI_PAGE_SIZE)));\r
54ea99a7 896 }\r
897 \r
a3a15d21 898 //\r
58dcdada 899 // Reserve the size of new stack at bottom of physical memory\r
a3a15d21 900 //\r
ef05e063 901 // The size of new stack in permenent memory must be the same size \r
902 // or larger than the size of old stack in temporary memory.\r
58dcdada 903 // But if new stack is smaller than the size of old stack, we also reserve\r
904 // the size of old stack at bottom of permenent memory.\r
905 //\r
ef05e063 906 NewStackSize = RShiftU64 (Private->PhysicalMemoryLength, 1);\r
907 NewStackSize = ALIGN_VALUE (NewStackSize, EFI_PAGE_SIZE);\r
908 NewStackSize = MIN (PcdGet32(PcdPeiCoreMaxPeiStackSize), NewStackSize);\r
909 DEBUG ((EFI_D_INFO, "Old Stack size %d, New stack size %d\n", (UINT32)SecCoreData->StackSize, (UINT32)NewStackSize));\r
910 ASSERT (NewStackSize >= SecCoreData->StackSize);\r
d74eeda8 911\r
58dcdada 912 //\r
ef05e063 913 // Caculate stack offset and heap offset between temporary memory and new permement \r
914 // memory seperately.\r
58dcdada 915 //\r
ef05e063 916 TopOfOldStack = (UINTN)SecCoreData->StackBase + SecCoreData->StackSize;\r
917 TopOfNewStack = Private->PhysicalMemoryBegin + NewStackSize;\r
ef05e063 918 if (TopOfNewStack >= TopOfOldStack) {\r
919 StackOffsetPositive = TRUE;\r
920 StackOffset = (UINTN)(TopOfNewStack - TopOfOldStack);\r
921 } else {\r
922 StackOffsetPositive = FALSE;\r
923 StackOffset = (UINTN)(TopOfOldStack - TopOfNewStack);\r
924 }\r
424b7c9f 925 Private->StackOffsetPositive = StackOffsetPositive;\r
926 Private->StackOffset = StackOffset;\r
ef05e063 927\r
928 DEBUG ((EFI_D_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (UINT64)Private->HeapOffset, (UINT64)(StackOffset)));\r
192f6d4c 929\r
930 //\r
ef05e063 931 // Build Stack HOB that describes the permanent memory stack\r
192f6d4c 932 //\r
ef05e063 933 DEBUG ((EFI_D_INFO, "Stack Hob: BaseAddress=0x%lX Length=0x%lX\n", TopOfNewStack - NewStackSize, NewStackSize));\r
934 BuildStackHob (TopOfNewStack - NewStackSize, NewStackSize);\r
935\r
40f26b8f 936 //\r
ef05e063 937 // Cache information from SecCoreData into locals before SecCoreData is converted to a permanent memory address\r
40f26b8f 938 //\r
0f9ebb32
LG
939 TemporaryRamBase = (EFI_PHYSICAL_ADDRESS)(UINTN)SecCoreData->TemporaryRamBase;\r
940 TemporaryRamSize = SecCoreData->TemporaryRamSize;\r
941 TemporaryStackSize = SecCoreData->StackSize;\r
942 TemporaryStackBase = SecCoreData->StackBase;\r
943 PeiTemporaryRamSize = SecCoreData->PeiTemporaryRamSize;\r
944 PeiTemporaryRamBase = SecCoreData->PeiTemporaryRamBase;\r
945 \r
192f6d4c 946 //\r
58dcdada 947 // TemporaryRamSupportPpi is produced by platform's SEC\r
192f6d4c 948 //\r
ef05e063 949 Status = PeiServicesLocatePpi (\r
58dcdada 950 &gEfiTemporaryRamSupportPpiGuid,\r
951 0,\r
952 NULL,\r
953 (VOID**)&TemporaryRamSupportPpi\r
954 );\r
58dcdada 955 if (!EFI_ERROR (Status)) {\r
0f9ebb32
LG
956 //\r
957 // Heap Offset\r
958 //\r
959 BaseOfNewHeap = TopOfNewStack;\r
960 if (BaseOfNewHeap >= (UINTN)SecCoreData->PeiTemporaryRamBase) {\r
961 Private->HeapOffsetPositive = TRUE;\r
962 Private->HeapOffset = (UINTN)(BaseOfNewHeap - (UINTN)SecCoreData->PeiTemporaryRamBase);\r
963 } else {\r
964 Private->HeapOffsetPositive = FALSE;\r
965 Private->HeapOffset = (UINTN)((UINTN)SecCoreData->PeiTemporaryRamBase - BaseOfNewHeap);\r
966 }\r
967 \r
968 //\r
969 // Caculate new HandOffTable and PrivateData address in permanent memory's stack\r
970 //\r
971 if (StackOffsetPositive) {\r
972 SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID *)SecCoreData + StackOffset);\r
973 Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private + StackOffset);\r
974 } else {\r
975 SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID *)SecCoreData - StackOffset);\r
976 Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - StackOffset);\r
977 }\r
978\r
40f26b8f 979 //\r
ef05e063 980 // Temporary Ram Support PPI is provided by platform, it will copy \r
40f26b8f 981 // temporary memory to permenent memory and do stack switching.\r
ef05e063 982 // After invoking Temporary Ram Support PPI, the following code's \r
983 // stack is in permanent memory.\r
40f26b8f 984 //\r
58dcdada 985 TemporaryRamSupportPpi->TemporaryRamMigration (\r
ef05e063 986 PeiServices,\r
987 TemporaryRamBase,\r
988 (EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize),\r
989 TemporaryRamSize\r
58dcdada 990 );\r
991\r
0f9ebb32
LG
992 //\r
993 // Entry PEI Phase 2\r
994 //\r
995 PeiCore (SecCoreData, NULL, Private);\r
58dcdada 996 } else {\r
b414ea4b 997 //\r
0f9ebb32 998 // Heap Offset\r
b414ea4b 999 //\r
0f9ebb32
LG
1000 BaseOfNewHeap = TopOfNewStack;\r
1001 HoleMemBase = TopOfNewStack;\r
1002 HoleMemSize = TemporaryRamSize - PeiTemporaryRamSize - TemporaryStackSize;\r
1003 if (HoleMemSize != 0) {\r
1004 BaseOfNewHeap = BaseOfNewHeap + HoleMemSize;\r
1005 }\r
1006 if (BaseOfNewHeap >= (UINTN)SecCoreData->PeiTemporaryRamBase) {\r
1007 Private->HeapOffsetPositive = TRUE;\r
1008 Private->HeapOffset = (UINTN)(BaseOfNewHeap - (UINTN)SecCoreData->PeiTemporaryRamBase);\r
1009 } else {\r
1010 Private->HeapOffsetPositive = FALSE;\r
1011 Private->HeapOffset = (UINTN)((UINTN)SecCoreData->PeiTemporaryRamBase - BaseOfNewHeap);\r
1012 }\r
58dcdada 1013\r
0f9ebb32
LG
1014 //\r
1015 // Migrate Heap\r
1016 //\r
1017 CopyMem ((UINT8 *) (UINTN) BaseOfNewHeap, (UINT8 *) PeiTemporaryRamBase, PeiTemporaryRamSize);\r
1018 \r
1019 //\r
1020 // Migrate Stack\r
1021 //\r
1022 CopyMem ((UINT8 *) (UINTN) (TopOfNewStack - TemporaryStackSize), TemporaryStackBase, TemporaryStackSize);\r
1023 \r
1024 //\r
1025 // Copy Hole Range Data\r
1026 // Convert PPI from Hole. \r
1027 //\r
1028 if (HoleMemSize != 0) {\r
1029 //\r
1030 // Prepare Hole\r
1031 //\r
1032 if (PeiTemporaryRamBase < TemporaryStackBase) {\r
1033 TempBase1 = (EFI_PHYSICAL_ADDRESS) (UINTN) PeiTemporaryRamBase;\r
1034 TempSize1 = PeiTemporaryRamSize;\r
1035 TempBase2 = (EFI_PHYSICAL_ADDRESS) (UINTN) TemporaryStackBase;\r
1036 TempSize2 = TemporaryStackSize;\r
1037 } else {\r
1038 TempBase1 = (EFI_PHYSICAL_ADDRESS) (UINTN) TemporaryStackBase;\r
1039 TempSize1 = TemporaryStackSize;\r
1040 TempBase2 =(EFI_PHYSICAL_ADDRESS) (UINTN) PeiTemporaryRamBase;\r
1041 TempSize2 = PeiTemporaryRamSize;\r
1042 }\r
1043 if (TemporaryRamBase < TempBase1) {\r
1044 Private->HoleData[0].Base = TemporaryRamBase;\r
1045 Private->HoleData[0].Size = (UINTN) (TempBase1 - TemporaryRamBase);\r
1046 }\r
1047 if (TempBase1 + TempSize1 < TempBase2) {\r
1048 Private->HoleData[1].Base = TempBase1 + TempSize1;\r
1049 Private->HoleData[1].Size = (UINTN) (TempBase2 - TempBase1 - TempSize1);\r
1050 }\r
1051 if (TempBase2 + TempSize2 < TemporaryRamBase + TemporaryRamSize) {\r
1052 Private->HoleData[2].Base = TempBase2 + TempSize2;\r
1053 Private->HoleData[2].Size = (UINTN) (TemporaryRamBase + TemporaryRamSize - TempBase2 - TempSize2);\r
1054 }\r
1055 \r
1056 //\r
1057 // Copy Hole Range data.\r
1058 //\r
1059 for (Index = 0; Index < HOLE_MAX_NUMBER; Index ++) {\r
1060 if (Private->HoleData[Index].Size > 0) {\r
1061 if (HoleMemBase > Private->HoleData[Index].Base) {\r
1062 Private->HoleData[Index].OffsetPositive = TRUE;\r
1063 Private->HoleData[Index].Offset = (UINTN) (HoleMemBase - Private->HoleData[Index].Base);\r
1064 } else {\r
1065 Private->HoleData[Index].OffsetPositive = FALSE;\r
1066 Private->HoleData[Index].Offset = (UINTN) (Private->HoleData[Index].Base - HoleMemBase);\r
1067 }\r
1068 CopyMem ((VOID *) (UINTN) HoleMemBase, (VOID *) (UINTN) Private->HoleData[Index].Base, Private->HoleData[Index].Size);\r
1069 HoleMemBase = HoleMemBase + Private->HoleData[Index].Size;\r
1070 }\r
1071 }\r
1072 }\r
1073\r
1074 //\r
1075 // Switch new stack\r
1076 //\r
1077 SwitchStack (\r
1078 (SWITCH_STACK_ENTRY_POINT)(UINTN)PeiCoreEntry,\r
1079 (VOID *) SecCoreData,\r
1080 (VOID *) Private,\r
1081 (VOID *) (UINTN) TopOfNewStack\r
1082 );\r
1083 }\r
b0d803fe 1084\r
58dcdada 1085 //\r
1086 // Code should not come here\r
1087 //\r
ef05e063 1088 ASSERT (FALSE);\r
192f6d4c 1089 }\r
192f6d4c 1090\r
58dcdada 1091 //\r
1092 // Process the Notify list and dispatch any notifies for\r
1093 // newly installed PPIs.\r
1094 //\r
1095 ProcessNotifyList (Private);\r
1096\r
b0d803fe 1097 if ((Private->PeiMemoryInstalled) && (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_REGISITER_FOR_SHADOW) && \\r
5d7f3126 1098 (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {\r
b0d803fe 1099 //\r
58dcdada 1100 // If memory is availble we shadow images by default for performance reasons.\r
1101 // We call the entry point a 2nd time so the module knows it's shadowed.\r
b0d803fe 1102 //\r
1103 //PERF_START (PeiServices, L"PEIM", PeimFileHandle, 0);\r
e67ca95c 1104 ASSERT (PeimEntryPoint != NULL);\r
797a9d67 1105 PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r
b0d803fe 1106 //PERF_END (PeiServices, L"PEIM", PeimFileHandle, 0);\r
58dcdada 1107\r
b0d803fe 1108 //\r
1109 // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE\r
1110 //\r
1111 Private->Fv[FvCount].PeimState[PeimCount]++;\r
192f6d4c 1112\r
192f6d4c 1113 //\r
b0d803fe 1114 // Process the Notify list and dispatch any notifies for\r
1115 // newly installed PPIs.\r
192f6d4c 1116 //\r
b0d803fe 1117 ProcessNotifyList (Private);\r
192f6d4c 1118 }\r
1119 }\r
1120 }\r
192f6d4c 1121 }\r
192f6d4c 1122\r
b0d803fe 1123 //\r
1124 // We set to NULL here to optimize the 2nd entry to this routine after\r
1125 // memory is found. This reprevents rescanning of the FV. We set to\r
1126 // NULL here so we start at the begining of the next FV\r
1127 //\r
1128 Private->CurrentFileHandle = NULL;\r
1129 Private->CurrentPeimCount = 0;\r
1130 //\r
1131 // Before walking through the next FV,Private->CurrentFvFileHandles[]should set to NULL\r
1132 //\r
1133 SetMem (Private->CurrentFvFileHandles, sizeof (Private->CurrentFvFileHandles), 0);\r
192f6d4c 1134 }\r
1135\r
1136 //\r
58dcdada 1137 // Before making another pass, we should set Private->CurrentPeimFvCount =0 to go\r
b0d803fe 1138 // through all the FV.\r
192f6d4c 1139 //\r
b0d803fe 1140 Private->CurrentPeimFvCount = 0;\r
192f6d4c 1141\r
1142 //\r
58dcdada 1143 // PeimNeedingDispatch being TRUE means we found a PEIM that did not get\r
b0d803fe 1144 // dispatched. So we need to make another pass\r
192f6d4c 1145 //\r
58dcdada 1146 // PeimDispatchOnThisPass being TRUE means we dispatched a PEIM on this\r
b0d803fe 1147 // pass. If we did not dispatch a PEIM there is no point in trying again\r
1148 // as it will fail the next time too (nothing has changed).\r
192f6d4c 1149 //\r
82b8c8df 1150 } while (Private->PeimNeedingDispatch && Private->PeimDispatchOnThisPass);\r
192f6d4c 1151\r
192f6d4c 1152}\r
1153\r
b1f6a7c6 1154/**\r
192f6d4c 1155 Initialize the Dispatcher's data members\r
1156\r
b1f6a7c6 1157 @param PrivateData PeiCore's private data structure\r
1158 @param OldCoreData Old data from SecCore\r
192f6d4c 1159 NULL if being run in non-permament memory mode.\r
b1f6a7c6 1160 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
5aae0aa7 1161 environment, such as the size and location of temporary RAM, the stack location and\r
1162 the BFV location.\r
192f6d4c 1163\r
b1f6a7c6 1164 @return None.\r
192f6d4c 1165\r
b1f6a7c6 1166**/\r
1167VOID\r
1168InitializeDispatcherData (\r
1169 IN PEI_CORE_INSTANCE *PrivateData,\r
1170 IN PEI_CORE_INSTANCE *OldCoreData,\r
1171 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
1172 )\r
192f6d4c 1173{\r
192f6d4c 1174 if (OldCoreData == NULL) {\r
82b8c8df 1175 PrivateData->PeimDispatcherReenter = FALSE;\r
b0d803fe 1176 PeiInitializeFv (PrivateData, SecCoreData);\r
8e0e40ed 1177 } else {\r
7ec93917 1178 PeiReinitializeFv (PrivateData);\r
192f6d4c 1179 }\r
1180\r
1181 return;\r
1182}\r
1183\r
b1f6a7c6 1184/**\r
1185 This routine parses the Dependency Expression, if available, and\r
1186 decides if the module can be executed.\r
1187\r
1188\r
1189 @param Private PeiCore's private data structure\r
1190 @param FileHandle PEIM's file handle\r
1191 @param PeimCount Peim count in all dispatched PEIMs.\r
192f6d4c 1192\r
b1f6a7c6 1193 @retval TRUE Can be dispatched\r
1194 @retval FALSE Cannot be dispatched\r
1195\r
1196**/\r
192f6d4c 1197BOOLEAN\r
1198DepexSatisfied (\r
b0d803fe 1199 IN PEI_CORE_INSTANCE *Private,\r
1200 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1201 IN UINTN PeimCount\r
192f6d4c 1202 )\r
192f6d4c 1203{\r
288f9b38
LG
1204 EFI_STATUS Status;\r
1205 VOID *DepexData;\r
6a55eea3 1206 EFI_FV_FILE_INFO FileInfo;\r
b0d803fe 1207\r
6a55eea3 1208 Status = PeiServicesFfsGetFileInfo (FileHandle, &FileInfo);\r
1209 if (EFI_ERROR (Status)) {\r
1210 DEBUG ((DEBUG_DISPATCH, "Evaluate PEI DEPEX for FFS(Unknown)\n"));\r
1211 } else {\r
1212 DEBUG ((DEBUG_DISPATCH, "Evaluate PEI DEPEX for FFS(%g)\n", &FileInfo.FileName));\r
1213 }\r
1214 \r
b0d803fe 1215 if (PeimCount < Private->AprioriCount) {\r
1216 //\r
1217 // If its in the A priori file then we set Depex to TRUE\r
1218 //\r
6a55eea3 1219 DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));\r
b0d803fe 1220 return TRUE;\r
1221 }\r
58dcdada 1222\r
288f9b38 1223 //\r
58dcdada 1224 // Depex section not in the encapsulated section.\r
288f9b38
LG
1225 //\r
1226 Status = PeiServicesFfsFindSectionData (\r
1227 EFI_SECTION_PEI_DEPEX,\r
58dcdada 1228 FileHandle,\r
288f9b38
LG
1229 (VOID **)&DepexData\r
1230 );\r
b0d803fe 1231\r
192f6d4c 1232 if (EFI_ERROR (Status)) {\r
b0d803fe 1233 //\r
1234 // If there is no DEPEX, assume the module can be executed\r
1235 //\r
6a55eea3 1236 DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (No DEPEX)\n"));\r
192f6d4c 1237 return TRUE;\r
1238 }\r
1239\r
1240 //\r
1241 // Evaluate a given DEPEX\r
1242 //\r
4140a663 1243 return PeimDispatchReadiness (&Private->Ps, DepexData);\r
192f6d4c 1244}\r
1245\r
14e8823a 1246/**\r
1247 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
1248 discovery permanent memory.\r
1249\r
b1f6a7c6 1250 @param FileHandle File handle of a PEIM.\r
58dcdada 1251\r
b1f6a7c6 1252 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
1253 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
1254 @retval EFI_SUCCESS Successfully to register itself.\r
14e8823a 1255\r
58dcdada 1256**/\r
14e8823a 1257EFI_STATUS\r
1258EFIAPI\r
1259PeiRegisterForShadow (\r
1260 IN EFI_PEI_FILE_HANDLE FileHandle\r
1261 )\r
1262{\r
1263 PEI_CORE_INSTANCE *Private;\r
1264 Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r
1265\r
1266 if (Private->CurrentFileHandle != FileHandle) {\r
1267 //\r
1268 // The FileHandle must be for the current PEIM\r
1269 //\r
1270 return EFI_NOT_FOUND;\r
1271 }\r
1272\r
1273 if (Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] >= PEIM_STATE_REGISITER_FOR_SHADOW) {\r
1274 //\r
1275 // If the PEIM has already entered the PEIM_STATE_REGISTER_FOR_SHADOW or PEIM_STATE_DONE then it's already been started\r
1276 //\r
1277 return EFI_ALREADY_STARTED;\r
1278 }\r
58dcdada 1279\r
14e8823a 1280 Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] = PEIM_STATE_REGISITER_FOR_SHADOW;\r
1281\r
1282 return EFI_SUCCESS;\r
1283}\r
1284\r
3b428ade 1285\r
341a658f 1286\r