]>
Commit | Line | Data |
---|---|---|
96226baa | 1 | /** @file\r |
fbc81c1e | 2 | Master header file for DxeIpl PEIM. All source files in this module should\r |
f45af90b | 3 | include this file for common defininitions.\r |
95276127 | 4 | \r |
96226baa | 5 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r |
95276127 | 6 | All rights reserved. This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
797a9d67 | 14 | **/\r |
95276127 | 15 | \r |
16 | #ifndef __PEI_DXEIPL_H__\r | |
17 | #define __PEI_DXEIPL_H__\r | |
18 | \r | |
859b72fa A |
19 | #include <PiPei.h>\r |
20 | #include <Ppi/DxeIpl.h>\r | |
859b72fa | 21 | #include <Ppi/EndOfPeiPhase.h>\r |
859b72fa | 22 | #include <Ppi/MemoryDiscovered.h>\r |
b74350e9 | 23 | #include <Ppi/ReadOnlyVariable2.h>\r |
b0d803fe | 24 | #include <Ppi/Decompress.h>\r |
25 | #include <Ppi/FirmwareVolumeInfo.h>\r | |
b98da1b1 | 26 | #include <Ppi/GuidedSectionExtraction.h>\r |
b0d803fe | 27 | \r |
b98da1b1 | 28 | #include <Guid/MemoryTypeInformation.h>\r |
30c8f861 | 29 | #include <Guid/MemoryAllocationHob.h>\r |
b0d803fe | 30 | #include <Guid/FirmwareFileSystem2.h>\r |
31 | \r | |
859b72fa A |
32 | #include <Library/DebugLib.h>\r |
33 | #include <Library/PeimEntryPoint.h>\r | |
34 | #include <Library/BaseLib.h>\r | |
35 | #include <Library/HobLib.h>\r | |
36 | #include <Library/PeiServicesLib.h>\r | |
37 | #include <Library/ReportStatusCodeLib.h>\r | |
38 | #include <Library/CacheMaintenanceLib.h>\r | |
859b72fa | 39 | #include <Library/UefiDecompressLib.h>\r |
18fd8d65 | 40 | #include <Library/ExtractGuidedSectionLib.h>\r |
859b72fa A |
41 | #include <Library/PeiServicesTablePointerLib.h>\r |
42 | #include <Library/BaseMemoryLib.h>\r | |
43 | #include <Library/MemoryAllocationLib.h>\r | |
44 | #include <Library/PcdLib.h>\r | |
45 | #include <Library/PeCoffLib.h>\r | |
4fb31c2c | 46 | #include <Library/S3Lib.h>\r |
47 | #include <Library/RecoveryLib.h>\r | |
95276127 | 48 | \r |
49 | #define STACK_SIZE 0x20000\r | |
50 | #define BSP_STORE_SIZE 0x4000\r | |
51 | \r | |
b98da1b1 | 52 | \r |
53 | //\r | |
54 | // This macro aligns the ActualSize with a given alignment and is used to \r | |
55 | // calculate the size an image occupies.\r | |
56 | //\r | |
95276127 | 57 | #define GET_OCCUPIED_SIZE(ActualSize, Alignment) ((ActualSize + (Alignment - 1)) & ~(Alignment - 1))\r |
58 | \r | |
b98da1b1 | 59 | //\r |
60 | // Indicate whether DxeIpl has been shadowed to memory.\r | |
61 | //\r | |
95276127 | 62 | extern BOOLEAN gInMemory;\r |
63 | \r | |
9b937a73 | 64 | //\r |
65 | // This PPI is installed to indicate the end of the PEI usage of memory \r | |
66 | //\r | |
67 | extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;\r | |
68 | \r | |
69 | \r | |
70 | \r | |
91d92e25 | 71 | /**\r |
72 | Loads and relocates a PE/COFF image into memory.\r | |
73 | \r | |
74 | @param FileHandle The image file handle\r | |
75 | @param ImageAddress The base address of the relocated PE/COFF image\r | |
76 | @param ImageSize The size of the relocated PE/COFF image\r | |
77 | @param EntryPoint The entry point of the relocated PE/COFF image\r | |
78 | \r | |
79 | @return EFI_SUCCESS The file was loaded and relocated\r | |
80 | @return EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file\r | |
81 | \r | |
82 | **/\r | |
95276127 | 83 | EFI_STATUS\r |
84 | PeiLoadFile (\r | |
b0d803fe | 85 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
95276127 | 86 | OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r |
87 | OUT UINT64 *ImageSize,\r | |
88 | OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r | |
f45af90b | 89 | );\r |
95276127 | 90 | \r |
91d92e25 | 91 | \r |
92 | \r | |
93 | /**\r | |
b6b98e91 | 94 | Searches DxeCore in all firmware Volumes and loads the first\r |
95 | instance that contains DxeCore.\r | |
91d92e25 | 96 | \r |
9b937a73 | 97 | @return FileHandle of DxeCore to load DxeCore.\r |
98 | \r | |
91d92e25 | 99 | **/\r |
9b937a73 | 100 | EFI_PEI_FILE_HANDLE\r |
288f9b38 | 101 | DxeIplFindDxeCore (\r |
b6b98e91 | 102 | VOID\r |
f45af90b | 103 | );\r |
95276127 | 104 | \r |
91d92e25 | 105 | \r |
91d92e25 | 106 | /**\r |
107 | This function simply retrieves the function pointer of ImageRead in\r | |
108 | ImageContext structure.\r | |
109 | \r | |
110 | @param ImageContext A pointer to the structure of \r | |
111 | PE_COFF_LOADER_IMAGE_CONTEXT\r | |
112 | \r | |
113 | @retval EFI_SUCCESS This function always return EFI_SUCCESS.\r | |
114 | \r | |
115 | **/\r | |
95276127 | 116 | EFI_STATUS\r |
117 | GetImageReadFunction (\r | |
118 | IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
f45af90b | 119 | );\r |
95276127 | 120 | \r |
91d92e25 | 121 | \r |
91d92e25 | 122 | /**\r |
123 | Main entry point to last PEIM \r | |
124 | \r | |
125 | @param This Entry point for DXE IPL PPI\r | |
126 | @param PeiServices General purpose services available to every PEIM.\r | |
127 | @param HobList Address to the Pei HOB list\r | |
128 | \r | |
129 | @return EFI_SUCCESS DXE core was successfully loaded. \r | |
130 | @return EFI_OUT_OF_RESOURCES There are not enough resources to load DXE core.\r | |
131 | \r | |
132 | **/\r | |
95276127 | 133 | EFI_STATUS\r |
134 | EFIAPI\r | |
135 | DxeLoadCore (\r | |
136 | IN EFI_DXE_IPL_PPI *This,\r | |
137 | IN EFI_PEI_SERVICES **PeiServices,\r | |
138 | IN EFI_PEI_HOB_POINTERS HobList\r | |
139 | );\r | |
140 | \r | |
91d92e25 | 141 | \r |
142 | \r | |
143 | /**\r | |
144 | Transfers control to DxeCore.\r | |
145 | \r | |
146 | This function performs a CPU architecture specific operations to execute\r | |
147 | the entry point of DxeCore with the parameters of HobList.\r | |
148 | It also intalls EFI_END_OF_PEI_PPI to signal the end of PEI phase.\r | |
149 | \r | |
150 | @param DxeCoreEntryPoint The entrypoint of DxeCore.\r | |
151 | @param HobList The start of HobList passed to DxeCore.\r | |
91d92e25 | 152 | \r |
153 | **/\r | |
95276127 | 154 | VOID\r |
155 | HandOffToDxeCore (\r | |
156 | IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r | |
9b937a73 | 157 | IN EFI_PEI_HOB_POINTERS HobList\r |
95276127 | 158 | );\r |
159 | \r | |
91d92e25 | 160 | \r |
161 | \r | |
162 | /**\r | |
163 | Updates the Stack HOB passed to DXE phase.\r | |
164 | \r | |
165 | This function traverses the whole HOB list and update the stack HOB to\r | |
166 | reflect the real stack that is used by DXE core.\r | |
167 | \r | |
168 | @param BaseAddress The lower address of stack used by DxeCore.\r | |
169 | @param Length The length of stack used by DxeCore.\r | |
170 | \r | |
171 | **/\r | |
30c8f861 | 172 | VOID\r |
173 | UpdateStackHob (\r | |
174 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
175 | IN UINT64 Length\r | |
176 | );\r | |
177 | \r | |
b98da1b1 | 178 | /**\r |
179 | The ExtractSection() function processes the input section and\r | |
180 | returns a pointer to the section contents. If the section being\r | |
181 | extracted does not require processing (if the section\r | |
182 | GuidedSectionHeader.Attributes has the\r | |
183 | EFI_GUIDED_SECTION_PROCESSING_REQUIRED field cleared), then\r | |
184 | OutputBuffer is just updated to point to the start of the\r | |
185 | section's contents. Otherwise, *Buffer must be allocated\r | |
186 | from PEI permanent memory.\r | |
187 | \r | |
188 | @param This Indicates the\r | |
189 | EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI instance.\r | |
190 | Buffer containing the input GUIDed section to be\r | |
191 | processed. OutputBuffer OutputBuffer is\r | |
192 | allocated from PEI permanent memory and contains\r | |
193 | the new section stream.\r | |
194 | @param InputSection A pointer to the input buffer, which contains\r | |
195 | the input section to be processed.\r | |
196 | @param OutputBuffer A pointer to a caller-allocated buffer, whose\r | |
197 | size is specified by the contents of OutputSize.\r | |
198 | @param OutputSize A pointer to a caller-allocated\r | |
199 | UINTN in which the size of *OutputBuffer\r | |
200 | allocation is stored. If the function\r | |
201 | returns anything other than EFI_SUCCESS,\r | |
202 | the value of OutputSize is undefined.\r | |
203 | @param AuthenticationStatus A pointer to a caller-allocated\r | |
204 | UINT32 that indicates the\r | |
205 | authentication status of the\r | |
206 | output buffer. If the input\r | |
207 | section's GuidedSectionHeader.\r | |
208 | Attributes field has the\r | |
209 | EFI_GUIDED_SECTION_AUTH_STATUS_VALID \r | |
210 | bit as clear,\r | |
211 | AuthenticationStatus must return\r | |
212 | zero. These bits reflect the\r | |
213 | status of the extraction\r | |
214 | operation. If the function\r | |
215 | returns anything other than\r | |
216 | EFI_SUCCESS, the value of\r | |
217 | AuthenticationStatus is\r | |
218 | undefined.\r | |
219 | \r | |
220 | @retval EFI_SUCCESS The InputSection was\r | |
221 | successfully processed and the\r | |
222 | section contents were returned.\r | |
223 | \r | |
224 | @retval EFI_OUT_OF_RESOURCES The system has insufficient\r | |
225 | resources to process the request.\r | |
226 | \r | |
227 | @retval EFI_INVALID_PARAMETER The GUID in InputSection does\r | |
228 | not match this instance of the\r | |
229 | GUIDed Section Extraction PPI.\r | |
91d92e25 | 230 | \r |
b98da1b1 | 231 | **/\r |
232 | EFI_STATUS\r | |
233 | CustomGuidedSectionExtract (\r | |
234 | IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,\r | |
235 | IN CONST VOID *InputSection,\r | |
236 | OUT VOID **OutputBuffer,\r | |
237 | OUT UINTN *OutputSize,\r | |
238 | OUT UINT32 *AuthenticationStatus\r | |
239 | );\r | |
240 | \r | |
241 | \r | |
242 | /**\r | |
243 | Decompresses a section to the output buffer.\r | |
244 | \r | |
245 | This function lookes up the compression type field in the input section and\r | |
246 | applies the appropriate compression algorithm to compress the section to a\r | |
247 | callee allocated buffer.\r | |
248 | \r | |
249 | @param This Points to this instance of the\r | |
250 | EFI_PEI_DECOMPRESS_PEI PPI.\r | |
251 | @param CompressionSection Points to the compressed section.\r | |
252 | @param OutputBuffer Holds the returned pointer to the decompressed\r | |
253 | sections.\r | |
254 | @param OutputSize Holds the returned size of the decompress\r | |
255 | section streams.\r | |
256 | \r | |
257 | @retval EFI_SUCCESS The section was decompressed successfully.\r | |
258 | OutputBuffer contains the resulting data and\r | |
259 | OutputSize contains the resulting size.\r | |
260 | \r | |
261 | **/\r | |
262 | EFI_STATUS\r | |
263 | EFIAPI \r | |
264 | Decompress (\r | |
265 | IN CONST EFI_PEI_DECOMPRESS_PPI *This,\r | |
266 | IN CONST EFI_COMPRESSION_SECTION *CompressionSection,\r | |
267 | OUT VOID **OutputBuffer,\r | |
268 | OUT UINTN *OutputSize\r | |
269 | );\r | |
91d92e25 | 270 | \r |
271 | /**\r | |
272 | Initializes the Dxe Ipl PPI\r | |
273 | \r | |
274 | @param FfsHandle The handle of FFS file.\r | |
275 | @param PeiServices General purpose services available to\r | |
276 | every PEIM.\r | |
277 | @return EFI_SUCESS\r | |
278 | \r | |
279 | **/\r | |
95276127 | 280 | EFI_STATUS\r |
281 | EFIAPI\r | |
282 | PeimInitializeDxeIpl (\r | |
b0d803fe | 283 | IN EFI_PEI_FILE_HANDLE FfsHandle,\r |
95276127 | 284 | IN EFI_PEI_SERVICES **PeiServices\r |
f45af90b | 285 | );\r |
95276127 | 286 | \r |
287 | \r | |
288 | #endif\r |