From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 213C8211093B2 for ; Tue, 4 Sep 2018 18:45:43 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2018 18:45:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,331,1531810800"; d="scan'208";a="83080556" Received: from lgao4-mobl1.ccr.corp.intel.com ([10.255.30.186]) by fmsmga002.fm.intel.com with ESMTP; 04 Sep 2018 18:45:42 -0700 From: Liming Gao To: edk2-devel@lists.01.org Date: Wed, 5 Sep 2018 09:40:32 +0800 Message-Id: <20180905014032.14596-1-liming.gao@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [Patch] MdeModulePkg PeiCore: Remove the copy logic for PeiImageRead function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 01:45:43 -0000 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 --- 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