diff options
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/DxeIpl.h | 51 | ||||
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 15 | ||||
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 140 | ||||
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c | 57 | ||||
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c | 51 |
5 files changed, 49 insertions, 265 deletions
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h index 916bc0d..1240ce6 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h @@ -24,6 +24,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Ppi/Decompress.h>
#include <Ppi/FirmwareVolumeInfo.h>
#include <Ppi/GuidedSectionExtraction.h>
+#include <Ppi/LoadFile.h>
+#include <Ppi/S3Resume.h>
+#include <Ppi/RecoveryModule.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/MemoryAllocationHob.h>
@@ -35,13 +38,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/HobLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/ReportStatusCodeLib.h>
-#include <Library/CacheMaintenanceLib.h>
#include <Library/UefiDecompressLib.h>
#include <Library/ExtractGuidedSectionLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
-#include <Library/PeCoffLib.h>
#include <Library/S3Lib.h>
#include <Library/RecoveryLib.h>
@@ -55,29 +56,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;
-
-/**
- Loads and relocates a PE/COFF image into memory.
-
- @param FileHandle The image file handle
- @param ImageAddress The base address of the relocated PE/COFF image
- @param ImageSize The size of the relocated PE/COFF image
- @param EntryPoint The entry point of the relocated PE/COFF image
-
- @return EFI_SUCCESS The file was loaded and relocated
- @return EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file
-
-**/
-EFI_STATUS
-PeiLoadFile (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
- OUT UINT64 *ImageSize,
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint
- );
-
-
-
/**
Searches DxeCore in all firmware Volumes and loads the first
instance that contains DxeCore.
@@ -92,29 +70,6 @@ DxeIplFindDxeCore ( /**
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
-
- @param FileHandle The handle to the PE/COFF file
- @param FileOffset The offset, in bytes, into the file to read
- @param ReadSize The number of bytes to read from the file starting at
- FileOffset
- @param Buffer A pointer to the buffer to read the data into.
-
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the
- PE/COFF file starting at FileOffset
-
-**/
-EFI_STATUS
-EFIAPI
-PeiImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
- );
-
-
-/**
Main entry point to last PEIM
@param This Entry point for DXE IPL PPI
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf index 6e2eab8..fadf2eb 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -5,7 +5,7 @@ # PPI to discover and dispatch the DXE Foundation and components that are
# needed to run the DXE Foundation.
#
-# Copyright (c) 2006 - 2008, Intel Corporation. <BR>
+# Copyright (c) 2006 - 2009, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -39,7 +39,6 @@ Ia32/VirtualMemory.h ||||PcdDxeIplSwitchToLongMode
Ia32/VirtualMemory.c ||||PcdDxeIplSwitchToLongMode
Ia32/DxeLoadFunc.c
- Ia32/ImageRead.c
Ia32/IdtVectorAsm.asm||||PcdDxeIplSwitchToLongMode
Ia32/IdtVectorAsm.S ||||PcdDxeIplSwitchToLongMode
@@ -47,42 +46,38 @@ X64/VirtualMemory.h
X64/VirtualMemory.c
X64/DxeLoadFunc.c
- Ia32/ImageRead.c
[Sources.IPF]
Ipf/DxeLoadFunc.c
- Ipf/ImageRead.c
[Sources.EBC]
Ebc/DxeLoadFunc.c
- Ia32/ImageRead.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
- PeCoffLib
PcdLib
MemoryAllocationLib
BaseMemoryLib
ExtractGuidedSectionLib
UefiDecompressLib
- CacheMaintenanceLib
ReportStatusCodeLib
PeiServicesLib
HobLib
BaseLib
PeimEntryPoint
DebugLib
- S3Lib
- RecoveryLib
[Ppis]
gEfiDxeIplPpiGuid ## PRODUCES
gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES(Not produced on S3 boot path)
gEfiPeiDecompressPpiGuid ## SOMETIMES_PRODUCES
gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES
+ gEfiPeiLoadFilePpiGuid ## CONSUMES
+ gEfiPeiS3ResumePpiGuid ## SOMETIMES_CONSUMES(Consumed on S3 boot path)
+ gEfiPeiRecoveryModulePpiGuid ## SOMETIMES_CONSUMES(Consumed on recovery boot path)
[Guids]
gEfiMemoryTypeInformationGuid ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
@@ -98,7 +93,7 @@ gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiHandoffToDxe
[Depex]
- gEfiPeiMemoryDiscoveredPpiGuid
+ gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid
#
# [BootMode]
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index d8f047e..3c9ed7c 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -154,7 +154,12 @@ DxeLoadCore ( EFI_BOOT_MODE BootMode;
EFI_PEI_FILE_HANDLE FileHandle;
EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
+ EFI_PEI_LOAD_FILE_PPI *LoadFile;
+ UINTN Instance;
+ UINT32 AuthenticationState;
UINTN DataSize;
+ EFI_PEI_S3_RESUME_PPI *S3Resume;
+ EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery;
EFI_MEMORY_TYPE_INFORMATION MemoryData[EfiMaxMemoryType + 1];
//
@@ -163,10 +168,26 @@ DxeLoadCore ( BootMode = GetBootModeHob ();
if (BootMode == BOOT_ON_S3_RESUME) {
- Status = AcpiS3ResumeOs();
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiS3ResumePpiGuid,
+ 0,
+ NULL,
+ (VOID **) &S3Resume
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = S3Resume->S3RestoreConfig (PeiServices);
ASSERT_EFI_ERROR (Status);
} else if (BootMode == BOOT_IN_RECOVERY_MODE) {
- Status = PeiRecoverFirmware ();
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiRecoveryModulePpiGuid,
+ 0,
+ NULL,
+ (VOID **) &PeiRecovery
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Load Recovery Capsule Failed.(Status = %r)\n", Status));
CpuDeadLoop ();
@@ -211,15 +232,25 @@ DxeLoadCore ( FileHandle = DxeIplFindDxeCore ();
//
- // Load the DXE Core from a Firmware Volume, may use LoadFile PPI to do this to save code size.
+ // Load the DXE Core from a Firmware Volume.
//
- Status = PeiLoadFile (
- FileHandle,
- &DxeCoreAddress,
- &DxeCoreSize,
- &DxeCoreEntryPoint
- );
- ASSERT_EFI_ERROR (Status);
+ Instance = 0;
+ do {
+ Status = PeiServicesLocatePpi (&gEfiPeiLoadFilePpiGuid, Instance++, NULL, (VOID **) &LoadFile);
+ //
+ // These must exist an instance of EFI_PEI_LOAD_FILE_PPI to support to load DxeCore file handle successfully.
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ Status = LoadFile->LoadFile (
+ LoadFile,
+ FileHandle,
+ &DxeCoreAddress,
+ &DxeCoreSize,
+ &DxeCoreEntryPoint,
+ &AuthenticationState
+ );
+ } while (EFI_ERROR (Status));
//
// Get the DxeCore File Info from the FileHandle for the DxeCore GUID file name.
@@ -309,95 +340,6 @@ DxeIplFindDxeCore ( }
-/**
- Loads and relocates a PE/COFF image into memory.
-
- @param FileHandle The image file handle
- @param ImageAddress The base address of the relocated PE/COFF image
- @param ImageSize The size of the relocated PE/COFF image
- @param EntryPoint The entry point of the relocated PE/COFF image
-
- @return EFI_SUCCESS The file was loaded and relocated
- @return EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file
-
-**/
-EFI_STATUS
-PeiLoadFile (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
- OUT UINT64 *ImageSize,
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint
- )
-{
-
- EFI_STATUS Status;
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
- VOID *Pe32Data;
-
- //
- // First try to find the PE32 section in this ffs file.
- //
- Status = PeiServicesFfsFindSectionData (
- EFI_SECTION_PE32,
- FileHandle,
- &Pe32Data
- );
- if (EFI_ERROR (Status)) {
- //
- // NO image types we support so exit.
- //
- return Status;
- }
-
- ZeroMem (&ImageContext, sizeof (ImageContext));
- ImageContext.Handle = Pe32Data;
- ImageContext.ImageRead = PeiImageRead;
-
-
- Status = PeCoffLoaderGetImageInfo (&ImageContext);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Allocate Memory for the image
- //
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize),
- &ImageContext.ImageAddress
- );
- ASSERT_EFI_ERROR (Status);
- ASSERT (ImageContext.ImageAddress != 0);
-
- //
- // Load the image to our new buffer
- //
- Status = PeCoffLoaderLoadImage (&ImageContext);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Relocate the image in our new buffer
- //
- Status = PeCoffLoaderRelocateImage (&ImageContext);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Flush the instruction cache so the image data are written before we execute it
- //
- InvalidateInstructionCacheRange ((VOID *)(UINTN) ImageContext.ImageAddress, (UINTN) ImageContext.ImageSize);
-
- *ImageAddress = ImageContext.ImageAddress;
- *ImageSize = ImageContext.ImageSize;
- *EntryPoint = ImageContext.EntryPoint;
-
- return EFI_SUCCESS;
-}
-
-
-
/**
The ExtractSection() function processes the input section and
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c b/MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c deleted file mode 100644 index 9eca493..0000000 --- a/MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c +++ /dev/null @@ -1,57 +0,0 @@ -/** @file
- This module loads an image to memory for IA32 Cpu architecture.
-
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DxeIpl.h"
-
-/**
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
-
- @param FileHandle The handle to the PE/COFF file
- @param FileOffset The offset, in bytes, into the file to read
- @param ReadSize The number of bytes to read from the file starting at
- FileOffset
- @param Buffer A pointer to the buffer to read the data into.
-
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the
- PE/COFF file starting at FileOffset
-
-**/
-EFI_STATUS
-EFIAPI
-PeiImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
- )
-{
- UINT8 *Destination32;
- UINT8 *Source32;
- UINTN Length;
-
-
- Destination32 = Buffer;
- Source32 = (UINT8 *) ((UINTN) FileHandle + FileOffset);
-
- //
- // This function assumes 32-bit alignment to increase performance
- //
-
- Length = *ReadSize;
- while (Length-- != 0) {
- *(Destination32++) = *(Source32++);
- }
-
- return EFI_SUCCESS;
-}
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c b/MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c deleted file mode 100644 index eeb6bc8..0000000 --- a/MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c +++ /dev/null @@ -1,51 +0,0 @@ -/** @file
- This module loads an image to memory for IPF Cpu architecture.
-
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DxeIpl.h"
-
-
-
-/**
- Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
-
- @param FileHandle The handle to the PE/COFF file
- @param FileOffset The offset, in bytes, into the file to read
- @param ReadSize The number of bytes to read from the file starting at
- FileOffset
- @param Buffer A pointer to the buffer to read the data into.
-
- @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the
- PE/COFF file starting at FileOffset
-
-**/
-EFI_STATUS
-PeiImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
- )
-{
- CHAR8 *Destination8;
- CHAR8 *Source8;
- volatile UINTN Length;
-
- Destination8 = Buffer;
- Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
- Length = *ReadSize;
- CopyMem (Destination8, Source8, Length);
-
- return EFI_SUCCESS;
-}
-
|