2 This module loads an image to memory for IA32 Cpu architecture.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 IN OUT UINTN
*ReadSize
,
29 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
33 FileHandle - The handle to the PE/COFF file
35 FileOffset - The offset, in bytes, into the file to read
37 ReadSize - The number of bytes to read from the file starting at FileOffset
39 Buffer - A pointer to the buffer to read the data into.
43 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
52 Destination32
= Buffer
;
53 Source32
= (UINT8
*) ((UINTN
) FileHandle
+ FileOffset
);
56 // This function assumes 32-bit alignment to increase performance
58 // ASSERT (ALIGN_POINTER (Destination32, sizeof (UINT32)) == Destination32);
59 // ASSERT (ALIGN_POINTER (Source32, sizeof (UINT32)) == Source32);
63 *(Destination32
++) = *(Source32
++);
70 GetImageReadFunction (
71 IN PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
76 Support routine to return the PE32 Image Reader.
77 If the PeiImageRead() function is less than a page
78 in legnth. If the function is more than a page the DXE IPL will crash!!!!
81 ImageContext - The context of the image being loaded
84 EFI_SUCCESS - If Image function location is found
91 ImageContext
->ImageRead
= PeiImageRead
;
96 // BugBug; This code assumes PeiImageRead() is less than a page in size!
97 // Allocate a page so we can shaddow the read function from FLASH into
98 // memory to increase performance.
101 MemoryBuffer
= AllocateCopyPool (0x400, (VOID
*)(UINTN
) PeiImageRead
);
102 ASSERT (MemoryBuffer
!= NULL
);
104 ImageContext
->ImageRead
= (PE_COFF_LOADER_READ_FILE
) (UINTN
) MemoryBuffer
;