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.
27 IN OUT UINTN
*ReadSize
,
34 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
38 FileHandle - The handle to the PE/COFF file
40 FileOffset - The offset, in bytes, into the file to read
42 ReadSize - The number of bytes to read from the file starting at FileOffset
44 Buffer - A pointer to the buffer to read the data into.
48 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
57 Destination32
= Buffer
;
58 Source32
= (UINT8
*) ((UINTN
) FileHandle
+ FileOffset
);
61 // This function assumes 32-bit alignment to increase performance
63 // ASSERT (ALIGN_POINTER (Destination32, sizeof (UINT32)) == Destination32);
64 // ASSERT (ALIGN_POINTER (Source32, sizeof (UINT32)) == Source32);
68 *(Destination32
++) = *(Source32
++);
75 GetImageReadFunction (
76 IN PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
81 Support routine to return the PE32 Image Reader.
82 If the PeiImageRead() function is less than a page
83 in legnth. If the function is more than a page the DXE IPL will crash!!!!
86 ImageContext - The context of the image being loaded
89 EFI_SUCCESS - If Image function location is found
96 ImageContext
->ImageRead
= PeiImageRead
;
101 // BugBug; This code assumes PeiImageRead() is less than a page in size!
102 // Allocate a page so we can shaddow the read function from FLASH into
103 // memory to increase performance.
106 MemoryBuffer
= AllocateCopyPool (0x400, (VOID
*)(UINTN
) PeiImageRead
);
107 ASSERT (MemoryBuffer
!= NULL
);
109 ImageContext
->ImageRead
= (PE_COFF_LOADER_READ_FILE
) (UINTN
) MemoryBuffer
;