]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PeiCore: Always use PeiImageRead() function to load PEI image
authorLiming Gao <liming.gao@intel.com>
Wed, 5 Sep 2018 14:17:44 +0000 (22:17 +0800)
committerLiming Gao <liming.gao@intel.com>
Fri, 7 Sep 2018 13:39:26 +0000 (21:39 +0800)
In V2, Remove GetImageReadFunction(), directly use PeiImageRead().

The copy PeiImageReadForShadow function doesn't improve the boot performance.
This patch removes this copy logic to simplify the code logic.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/Pei/Image/Image.c

index f84f2c77adf0391a27c3220f6f9c7f65e52bf076..315b551bfdb7f56b61761a8601c6caf181eb4338 100644 (file)
@@ -60,87 +60,6 @@ PeiImageRead (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-\r
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file.\r
-  The function is implemented as PIC so as to support shadowing.\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 FileOffset\r
-  @param Buffer          - A pointer to the buffer to read the data into.\r
-\r
-  @return EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiImageReadForShadow (\r
-  IN     VOID    *FileHandle,\r
-  IN     UINTN   FileOffset,\r
-  IN     UINTN   *ReadSize,\r
-  OUT    VOID    *Buffer\r
-  )\r
-{\r
-  volatile CHAR8  *Destination8;\r
-  CHAR8           *Source8;\r
-  UINTN           Length;\r
-\r
-  Destination8  = Buffer;\r
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
-  if (Destination8 != Source8) {\r
-    Length        = *ReadSize;\r
-    while ((Length--) > 0) {\r
-      *(Destination8++) = *(Source8++);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Support routine to get the Image read file function.\r
-\r
-  @param ImageContext    - The context of the image being loaded\r
-\r
-  @retval EFI_SUCCESS - If Image function location is found\r
-\r
-**/\r
-EFI_STATUS\r
-GetImageReadFunction (\r
-  IN      PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
-  PEI_CORE_INSTANCE     *Private;\r
-  EFI_PHYSICAL_ADDRESS  MemoryBuffer;\r
-\r
-  Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r
-  MemoryBuffer = 0;\r
-\r
-  if (Private->PeiMemoryInstalled  && (((Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoot)) ||\r
-      ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) {\r
-    //\r
-    // Shadow algorithm makes lots of non ANSI C assumptions and only works for IA32 and X64\r
-    //  compilers that have been tested\r
-    //\r
-    if (Private->ShadowedImageRead == NULL) {\r
-      PeiServicesAllocatePages (EfiBootServicesCode, 0x400 / EFI_PAGE_SIZE + 1, &MemoryBuffer);\r
-      ASSERT (MemoryBuffer != 0);\r
-      CopyMem ((VOID *)(UINTN)MemoryBuffer, (CONST VOID *) (UINTN) PeiImageReadForShadow, 0x400);\r
-      Private->ShadowedImageRead = (PE_COFF_LOADER_READ_FILE) (UINTN) MemoryBuffer;\r
-    }\r
-\r
-    ImageContext->ImageRead = Private->ShadowedImageRead;\r
-  } else {\r
-    ImageContext->ImageRead = PeiImageRead;\r
-  }\r
-#else\r
-  ImageContext->ImageRead = PeiImageRead;\r
-#endif\r
-  return EFI_SUCCESS;\r
-}\r
 /**\r
   To check memory usage bit map array to figure out if the memory range the image will be loaded in is available or not. If\r
   memory range is available, the function will mark the corresponding bits to 1 which indicates the memory range is used.\r
@@ -369,9 +288,7 @@ LoadAndRelocatePeCoffImage (
   IsXipImage   = FALSE;\r
   ZeroMem (&ImageContext, sizeof (ImageContext));\r
   ImageContext.Handle = Pe32Data;\r
-  Status              = GetImageReadFunction (&ImageContext);\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
+  ImageContext.ImageRead = PeiImageRead;\r
 \r
   Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r