#include <Ppi/Decompress.h>\r
#include <Ppi/FirmwareVolumeInfo.h>\r
#include <Ppi/GuidedSectionExtraction.h>\r
+#include <Ppi/LoadFile.h>\r
+#include <Ppi/S3Resume.h>\r
+#include <Ppi/RecoveryModule.h>\r
\r
#include <Guid/MemoryTypeInformation.h>\r
#include <Guid/MemoryAllocationHob.h>\r
#include <Library/HobLib.h>\r
#include <Library/PeiServicesLib.h>\r
#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/CacheMaintenanceLib.h>\r
#include <Library/UefiDecompressLib.h>\r
#include <Library/ExtractGuidedSectionLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
-#include <Library/PeCoffLib.h>\r
#include <Library/S3Lib.h>\r
#include <Library/RecoveryLib.h>\r
\r
extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;\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
-\r
/**\r
Searches DxeCore in all firmware Volumes and loads the first\r
instance that contains DxeCore.\r
);\r
\r
\r
-/**\r
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
-\r
- @param FileHandle The handle to the PE/COFF file \r
- @param FileOffset The offset, in bytes, into the file to read \r
- @param ReadSize The number of bytes to read from the file starting at \r
- FileOffset \r
- @param Buffer A pointer to the buffer to read the data into. \r
-\r
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the \r
- PE/COFF file starting at FileOffset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiImageRead (\r
- IN VOID *FileHandle,\r
- IN UINTN FileOffset,\r
- IN OUT UINTN *ReadSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-\r
/**\r
Main entry point to last PEIM \r
\r
# PPI to discover and dispatch the DXE Foundation and components that are\r
# needed to run the DXE Foundation.\r
#\r
-# Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+# Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
# All rights reserved. This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
Ia32/VirtualMemory.h ||||PcdDxeIplSwitchToLongMode\r
Ia32/VirtualMemory.c ||||PcdDxeIplSwitchToLongMode\r
Ia32/DxeLoadFunc.c\r
- Ia32/ImageRead.c\r
Ia32/IdtVectorAsm.asm||||PcdDxeIplSwitchToLongMode\r
Ia32/IdtVectorAsm.S ||||PcdDxeIplSwitchToLongMode\r
\r
X64/VirtualMemory.h\r
X64/VirtualMemory.c\r
X64/DxeLoadFunc.c\r
- Ia32/ImageRead.c\r
\r
[Sources.IPF]\r
Ipf/DxeLoadFunc.c\r
- Ipf/ImageRead.c\r
\r
[Sources.EBC]\r
Ebc/DxeLoadFunc.c\r
- Ia32/ImageRead.c\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
MdeModulePkg/MdeModulePkg.dec\r
\r
[LibraryClasses]\r
- PeCoffLib\r
PcdLib\r
MemoryAllocationLib\r
BaseMemoryLib\r
ExtractGuidedSectionLib\r
UefiDecompressLib\r
- CacheMaintenanceLib\r
ReportStatusCodeLib\r
PeiServicesLib\r
HobLib\r
BaseLib\r
PeimEntryPoint\r
DebugLib\r
- S3Lib\r
- RecoveryLib\r
\r
[Ppis]\r
gEfiDxeIplPpiGuid ## PRODUCES\r
gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES(Not produced on S3 boot path)\r
gEfiPeiDecompressPpiGuid ## SOMETIMES_PRODUCES\r
gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES\r
+ gEfiPeiLoadFilePpiGuid ## CONSUMES\r
+ gEfiPeiS3ResumePpiGuid ## SOMETIMES_CONSUMES(Consumed on S3 boot path)\r
+ gEfiPeiRecoveryModulePpiGuid ## SOMETIMES_CONSUMES(Consumed on recovery boot path)\r
\r
[Guids]\r
gEfiMemoryTypeInformationGuid ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"\r
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiHandoffToDxe\r
\r
[Depex]\r
- gEfiPeiMemoryDiscoveredPpiGuid\r
+ gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid\r
\r
#\r
# [BootMode] \r
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
+++ /dev/null
-/** @file\r
- This module loads an image to memory for IA32 Cpu architecture.\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-\r
-/**\r
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
-\r
- @param FileHandle The handle to the PE/COFF file \r
- @param FileOffset The offset, in bytes, into the file to read \r
- @param ReadSize The number of bytes to read from the file starting at \r
- FileOffset \r
- @param Buffer A pointer to the buffer to read the data into. \r
-\r
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the \r
- PE/COFF file starting at FileOffset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiImageRead (\r
- IN VOID *FileHandle,\r
- IN UINTN FileOffset,\r
- IN OUT UINTN *ReadSize,\r
- OUT VOID *Buffer\r
- )\r
-{\r
- UINT8 *Destination32;\r
- UINT8 *Source32;\r
- UINTN Length;\r
-\r
- \r
- Destination32 = Buffer;\r
- Source32 = (UINT8 *) ((UINTN) FileHandle + FileOffset);\r
-\r
- //\r
- // This function assumes 32-bit alignment to increase performance\r
- //\r
-\r
- Length = *ReadSize;\r
- while (Length-- != 0) {\r
- *(Destination32++) = *(Source32++);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
+++ /dev/null
-/** @file\r
- This module loads an image to memory for IPF Cpu architecture.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-\r
-\r
-\r
-/**\r
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
-\r
- @param FileHandle The handle to the PE/COFF file \r
- @param FileOffset The offset, in bytes, into the file to read \r
- @param ReadSize The number of bytes to read from the file starting at \r
- FileOffset \r
- @param Buffer A pointer to the buffer to read the data into. \r
-\r
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the \r
- PE/COFF file starting at FileOffset\r
-\r
-**/\r
-EFI_STATUS\r
-PeiImageRead (\r
- IN VOID *FileHandle,\r
- IN UINTN FileOffset,\r
- IN OUT UINTN *ReadSize,\r
- OUT VOID *Buffer\r
- )\r
-{\r
- CHAR8 *Destination8;\r
- CHAR8 *Source8;\r
- volatile UINTN Length;\r
-\r
- Destination8 = Buffer;\r
- Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
- Length = *ReadSize;\r
- CopyMem (Destination8, Source8, Length);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r