6f8e13d21335268a92fbd30caa33cd13c4c7ce55
[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 definitions.
4
5 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
6 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 #include <Ppi/LoadFile.h>
28 #include <Ppi/S3Resume2.h>
29 #include <Ppi/RecoveryModule.h>
30 #include <Ppi/VectorHandoffInfo.h>
31
32 #include <Guid/MemoryTypeInformation.h>
33 #include <Guid/MemoryAllocationHob.h>
34 #include <Guid/FirmwareFileSystem2.h>
35
36 #include <Library/DebugLib.h>
37 #include <Library/PeimEntryPoint.h>
38 #include <Library/BaseLib.h>
39 #include <Library/HobLib.h>
40 #include <Library/PeiServicesLib.h>
41 #include <Library/ReportStatusCodeLib.h>
42 #include <Library/UefiDecompressLib.h>
43 #include <Library/ExtractGuidedSectionLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/MemoryAllocationLib.h>
46 #include <Library/PcdLib.h>
47 #include <Library/S3Lib.h>
48 #include <Library/RecoveryLib.h>
49 #include <Library/DebugAgentLib.h>
50 #include <Library/PeiServicesTablePointerLib.h>
51
52 #define STACK_SIZE 0x20000
53 #define BSP_STORE_SIZE 0x4000
54
55
56 //
57 // This PPI is installed to indicate the end of the PEI usage of memory
58 //
59 extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;
60
61 /**
62 This function installs the PPIs that require permanent memory.
63
64 @param PeiServices Indirect reference to the PEI Services Table.
65 @param NotifyDescriptor Address of the notification descriptor data structure.
66 @param Ppi Address of the PPI that was installed.
67
68 @return EFI_SUCCESS The PPIs were installed successfully.
69 @return Others Some error occurs during the execution of this function.
70
71 **/
72 EFI_STATUS
73 EFIAPI
74 InstallIplPermanentMemoryPpis (
75 IN EFI_PEI_SERVICES **PeiServices,
76 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
77 IN VOID *Ppi
78 );
79
80 /**
81 Searches DxeCore in all firmware Volumes and loads the first
82 instance that contains DxeCore.
83
84 @return FileHandle of DxeCore to load DxeCore.
85
86 **/
87 EFI_PEI_FILE_HANDLE
88 DxeIplFindDxeCore (
89 VOID
90 );
91
92
93 /**
94 Main entry point to last PEIM
95
96 @param This Entry point for DXE IPL PPI
97 @param PeiServices General purpose services available to every PEIM.
98 @param HobList Address to the Pei HOB list
99
100 @return EFI_SUCCESS DXE core was successfully loaded.
101 @return EFI_OUT_OF_RESOURCES There are not enough resources to load DXE core.
102
103 **/
104 EFI_STATUS
105 EFIAPI
106 DxeLoadCore (
107 IN CONST EFI_DXE_IPL_PPI *This,
108 IN EFI_PEI_SERVICES **PeiServices,
109 IN EFI_PEI_HOB_POINTERS HobList
110 );
111
112
113
114 /**
115 Transfers control to DxeCore.
116
117 This function performs a CPU architecture specific operations to execute
118 the entry point of DxeCore with the parameters of HobList.
119 It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
120
121 @param DxeCoreEntryPoint The entry point of DxeCore.
122 @param HobList The start of HobList passed to DxeCore.
123
124 **/
125 VOID
126 HandOffToDxeCore (
127 IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
128 IN EFI_PEI_HOB_POINTERS HobList
129 );
130
131
132
133 /**
134 Updates the Stack HOB passed to DXE phase.
135
136 This function traverses the whole HOB list and update the stack HOB to
137 reflect the real stack that is used by DXE core.
138
139 @param BaseAddress The lower address of stack used by DxeCore.
140 @param Length The length of stack used by DxeCore.
141
142 **/
143 VOID
144 UpdateStackHob (
145 IN EFI_PHYSICAL_ADDRESS BaseAddress,
146 IN UINT64 Length
147 );
148
149 /**
150 The ExtractSection() function processes the input section and
151 returns a pointer to the section contents. If the section being
152 extracted does not require processing (if the section
153 GuidedSectionHeader.Attributes has the
154 EFI_GUIDED_SECTION_PROCESSING_REQUIRED field cleared), then
155 OutputBuffer is just updated to point to the start of the
156 section's contents. Otherwise, *Buffer must be allocated
157 from PEI permanent memory.
158
159 @param This Indicates the
160 EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI instance.
161 Buffer containing the input GUIDed section to be
162 processed. OutputBuffer OutputBuffer is
163 allocated from PEI permanent memory and contains
164 the new section stream.
165 @param InputSection A pointer to the input buffer, which contains
166 the input section to be processed.
167 @param OutputBuffer A pointer to a caller-allocated buffer, whose
168 size is specified by the contents of OutputSize.
169 @param OutputSize A pointer to a caller-allocated
170 UINTN in which the size of *OutputBuffer
171 allocation is stored. If the function
172 returns anything other than EFI_SUCCESS,
173 the value of OutputSize is undefined.
174 @param AuthenticationStatus A pointer to a caller-allocated
175 UINT32 that indicates the
176 authentication status of the
177 output buffer. If the input
178 section's GuidedSectionHeader.
179 Attributes field has the
180 EFI_GUIDED_SECTION_AUTH_STATUS_VALID
181 bit as clear,
182 AuthenticationStatus must return
183 zero. These bits reflect the
184 status of the extraction
185 operation. If the function
186 returns anything other than
187 EFI_SUCCESS, the value of
188 AuthenticationStatus is
189 undefined.
190
191 @retval EFI_SUCCESS The InputSection was
192 successfully processed and the
193 section contents were returned.
194
195 @retval EFI_OUT_OF_RESOURCES The system has insufficient
196 resources to process the request.
197
198 @retval EFI_INVALID_PARAMETER The GUID in InputSection does
199 not match this instance of the
200 GUIDed Section Extraction PPI.
201
202 **/
203 EFI_STATUS
204 EFIAPI
205 CustomGuidedSectionExtract (
206 IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,
207 IN CONST VOID *InputSection,
208 OUT VOID **OutputBuffer,
209 OUT UINTN *OutputSize,
210 OUT UINT32 *AuthenticationStatus
211 );
212
213
214 /**
215 Decompresses a section to the output buffer.
216
217 This function looks up the compression type field in the input section and
218 applies the appropriate compression algorithm to compress the section to a
219 callee allocated buffer.
220
221 @param This Points to this instance of the
222 EFI_PEI_DECOMPRESS_PEI PPI.
223 @param CompressionSection Points to the compressed section.
224 @param OutputBuffer Holds the returned pointer to the decompressed
225 sections.
226 @param OutputSize Holds the returned size of the decompress
227 section streams.
228
229 @retval EFI_SUCCESS The section was decompressed successfully.
230 OutputBuffer contains the resulting data and
231 OutputSize contains the resulting size.
232
233 **/
234 EFI_STATUS
235 EFIAPI
236 Decompress (
237 IN CONST EFI_PEI_DECOMPRESS_PPI *This,
238 IN CONST EFI_COMPRESSION_SECTION *CompressionSection,
239 OUT VOID **OutputBuffer,
240 OUT UINTN *OutputSize
241 );
242
243 #endif