]>
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/BaseMemoryLib.h>\r |
42 | #include <Library/MemoryAllocationLib.h>\r | |
43 | #include <Library/PcdLib.h>\r | |
44 | #include <Library/PeCoffLib.h>\r | |
4fb31c2c | 45 | #include <Library/S3Lib.h>\r |
46 | #include <Library/RecoveryLib.h>\r | |
95276127 | 47 | \r |
48 | #define STACK_SIZE 0x20000\r | |
49 | #define BSP_STORE_SIZE 0x4000\r | |
50 | \r | |
b98da1b1 | 51 | \r |
52 | //\r | |
53 | // This macro aligns the ActualSize with a given alignment and is used to \r | |
54 | // calculate the size an image occupies.\r | |
55 | //\r | |
95276127 | 56 | #define GET_OCCUPIED_SIZE(ActualSize, Alignment) ((ActualSize + (Alignment - 1)) & ~(Alignment - 1))\r |
57 | \r | |
b98da1b1 | 58 | //\r |
59 | // Indicate whether DxeIpl has been shadowed to memory.\r | |
60 | //\r | |
95276127 | 61 | extern BOOLEAN gInMemory;\r |
62 | \r | |
9b937a73 | 63 | //\r |
64 | // This PPI is installed to indicate the end of the PEI usage of memory \r | |
65 | //\r | |
66 | extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;\r | |
67 | \r | |
68 | \r | |
69 | \r | |
91d92e25 | 70 | /**\r |
71 | Loads and relocates a PE/COFF image into memory.\r | |
72 | \r | |
73 | @param FileHandle The image file handle\r | |
74 | @param ImageAddress The base address of the relocated PE/COFF image\r | |
75 | @param ImageSize The size of the relocated PE/COFF image\r | |
76 | @param EntryPoint The entry point of the relocated PE/COFF image\r | |
77 | \r | |
78 | @return EFI_SUCCESS The file was loaded and relocated\r | |
79 | @return EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file\r | |
80 | \r | |
81 | **/\r | |
95276127 | 82 | EFI_STATUS\r |
83 | PeiLoadFile (\r | |
b0d803fe | 84 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
95276127 | 85 | OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r |
86 | OUT UINT64 *ImageSize,\r | |
87 | OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r | |
f45af90b | 88 | );\r |
95276127 | 89 | \r |
91d92e25 | 90 | \r |
91 | \r | |
92 | /**\r | |
b6b98e91 | 93 | Searches DxeCore in all firmware Volumes and loads the first\r |
94 | instance that contains DxeCore.\r | |
91d92e25 | 95 | \r |
9b937a73 | 96 | @return FileHandle of DxeCore to load DxeCore.\r |
97 | \r | |
91d92e25 | 98 | **/\r |
9b937a73 | 99 | EFI_PEI_FILE_HANDLE\r |
288f9b38 | 100 | DxeIplFindDxeCore (\r |
b6b98e91 | 101 | VOID\r |
f45af90b | 102 | );\r |
95276127 | 103 | \r |
91d92e25 | 104 | \r |
91d92e25 | 105 | /**\r |
106 | This function simply retrieves the function pointer of ImageRead in\r | |
107 | ImageContext structure.\r | |
108 | \r | |
109 | @param ImageContext A pointer to the structure of \r | |
110 | PE_COFF_LOADER_IMAGE_CONTEXT\r | |
111 | \r | |
112 | @retval EFI_SUCCESS This function always return EFI_SUCCESS.\r | |
113 | \r | |
114 | **/\r | |
95276127 | 115 | EFI_STATUS\r |
116 | GetImageReadFunction (\r | |
117 | IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
f45af90b | 118 | );\r |
95276127 | 119 | \r |
91d92e25 | 120 | \r |
91d92e25 | 121 | /**\r |
122 | Main entry point to last PEIM \r | |
123 | \r | |
124 | @param This Entry point for DXE IPL PPI\r | |
125 | @param PeiServices General purpose services available to every PEIM.\r | |
126 | @param HobList Address to the Pei HOB list\r | |
127 | \r | |
128 | @return EFI_SUCCESS DXE core was successfully loaded. \r | |
129 | @return EFI_OUT_OF_RESOURCES There are not enough resources to load DXE core.\r | |
130 | \r | |
131 | **/\r | |
95276127 | 132 | EFI_STATUS\r |
133 | EFIAPI\r | |
134 | DxeLoadCore (\r | |
1f3a753e | 135 | IN CONST EFI_DXE_IPL_PPI *This,\r |
95276127 | 136 | IN EFI_PEI_SERVICES **PeiServices,\r |
137 | IN EFI_PEI_HOB_POINTERS HobList\r | |
138 | );\r | |
139 | \r | |
91d92e25 | 140 | \r |
141 | \r | |
142 | /**\r | |
143 | Transfers control to DxeCore.\r | |
144 | \r | |
145 | This function performs a CPU architecture specific operations to execute\r | |
146 | the entry point of DxeCore with the parameters of HobList.\r | |
147 | It also intalls EFI_END_OF_PEI_PPI to signal the end of PEI phase.\r | |
148 | \r | |
149 | @param DxeCoreEntryPoint The entrypoint of DxeCore.\r | |
150 | @param HobList The start of HobList passed to DxeCore.\r | |
91d92e25 | 151 | \r |
152 | **/\r | |
95276127 | 153 | VOID\r |
154 | HandOffToDxeCore (\r | |
155 | IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r | |
9b937a73 | 156 | IN EFI_PEI_HOB_POINTERS HobList\r |
95276127 | 157 | );\r |
158 | \r | |
91d92e25 | 159 | \r |
160 | \r | |
161 | /**\r | |
162 | Updates the Stack HOB passed to DXE phase.\r | |
163 | \r | |
164 | This function traverses the whole HOB list and update the stack HOB to\r | |
165 | reflect the real stack that is used by DXE core.\r | |
166 | \r | |
167 | @param BaseAddress The lower address of stack used by DxeCore.\r | |
168 | @param Length The length of stack used by DxeCore.\r | |
169 | \r | |
170 | **/\r | |
30c8f861 | 171 | VOID\r |
172 | UpdateStackHob (\r | |
173 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
174 | IN UINT64 Length\r | |
175 | );\r | |
176 | \r | |
b98da1b1 | 177 | /**\r |
178 | The ExtractSection() function processes the input section and\r | |
179 | returns a pointer to the section contents. If the section being\r | |
180 | extracted does not require processing (if the section\r | |
181 | GuidedSectionHeader.Attributes has the\r | |
182 | EFI_GUIDED_SECTION_PROCESSING_REQUIRED field cleared), then\r | |
183 | OutputBuffer is just updated to point to the start of the\r | |
184 | section's contents. Otherwise, *Buffer must be allocated\r | |
185 | from PEI permanent memory.\r | |
186 | \r | |
187 | @param This Indicates the\r | |
188 | EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI instance.\r | |
189 | Buffer containing the input GUIDed section to be\r | |
190 | processed. OutputBuffer OutputBuffer is\r | |
191 | allocated from PEI permanent memory and contains\r | |
192 | the new section stream.\r | |
193 | @param InputSection A pointer to the input buffer, which contains\r | |
194 | the input section to be processed.\r | |
195 | @param OutputBuffer A pointer to a caller-allocated buffer, whose\r | |
196 | size is specified by the contents of OutputSize.\r | |
197 | @param OutputSize A pointer to a caller-allocated\r | |
198 | UINTN in which the size of *OutputBuffer\r | |
199 | allocation is stored. If the function\r | |
200 | returns anything other than EFI_SUCCESS,\r | |
201 | the value of OutputSize is undefined.\r | |
202 | @param AuthenticationStatus A pointer to a caller-allocated\r | |
203 | UINT32 that indicates the\r | |
204 | authentication status of the\r | |
205 | output buffer. If the input\r | |
206 | section's GuidedSectionHeader.\r | |
207 | Attributes field has the\r | |
208 | EFI_GUIDED_SECTION_AUTH_STATUS_VALID \r | |
209 | bit as clear,\r | |
210 | AuthenticationStatus must return\r | |
211 | zero. These bits reflect the\r | |
212 | status of the extraction\r | |
213 | operation. If the function\r | |
214 | returns anything other than\r | |
215 | EFI_SUCCESS, the value of\r | |
216 | AuthenticationStatus is\r | |
217 | undefined.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS The InputSection was\r | |
220 | successfully processed and the\r | |
221 | section contents were returned.\r | |
222 | \r | |
223 | @retval EFI_OUT_OF_RESOURCES The system has insufficient\r | |
224 | resources to process the request.\r | |
225 | \r | |
226 | @retval EFI_INVALID_PARAMETER The GUID in InputSection does\r | |
227 | not match this instance of the\r | |
228 | GUIDed Section Extraction PPI.\r | |
91d92e25 | 229 | \r |
b98da1b1 | 230 | **/\r |
231 | EFI_STATUS\r | |
232 | CustomGuidedSectionExtract (\r | |
233 | IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,\r | |
234 | IN CONST VOID *InputSection,\r | |
235 | OUT VOID **OutputBuffer,\r | |
236 | OUT UINTN *OutputSize,\r | |
237 | OUT UINT32 *AuthenticationStatus\r | |
238 | );\r | |
239 | \r | |
240 | \r | |
241 | /**\r | |
242 | Decompresses a section to the output buffer.\r | |
243 | \r | |
244 | This function lookes up the compression type field in the input section and\r | |
245 | applies the appropriate compression algorithm to compress the section to a\r | |
246 | callee allocated buffer.\r | |
247 | \r | |
248 | @param This Points to this instance of the\r | |
249 | EFI_PEI_DECOMPRESS_PEI PPI.\r | |
250 | @param CompressionSection Points to the compressed section.\r | |
251 | @param OutputBuffer Holds the returned pointer to the decompressed\r | |
252 | sections.\r | |
253 | @param OutputSize Holds the returned size of the decompress\r | |
254 | section streams.\r | |
255 | \r | |
256 | @retval EFI_SUCCESS The section was decompressed successfully.\r | |
257 | OutputBuffer contains the resulting data and\r | |
258 | OutputSize contains the resulting size.\r | |
259 | \r | |
260 | **/\r | |
261 | EFI_STATUS\r | |
262 | EFIAPI \r | |
263 | Decompress (\r | |
264 | IN CONST EFI_PEI_DECOMPRESS_PPI *This,\r | |
265 | IN CONST EFI_COMPRESSION_SECTION *CompressionSection,\r | |
266 | OUT VOID **OutputBuffer,\r | |
267 | OUT UINTN *OutputSize\r | |
268 | );\r | |
91d92e25 | 269 | \r |
95276127 | 270 | #endif\r |