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