public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: "Gao, Liming" <liming.gao@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [Patch] MdeModulePkg PeiCore: Remove the copy logic for PeiImageRead function
Date: Wed, 5 Sep 2018 10:27:02 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BBB56A8@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20180905014032.14596-1-liming.gao@intel.com>

Hi Liming,

The code removed is about copying PeiImageReadForShadow, but not PeiImageRead.
How about updating the title and commit log a little?

And I suggest eliminating GetImageReadFunction() further in this patch and move " ImageContext->ImageRead = PeiImageRead; " into LoadAndRelocatePeCoffImage() directly.
What do you think?


Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Liming Gao
Sent: Wednesday, September 5, 2018 9:41 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] MdeModulePkg PeiCore: Remove the copy logic for PeiImageRead function

The copy PeiImageRead 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>
---
 MdeModulePkg/Core/Pei/Image/Image.c | 65 +------------------------------------
 1 file changed, 1 insertion(+), 64 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c
index f84f2c7..303acf3 100644
--- a/MdeModulePkg/Core/Pei/Image/Image.c
+++ b/MdeModulePkg/Core/Pei/Image/Image.c
@@ -62,44 +62,6 @@ PeiImageRead (
 
 /**
 
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file.
-  The function is implemented as PIC so as to support shadowing.
-
-  @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.
-
-  @return EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
-
-**/
-EFI_STATUS
-EFIAPI
-PeiImageReadForShadow (
-  IN     VOID    *FileHandle,
-  IN     UINTN   FileOffset,
-  IN     UINTN   *ReadSize,
-  OUT    VOID    *Buffer
-  )
-{
-  volatile CHAR8  *Destination8;
-  CHAR8           *Source8;
-  UINTN           Length;
-
-  Destination8  = Buffer;
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
-  if (Destination8 != Source8) {
-    Length        = *ReadSize;
-    while ((Length--) > 0) {
-      *(Destination8++) = *(Source8++);
-    }
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
-
   Support routine to get the Image read file function.
 
   @param ImageContext    - The context of the image being loaded
@@ -112,35 +74,10 @@ GetImageReadFunction (
   IN      PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
-  PEI_CORE_INSTANCE     *Private;
-  EFI_PHYSICAL_ADDRESS  MemoryBuffer;
-
-  Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
-  MemoryBuffer = 0;
-
-  if (Private->PeiMemoryInstalled  && (((Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoot)) ||
-      ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) {
-    //
-    // Shadow algorithm makes lots of non ANSI C assumptions and only works for IA32 and X64
-    //  compilers that have been tested
-    //
-    if (Private->ShadowedImageRead == NULL) {
-      PeiServicesAllocatePages (EfiBootServicesCode, 0x400 / EFI_PAGE_SIZE + 1, &MemoryBuffer);
-      ASSERT (MemoryBuffer != 0);
-      CopyMem ((VOID *)(UINTN)MemoryBuffer, (CONST VOID *) (UINTN) PeiImageReadForShadow, 0x400);
-      Private->ShadowedImageRead = (PE_COFF_LOADER_READ_FILE) (UINTN) MemoryBuffer;
-    }
-
-    ImageContext->ImageRead = Private->ShadowedImageRead;
-  } else {
-    ImageContext->ImageRead = PeiImageRead;
-  }
-#else
   ImageContext->ImageRead = PeiImageRead; -#endif
   return EFI_SUCCESS;
 }
+
 /**
   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
   memory range is available, the function will mark the corresponding bits to 1 which indicates the memory range is used.
--
2.10.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2018-09-05 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  1:40 [Patch] MdeModulePkg PeiCore: Remove the copy logic for PeiImageRead function Liming Gao
2018-09-05 10:27 ` Zeng, Star [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103BBB56A8@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox