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