]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 Definition of Pei Core Structures and Services\r
d1102dba
LG
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
192f6d4c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
615c6dd0 13**/\r
192f6d4c 14\r
15#ifndef _PEI_MAIN_H_\r
16#define _PEI_MAIN_H_\r
17\r
859b72fa 18#include <PiPei.h>\r
859b72fa
A
19#include <Ppi/DxeIpl.h>\r
20#include <Ppi/MemoryDiscovered.h>\r
859b72fa 21#include <Ppi/StatusCode.h>\r
859b72fa 22#include <Ppi/Reset.h>\r
672473ea 23#include <Ppi/Reset2.h>\r
b0d803fe 24#include <Ppi/FirmwareVolume.h>\r
25#include <Ppi/FirmwareVolumeInfo.h>\r
c7935105 26#include <Ppi/FirmwareVolumeInfo2.h>\r
b0d803fe 27#include <Ppi/Decompress.h>\r
28#include <Ppi/GuidedSectionExtraction.h>\r
29#include <Ppi/LoadFile.h>\r
30#include <Ppi/Security2.h>\r
58dcdada 31#include <Ppi/TemporaryRamSupport.h>\r
0f9ebb32 32#include <Ppi/TemporaryRamDone.h>\r
483e2cdd 33#include <Ppi/SecHobData.h>\r
859b72fa
A
34#include <Library/DebugLib.h>\r
35#include <Library/PeiCoreEntryPoint.h>\r
36#include <Library/BaseLib.h>\r
37#include <Library/HobLib.h>\r
38#include <Library/PerformanceLib.h>\r
39#include <Library/PeiServicesLib.h>\r
40#include <Library/ReportStatusCodeLib.h>\r
c58cf83d 41#include <Library/PeCoffLib.h>\r
859b72fa
A
42#include <Library/PeCoffGetEntryPointLib.h>\r
43#include <Library/BaseMemoryLib.h>\r
b0d803fe 44#include <Library/CacheMaintenanceLib.h>\r
177aabe6 45#include <Library/PcdLib.h>\r
28dc3c67 46#include <IndustryStandard/PeImage.h>\r
14e8823a 47#include <Library/PeiServicesTablePointerLib.h>\r
b0d803fe 48#include <Library/MemoryAllocationLib.h>\r
49#include <Guid/FirmwareFileSystem2.h>\r
890e5417 50#include <Guid/FirmwareFileSystem3.h>\r
b0d803fe 51#include <Guid/AprioriFileName.h>\r
192f6d4c 52\r
15273993 53///\r
54/// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
55/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
56///\r
3a63377f 57#define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff\r
58\r
b1f6a7c6 59///\r
60/// Pei Core private data structures\r
61///\r
192f6d4c 62typedef union {\r
63 EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
64 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
65 VOID *Raw;\r
66} PEI_PPI_LIST_POINTERS;\r
67\r
40f26b8f 68///\r
1cc76977 69/// PPI database structure which contains two link: PpiList and NotifyList. PpiList\r
70/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.\r
40f26b8f 71///\r
192f6d4c 72typedef struct {\r
1cc76977 73 ///\r
74 /// index of end of PpiList link list.\r
75 ///\r
192f6d4c 76 INTN PpiListEnd;\r
1cc76977 77 ///\r
78 /// index of end of notify link list.\r
79 ///\r
192f6d4c 80 INTN NotifyListEnd;\r
1cc76977 81 ///\r
82 /// index of the dispatched notify list.\r
83 ///\r
192f6d4c 84 INTN DispatchListEnd;\r
1cc76977 85 ///\r
86 /// index of last installed Ppi description in PpiList link list.\r
87 ///\r
192f6d4c 88 INTN LastDispatchedInstall;\r
1cc76977 89 ///\r
90 /// index of last dispatched notify in Notify link list.\r
d1102dba 91 ///\r
192f6d4c 92 INTN LastDispatchedNotify;\r
1cc76977 93 ///\r
fe781940 94 /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.\r
1cc76977 95 ///\r
fe781940 96 PEI_PPI_LIST_POINTERS *PpiListPtrs;\r
192f6d4c 97} PEI_PPI_DATABASE;\r
98\r
3a63377f 99\r
3a63377f 100//\r
101// PEI_CORE_FV_HANDE.PeimState\r
102// Do not change these values as there is code doing math to change states.\r
103// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
104//\r
105#define PEIM_STATE_NOT_DISPATCHED 0x00\r
106#define PEIM_STATE_DISPATCHED 0x01\r
c2c4199b 107#define PEIM_STATE_REGISTER_FOR_SHADOW 0x02\r
3a63377f 108#define PEIM_STATE_DONE 0x03\r
109\r
111e6c92
SZ
110//\r
111// Number of FV instances to grow by each time we run out of room\r
112//\r
113#define FV_GROWTH_STEP 8\r
114\r
3a63377f 115typedef struct {\r
116 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
3b428ade 117 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
118 EFI_PEI_FV_HANDLE FvHandle;\r
b62fe570 119 UINTN PeimCount;\r
fe781940 120 //\r
b62fe570 121 // Ponter to the buffer with the PeimCount number of Entries.\r
fe781940
SZ
122 //\r
123 UINT8 *PeimState;\r
124 //\r
b62fe570 125 // Ponter to the buffer with the PeimCount number of Entries.\r
fe781940
SZ
126 //\r
127 EFI_PEI_FILE_HANDLE *FvFileHandles;\r
3a63377f 128 BOOLEAN ScanFv;\r
c7935105 129 UINT32 AuthenticationStatus;\r
3a63377f 130} PEI_CORE_FV_HANDLE;\r
131\r
f3358329 132typedef struct {\r
133 EFI_GUID FvFormat;\r
134 VOID *FvInfo;\r
135 UINT32 FvInfoSize;\r
c7935105 136 UINT32 AuthenticationStatus;\r
f3358329 137 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
138} PEI_CORE_UNKNOW_FORMAT_FV_INFO;\r
139\r
288f9b38
LG
140#define CACHE_SETION_MAX_NUMBER 0x10\r
141typedef struct {\r
142 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
143 VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
144 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
c7935105 145 UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER];\r
288f9b38
LG
146 UINTN AllSectionCount;\r
147 UINTN SectionIndex;\r
148} CACHE_SECTION_DATA;\r
149\r
0f9ebb32
LG
150#define HOLE_MAX_NUMBER 0x3\r
151typedef struct {\r
152 EFI_PHYSICAL_ADDRESS Base;\r
153 UINTN Size;\r
154 UINTN Offset;\r
155 BOOLEAN OffsetPositive;\r
156} HOLE_MEMORY_DATA;\r
157\r
ef05e063 158///\r
159/// Forward declaration for PEI_CORE_INSTANCE\r
160///\r
161typedef struct _PEI_CORE_INSTANCE PEI_CORE_INSTANCE;\r
162\r
163\r
164/**\r
165 Function Pointer type for PeiCore function.\r
d1102dba 166 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
ef05e063 167 and location of temporary RAM, the stack location and the BFV location.\r
168 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
169 An empty PPI list consists of a single descriptor with the end-tag\r
170 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
171 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
172 that both the PEI Foundation and any modules can leverage the associated service\r
173 calls and/or code in these early PPIs\r
174 @param OldCoreData Pointer to old core data that is used to initialize the\r
175 core's data areas.\r
176**/\r
177typedef\r
178EFI_STATUS\r
179(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
180 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
181 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
182 IN PEI_CORE_INSTANCE *OldCoreData\r
183 );\r
192f6d4c 184\r
b62fe570
SZ
185//\r
186// Number of files to grow by each time we run out of room\r
187//\r
188#define TEMP_FILE_GROWTH_STEP 32\r
189\r
f3f2e05d 190#define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')\r
192f6d4c 191\r
40f26b8f 192///\r
193/// Pei Core private data structure instance\r
194///\r
ef05e063 195struct _PEI_CORE_INSTANCE {\r
192f6d4c 196 UINTN Signature;\r
d1102dba 197\r
3b428ade 198 ///\r
199 /// Point to ServiceTableShadow\r
200 ///\r
4140a663 201 EFI_PEI_SERVICES *Ps;\r
192f6d4c 202 PEI_PPI_DATABASE PpiData;\r
d1102dba 203\r
3b428ade 204 ///\r
205 /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
206 ///\r
3a63377f 207 UINTN FvCount;\r
d1102dba 208\r
3b428ade 209 ///\r
111e6c92
SZ
210 /// The max count of FVs which contains FFS and could be dispatched by PeiCore.\r
211 ///\r
212 UINTN MaxFvCount;\r
213\r
214 ///\r
215 /// Pointer to the buffer with the MaxFvCount number of entries.\r
fe781940 216 /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.\r
3b428ade 217 ///\r
fe781940
SZ
218 PEI_CORE_FV_HANDLE *Fv;\r
219\r
220 ///\r
111e6c92 221 /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.\r
fe781940
SZ
222 /// Each entry is for one FV which could not be dispatched by PeiCore.\r
223 ///\r
224 PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;\r
111e6c92 225 UINTN MaxUnknownFvInfoCount;\r
f3358329 226 UINTN UnknownFvInfoCount;\r
d1102dba 227\r
fe781940 228 ///\r
b62fe570 229 /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.\r
fe781940
SZ
230 ///\r
231 EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;\r
3a63377f 232 UINTN AprioriCount;\r
50cb16d9 233 UINTN CurrentPeimFvCount;\r
3a63377f 234 UINTN CurrentPeimCount;\r
235 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
82b8c8df 236 BOOLEAN PeimNeedingDispatch;\r
237 BOOLEAN PeimDispatchOnThisPass;\r
238 BOOLEAN PeimDispatcherReenter;\r
192f6d4c 239 EFI_PEI_HOB_POINTERS HobList;\r
240 BOOLEAN SwitchStackSignal;\r
241 BOOLEAN PeiMemoryInstalled;\r
192f6d4c 242 VOID *CpuIo;\r
b0d803fe 243 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
192f6d4c 244 EFI_PEI_SERVICES ServiceTableShadow;\r
b0d803fe 245 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
58dcdada 246 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
247 UINT64 PhysicalMemoryLength;\r
248 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;\r
ef05e063 249 UINTN HeapOffset;\r
250 BOOLEAN HeapOffsetPositive;\r
424b7c9f 251 UINTN StackOffset;\r
252 BOOLEAN StackOffsetPositive;\r
b2374cec
SZ
253 //\r
254 // Information for migrating memory pages allocated in pre-memory phase.\r
255 //\r
256 HOLE_MEMORY_DATA MemoryPages;\r
ef05e063 257 PEICORE_FUNCTION_POINTER ShadowedPeiCore;\r
288f9b38 258 CACHE_SECTION_DATA CacheSection;\r
54ea99a7 259 //\r
d1102dba
LG
260 // For Loading modules at fixed address feature to cache the top address below which the\r
261 // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field\r
262 // and Ps should not be changed since maybe user could get this top address by using the offet to Ps.\r
54ea99a7 263 //\r
264 EFI_PHYSICAL_ADDRESS LoadModuleAtFixAddressTopAddress;\r
265 //\r
266 // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
267 // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
d1102dba 268 // available or not.\r
54ea99a7 269 //\r
270 UINT64 *PeiCodeMemoryRangeUsageBitMap;\r
25973fc3 271 //\r
272 // This field points to the shadowed image read function\r
273 //\r
274 PE_COFF_LOADER_READ_FILE ShadowedImageRead;\r
fe781940 275\r
b62fe570
SZ
276 UINTN TempPeimCount;\r
277\r
fe781940 278 //\r
b62fe570 279 // Pointer to the temp buffer with the TempPeimCount number of entries.\r
fe781940 280 //\r
b62fe570 281 EFI_PEI_FILE_HANDLE *TempFileHandles;\r
fe781940 282 //\r
b62fe570 283 // Pointer to the temp buffer with the TempPeimCount number of entries.\r
fe781940 284 //\r
b62fe570 285 EFI_GUID *TempFileGuid;\r
fe781940 286\r
0f9ebb32
LG
287 //\r
288 // Temp Memory Range is not covered by PeiTempMem and Stack.\r
b2374cec 289 // Those Memory Range will be migrated into physical memory.\r
0f9ebb32
LG
290 //\r
291 HOLE_MEMORY_DATA HoleData[HOLE_MAX_NUMBER];\r
ef05e063 292};\r
192f6d4c 293\r
40f26b8f 294///\r
295/// Pei Core Instance Data Macros\r
296///\r
192f6d4c 297#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
4140a663 298 CR(a, PEI_CORE_INSTANCE, Ps, PEI_CORE_HANDLE_SIGNATURE)\r
192f6d4c 299\r
b1f6a7c6 300///\r
301/// Union of temporarily used function pointers (to save stack space)\r
302///\r
192f6d4c 303typedef union {\r
15273993 304 PEICORE_FUNCTION_POINTER PeiCore;\r
1c9d209f 305 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
192f6d4c 306 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
307 EFI_DXE_IPL_PPI *DxeIpl;\r
308 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
309 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
310 VOID *Raw;\r
311} PEI_CORE_TEMP_POINTERS;\r
312\r
b98c2ab7 313typedef struct {\r
314 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
315 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
316 VOID *Data;\r
317} PEI_CORE_PARAMETERS;\r
318\r
192f6d4c 319//\r
320// PeiCore function\r
321//\r
b1f6a7c6 322/**\r
192f6d4c 323\r
324 The entry routine to Pei Core, invoked by PeiMain during transition\r
325 from SEC to PEI. After switching stack in the PEI core, it will restart\r
326 with the old core data.\r
327\r
192f6d4c 328\r
d1102dba 329 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
f34aec3b 330 and location of temporary RAM, the stack location and the BFV location.\r
b1f6a7c6 331 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
332 An empty PPI list consists of a single descriptor with the end-tag\r
333 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
334 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
335 that both the PEI Foundation and any modules can leverage the associated service\r
336 calls and/or code in these early PPIs\r
337 @param Data Pointer to old core data that is used to initialize the\r
192f6d4c 338 core's data areas.\r
339\r
b1f6a7c6 340**/\r
0308e20d 341VOID\r
b1f6a7c6 342EFIAPI\r
343PeiCore (\r
344 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
d976bf31 345 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
b1f6a7c6 346 IN VOID *Data\r
ed66e1bc 347 );\r
192f6d4c 348\r
349//\r
350// Dispatcher support functions\r
351//\r
352\r
b1f6a7c6 353/**\r
192f6d4c 354\r
355 This is the POSTFIX version of the dependency evaluator. When a\r
356 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
357 the evaluation stack. When that entry is poped from the evaluation\r
358 stack, the PPI is checked if it is installed. This method allows\r
359 some time savings as not all PPIs must be checked for certain\r
360 operation types (AND, OR).\r
361\r
192f6d4c 362\r
1cc76977 363 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 364 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to\r
365 the BNF described above and is stored in postfix notation.\r
192f6d4c 366\r
b1f6a7c6 367 @retval TRUE if it is a well-formed Grammar\r
368 @retval FALSE if the dependency expression overflows the evaluation stack\r
369 if the dependency expression underflows the evaluation stack\r
370 if the dependency expression is not a well-formed Grammar.\r
192f6d4c 371\r
b1f6a7c6 372**/\r
373BOOLEAN\r
374PeimDispatchReadiness (\r
375 IN EFI_PEI_SERVICES **PeiServices,\r
376 IN VOID *DependencyExpression\r
ed66e1bc 377 );\r
192f6d4c 378\r
b1f6a7c6 379/**\r
380 Conduct PEIM dispatch.\r
381\r
731bd38e 382 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data\r
1cc76977 383 @param PrivateData Pointer to the private data passed in from caller\r
192f6d4c 384\r
b1f6a7c6 385**/\r
b0d803fe 386VOID\r
192f6d4c 387PeiDispatcher (\r
5aae0aa7 388 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
b0d803fe 389 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 390 );\r
192f6d4c 391\r
b1f6a7c6 392/**\r
393 Initialize the Dispatcher's data members\r
192f6d4c 394\r
b1f6a7c6 395 @param PrivateData PeiCore's private data structure\r
396 @param OldCoreData Old data from SecCore\r
397 NULL if being run in non-permament memory mode.\r
aa79b0b3 398 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
399 and location of temporary RAM, the stack location and the BFV location.\r
192f6d4c 400\r
b1f6a7c6 401**/\r
192f6d4c 402VOID\r
403InitializeDispatcherData (\r
b0d803fe 404 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 405 IN PEI_CORE_INSTANCE *OldCoreData,\r
5aae0aa7 406 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
ed66e1bc 407 );\r
192f6d4c 408\r
b1f6a7c6 409/**\r
410 This routine parses the Dependency Expression, if available, and\r
411 decides if the module can be executed.\r
192f6d4c 412\r
192f6d4c 413\r
b1f6a7c6 414 @param Private PeiCore's private data structure\r
415 @param FileHandle PEIM's file handle\r
731bd38e 416 @param PeimCount The index of last dispatched PEIM.\r
192f6d4c 417\r
731bd38e 418 @retval TRUE Can be dispatched\r
419 @retval FALSE Cannot be dispatched\r
192f6d4c 420\r
b1f6a7c6 421**/\r
192f6d4c 422BOOLEAN\r
423DepexSatisfied (\r
b0d803fe 424 IN PEI_CORE_INSTANCE *Private,\r
425 IN EFI_PEI_FILE_HANDLE FileHandle,\r
426 IN UINTN PeimCount\r
ed66e1bc 427 );\r
192f6d4c 428\r
192f6d4c 429//\r
430// PPI support functions\r
431//\r
b1f6a7c6 432/**\r
433\r
434 Initialize PPI services.\r
435\r
b1f6a7c6 436 @param PrivateData Pointer to the PEI Core data.\r
d1102dba 437 @param OldCoreData Pointer to old PEI Core data.\r
b1f6a7c6 438 NULL if being run in non-permament memory mode.\r
439\r
440**/\r
192f6d4c 441VOID\r
442InitializePpiServices (\r
b0d803fe 443 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 444 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 445 );\r
192f6d4c 446\r
b1f6a7c6 447/**\r
192f6d4c 448\r
b2374cec 449 Migrate the Hob list from the temporary memory to PEI installed memory.\r
731bd38e 450\r
d1102dba 451 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
424b7c9f 452 and location of temporary RAM, the stack location and the BFV location.\r
453 @param PrivateData Pointer to PeiCore's private data structure.\r
192f6d4c 454\r
b1f6a7c6 455**/\r
192f6d4c 456VOID\r
457ConvertPpiPointers (\r
424b7c9f 458 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
459 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 460 );\r
192f6d4c 461\r
b1f6a7c6 462/**\r
192f6d4c 463\r
731bd38e 464 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
192f6d4c 465\r
15273993 466 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
467 @param PpiList Pointer to ppi array that want to be installed.\r
192f6d4c 468\r
15273993 469 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r
470 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r
731bd38e 471 if any PPI in PpiList is not valid\r
15273993 472 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r
192f6d4c 473\r
b1f6a7c6 474**/\r
192f6d4c 475EFI_STATUS\r
476EFIAPI\r
477PeiInstallPpi (\r
0c2b5da8 478 IN CONST EFI_PEI_SERVICES **PeiServices,\r
479 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
ed66e1bc 480 );\r
192f6d4c 481\r
b1f6a7c6 482/**\r
192f6d4c 483\r
b1f6a7c6 484 Re-Install PPI services.\r
192f6d4c 485\r
1cc76977 486 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
487 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
488 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
192f6d4c 489\r
1cc76977 490 @retval EFI_SUCCESS if the operation was successful\r
491 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
731bd38e 492 if NewPpi is not valid\r
1cc76977 493 @retval EFI_NOT_FOUND if the PPI was not in the database\r
192f6d4c 494\r
b1f6a7c6 495**/\r
192f6d4c 496EFI_STATUS\r
497EFIAPI\r
498PeiReInstallPpi (\r
0c2b5da8 499 IN CONST EFI_PEI_SERVICES **PeiServices,\r
500 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
501 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
ed66e1bc 502 );\r
192f6d4c 503\r
b1f6a7c6 504/**\r
192f6d4c 505\r
b1f6a7c6 506 Locate a given named PPI.\r
192f6d4c 507\r
192f6d4c 508\r
1cc76977 509 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
510 @param Guid Pointer to GUID of the PPI.\r
511 @param Instance Instance Number to discover.\r
512 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,\r
b1f6a7c6 513 returns a pointer to the descriptor (includes flags, etc)\r
1cc76977 514 @param Ppi Pointer to reference the found PPI\r
192f6d4c 515\r
b1f6a7c6 516 @retval EFI_SUCCESS if the PPI is in the database\r
517 @retval EFI_NOT_FOUND if the PPI is not in the database\r
192f6d4c 518\r
b1f6a7c6 519**/\r
192f6d4c 520EFI_STATUS\r
521EFIAPI\r
522PeiLocatePpi (\r
1cc76977 523 IN CONST EFI_PEI_SERVICES **PeiServices,\r
524 IN CONST EFI_GUID *Guid,\r
192f6d4c 525 IN UINTN Instance,\r
526 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
527 IN OUT VOID **Ppi\r
ed66e1bc 528 );\r
192f6d4c 529\r
b1f6a7c6 530/**\r
192f6d4c 531\r
b1f6a7c6 532 Install a notification for a given PPI.\r
192f6d4c 533\r
192f6d4c 534\r
1cc76977 535 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
536 @param NotifyList Pointer to list of Descriptors to notify upon.\r
192f6d4c 537\r
b1f6a7c6 538 @retval EFI_SUCCESS if successful\r
539 @retval EFI_OUT_OF_RESOURCES if no space in the database\r
540 @retval EFI_INVALID_PARAMETER if not a good decriptor\r
192f6d4c 541\r
b1f6a7c6 542**/\r
192f6d4c 543EFI_STATUS\r
544EFIAPI\r
545PeiNotifyPpi (\r
0c2b5da8 546 IN CONST EFI_PEI_SERVICES **PeiServices,\r
547 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
ed66e1bc 548 );\r
192f6d4c 549\r
b1f6a7c6 550/**\r
192f6d4c 551\r
b1f6a7c6 552 Process the Notify List at dispatch level.\r
192f6d4c 553\r
b1f6a7c6 554 @param PrivateData PeiCore's private data structure.\r
192f6d4c 555\r
b1f6a7c6 556**/\r
192f6d4c 557VOID\r
558ProcessNotifyList (\r
b0d803fe 559 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 560 );\r
192f6d4c 561\r
b1f6a7c6 562/**\r
192f6d4c 563\r
b1f6a7c6 564 Dispatch notifications.\r
192f6d4c 565\r
b1f6a7c6 566 @param PrivateData PeiCore's private data structure\r
567 @param NotifyType Type of notify to fire.\r
568 @param InstallStartIndex Install Beginning index.\r
569 @param InstallStopIndex Install Ending index.\r
570 @param NotifyStartIndex Notify Beginning index.\r
571 @param NotifyStopIndex Notify Ending index.\r
192f6d4c 572\r
b1f6a7c6 573**/\r
192f6d4c 574VOID\r
575DispatchNotify (\r
b0d803fe 576 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 577 IN UINTN NotifyType,\r
578 IN INTN InstallStartIndex,\r
579 IN INTN InstallStopIndex,\r
580 IN INTN NotifyStartIndex,\r
581 IN INTN NotifyStopIndex\r
ed66e1bc 582 );\r
192f6d4c 583\r
884200f9
SZ
584/**\r
585 Process PpiList from SEC phase.\r
586\r
587 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
588 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
589 These PPI's will be installed and/or immediately signaled if they are notification type.\r
590\r
591**/\r
592VOID\r
593ProcessPpiListFromSec (\r
594 IN CONST EFI_PEI_SERVICES **PeiServices,\r
595 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
596 );\r
597\r
192f6d4c 598//\r
599// Boot mode support functions\r
600//\r
b1f6a7c6 601/**\r
602 This service enables PEIMs to ascertain the present value of the boot mode.\r
603\r
1cc76977 604 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 605 @param BootMode A pointer to contain the value of the boot mode.\r
606\r
607 @retval EFI_SUCCESS The boot mode was returned successfully.\r
608 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
609\r
610**/\r
192f6d4c 611EFI_STATUS\r
612EFIAPI\r
613PeiGetBootMode (\r
0c2b5da8 614 IN CONST EFI_PEI_SERVICES **PeiServices,\r
d976bf31 615 IN OUT EFI_BOOT_MODE *BootMode\r
ed66e1bc 616 );\r
192f6d4c 617\r
b1f6a7c6 618/**\r
619 This service enables PEIMs to update the boot mode variable.\r
192f6d4c 620\r
192f6d4c 621\r
1cc76977 622 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
623 @param BootMode The value of the boot mode to set.\r
192f6d4c 624\r
1cc76977 625 @return EFI_SUCCESS The value was successfully updated\r
192f6d4c 626\r
b1f6a7c6 627**/\r
192f6d4c 628EFI_STATUS\r
629EFIAPI\r
630PeiSetBootMode (\r
0c2b5da8 631 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 632 IN EFI_BOOT_MODE BootMode\r
ed66e1bc 633 );\r
192f6d4c 634\r
635//\r
636// Security support functions\r
637//\r
b1f6a7c6 638/**\r
639\r
640 Initialize the security services.\r
641\r
1cc76977 642 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
40f26b8f 643 @param OldCoreData Pointer to the old core data.\r
b1f6a7c6 644 NULL if being run in non-permament memory mode.\r
645\r
646**/\r
192f6d4c 647VOID\r
648InitializeSecurityServices (\r
649 IN EFI_PEI_SERVICES **PeiServices,\r
650 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 651 );\r
192f6d4c 652\r
b1f6a7c6 653/**\r
d976bf31 654 Verify a Firmware volume.\r
192f6d4c 655\r
40f26b8f 656 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration\r
192f6d4c 657\r
40f26b8f 658 @retval EFI_SUCCESS Firmware Volume is legal\r
659 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test\r
192f6d4c 660\r
b1f6a7c6 661**/\r
192f6d4c 662EFI_STATUS\r
663VerifyFv (\r
664 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
ed66e1bc 665 );\r
192f6d4c 666\r
b1f6a7c6 667/**\r
b1f6a7c6 668 Provide a callout to the security verification service.\r
192f6d4c 669\r
b1f6a7c6 670 @param PrivateData PeiCore's private data structure\r
671 @param VolumeHandle Handle of FV\r
672 @param FileHandle Handle of PEIM's ffs\r
c7935105 673 @param AuthenticationStatus Authentication status\r
192f6d4c 674\r
b1f6a7c6 675 @retval EFI_SUCCESS Image is OK\r
676 @retval EFI_SECURITY_VIOLATION Image is illegal\r
c7935105 677 @retval EFI_NOT_FOUND If security PPI is not installed.\r
b1f6a7c6 678**/\r
192f6d4c 679EFI_STATUS\r
680VerifyPeim (\r
b0d803fe 681 IN PEI_CORE_INSTANCE *PrivateData,\r
682 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
c7935105
SZ
683 IN EFI_PEI_FILE_HANDLE FileHandle,\r
684 IN UINT32 AuthenticationStatus\r
ed66e1bc 685 );\r
192f6d4c 686\r
b1f6a7c6 687/**\r
192f6d4c 688\r
b1f6a7c6 689 Gets the pointer to the HOB List.\r
192f6d4c 690\r
192f6d4c 691\r
1cc76977 692 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 693 @param HobList Pointer to the HOB List.\r
192f6d4c 694\r
b1f6a7c6 695 @retval EFI_SUCCESS Get the pointer of HOB List\r
696 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
697 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
192f6d4c 698\r
b1f6a7c6 699**/\r
192f6d4c 700EFI_STATUS\r
701EFIAPI\r
702PeiGetHobList (\r
0c2b5da8 703 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 704 IN OUT VOID **HobList\r
ed66e1bc 705 );\r
192f6d4c 706\r
b1f6a7c6 707/**\r
708 Add a new HOB to the HOB List.\r
192f6d4c 709\r
1cc76977 710 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
711 @param Type Type of the new HOB.\r
712 @param Length Length of the new HOB to allocate.\r
713 @param Hob Pointer to the new HOB.\r
192f6d4c 714\r
b1f6a7c6 715 @return EFI_SUCCESS Success to create hob.\r
716 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
717 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
718 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
192f6d4c 719\r
b1f6a7c6 720**/\r
192f6d4c 721EFI_STATUS\r
722EFIAPI\r
723PeiCreateHob (\r
0c2b5da8 724 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 725 IN UINT16 Type,\r
726 IN UINT16 Length,\r
727 IN OUT VOID **Hob\r
ed66e1bc 728 );\r
192f6d4c 729\r
b1f6a7c6 730/**\r
192f6d4c 731\r
b1f6a7c6 732 Builds a Handoff Information Table HOB\r
192f6d4c 733\r
b1f6a7c6 734 @param BootMode - Current Bootmode\r
735 @param MemoryBegin - Start Memory Address.\r
736 @param MemoryLength - Length of Memory.\r
192f6d4c 737\r
b1f6a7c6 738 @return EFI_SUCCESS Always success to initialize HOB.\r
192f6d4c 739\r
b1f6a7c6 740**/\r
192f6d4c 741EFI_STATUS\r
742PeiCoreBuildHobHandoffInfoTable (\r
743 IN EFI_BOOT_MODE BootMode,\r
744 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
745 IN UINT64 MemoryLength\r
ed66e1bc 746 );\r
192f6d4c 747\r
483e2cdd
SZ
748/**\r
749 Install SEC HOB data to the HOB List.\r
750\r
751 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
752 @param SecHobList Pointer to SEC HOB List.\r
753\r
754 @return EFI_SUCCESS Success to install SEC HOB data.\r
755 @retval EFI_OUT_OF_RESOURCES If there is no more memory to grow the Hoblist.\r
756\r
757**/\r
758EFI_STATUS\r
759PeiInstallSecHobData (\r
760 IN CONST EFI_PEI_SERVICES **PeiServices,\r
761 IN EFI_HOB_GENERIC_HEADER *SecHobList\r
762 );\r
763\r
192f6d4c 764\r
765//\r
766// FFS Fw Volume support functions\r
767//\r
b1f6a7c6 768/**\r
3b428ade 769 Searches for the next matching file in the firmware volume.\r
b1f6a7c6 770\r
1cc76977 771 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 772 @param SearchType Filter to find only files of this type.\r
773 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
aa75dfec 774 @param FvHandle Handle of firmware volume in which to search.\r
3b428ade 775 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start\r
776 at the beginning of the firmware volume. On exit, points the file handle of the next file\r
777 in the volume or NULL if there are no more files.\r
778\r
779 @retval EFI_NOT_FOUND The file was not found.\r
780 @retval EFI_NOT_FOUND The header checksum was not zero.\r
781 @retval EFI_SUCCESS The file was found.\r
b1f6a7c6 782\r
783**/\r
192f6d4c 784EFI_STATUS\r
785EFIAPI\r
786PeiFfsFindNextFile (\r
0c2b5da8 787 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 788 IN UINT8 SearchType,\r
3b428ade 789 IN EFI_PEI_FV_HANDLE FvHandle,\r
790 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
ed66e1bc 791 );\r
192f6d4c 792\r
b1f6a7c6 793/**\r
3b428ade 794 Searches for the next matching section within the specified file.\r
192f6d4c 795\r
3b428ade 796 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
b1f6a7c6 797 @param SectionType Filter to find only sections of this type.\r
3b428ade 798 @param FileHandle Pointer to the current file to search.\r
799 @param SectionData A pointer to the discovered section, if successful.\r
b1f6a7c6 800 NULL if section not found\r
192f6d4c 801\r
3b428ade 802 @retval EFI_NOT_FOUND The section was not found.\r
803 @retval EFI_SUCCESS The section was found.\r
192f6d4c 804\r
b1f6a7c6 805**/\r
192f6d4c 806EFI_STATUS\r
807EFIAPI\r
808PeiFfsFindSectionData (\r
3b428ade 809 IN CONST EFI_PEI_SERVICES **PeiServices,\r
810 IN EFI_SECTION_TYPE SectionType,\r
811 IN EFI_PEI_FILE_HANDLE FileHandle,\r
812 OUT VOID **SectionData\r
ed66e1bc 813 );\r
192f6d4c 814\r
c7935105
SZ
815/**\r
816 Searches for the next matching section within the specified file.\r
817\r
818 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
819 @param SectionType The value of the section type to find.\r
820 @param SectionInstance Section instance to find.\r
821 @param FileHandle Handle of the firmware file to search.\r
822 @param SectionData A pointer to the discovered section, if successful.\r
823 @param AuthenticationStatus A pointer to the authentication status for this section.\r
824\r
825 @retval EFI_SUCCESS The section was found.\r
826 @retval EFI_NOT_FOUND The section was not found.\r
827\r
828**/\r
829EFI_STATUS\r
830EFIAPI\r
831PeiFfsFindSectionData3 (\r
832 IN CONST EFI_PEI_SERVICES **PeiServices,\r
833 IN EFI_SECTION_TYPE SectionType,\r
834 IN UINTN SectionInstance,\r
835 IN EFI_PEI_FILE_HANDLE FileHandle,\r
836 OUT VOID **SectionData,\r
837 OUT UINT32 *AuthenticationStatus\r
838 );\r
839\r
b1f6a7c6 840/**\r
3b428ade 841 Search the firmware volumes by index\r
192f6d4c 842\r
3b428ade 843 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
844 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
845 Volume (BFV).\r
846 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.\r
192f6d4c 847\r
3b428ade 848 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL\r
849 @retval EFI_NOT_FOUND The volume was not found.\r
850 @retval EFI_SUCCESS The volume was found.\r
192f6d4c 851\r
b1f6a7c6 852**/\r
192f6d4c 853EFI_STATUS\r
854EFIAPI\r
3b428ade 855PeiFfsFindNextVolume (\r
15273993 856 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 857 IN UINTN Instance,\r
aa75dfec 858 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
ed66e1bc 859 );\r
192f6d4c 860\r
861//\r
862// Memory support functions\r
863//\r
b1f6a7c6 864/**\r
865\r
866 Initialize the memory services.\r
867\r
1cc76977 868 @param PrivateData PeiCore's private data structure\r
d1102dba 869 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
f34aec3b 870 and location of temporary RAM, the stack location and the BFV location.\r
b1f6a7c6 871 @param OldCoreData Pointer to the PEI Core data.\r
872 NULL if being run in non-permament memory mode.\r
873\r
874**/\r
192f6d4c 875VOID\r
876InitializeMemoryServices (\r
b0d803fe 877 IN PEI_CORE_INSTANCE *PrivateData,\r
5aae0aa7 878 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
192f6d4c 879 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 880 );\r
192f6d4c 881\r
b1f6a7c6 882/**\r
192f6d4c 883\r
b1f6a7c6 884 Install the permanent memory is now available.\r
885 Creates HOB (PHIT and Stack).\r
192f6d4c 886\r
1cc76977 887 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
888 @param MemoryBegin Start of memory address.\r
889 @param MemoryLength Length of memory.\r
192f6d4c 890\r
b1f6a7c6 891 @return EFI_SUCCESS Always success.\r
192f6d4c 892\r
b1f6a7c6 893**/\r
192f6d4c 894EFI_STATUS\r
895EFIAPI\r
896PeiInstallPeiMemory (\r
0c2b5da8 897 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 898 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
899 IN UINT64 MemoryLength\r
ed66e1bc 900 );\r
192f6d4c 901\r
b1f6a7c6 902/**\r
b2374cec
SZ
903 Migrate memory pages allocated in pre-memory phase.\r
904 Copy memory pages at temporary heap top to permanent heap top.\r
192f6d4c 905\r
b2374cec
SZ
906 @param[in] Private Pointer to the private data passed in from caller.\r
907 @param[in] TemporaryRamMigrated Temporary memory has been migrated to permanent memory.\r
192f6d4c 908\r
b2374cec
SZ
909**/\r
910VOID\r
911MigrateMemoryPages (\r
912 IN PEI_CORE_INSTANCE *Private,\r
913 IN BOOLEAN TemporaryRamMigrated\r
914 );\r
192f6d4c 915\r
b2374cec
SZ
916/**\r
917 Migrate MemoryBaseAddress in memory allocation HOBs\r
918 from the temporary memory to PEI installed memory.\r
192f6d4c 919\r
b2374cec
SZ
920 @param[in] PrivateData Pointer to PeiCore's private data structure.\r
921\r
922**/\r
923VOID\r
924ConvertMemoryAllocationHobs (\r
925 IN PEI_CORE_INSTANCE *PrivateData\r
926 );\r
927\r
928/**\r
929 The purpose of the service is to publish an interface that allows\r
930 PEIMs to allocate memory ranges that are managed by the PEI Foundation.\r
931\r
932 Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.\r
933 After InstallPeiMemory() is called, PEI will allocate pages within the region\r
934 of memory provided by InstallPeiMemory() service in a best-effort fashion.\r
935 Location-specific allocations are not managed by the PEI foundation code.\r
936\r
937 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
938 @param MemoryType The type of memory to allocate.\r
939 @param Pages The number of contiguous 4 KB pages to allocate.\r
940 @param Memory Pointer to a physical address. On output, the address is set to the base\r
941 of the page range that was allocated.\r
942\r
943 @retval EFI_SUCCESS The memory range was successfully allocated.\r
944 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
945 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r
946 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
947 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r
192f6d4c 948\r
b1f6a7c6 949**/\r
192f6d4c 950EFI_STATUS\r
951EFIAPI\r
952PeiAllocatePages (\r
b2374cec
SZ
953 IN CONST EFI_PEI_SERVICES **PeiServices,\r
954 IN EFI_MEMORY_TYPE MemoryType,\r
955 IN UINTN Pages,\r
956 OUT EFI_PHYSICAL_ADDRESS *Memory\r
957 );\r
958\r
959/**\r
960 Frees memory pages.\r
961\r
962 @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
963 @param[in] Memory The base physical address of the pages to be freed.\r
964 @param[in] Pages The number of contiguous 4 KB pages to free.\r
965\r
966 @retval EFI_SUCCESS The requested pages were freed.\r
967 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r
968 @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r
969 AllocatePages().\r
970\r
971**/\r
972EFI_STATUS\r
973EFIAPI\r
974PeiFreePages (\r
975 IN CONST EFI_PEI_SERVICES **PeiServices,\r
976 IN EFI_PHYSICAL_ADDRESS Memory,\r
977 IN UINTN Pages\r
ed66e1bc 978 );\r
192f6d4c 979\r
b1f6a7c6 980/**\r
192f6d4c 981\r
3d4d0c34 982 Memory allocation service on the temporary memory.\r
192f6d4c 983\r
192f6d4c 984\r
1cc76977 985 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
986 @param Size Amount of memory required\r
987 @param Buffer Address of pointer to the buffer\r
192f6d4c 988\r
b1f6a7c6 989 @retval EFI_SUCCESS The allocation was successful\r
990 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
991 to allocate the requested size.\r
192f6d4c 992\r
b1f6a7c6 993**/\r
192f6d4c 994EFI_STATUS\r
995EFIAPI\r
996PeiAllocatePool (\r
0c2b5da8 997 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 998 IN UINTN Size,\r
999 OUT VOID **Buffer\r
ed66e1bc 1000 );\r
192f6d4c 1001\r
b1f6a7c6 1002/**\r
192f6d4c 1003\r
b1f6a7c6 1004 Routine for load image file.\r
192f6d4c 1005\r
192f6d4c 1006\r
1cc76977 1007 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1008 @param FileHandle Pointer to the FFS file header of the image.\r
341a658f 1009 @param PeimState The dispatch state of the input PEIM handle.\r
1cc76977 1010 @param EntryPoint Pointer to entry point of specified image file for output.\r
1011 @param AuthenticationState Pointer to attestation authentication state of image.\r
192f6d4c 1012\r
1cc76977 1013 @retval EFI_SUCCESS Image is successfully loaded.\r
1014 @retval EFI_NOT_FOUND Fail to locate necessary PPI\r
1015 @retval Others Fail to load file.\r
192f6d4c 1016\r
b1f6a7c6 1017**/\r
192f6d4c 1018EFI_STATUS\r
1019PeiLoadImage (\r
6c7a807a 1020 IN CONST EFI_PEI_SERVICES **PeiServices,\r
b0d803fe 1021 IN EFI_PEI_FILE_HANDLE FileHandle,\r
341a658f 1022 IN UINT8 PeimState,\r
b0d803fe 1023 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1024 OUT UINT32 *AuthenticationState\r
ed66e1bc 1025 );\r
192f6d4c 1026\r
b1f6a7c6 1027/**\r
192f6d4c 1028\r
b1f6a7c6 1029 Core version of the Status Code reporter\r
192f6d4c 1030\r
192f6d4c 1031\r
1cc76977 1032 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1033 @param CodeType Type of Status Code.\r
1034 @param Value Value to output for Status Code.\r
1035 @param Instance Instance Number of this status code.\r
1036 @param CallerId ID of the caller of this status code.\r
1037 @param Data Optional data associated with this status code.\r
192f6d4c 1038\r
b1f6a7c6 1039 @retval EFI_SUCCESS if status code is successfully reported\r
1040 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
192f6d4c 1041\r
b1f6a7c6 1042**/\r
192f6d4c 1043EFI_STATUS\r
1044EFIAPI\r
1045PeiReportStatusCode (\r
0c2b5da8 1046 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 1047 IN EFI_STATUS_CODE_TYPE CodeType,\r
1048 IN EFI_STATUS_CODE_VALUE Value,\r
1049 IN UINT32 Instance,\r
0c2b5da8 1050 IN CONST EFI_GUID *CallerId,\r
1051 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
ed66e1bc 1052 );\r
192f6d4c 1053\r
b1f6a7c6 1054/**\r
192f6d4c 1055\r
b1f6a7c6 1056 Core version of the Reset System\r
192f6d4c 1057\r
192f6d4c 1058\r
1cc76977 1059 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
192f6d4c 1060\r
b1f6a7c6 1061 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
1062 @retval EFI_DEVICE_ERROR Did not reset system.\r
1063 Otherwise, resets the system.\r
192f6d4c 1064\r
b1f6a7c6 1065**/\r
192f6d4c 1066EFI_STATUS\r
1067EFIAPI\r
1068PeiResetSystem (\r
b0d803fe 1069 IN CONST EFI_PEI_SERVICES **PeiServices\r
ed66e1bc 1070 );\r
192f6d4c 1071\r
672473ea
SZ
1072/**\r
1073 Resets the entire platform.\r
1074\r
1075 @param[in] ResetType The type of reset to perform.\r
1076 @param[in] ResetStatus The status code for the reset.\r
c8721bb2 1077 @param[in] DataSize The size, in bytes, of ResetData.\r
672473ea
SZ
1078 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
1079 the data buffer starts with a Null-terminated string, optionally\r
1080 followed by additional binary data. The string is a description\r
1081 that the caller may use to further indicate the reason for the\r
1082 system reset. ResetData is only valid if ResetStatus is something\r
1083 other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
1084 where a minimum amount of ResetData is always required.\r
1085\r
1086**/\r
1087VOID\r
1088EFIAPI\r
1089PeiResetSystem2 (\r
1090 IN EFI_RESET_TYPE ResetType,\r
1091 IN EFI_STATUS ResetStatus,\r
1092 IN UINTN DataSize,\r
1093 IN VOID *ResetData OPTIONAL\r
1094 );\r
1095\r
b1f6a7c6 1096/**\r
192f6d4c 1097\r
b1f6a7c6 1098 Initialize PeiCore Fv List.\r
192f6d4c 1099\r
192f6d4c 1100\r
b1f6a7c6 1101 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1102 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
192f6d4c 1103\r
b1f6a7c6 1104**/\r
50cb16d9 1105VOID\r
b0d803fe 1106PeiInitializeFv (\r
1107 IN PEI_CORE_INSTANCE *PrivateData,\r
1108 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
ed66e1bc 1109 );\r
b0d803fe 1110\r
b1f6a7c6 1111/**\r
1112 Process Firmware Volum Information once FvInfoPPI install.\r
b0d803fe 1113\r
1cc76977 1114 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1115 @param NotifyDescriptor Address of the notification descriptor data structure.\r
1116 @param Ppi Address of the PPI that was installed.\r
50cb16d9 1117\r
b1f6a7c6 1118 @retval EFI_SUCCESS if the interface could be successfully installed\r
b0d803fe 1119\r
b1f6a7c6 1120**/\r
b0d803fe 1121EFI_STATUS\r
1122EFIAPI\r
1123FirmwareVolmeInfoPpiNotifyCallback (\r
1124 IN EFI_PEI_SERVICES **PeiServices,\r
1125 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1126 IN VOID *Ppi\r
ed66e1bc 1127 );\r
b0d803fe 1128\r
b1f6a7c6 1129/**\r
50cb16d9 1130\r
b1f6a7c6 1131 Given the input VolumeHandle, search for the next matching name file.\r
b0d803fe 1132\r
1cc76977 1133 @param FileName File name to search.\r
1134 @param VolumeHandle The current FV to search.\r
1135 @param FileHandle Pointer to the file matching name in VolumeHandle.\r
1136 NULL if file not found\r
b0d803fe 1137\r
15273993 1138 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
1139 @retval EFI_SUCCESS Success to search given file\r
b0d803fe 1140\r
b1f6a7c6 1141**/\r
b0d803fe 1142EFI_STATUS\r
50cb16d9 1143EFIAPI\r
b0d803fe 1144PeiFfsFindFileByName (\r
1145 IN CONST EFI_GUID *FileName,\r
1146 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1147 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
ed66e1bc 1148 );\r
b0d803fe 1149\r
b1f6a7c6 1150/**\r
b1f6a7c6 1151 Returns information about a specific file.\r
b0d803fe 1152\r
3b428ade 1153 @param FileHandle Handle of the file.\r
aa75dfec 1154 @param FileInfo Upon exit, points to the file's information.\r
b0d803fe 1155\r
3b428ade 1156 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
1157 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
1158 @retval EFI_SUCCESS File information returned.\r
b0d803fe 1159\r
b1f6a7c6 1160**/\r
b0d803fe 1161EFI_STATUS\r
50cb16d9 1162EFIAPI\r
b0d803fe 1163PeiFfsGetFileInfo (\r
1164 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1165 OUT EFI_FV_FILE_INFO *FileInfo\r
ed66e1bc 1166 );\r
b0d803fe 1167\r
c7935105
SZ
1168/**\r
1169 Returns information about a specific file.\r
1170\r
1171 @param FileHandle Handle of the file.\r
1172 @param FileInfo Upon exit, points to the file's information.\r
1173\r
1174 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
1175 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
1176 @retval EFI_SUCCESS File information returned.\r
1177\r
1178**/\r
1179EFI_STATUS\r
d1102dba 1180EFIAPI\r
c7935105
SZ
1181PeiFfsGetFileInfo2 (\r
1182 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1183 OUT EFI_FV_FILE_INFO2 *FileInfo\r
1184 );\r
1185\r
b1f6a7c6 1186/**\r
3b428ade 1187 Returns information about the specified volume.\r
b0d803fe 1188\r
3b428ade 1189 @param VolumeHandle Handle of the volume.\r
aa75dfec 1190 @param VolumeInfo Upon exit, points to the volume's information.\r
b0d803fe 1191\r
3b428ade 1192 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
1193 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
1194 @retval EFI_SUCCESS Volume information returned.\r
b1f6a7c6 1195**/\r
b0d803fe 1196EFI_STATUS\r
50cb16d9 1197EFIAPI\r
b0d803fe 1198PeiFfsGetVolumeInfo (\r
1199 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1200 OUT EFI_FV_INFO *VolumeInfo\r
ed66e1bc 1201 );\r
b0d803fe 1202\r
14e8823a 1203/**\r
1204 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
1205 discovery permanent memory.\r
1206\r
b1f6a7c6 1207 @param FileHandle File handle of a PEIM.\r
50cb16d9 1208\r
b1f6a7c6 1209 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
1210 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
1211 @retval EFI_SUCCESS Successfully to register itself.\r
14e8823a 1212\r
50cb16d9 1213**/\r
14e8823a 1214EFI_STATUS\r
1215EFIAPI\r
1216PeiRegisterForShadow (\r
1217 IN EFI_PEI_FILE_HANDLE FileHandle\r
ed66e1bc 1218 );\r
14e8823a 1219\r
b1f6a7c6 1220/**\r
15273993 1221 Initialize image service that install PeiLoadFilePpi.\r
b0d803fe 1222\r
15273993 1223 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.\r
1224 @param OldCoreData Pointer to Old PeiCore's private data.\r
1225 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
1226 If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
6393d9c8 1227 to permanent memory.\r
b0d803fe 1228\r
b1f6a7c6 1229**/\r
1230VOID\r
1231InitializeImageServices (\r
1232 IN PEI_CORE_INSTANCE *PrivateData,\r
1233 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 1234 );\r
b0d803fe 1235\r
aa79b0b3 1236/**\r
1237 The wrapper function of PeiLoadImageLoadImage().\r
1238\r
f34aec3b 1239 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.\r
1240 @param FileHandle Pointer to the FFS file header of the image.\r
1241 @param ImageAddressArg Pointer to PE/TE image.\r
1242 @param ImageSizeArg Size of PE/TE image.\r
1243 @param EntryPoint Pointer to entry point of specified image file for output.\r
1244 @param AuthenticationState Pointer to attestation authentication state of image.\r
aa79b0b3 1245\r
1246 @return Status of PeiLoadImageLoadImage().\r
1247\r
1248**/\r
1249EFI_STATUS\r
1250EFIAPI\r
1251PeiLoadImageLoadImageWrapper (\r
1252 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
1253 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1254 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
1255 OUT UINT64 *ImageSizeArg, OPTIONAL\r
1256 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1257 OUT UINT32 *AuthenticationState\r
1258 );\r
1259\r
1260/**\r
1261\r
1262 Provide a callback for when the security PPI is installed.\r
1263\r
1264 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1265 @param NotifyDescriptor The descriptor for the notification event.\r
1266 @param Ppi Pointer to the PPI in question.\r
1267\r
1268 @return Always success\r
1269\r
1270**/\r
1271EFI_STATUS\r
1272EFIAPI\r
1273SecurityPpiNotifyCallback (\r
1274 IN EFI_PEI_SERVICES **PeiServices,\r
1275 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1276 IN VOID *Ppi\r
1277 );\r
1278\r
3b428ade 1279/**\r
0e042d0a 1280 Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.\r
3b428ade 1281\r
c7935105 1282 @param PrivateData PeiCore's private data structure\r
3b428ade 1283 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
1284 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
1285\r
1286 @retval EFI_NOT_FOUND FV image can't be found.\r
1287 @retval EFI_SUCCESS Successfully to process it.\r
1288 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image\r
c7935105 1289 @retval EFI_SECURITY_VIOLATION Image is illegal\r
3b428ade 1290 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
d1102dba 1291\r
3b428ade 1292**/\r
1293EFI_STATUS\r
1294ProcessFvFile (\r
c7935105 1295 IN PEI_CORE_INSTANCE *PrivateData,\r
3b428ade 1296 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,\r
1297 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle\r
1298 );\r
d1102dba 1299\r
3b428ade 1300/**\r
1301 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
d1102dba 1302\r
3b428ade 1303 This routine also will install FvInfo ppi for FV hob in PI ways.\r
d1102dba 1304\r
3b428ade 1305 @param Private Pointer of PEI_CORE_INSTANCE\r
1306 @param Instance The index of FV want to be searched.\r
d1102dba 1307\r
3b428ade 1308 @return Instance of PEI_CORE_FV_HANDLE.\r
1309**/\r
1310PEI_CORE_FV_HANDLE *\r
1311FindNextCoreFvHandle (\r
1312 IN PEI_CORE_INSTANCE *Private,\r
1313 IN UINTN Instance\r
1314 );\r
d1102dba 1315\r
8d415937 1316//\r
1317// Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
d1102dba 1318//\r
8d415937 1319\r
1320/**\r
1321 Memory-based read services.\r
d1102dba
LG
1322\r
1323 This function is to perform the Memory Access Read service based on installed\r
1324 instance of the EFI_PEI_CPU_IO_PPI.\r
1325 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1326 return EFI_NOT_YET_AVAILABLE.\r
1327\r
8d415937 1328 @param PeiServices An indirect pointer to the PEI Services Table\r
1329 published by the PEI Foundation.\r
1330 @param This Pointer to local data for the interface.\r
1331 @param Width The width of the access. Enumerated in bytes.\r
1332 @param Address The physical address of the access.\r
1333 @param Count The number of accesses to perform.\r
1334 @param Buffer A pointer to the buffer of data.\r
1335\r
1336 @retval EFI_SUCCESS The function completed successfully.\r
d1102dba 1337 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
8d415937 1338**/\r
1339EFI_STATUS\r
1340EFIAPI\r
1341PeiDefaultMemRead (\r
1342 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1343 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1344 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1345 IN UINT64 Address,\r
1346 IN UINTN Count,\r
1347 IN OUT VOID *Buffer\r
1348 );\r
d1102dba 1349\r
8d415937 1350/**\r
1351 Memory-based write services.\r
d1102dba
LG
1352\r
1353 This function is to perform the Memory Access Write service based on installed\r
1354 instance of the EFI_PEI_CPU_IO_PPI.\r
1355 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1356 return EFI_NOT_YET_AVAILABLE.\r
1357\r
8d415937 1358 @param PeiServices An indirect pointer to the PEI Services Table\r
1359 published by the PEI Foundation.\r
1360 @param This Pointer to local data for the interface.\r
1361 @param Width The width of the access. Enumerated in bytes.\r
1362 @param Address The physical address of the access.\r
1363 @param Count The number of accesses to perform.\r
1364 @param Buffer A pointer to the buffer of data.\r
1365\r
1366 @retval EFI_SUCCESS The function completed successfully.\r
d1102dba 1367 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
8d415937 1368**/\r
1369EFI_STATUS\r
1370EFIAPI\r
1371PeiDefaultMemWrite (\r
1372 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1373 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1374 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1375 IN UINT64 Address,\r
1376 IN UINTN Count,\r
1377 IN OUT VOID *Buffer\r
1378 );\r
d1102dba 1379\r
8d415937 1380/**\r
1381 IO-based read services.\r
d1102dba 1382\r
8d415937 1383 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.\r
d1102dba
LG
1384 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1385 return EFI_NOT_YET_AVAILABLE.\r
1386\r
8d415937 1387 @param PeiServices An indirect pointer to the PEI Services Table\r
1388 published by the PEI Foundation.\r
1389 @param This Pointer to local data for the interface.\r
1390 @param Width The width of the access. Enumerated in bytes.\r
1391 @param Address The physical address of the access.\r
1392 @param Count The number of accesses to perform.\r
1393 @param Buffer A pointer to the buffer of data.\r
1394\r
1395 @retval EFI_SUCCESS The function completed successfully.\r
1396 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1397**/\r
1398EFI_STATUS\r
1399EFIAPI\r
1400PeiDefaultIoRead (\r
1401 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1402 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1403 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1404 IN UINT64 Address,\r
1405 IN UINTN Count,\r
1406 IN OUT VOID *Buffer\r
1407 );\r
d1102dba 1408\r
8d415937 1409/**\r
1410 IO-based write services.\r
d1102dba 1411\r
8d415937 1412 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.\r
d1102dba
LG
1413 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1414 return EFI_NOT_YET_AVAILABLE.\r
1415\r
8d415937 1416 @param PeiServices An indirect pointer to the PEI Services Table\r
1417 published by the PEI Foundation.\r
1418 @param This Pointer to local data for the interface.\r
1419 @param Width The width of the access. Enumerated in bytes.\r
1420 @param Address The physical address of the access.\r
1421 @param Count The number of accesses to perform.\r
1422 @param Buffer A pointer to the buffer of data.\r
1423\r
1424 @retval EFI_SUCCESS The function completed successfully.\r
1425 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1426**/\r
1427EFI_STATUS\r
1428EFIAPI\r
1429PeiDefaultIoWrite (\r
1430 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1431 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1432 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1433 IN UINT64 Address,\r
1434 IN UINTN Count,\r
1435 IN OUT VOID *Buffer\r
1436 );\r
d1102dba 1437\r
8d415937 1438/**\r
1439 8-bit I/O read operations.\r
d1102dba
LG
1440\r
1441 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1442 return 0.\r
d1102dba 1443\r
8d415937 1444 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1445 @param This Pointer to local data for the interface.\r
1446 @param Address The physical address of the access.\r
1447\r
1448 @return An 8-bit value returned from the I/O space.\r
1449**/\r
1450UINT8\r
1451EFIAPI\r
1452PeiDefaultIoRead8 (\r
1453 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1454 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1455 IN UINT64 Address\r
1456 );\r
d1102dba 1457\r
8d415937 1458/**\r
1459 Reads an 16-bit I/O port.\r
d1102dba
LG
1460\r
1461 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1462 return 0.\r
d1102dba 1463\r
8d415937 1464 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1465 @param This Pointer to local data for the interface.\r
1466 @param Address The physical address of the access.\r
1467\r
1468 @return A 16-bit value returned from the I/O space.\r
1469**/\r
1470UINT16\r
1471EFIAPI\r
1472PeiDefaultIoRead16 (\r
1473 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1474 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1475 IN UINT64 Address\r
1476 );\r
d1102dba 1477\r
8d415937 1478/**\r
1479 Reads an 32-bit I/O port.\r
d1102dba
LG
1480\r
1481 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1482 return 0.\r
d1102dba 1483\r
8d415937 1484 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1485 @param This Pointer to local data for the interface.\r
1486 @param Address The physical address of the access.\r
1487\r
1488 @return A 32-bit value returned from the I/O space.\r
1489**/\r
1490UINT32\r
1491EFIAPI\r
1492PeiDefaultIoRead32 (\r
1493 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1494 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1495 IN UINT64 Address\r
1496 );\r
d1102dba 1497\r
8d415937 1498/**\r
1499 Reads an 64-bit I/O port.\r
d1102dba
LG
1500\r
1501 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1502 return 0.\r
d1102dba 1503\r
8d415937 1504 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1505 @param This Pointer to local data for the interface.\r
1506 @param Address The physical address of the access.\r
1507\r
1508 @return A 64-bit value returned from the I/O space.\r
1509**/\r
1510UINT64\r
1511EFIAPI\r
1512PeiDefaultIoRead64 (\r
1513 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1514 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1515 IN UINT64 Address\r
1516 );\r
d1102dba 1517\r
8d415937 1518/**\r
1519 8-bit I/O write operations.\r
1520\r
1521 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1522 @param This Pointer to local data for the interface.\r
1523 @param Address The physical address of the access.\r
1524 @param Data The data to write.\r
1525**/\r
1526VOID\r
1527EFIAPI\r
1528PeiDefaultIoWrite8 (\r
1529 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1530 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1531 IN UINT64 Address,\r
1532 IN UINT8 Data\r
1533 );\r
d1102dba 1534\r
8d415937 1535/**\r
1536 16-bit I/O write operations.\r
1537\r
1538 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1539 @param This Pointer to local data for the interface.\r
1540 @param Address The physical address of the access.\r
1541 @param Data The data to write.\r
1542**/\r
1543VOID\r
1544EFIAPI\r
1545PeiDefaultIoWrite16 (\r
1546 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1547 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1548 IN UINT64 Address,\r
1549 IN UINT16 Data\r
1550 );\r
d1102dba 1551\r
8d415937 1552/**\r
1553 32-bit I/O write operations.\r
1554\r
1555 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1556 @param This Pointer to local data for the interface.\r
1557 @param Address The physical address of the access.\r
1558 @param Data The data to write.\r
1559**/\r
1560VOID\r
1561EFIAPI\r
1562PeiDefaultIoWrite32 (\r
1563 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1564 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1565 IN UINT64 Address,\r
1566 IN UINT32 Data\r
1567 );\r
d1102dba 1568\r
8d415937 1569/**\r
1570 64-bit I/O write operations.\r
1571\r
1572 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1573 @param This Pointer to local data for the interface.\r
1574 @param Address The physical address of the access.\r
1575 @param Data The data to write.\r
1576**/\r
1577VOID\r
1578EFIAPI\r
1579PeiDefaultIoWrite64 (\r
1580 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1581 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1582 IN UINT64 Address,\r
1583 IN UINT64 Data\r
1584 );\r
d1102dba 1585\r
8d415937 1586/**\r
1587 8-bit memory read operations.\r
1588\r
d1102dba 1589 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1590 return 0.\r
d1102dba 1591\r
8d415937 1592 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1593 @param This Pointer to local data for the interface.\r
1594 @param Address The physical address of the access.\r
1595\r
1596 @return An 8-bit value returned from the memory space.\r
1597\r
1598**/\r
1599UINT8\r
1600EFIAPI\r
1601PeiDefaultMemRead8 (\r
1602 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1603 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1604 IN UINT64 Address\r
1605 );\r
d1102dba 1606\r
8d415937 1607/**\r
1608 16-bit memory read operations.\r
1609\r
d1102dba 1610 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1611 return 0.\r
d1102dba 1612\r
8d415937 1613 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1614 @param This Pointer to local data for the interface.\r
1615 @param Address The physical address of the access.\r
1616\r
1617 @return An 16-bit value returned from the memory space.\r
1618\r
1619**/\r
1620UINT16\r
1621EFIAPI\r
1622PeiDefaultMemRead16 (\r
1623 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1624 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1625 IN UINT64 Address\r
1626 );\r
d1102dba 1627\r
8d415937 1628/**\r
1629 32-bit memory read operations.\r
1630\r
d1102dba 1631 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1632 return 0.\r
d1102dba 1633\r
8d415937 1634 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1635 @param This Pointer to local data for the interface.\r
1636 @param Address The physical address of the access.\r
1637\r
1638 @return An 32-bit value returned from the memory space.\r
1639\r
1640**/\r
1641UINT32\r
1642EFIAPI\r
1643PeiDefaultMemRead32 (\r
1644 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1645 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1646 IN UINT64 Address\r
1647 );\r
d1102dba 1648\r
8d415937 1649/**\r
1650 64-bit memory read operations.\r
1651\r
d1102dba 1652 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1653 return 0.\r
d1102dba 1654\r
8d415937 1655 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1656 @param This Pointer to local data for the interface.\r
1657 @param Address The physical address of the access.\r
1658\r
1659 @return An 64-bit value returned from the memory space.\r
1660\r
1661**/\r
1662UINT64\r
1663EFIAPI\r
1664PeiDefaultMemRead64 (\r
1665 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1666 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1667 IN UINT64 Address\r
1668 );\r
d1102dba 1669\r
8d415937 1670/**\r
1671 8-bit memory write operations.\r
1672\r
1673 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1674 @param This Pointer to local data for the interface.\r
1675 @param Address The physical address of the access.\r
1676 @param Data The data to write.\r
1677\r
1678**/\r
1679VOID\r
1680EFIAPI\r
1681PeiDefaultMemWrite8 (\r
1682 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1683 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1684 IN UINT64 Address,\r
1685 IN UINT8 Data\r
1686 );\r
d1102dba 1687\r
8d415937 1688/**\r
1689 16-bit memory write operations.\r
1690\r
1691 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1692 @param This Pointer to local data for the interface.\r
1693 @param Address The physical address of the access.\r
1694 @param Data The data to write.\r
1695\r
1696**/\r
1697VOID\r
1698EFIAPI\r
1699PeiDefaultMemWrite16 (\r
1700 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1701 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1702 IN UINT64 Address,\r
1703 IN UINT16 Data\r
1704 );\r
1705\r
1706/**\r
1707 32-bit memory write operations.\r
1708\r
1709 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1710 @param This Pointer to local data for the interface.\r
1711 @param Address The physical address of the access.\r
1712 @param Data The data to write.\r
1713\r
1714**/\r
1715VOID\r
1716EFIAPI\r
1717PeiDefaultMemWrite32 (\r
1718 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1719 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1720 IN UINT64 Address,\r
1721 IN UINT32 Data\r
1722 );\r
d1102dba 1723\r
8d415937 1724/**\r
1725 64-bit memory write operations.\r
1726\r
1727 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1728 @param This Pointer to local data for the interface.\r
1729 @param Address The physical address of the access.\r
1730 @param Data The data to write.\r
1731\r
1732**/\r
1733VOID\r
1734EFIAPI\r
1735PeiDefaultMemWrite64 (\r
1736 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1737 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1738 IN UINT64 Address,\r
1739 IN UINT64 Data\r
1740 );\r
d1102dba
LG
1741\r
1742extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;\r
8d415937 1743\r
1744//\r
1745// Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
d1102dba 1746//\r
8d415937 1747\r
1748/**\r
1749 Reads from a given location in the PCI configuration space.\r
1750\r
d1102dba
LG
1751 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then\r
1752 return EFI_NOT_YET_AVAILABLE.\r
1753\r
8d415937 1754 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1755 @param This Pointer to local data for the interface.\r
1756 @param Width The width of the access. Enumerated in bytes.\r
1757 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1758 @param Address The physical address of the access. The format of\r
1759 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1760 @param Buffer A pointer to the buffer of data.\r
1761\r
1762 @retval EFI_SUCCESS The function completed successfully.\r
1763 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1764 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
d1102dba 1765\r
8d415937 1766**/\r
1767EFI_STATUS\r
1768EFIAPI\r
1769PeiDefaultPciCfg2Read (\r
1770 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1771 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1772 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1773 IN UINT64 Address,\r
1774 IN OUT VOID *Buffer\r
1775 );\r
d1102dba 1776\r
8d415937 1777/**\r
1778 Write to a given location in the PCI configuration space.\r
1779\r
d1102dba
LG
1780 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then\r
1781 return EFI_NOT_YET_AVAILABLE.\r
1782\r
8d415937 1783 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1784 @param This Pointer to local data for the interface.\r
1785 @param Width The width of the access. Enumerated in bytes.\r
1786 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1787 @param Address The physical address of the access. The format of\r
1788 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1789 @param Buffer A pointer to the buffer of data.\r
1790\r
1791 @retval EFI_SUCCESS The function completed successfully.\r
1792 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1793 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1794**/\r
1795EFI_STATUS\r
1796EFIAPI\r
1797PeiDefaultPciCfg2Write (\r
1798 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1799 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1800 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1801 IN UINT64 Address,\r
1802 IN OUT VOID *Buffer\r
1803 );\r
d1102dba 1804\r
8d415937 1805/**\r
1806 This function performs a read-modify-write operation on the contents from a given\r
1807 location in the PCI configuration space.\r
1808\r
1809 @param PeiServices An indirect pointer to the PEI Services Table\r
1810 published by the PEI Foundation.\r
1811 @param This Pointer to local data for the interface.\r
1812 @param Width The width of the access. Enumerated in bytes. Type\r
1813 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
1814 @param Address The physical address of the access.\r
1815 @param SetBits Points to value to bitwise-OR with the read configuration value.\r
1816 The size of the value is determined by Width.\r
1817 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
1818 The size of the value is determined by Width.\r
1819\r
1820 @retval EFI_SUCCESS The function completed successfully.\r
1821 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1822 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1823**/\r
1824EFI_STATUS\r
1825EFIAPI\r
1826PeiDefaultPciCfg2Modify (\r
1827 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1828 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1829 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1830 IN UINT64 Address,\r
1831 IN VOID *SetBits,\r
1832 IN VOID *ClearBits\r
d1102dba
LG
1833 );\r
1834\r
8d415937 1835extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;\r
1836\r
8e0e40ed 1837/**\r
1838 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
d1102dba 1839 be re-installed with the instance in permanent memory and all cached FvPpi pointers in\r
6393d9c8 1840 PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent\r
8e0e40ed 1841 memory.\r
d1102dba 1842\r
8e0e40ed 1843 @param PrivateData Pointer to PEI_CORE_INSTANCE.\r
d1102dba 1844**/\r
8e0e40ed 1845VOID\r
1846PeiReinitializeFv (\r
1847 IN PEI_CORE_INSTANCE *PrivateData\r
1848 );\r
d1102dba 1849\r
192f6d4c 1850#endif\r