]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Update DxeIpl PEIM to not use PeCoffLoaderLib to load DXE core. Instead, we choose...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Aug 2009 15:49:15 +0000 (15:49 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Aug 2009 15:49:15 +0000 (15:49 +0000)
2. Update DxeIpl PEIM to not use S3Lib and RecoveryLib since the dependent PPIs have been moved from IntelFrameworkPkg to MdePkg. This will help to reduce the library instance selection in platform DSC files.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9046 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c [deleted file]
MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c [deleted file]

index 916bc0d82d14292bffb007c1281e2800bbd29346..1240ce6c2bf2b17a15fba47b778ed92df9c7fe0a 100644 (file)
@@ -24,6 +24,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -35,13 +38,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -55,29 +56,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 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
@@ -91,29 +69,6 @@ DxeIplFindDxeCore (
   );\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
index 6e2eab8a04a279611bd237142535df0b009dd7d0..fadf2ebc52b5c6de6cbc83a7a0c1a38db96e1896 100644 (file)
@@ -5,7 +5,7 @@
 #  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
@@ -39,7 +39,6 @@
   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
@@ -98,7 +93,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiHandoffToDxe\r
 \r
 [Depex]\r
-  gEfiPeiMemoryDiscoveredPpiGuid\r
+  gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid\r
 \r
 #\r
 # [BootMode] \r
index d8f047e80d8677731f300b8be9bb4f39690c328d..3c9ed7c23545a194389374f613d1fefdb88a90d0 100644 (file)
@@ -154,7 +154,12 @@ DxeLoadCore (
   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
@@ -163,10 +168,26 @@ DxeLoadCore (
   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
@@ -211,15 +232,25 @@ DxeLoadCore (
   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
@@ -309,95 +340,6 @@ DxeIplFindDxeCore (
 }\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
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c b/MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c
deleted file mode 100644 (file)
index 9eca493..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/** @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
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c b/MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c
deleted file mode 100644 (file)
index eeb6bc8..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/** @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