EFI_BOOT_MODE BootMode;\r
EFI_PEI_FILE_HANDLE FileHandle;\r
EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;\r
+ EFI_PEI_LOAD_FILE_PPI *LoadFile;\r
+ UINTN Instance;\r
+ UINT32 AuthenticationState;\r
UINTN DataSize;\r
+ EFI_PEI_S3_RESUME_PPI *S3Resume;\r
+ EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery;\r
EFI_MEMORY_TYPE_INFORMATION MemoryData[EfiMaxMemoryType + 1];\r
\r
//\r
BootMode = GetBootModeHob ();\r
\r
if (BootMode == BOOT_ON_S3_RESUME) {\r
- Status = AcpiS3ResumeOs();\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiS3ResumePpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **) &S3Resume\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ Status = S3Resume->S3RestoreConfig (PeiServices);\r
ASSERT_EFI_ERROR (Status);\r
} else if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
- Status = PeiRecoverFirmware ();\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiRecoveryModulePpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **) &PeiRecovery\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "Load Recovery Capsule Failed.(Status = %r)\n", Status));\r
CpuDeadLoop ();\r
FileHandle = DxeIplFindDxeCore ();\r
\r
//\r
- // Load the DXE Core from a Firmware Volume, may use LoadFile PPI to do this to save code size.\r
+ // Load the DXE Core from a Firmware Volume.\r
//\r
- Status = PeiLoadFile (\r
- FileHandle,\r
- &DxeCoreAddress,\r
- &DxeCoreSize,\r
- &DxeCoreEntryPoint\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ Instance = 0;\r
+ do {\r
+ Status = PeiServicesLocatePpi (&gEfiPeiLoadFilePpiGuid, Instance++, NULL, (VOID **) &LoadFile);\r
+ //\r
+ // These must exist an instance of EFI_PEI_LOAD_FILE_PPI to support to load DxeCore file handle successfully.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = LoadFile->LoadFile (\r
+ LoadFile,\r
+ FileHandle,\r
+ &DxeCoreAddress,\r
+ &DxeCoreSize,\r
+ &DxeCoreEntryPoint,\r
+ &AuthenticationState\r
+ );\r
+ } while (EFI_ERROR (Status));\r
\r
//\r
// Get the DxeCore File Info from the FileHandle for the DxeCore GUID file name.\r
}\r
\r
\r
-/**\r
- Loads and relocates a PE/COFF image into memory.\r
-\r
- @param FileHandle The image file handle\r
- @param ImageAddress The base address of the relocated PE/COFF image\r
- @param ImageSize The size of the relocated PE/COFF image\r
- @param EntryPoint The entry point of the relocated PE/COFF image\r
- \r
- @return EFI_SUCCESS The file was loaded and relocated\r
- @return EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file\r
-\r
-**/\r
-EFI_STATUS\r
-PeiLoadFile (\r
- IN EFI_PEI_FILE_HANDLE FileHandle,\r
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r
- OUT UINT64 *ImageSize,\r
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r
- )\r
-{\r
-\r
- EFI_STATUS Status;\r
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
- VOID *Pe32Data;\r
-\r
- //\r
- // First try to find the PE32 section in this ffs file.\r
- //\r
- Status = PeiServicesFfsFindSectionData (\r
- EFI_SECTION_PE32,\r
- FileHandle,\r
- &Pe32Data\r
- );\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // NO image types we support so exit.\r
- //\r
- return Status;\r
- }\r
-\r
- ZeroMem (&ImageContext, sizeof (ImageContext));\r
- ImageContext.Handle = Pe32Data;\r
- ImageContext.ImageRead = PeiImageRead;\r
-\r
-\r
- Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Allocate Memory for the image\r
- //\r
- Status = PeiServicesAllocatePages (\r
- EfiBootServicesCode, \r
- EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize), \r
- &ImageContext.ImageAddress\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- ASSERT (ImageContext.ImageAddress != 0);\r
-\r
- //\r
- // Load the image to our new buffer\r
- //\r
- Status = PeCoffLoaderLoadImage (&ImageContext);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Relocate the image in our new buffer\r
- //\r
- Status = PeCoffLoaderRelocateImage (&ImageContext);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Flush the instruction cache so the image data are written before we execute it\r
- //\r
- InvalidateInstructionCacheRange ((VOID *)(UINTN) ImageContext.ImageAddress, (UINTN) ImageContext.ImageSize);\r
-\r
- *ImageAddress = ImageContext.ImageAddress;\r
- *ImageSize = ImageContext.ImageSize;\r
- *EntryPoint = ImageContext.EntryPoint;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
\r
/**\r
The ExtractSection() function processes the input section and\r