]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Image/Image.c
Enable PeiCore to dispatch the encapsulated fv images with depex expression. This...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Image / Image.c
CommitLineData
192f6d4c 1/*++\r
2\r
3Copyright (c) 2006 - 2007, 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 Image.c\r
15\r
16Abstract:\r
17\r
18 Pei Core Load Image Support\r
19\r
20--*/\r
21\r
192f6d4c 22#include <PeiMain.h>\r
23\r
b0d803fe 24/*++\r
25\r
26Routine Description:\r
27\r
28 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
192f6d4c 29\r
b0d803fe 30Arguments:\r
31\r
32 FileHandle - The handle to the PE/COFF file\r
33 FileOffset - The offset, in bytes, into the file to read\r
34 ReadSize - The number of bytes to read from the file starting at FileOffset\r
35 Buffer - A pointer to the buffer to read the data into.\r
36\r
37Returns:\r
38\r
39 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
40\r
41--*/ \r
192f6d4c 42\r
43EFI_STATUS\r
b0d803fe 44PeiLoadImageLoadImage (\r
45 IN EFI_PEI_SERVICES **PeiServices,\r
46 IN EFI_PEI_FILE_HANDLE FileHandle,\r
47 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
48 OUT UINT64 *ImageSizeArg, OPTIONAL\r
49 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
50 OUT UINT32 *AuthenticationState\r
192f6d4c 51 )\r
52/*++\r
53\r
54Routine Description:\r
55\r
56 Routine for loading file image.\r
57\r
58Arguments:\r
59\r
b0d803fe 60 PeiServices - The PEI core services table.\r
61 FileHandle - Pointer to the FFS file header of the image.\r
62 ImageAddressArg - Pointer to PE/TE image.\r
63 ImageSizeArg - Size of PE/TE image.\r
64 EntryPoint - Pointer to entry point of specified image file for output.\r
65 AuthenticationState - Pointer to attestation authentication state of image.\r
66\r
67Returns:\r
68\r
69 Status - EFI_SUCCESS - Image is successfully loaded.\r
70 EFI_NOT_FOUND - Fail to locate necessary PPI\r
71 Others - Fail to load file.\r
72\r
73--*/\r
74;\r
75\r
76EFI_STATUS\r
77EFIAPI\r
78PeiLoadImageLoadImageWrapper (\r
79 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
80 IN EFI_PEI_FILE_HANDLE FileHandle,\r
81 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
82 OUT UINT64 *ImageSizeArg, OPTIONAL\r
83 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
84 OUT UINT32 *AuthenticationState\r
85 )\r
86/*++\r
87\r
88Routine Description:\r
89\r
90 The wrapper function of PeiLoadImageLoadImage().\r
91\r
92Arguments:\r
93\r
94 This - Pointer to EFI_PEI_LOAD_FILE_PPI.\r
95 PeiServices - The PEI core services table.\r
96 FileHandle - Pointer to the FFS file header of the image.\r
97 ImageAddressArg - Pointer to PE/TE image.\r
98 ImageSizeArg - Size of PE/TE image.\r
99 EntryPoint - Pointer to entry point of specified image file for output.\r
100 AuthenticationState - Pointer to attestation authentication state of image.\r
101\r
102Returns:\r
103\r
104 EFI_STATUS.\r
105 \r
106--*/ \r
107;\r
108\r
109STATIC EFI_PEI_LOAD_FILE_PPI mPeiLoadImagePpi = {\r
110 PeiLoadImageLoadImageWrapper\r
111};\r
112\r
113\r
114STATIC EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {\r
115 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
116 &gEfiPeiLoadFilePpiGuid,\r
117 &mPeiLoadImagePpi\r
118};\r
119\r
120EFI_STATUS\r
121EFIAPI\r
122PeiImageRead (\r
123 IN VOID *FileHandle,\r
124 IN UINTN FileOffset,\r
125 IN OUT UINTN *ReadSize,\r
126 OUT VOID *Buffer\r
127 )\r
128/*++\r
129\r
130Routine Description:\r
131\r
132 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
133\r
134Arguments:\r
135\r
136 FileHandle - The handle to the PE/COFF file\r
137 FileOffset - The offset, in bytes, into the file to read\r
138 ReadSize - The number of bytes to read from the file starting at FileOffset\r
139 Buffer - A pointer to the buffer to read the data into.\r
140\r
141Returns:\r
142\r
143 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
144\r
145--*/\r
146{\r
147 CHAR8 *Destination8;\r
148 CHAR8 *Source8;\r
149 UINTN Length;\r
150\r
151 Destination8 = Buffer;\r
152 Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
153 Length = *ReadSize;\r
154 while (Length--) {\r
155 *(Destination8++) = *(Source8++);\r
156 }\r
157\r
158 return EFI_SUCCESS;\r
159}\r
160\r
161EFI_STATUS\r
162GetImageReadFunction (\r
163 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
164 )\r
165/*++\r
166\r
167Routine Description:\r
168\r
169 Support routine to return the Image Read\r
170\r
171Arguments:\r
172\r
173 PeiServices - PEI Services Table\r
174\r
175 ImageContext - The context of the image being loaded\r
176\r
177Returns:\r
178\r
179 EFI_SUCCESS - If Image function location is found\r
180\r
181--*/\r
182{\r
183 VOID* MemoryBuffer;\r
184\r
185 MemoryBuffer = AllocatePages (0x400 / EFI_PAGE_SIZE + 1);\r
186 ASSERT (MemoryBuffer != NULL);\r
187\r
188 CopyMem (MemoryBuffer, (CONST VOID *) (UINTN) PeiImageRead, 0x400);\r
189\r
190 ImageContext->ImageRead = (PE_COFF_LOADER_READ_FILE) (UINTN) MemoryBuffer;\r
191\r
192 return EFI_SUCCESS;\r
193}\r
194\r
195STATIC\r
196EFI_STATUS\r
197LoadAndRelocatePeCoffImage (\r
b0d803fe 198 IN VOID *Pe32Data,\r
199 OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
200 OUT UINT64 *ImageSize,\r
201 OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
202 )\r
203/*++\r
204\r
205Routine Description:\r
206\r
207 Loads and relocates a PE/COFF image into memory.\r
208\r
209Arguments:\r
210\r
b0d803fe 211 Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated\r
212\r
213 ImageAddress - The base address of the relocated PE/COFF image\r
214\r
215 ImageSize - The size of the relocated PE/COFF image\r
216\r
217 EntryPoint - The entry point of the relocated PE/COFF image\r
218\r
219Returns:\r
220\r
221 EFI_SUCCESS - The file was loaded and relocated\r
222\r
223 EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
224\r
225--*/\r
226{\r
227 EFI_STATUS Status;\r
228 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
229\r
b0d803fe 230 ZeroMem (&ImageContext, sizeof (ImageContext));\r
231 ImageContext.Handle = Pe32Data;\r
232 Status = GetImageReadFunction (&ImageContext);\r
233\r
234 ASSERT_EFI_ERROR (Status);\r
235\r
3d7b0992 236 Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
b0d803fe 237 if (EFI_ERROR (Status)) {\r
238 return Status;\r
239 }\r
240 //\r
9626a87e
LG
241 // When Image has no reloc section, it can't be relocated into memory.\r
242 //\r
243 if (ImageContext.RelocationsStripped) {\r
288f9b38 244 DEBUG ((EFI_D_ERROR, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));\r
9626a87e
LG
245 return EFI_INVALID_PARAMETER;\r
246 }\r
247 //\r
b0d803fe 248 // Allocate Memory for the image\r
249 //\r
250 ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize));\r
251 ASSERT (ImageContext.ImageAddress != 0);\r
4e844595
LG
252 \r
253 //\r
254 // Skip the reserved space for the stripped PeHeader when load TeImage into memory.\r
255 //\r
256 if (ImageContext.IsTeImage) {\r
257 ImageContext.ImageAddress = ImageContext.ImageAddress + \r
258 ((EFI_TE_IMAGE_HEADER *) Pe32Data)->StrippedSize -\r
259 sizeof (EFI_TE_IMAGE_HEADER);\r
260 }\r
b0d803fe 261\r
262 //\r
263 // Load the image to our new buffer\r
264 //\r
3d7b0992 265 Status = PeCoffLoaderLoadImage (&ImageContext);\r
b0d803fe 266 if (EFI_ERROR (Status)) {\r
267 return Status;\r
268 }\r
269 //\r
270 // Relocate the image in our new buffer\r
271 //\r
3d7b0992 272 Status = PeCoffLoaderRelocateImage (&ImageContext);\r
b0d803fe 273 if (EFI_ERROR (Status)) {\r
274 return Status;\r
275 }\r
276\r
277 //\r
278 // Flush the instruction cache so the image data is written before we execute it\r
279 //\r
280 InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
281\r
282 *ImageAddress = ImageContext.ImageAddress;\r
283 *ImageSize = ImageContext.ImageSize;\r
284 *EntryPoint = ImageContext.EntryPoint;\r
285\r
286 return EFI_SUCCESS;\r
287}\r
288\r
289EFI_STATUS\r
290PeiLoadImageLoadImage (\r
291 IN EFI_PEI_SERVICES **PeiServices,\r
292 IN EFI_PEI_FILE_HANDLE FileHandle,\r
293 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
294 OUT UINT64 *ImageSizeArg, OPTIONAL\r
295 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
296 OUT UINT32 *AuthenticationState\r
297 )\r
298/*++\r
299\r
300Routine Description:\r
301\r
302 Routine for loading file image.\r
303\r
304Arguments:\r
305\r
306 PeiServices - The PEI core services table.\r
307 FileHandle - Pointer to the FFS file header of the image.\r
308 ImageAddressArg - Pointer to PE/TE image.\r
309 ImageSizeArg - Size of PE/TE image.\r
310 EntryPoint - Pointer to entry point of specified image file for output.\r
311 AuthenticationState - Pointer to attestation authentication state of image.\r
192f6d4c 312\r
313Returns:\r
314\r
315 Status - EFI_SUCCESS - Image is successfully loaded.\r
316 EFI_NOT_FOUND - Fail to locate necessary PPI\r
317 Others - Fail to load file.\r
318\r
319--*/\r
320{\r
321 EFI_STATUS Status;\r
322 VOID *Pe32Data;\r
192f6d4c 323 EFI_PHYSICAL_ADDRESS ImageAddress;\r
324 UINT64 ImageSize;\r
325 EFI_PHYSICAL_ADDRESS ImageEntryPoint;\r
192f6d4c 326 UINT16 Machine;\r
b0d803fe 327 PEI_CORE_INSTANCE *Private;\r
328 VOID *EntryPointArg;\r
3076397e 329 EFI_SECTION_TYPE SearchType1;\r
330 EFI_SECTION_TYPE SearchType2;\r
192f6d4c 331\r
3d7b0992
LG
332 *EntryPoint = 0;\r
333 ImageSize = 0;\r
b0d803fe 334 *AuthenticationState = 0;\r
192f6d4c 335\r
3076397e 336 if (FeaturePcdGet (PcdPeiCoreImageLoaderSearchTeSectionFirst)) {\r
337 SearchType1 = EFI_SECTION_TE;\r
338 SearchType2 = EFI_SECTION_PE32;\r
339 } else {\r
340 SearchType1 = EFI_SECTION_PE32;\r
341 SearchType2 = EFI_SECTION_TE;\r
342 }\r
192f6d4c 343 //\r
3076397e 344 // Try to find a first exe section (if PcdPeiCoreImageLoaderSearchTeSectionFirst \r
345 // is true, TE will be searched first).\r
192f6d4c 346 //\r
347 Status = PeiServicesFfsFindSectionData (\r
3076397e 348 SearchType1,\r
b0d803fe 349 FileHandle,\r
192f6d4c 350 &Pe32Data\r
351 );\r
352 //\r
3076397e 353 // If we didn't find a first exe section, try to find the second exe section.\r
192f6d4c 354 //\r
355 if (EFI_ERROR (Status)) {\r
356 Status = PeiServicesFfsFindSectionData (\r
3076397e 357 SearchType2,\r
b0d803fe 358 FileHandle,\r
359 &Pe32Data\r
192f6d4c 360 );\r
b0d803fe 361 if (EFI_ERROR (Status)) {\r
192f6d4c 362 //\r
b0d803fe 363 // PEI core only carry the loader function fro TE and PE32 executables\r
364 // If this two section does not exist, just return.\r
192f6d4c 365 //\r
b0d803fe 366 return Status;\r
367 }\r
368 }\r
369 \r
370 Private = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
192f6d4c 371\r
b0d803fe 372 if (Private->PeiMemoryInstalled && \r
373 (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r
3d7b0992
LG
374 //\r
375 // If memory is installed, perform the shadow operations\r
376 //\r
377 Status = LoadAndRelocatePeCoffImage (\r
378 Pe32Data,\r
379 &ImageAddress,\r
380 &ImageSize,\r
381 &ImageEntryPoint\r
382 );\r
192f6d4c 383\r
3d7b0992
LG
384 if (EFI_ERROR (Status)) {\r
385 return Status;\r
b0d803fe 386 }\r
3d7b0992
LG
387\r
388 //\r
389 // Got the entry point from the loaded Pe32Data\r
390 //\r
391 Pe32Data = (VOID *) ((UINTN) ImageAddress);\r
392 *EntryPoint = ImageEntryPoint;\r
b0d803fe 393 } else {\r
3d7b0992
LG
394 //\r
395 // Retrieve the entry point from the PE/COFF or TE image header\r
396 //\r
397 ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data;\r
398 Status = PeCoffLoaderGetEntryPoint (Pe32Data, &EntryPointArg);\r
399 if (EFI_ERROR (Status)) {\r
400 return Status;\r
192f6d4c 401 }\r
3d7b0992 402 *EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) EntryPointArg;\r
192f6d4c 403 }\r
3d7b0992
LG
404 \r
405 Machine = PeCoffLoaderGetMachineType (Pe32Data);\r
192f6d4c 406 \r
407 if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Machine)) {\r
408 return EFI_UNSUPPORTED; \r
409 }\r
410\r
b0d803fe 411 if (ImageAddressArg != NULL) {\r
412 *ImageAddressArg = ImageAddress;\r
413 }\r
414\r
415 if (ImageSizeArg != NULL) {\r
416 *ImageSizeArg = ImageSize;\r
417 }\r
418 \r
192f6d4c 419 DEBUG_CODE_BEGIN ();\r
3d7b0992
LG
420 CHAR8 *AsciiString;\r
421 CHAR8 AsciiBuffer[512];\r
422 INT32 Index;\r
423 INT32 Index1;\r
e98cd821
LG
424\r
425 //\r
426 // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
427 //\r
428 if (Machine != IMAGE_FILE_MACHINE_IA64) {\r
a85e7bfc 429 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%10p EntryPoint=0x%10p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint));\r
e98cd821
LG
430 } else {\r
431 //\r
432 // For IPF Image, the real entry point should be print.\r
433 //\r
a85e7bfc 434 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%10p EntryPoint=0x%10p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint)));\r
e98cd821 435 }\r
192f6d4c 436 \r
e98cd821
LG
437 //\r
438 // Print Module Name by PeImage PDB file name.\r
439 //\r
3d7b0992
LG
440 AsciiString = PeCoffLoaderGetPdbPointer (Pe32Data);\r
441 \r
442 if (AsciiString != NULL) {\r
19ea58a1 443 for (Index = (INT32) AsciiStrLen (AsciiString) - 1; Index >= 0; Index --) {\r
3d7b0992
LG
444 if (AsciiString[Index] == '\\') {\r
445 break;\r
446 }\r
192f6d4c 447 }\r
192f6d4c 448\r
3d7b0992
LG
449 if (Index != 0) {\r
450 for (Index1 = 0; AsciiString[Index + 1 + Index1] != '.'; Index1 ++) {\r
451 AsciiBuffer [Index1] = AsciiString[Index + 1 + Index1];\r
192f6d4c 452 }\r
3d7b0992
LG
453 AsciiBuffer [Index1] = '\0';\r
454 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));\r
192f6d4c 455 }\r
456 }\r
3d7b0992 457\r
192f6d4c 458 DEBUG_CODE_END ();\r
459\r
460 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));\r
461\r
462 return EFI_SUCCESS;\r
b0d803fe 463\r
464}\r
465\r
466\r
467EFI_STATUS\r
468EFIAPI\r
469PeiLoadImageLoadImageWrapper (\r
470 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
471 IN EFI_PEI_FILE_HANDLE FileHandle,\r
472 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
473 OUT UINT64 *ImageSizeArg, OPTIONAL\r
474 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
475 OUT UINT32 *AuthenticationState\r
476 )\r
477/*++\r
478\r
479Routine Description:\r
480\r
481 The wrapper function of PeiLoadImageLoadImage().\r
482\r
483Arguments:\r
484\r
485 This - Pointer to EFI_PEI_LOAD_FILE_PPI.\r
486 PeiServices - The PEI core services table.\r
487 FileHandle - Pointer to the FFS file header of the image.\r
488 ImageAddressArg - Pointer to PE/TE image.\r
489 ImageSizeArg - Size of PE/TE image.\r
490 EntryPoint - Pointer to entry point of specified image file for output.\r
491 AuthenticationState - Pointer to attestation authentication state of image.\r
492\r
493Returns:\r
494\r
495 EFI_STATUS.\r
496 \r
497--*/ \r
498{\r
499 return PeiLoadImageLoadImage (\r
500 GetPeiServicesTablePointer (),\r
501 FileHandle,\r
502 ImageAddressArg,\r
503 ImageSizeArg,\r
504 EntryPoint,\r
505 AuthenticationState\r
506 );\r
192f6d4c 507}\r
b0d803fe 508\r
509EFI_STATUS\r
510PeiLoadImage (\r
511 IN EFI_PEI_SERVICES **PeiServices,\r
512 IN EFI_PEI_FILE_HANDLE FileHandle,\r
513 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
514 OUT UINT32 *AuthenticationState\r
515 )\r
516/*++\r
517\r
518Routine Description:\r
519\r
520 Routine for load image file.\r
521\r
522Arguments:\r
523\r
524 PeiServices - The PEI core services table.\r
525 FileHandle - Pointer to the FFS file header of the image.\r
526 EntryPoint - Pointer to entry point of specified image file for output.\r
527 AuthenticationState - Pointer to attestation authentication state of image.\r
528\r
529Returns:\r
530\r
531 Status - EFI_SUCCESS - Image is successfully loaded.\r
532 EFI_NOT_FOUND - Fail to locate necessary PPI\r
533 Others - Fail to load file.\r
534 \r
535--*/ \r
536{\r
537 EFI_STATUS PpiStatus;\r
538 EFI_STATUS Status;\r
539 UINTN Index;\r
540 EFI_PEI_LOAD_FILE_PPI *LoadFile;\r
541 EFI_PHYSICAL_ADDRESS ImageAddress;\r
542 UINT64 ImageSize;\r
543\r
544 //\r
545 // If any instances of PEI_LOAD_FILE_PPI are installed, they are called.\r
546 // one at a time, until one reports EFI_SUCCESS.\r
547 //\r
548 Index = 0;\r
549 do {\r
550 PpiStatus = PeiServicesLocatePpi (\r
551 &gEfiPeiLoadFilePpiGuid,\r
552 Index,\r
553 NULL,\r
554 (VOID **)&LoadFile\r
555 );\r
556 if (!EFI_ERROR (PpiStatus)) {\r
557 Status = LoadFile->LoadFile (\r
558 LoadFile, \r
559 FileHandle, \r
560 &ImageAddress, \r
561 &ImageSize,\r
562 EntryPoint,\r
563 AuthenticationState\r
564 );\r
565 if (!EFI_ERROR (Status)) {\r
566 return Status;\r
567 }\r
568 }\r
569 Index++;\r
570 } while (!EFI_ERROR (PpiStatus));\r
571\r
572 //\r
573 // If no instances reports EFI_SUCCESS, then build-in support for\r
574 // the PE32+/TE XIP image format is used.\r
575 //\r
576 Status = PeiLoadImageLoadImage (\r
577 PeiServices, \r
578 FileHandle, \r
579 NULL, \r
580 NULL, \r
581 EntryPoint, \r
582 AuthenticationState\r
583 );\r
584 return Status;\r
585}\r
586\r
587\r
588VOID\r
589InitializeImageServices (\r
590 IN PEI_CORE_INSTANCE *PrivateData,\r
591 IN PEI_CORE_INSTANCE *OldCoreData\r
592 )\r
593/*++\r
594\r
595Routine Description:\r
596\r
c58cf83d 597 Install Pei Load File PPI.\r
b0d803fe 598\r
599Arguments:\r
600\r
601 PrivateData - Pointer to PEI_CORE_INSTANCE.\r
602 OldCoreData - Pointer to PEI_CORE_INSTANCE.\r
603\r
604Returns:\r
605\r
606 NONE.\r
607 \r
608--*/ \r
609{\r
b0d803fe 610 if (OldCoreData == NULL) {\r
611 //\r
612 // The first time we are XIP (running from FLASH). We need to remember the\r
613 // FLASH address so we can reinstall the memory version that runs faster\r
614 //\r
615 PrivateData->XipLoadFile = &gPpiLoadFilePpiList;\r
616 PeiServicesInstallPpi (PrivateData->XipLoadFile);\r
617 } else {\r
618 //\r
619 // 2nd time we are running from memory so replace the XIP version with the \r
620 // new memory version. \r
621 //\r
622 PeiServicesReInstallPpi (PrivateData->XipLoadFile, &gPpiLoadFilePpiList); \r
623 }\r
624}\r
625\r
626\r
627\r