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
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.
21 // Include common header file for this module.
23 #include "CommonHeader.h"
32 IN OUT UINTN
*ReadSize
,
39 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
43 FileHandle - The handle to the PE/COFF file
45 FileOffset - The offset, in bytes, into the file to read
47 ReadSize - The number of bytes to read from the file starting at FileOffset
49 Buffer - A pointer to the buffer to read the data into.
53 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
62 Destination32
= Buffer
;
63 Source32
= (UINT8
*) ((UINTN
) FileHandle
+ FileOffset
);
66 // This function assumes 32-bit alignment to increase performance
68 // ASSERT (ALIGN_POINTER (Destination32, sizeof (UINT32)) == Destination32);
69 // ASSERT (ALIGN_POINTER (Source32, sizeof (UINT32)) == Source32);
73 *(Destination32
++) = *(Source32
++);
80 GetImageReadFunction (
81 IN PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
86 Support routine to return the PE32 Image Reader.
87 If the PeiImageRead() function is less than a page
88 in legnth. If the function is more than a page the DXE IPL will crash!!!!
91 ImageContext - The context of the image being loaded
94 EFI_SUCCESS - If Image function location is found
101 ImageContext
->ImageRead
= PeiImageRead
;
106 // BugBug; This code assumes PeiImageRead() is less than a page in size!
107 // Allocate a page so we can shaddow the read function from FLASH into
108 // memory to increase performance.
111 MemoryBuffer
= AllocateCopyPool (0x400, (VOID
*)(UINTN
) PeiImageRead
);
112 ASSERT (MemoryBuffer
!= NULL
);
114 ImageContext
->ImageRead
= (PE_COFF_LOADER_READ_FILE
) (UINTN
) MemoryBuffer
;