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