]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/DxeIplPeim/Ipf/ImageRead.c
Using CopyMem service to replace the "while" loop for the memory copy
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / Ipf / ImageRead.c
CommitLineData
95276127 1/*++\r
2\r
31528f0c 3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 11\r
12Module Name:\r
13\r
14 ImageRead.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
95276127 20#include "DxeIpl.h"\r
21\r
22EFI_STATUS\r
23PeiImageRead (\r
24 IN VOID *FileHandle,\r
25 IN UINTN FileOffset,\r
26 IN OUT UINTN *ReadSize,\r
27 OUT VOID *Buffer\r
28 )\r
29/*++\r
30\r
31Routine Description:\r
32\r
33 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
34\r
35Arguments:\r
36\r
37 FileHandle - The handle to the PE/COFF file\r
38\r
39 FileOffset - The offset, in bytes, into the file to read\r
40\r
41 ReadSize - The number of bytes to read from the file starting at FileOffset\r
42\r
43 Buffer - A pointer to the buffer to read the data into.\r
44\r
45Returns:\r
46\r
47 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
48\r
49--*/\r
50{\r
51 CHAR8 *Destination8;\r
52 CHAR8 *Source8;\r
53 volatile UINTN Length;\r
54\r
55 Destination8 = Buffer;\r
56 Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
57 Length = *ReadSize;\r
31528f0c 58 CopyMem (Destination8, Source8, Length);\r
95276127 59\r
60 return EFI_SUCCESS;\r
61}\r
62\r
63EFI_STATUS\r
64GetImageReadFunction (\r
65 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
66 )\r
67{\r
68 ImageContext->ImageRead = PeiImageRead;\r
69 return EFI_SUCCESS;\r
70}\r