]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/DxeIplPeim/Ia32/ImageRead.c
Add doxygen style comments for functions in DxeIpl.
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / Ia32 / ImageRead.c
CommitLineData
96226baa 1/** @file\r
2 This module loads an image to memory for IA32 Cpu architecture.\r
95276127 3\r
96226baa 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
95276127 9\r
96226baa 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 12\r
96226baa 13**/\r
95276127 14\r
95276127 15#include "DxeIpl.h"\r
16\r
91d92e25 17\r
18\r
19\r
20\r
21/**\r
22 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
23\r
24 @param FileHandle The handle to the PE/COFF file \r
25 @param FileOffset The offset, in bytes, into the file to read \r
26 @param ReadSize The number of bytes to read from the file starting at \r
27 FileOffset \r
28 @param Buffer A pointer to the buffer to read the data into. \r
29\r
30 @retval EFI_SUCCESS ReadSize bytes of data were read into Buffer from the \r
31 PE/COFF file starting at FileOffset\r
32\r
33**/\r
95276127 34EFI_STATUS\r
35EFIAPI\r
36PeiImageRead (\r
37 IN VOID *FileHandle,\r
38 IN UINTN FileOffset,\r
39 IN OUT UINTN *ReadSize,\r
40 OUT VOID *Buffer\r
41 )\r
95276127 42{\r
43 UINT8 *Destination32;\r
44 UINT8 *Source32;\r
45 UINTN Length;\r
46\r
47 \r
48 Destination32 = Buffer;\r
49 Source32 = (UINT8 *) ((UINTN) FileHandle + FileOffset);\r
50\r
51 //\r
52 // This function assumes 32-bit alignment to increase performance\r
53 //\r
54// ASSERT (ALIGN_POINTER (Destination32, sizeof (UINT32)) == Destination32);\r
55// ASSERT (ALIGN_POINTER (Source32, sizeof (UINT32)) == Source32);\r
56\r
57 Length = *ReadSize;\r
58 while (Length--) {\r
59 *(Destination32++) = *(Source32++);\r
60 }\r
61\r
62 return EFI_SUCCESS;\r
63}\r
64\r
95276127 65\r
95276127 66\r
95276127 67\r
95276127 68\r
91d92e25 69/**\r
70 This function simply retrieves the function pointer of ImageRead in\r
71 ImageContext structure.\r
72 \r
73 @param ImageContext A pointer to the structure of \r
74 PE_COFF_LOADER_IMAGE_CONTEXT\r
75 \r
76 @retval EFI_SUCCESS This function always return EFI_SUCCESS.\r
77\r
78**/\r
79EFI_STATUS\r
80GetImageReadFunction (\r
81 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
82 )\r
95276127 83{\r
84 VOID *MemoryBuffer;\r
85\r
86 if (gInMemory) {\r
87 ImageContext->ImageRead = PeiImageRead;\r
88 return EFI_SUCCESS;\r
89 }\r
90\r
91 //\r
92 // BugBug; This code assumes PeiImageRead() is less than a page in size!\r
93 // Allocate a page so we can shaddow the read function from FLASH into \r
94 // memory to increase performance. \r
95 //\r
96 \r
97 MemoryBuffer = AllocateCopyPool (0x400, (VOID *)(UINTN) PeiImageRead);\r
98 ASSERT (MemoryBuffer != NULL);\r
99\r
100 ImageContext->ImageRead = (PE_COFF_LOADER_READ_FILE) (UINTN) MemoryBuffer;\r
101\r
102 return EFI_SUCCESS;\r
103}\r