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