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