Enable Nt32 platform boot to DXE phase.
[mirror_edk2.git] / MdeModulePkg / 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 //
21 // Include common header file for this module.
22 //
23 #include "CommonHeader.h"
24
25 #include "DxeIpl.h"
26
27 EFI_STATUS
28 PeiImageRead (
29 IN VOID *FileHandle,
30 IN UINTN FileOffset,
31 IN OUT UINTN *ReadSize,
32 OUT VOID *Buffer
33 )
34 /*++
35
36 Routine Description:
37
38 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
39
40 Arguments:
41
42 FileHandle - The handle to the PE/COFF file
43
44 FileOffset - The offset, in bytes, into the file to read
45
46 ReadSize - The number of bytes to read from the file starting at FileOffset
47
48 Buffer - A pointer to the buffer to read the data into.
49
50 Returns:
51
52 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
53
54 --*/
55 {
56 CHAR8 *Destination8;
57 CHAR8 *Source8;
58 volatile UINTN Length;
59
60 Destination8 = Buffer;
61 Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
62 Length = *ReadSize;
63 while (Length--) {
64 *(Destination8++) = *(Source8++);
65 }
66
67 return EFI_SUCCESS;
68 }
69
70 EFI_STATUS
71 GetImageReadFunction (
72 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
73 )
74 {
75 ImageContext->ImageRead = PeiImageRead;
76 return EFI_SUCCESS;
77 }