]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
f2aa97c6640c0bd26aba5d7b8020a196604c95a9
[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_HANDE.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 // Ponter to the buffer with the PeimCount number of Entries.
140 //
141 UINT8 *PeimState;
142 //
143 // Ponter 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 offet 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 correspoding 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 poped 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 Conduct PEIM dispatch.
399
400 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data
401 @param PrivateData Pointer to the private data passed in from caller
402
403 **/
404 VOID
405 PeiDispatcher (
406 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
407 IN PEI_CORE_INSTANCE *PrivateData
408 );
409
410 /**
411 Initialize the Dispatcher's data members
412
413 @param PrivateData PeiCore's private data structure
414 @param OldCoreData Old data from SecCore
415 NULL if being run in non-permament memory mode.
416 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
417 and location of temporary RAM, the stack location and the BFV location.
418
419 **/
420 VOID
421 InitializeDispatcherData (
422 IN PEI_CORE_INSTANCE *PrivateData,
423 IN PEI_CORE_INSTANCE *OldCoreData,
424 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
425 );
426
427 /**
428 This routine parses the Dependency Expression, if available, and
429 decides if the module can be executed.
430
431
432 @param Private PeiCore's private data structure
433 @param FileHandle PEIM's file handle
434 @param PeimCount The index of last dispatched PEIM.
435
436 @retval TRUE Can be dispatched
437 @retval FALSE Cannot be dispatched
438
439 **/
440 BOOLEAN
441 DepexSatisfied (
442 IN PEI_CORE_INSTANCE *Private,
443 IN EFI_PEI_FILE_HANDLE FileHandle,
444 IN UINTN PeimCount
445 );
446
447 //
448 // PPI support functions
449 //
450 /**
451
452 Initialize PPI services.
453
454 @param PrivateData Pointer to the PEI Core data.
455 @param OldCoreData Pointer to old PEI Core data.
456 NULL if being run in non-permament memory mode.
457
458 **/
459 VOID
460 InitializePpiServices (
461 IN PEI_CORE_INSTANCE *PrivateData,
462 IN PEI_CORE_INSTANCE *OldCoreData
463 );
464
465 /**
466
467 Migrate the Hob list from the temporary memory to PEI installed memory.
468
469 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
470 and location of temporary RAM, the stack location and the BFV location.
471 @param PrivateData Pointer to PeiCore's private data structure.
472
473 **/
474 VOID
475 ConvertPpiPointers (
476 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
477 IN PEI_CORE_INSTANCE *PrivateData
478 );
479
480 /**
481
482 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.
483
484 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
485 @param PpiList Pointer to ppi array that want to be installed.
486
487 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
488 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
489 if any PPI in PpiList is not valid
490 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
491
492 **/
493 EFI_STATUS
494 EFIAPI
495 PeiInstallPpi (
496 IN CONST EFI_PEI_SERVICES **PeiServices,
497 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
498 );
499
500 /**
501
502 Re-Install PPI services.
503
504 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
505 @param OldPpi Pointer to the old PEI PPI Descriptors.
506 @param NewPpi Pointer to the new PEI PPI Descriptors.
507
508 @retval EFI_SUCCESS if the operation was successful
509 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL
510 if NewPpi is not valid
511 @retval EFI_NOT_FOUND if the PPI was not in the database
512
513 **/
514 EFI_STATUS
515 EFIAPI
516 PeiReInstallPpi (
517 IN CONST EFI_PEI_SERVICES **PeiServices,
518 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
519 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
520 );
521
522 /**
523
524 Locate a given named PPI.
525
526
527 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
528 @param Guid Pointer to GUID of the PPI.
529 @param Instance Instance Number to discover.
530 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,
531 returns a pointer to the descriptor (includes flags, etc)
532 @param Ppi Pointer to reference the found PPI
533
534 @retval EFI_SUCCESS if the PPI is in the database
535 @retval EFI_NOT_FOUND if the PPI is not in the database
536
537 **/
538 EFI_STATUS
539 EFIAPI
540 PeiLocatePpi (
541 IN CONST EFI_PEI_SERVICES **PeiServices,
542 IN CONST EFI_GUID *Guid,
543 IN UINTN Instance,
544 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
545 IN OUT VOID **Ppi
546 );
547
548 /**
549
550 Install a notification for a given PPI.
551
552
553 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
554 @param NotifyList Pointer to list of Descriptors to notify upon.
555
556 @retval EFI_SUCCESS if successful
557 @retval EFI_OUT_OF_RESOURCES if no space in the database
558 @retval EFI_INVALID_PARAMETER if not a good decriptor
559
560 **/
561 EFI_STATUS
562 EFIAPI
563 PeiNotifyPpi (
564 IN CONST EFI_PEI_SERVICES **PeiServices,
565 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
566 );
567
568 /**
569
570 Process the Notify List at dispatch level.
571
572 @param PrivateData PeiCore's private data structure.
573
574 **/
575 VOID
576 ProcessDispatchNotifyList (
577 IN PEI_CORE_INSTANCE *PrivateData
578 );
579
580 /**
581
582 Process notifications.
583
584 @param PrivateData PeiCore's private data structure
585 @param NotifyType Type of notify to fire.
586 @param InstallStartIndex Install Beginning index.
587 @param InstallStopIndex Install Ending index.
588 @param NotifyStartIndex Notify Beginning index.
589 @param NotifyStopIndex Notify Ending index.
590
591 **/
592 VOID
593 ProcessNotify (
594 IN PEI_CORE_INSTANCE *PrivateData,
595 IN UINTN NotifyType,
596 IN INTN InstallStartIndex,
597 IN INTN InstallStopIndex,
598 IN INTN NotifyStartIndex,
599 IN INTN NotifyStopIndex
600 );
601
602 /**
603 Process PpiList from SEC phase.
604
605 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
606 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
607 These PPI's will be installed and/or immediately signaled if they are notification type.
608
609 **/
610 VOID
611 ProcessPpiListFromSec (
612 IN CONST EFI_PEI_SERVICES **PeiServices,
613 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
614 );
615
616 //
617 // Boot mode support functions
618 //
619 /**
620 This service enables PEIMs to ascertain the present value of the boot mode.
621
622 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
623 @param BootMode A pointer to contain the value of the boot mode.
624
625 @retval EFI_SUCCESS The boot mode was returned successfully.
626 @retval EFI_INVALID_PARAMETER BootMode is NULL.
627
628 **/
629 EFI_STATUS
630 EFIAPI
631 PeiGetBootMode (
632 IN CONST EFI_PEI_SERVICES **PeiServices,
633 IN OUT EFI_BOOT_MODE *BootMode
634 );
635
636 /**
637 This service enables PEIMs to update the boot mode variable.
638
639
640 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
641 @param BootMode The value of the boot mode to set.
642
643 @return EFI_SUCCESS The value was successfully updated
644
645 **/
646 EFI_STATUS
647 EFIAPI
648 PeiSetBootMode (
649 IN CONST EFI_PEI_SERVICES **PeiServices,
650 IN EFI_BOOT_MODE BootMode
651 );
652
653 //
654 // Security support functions
655 //
656 /**
657
658 Initialize the security services.
659
660 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
661 @param OldCoreData Pointer to the old core data.
662 NULL if being run in non-permament memory mode.
663
664 **/
665 VOID
666 InitializeSecurityServices (
667 IN EFI_PEI_SERVICES **PeiServices,
668 IN PEI_CORE_INSTANCE *OldCoreData
669 );
670
671 /**
672 Verify a Firmware volume.
673
674 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration
675
676 @retval EFI_SUCCESS Firmware Volume is legal
677 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test
678
679 **/
680 EFI_STATUS
681 VerifyFv (
682 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
683 );
684
685 /**
686 Provide a callout to the security verification service.
687
688 @param PrivateData PeiCore's private data structure
689 @param VolumeHandle Handle of FV
690 @param FileHandle Handle of PEIM's ffs
691 @param AuthenticationStatus Authentication status
692
693 @retval EFI_SUCCESS Image is OK
694 @retval EFI_SECURITY_VIOLATION Image is illegal
695 @retval EFI_NOT_FOUND If security PPI is not installed.
696 **/
697 EFI_STATUS
698 VerifyPeim (
699 IN PEI_CORE_INSTANCE *PrivateData,
700 IN EFI_PEI_FV_HANDLE VolumeHandle,
701 IN EFI_PEI_FILE_HANDLE FileHandle,
702 IN UINT32 AuthenticationStatus
703 );
704
705 /**
706
707 Gets the pointer to the HOB List.
708
709
710 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
711 @param HobList Pointer to the HOB List.
712
713 @retval EFI_SUCCESS Get the pointer of HOB List
714 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published
715 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)
716
717 **/
718 EFI_STATUS
719 EFIAPI
720 PeiGetHobList (
721 IN CONST EFI_PEI_SERVICES **PeiServices,
722 IN OUT VOID **HobList
723 );
724
725 /**
726 Add a new HOB to the HOB List.
727
728 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
729 @param Type Type of the new HOB.
730 @param Length Length of the new HOB to allocate.
731 @param Hob Pointer to the new HOB.
732
733 @return EFI_SUCCESS Success to create hob.
734 @retval EFI_INVALID_PARAMETER if Hob is NULL
735 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.
736 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
737
738 **/
739 EFI_STATUS
740 EFIAPI
741 PeiCreateHob (
742 IN CONST EFI_PEI_SERVICES **PeiServices,
743 IN UINT16 Type,
744 IN UINT16 Length,
745 IN OUT VOID **Hob
746 );
747
748 /**
749
750 Builds a Handoff Information Table HOB
751
752 @param BootMode - Current Bootmode
753 @param MemoryBegin - Start Memory Address.
754 @param MemoryLength - Length of Memory.
755
756 @return EFI_SUCCESS Always success to initialize HOB.
757
758 **/
759 EFI_STATUS
760 PeiCoreBuildHobHandoffInfoTable (
761 IN EFI_BOOT_MODE BootMode,
762 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
763 IN UINT64 MemoryLength
764 );
765
766 /**
767 Install SEC HOB data to the HOB List.
768
769 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
770 @param SecHobList Pointer to SEC HOB List.
771
772 @return EFI_SUCCESS Success to install SEC HOB data.
773 @retval EFI_OUT_OF_RESOURCES If there is no more memory to grow the Hoblist.
774
775 **/
776 EFI_STATUS
777 PeiInstallSecHobData (
778 IN CONST EFI_PEI_SERVICES **PeiServices,
779 IN EFI_HOB_GENERIC_HEADER *SecHobList
780 );
781
782
783 //
784 // FFS Fw Volume support functions
785 //
786 /**
787 Searches for the next matching file in the firmware volume.
788
789 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
790 @param SearchType Filter to find only files of this type.
791 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
792 @param FvHandle Handle of firmware volume in which to search.
793 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start
794 at the beginning of the firmware volume. On exit, points the file handle of the next file
795 in the volume or NULL if there are no more files.
796
797 @retval EFI_NOT_FOUND The file was not found.
798 @retval EFI_NOT_FOUND The header checksum was not zero.
799 @retval EFI_SUCCESS The file was found.
800
801 **/
802 EFI_STATUS
803 EFIAPI
804 PeiFfsFindNextFile (
805 IN CONST EFI_PEI_SERVICES **PeiServices,
806 IN UINT8 SearchType,
807 IN EFI_PEI_FV_HANDLE FvHandle,
808 IN OUT EFI_PEI_FILE_HANDLE *FileHandle
809 );
810
811 /**
812 Searches for the next matching section within the specified file.
813
814 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
815 @param SectionType Filter to find only sections of this type.
816 @param FileHandle Pointer to the current file to search.
817 @param SectionData A pointer to the discovered section, if successful.
818 NULL if section not found
819
820 @retval EFI_NOT_FOUND The section was not found.
821 @retval EFI_SUCCESS The section was found.
822
823 **/
824 EFI_STATUS
825 EFIAPI
826 PeiFfsFindSectionData (
827 IN CONST EFI_PEI_SERVICES **PeiServices,
828 IN EFI_SECTION_TYPE SectionType,
829 IN EFI_PEI_FILE_HANDLE FileHandle,
830 OUT VOID **SectionData
831 );
832
833 /**
834 Searches for the next matching section within the specified file.
835
836 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
837 @param SectionType The value of the section type to find.
838 @param SectionInstance Section instance to find.
839 @param FileHandle Handle of the firmware file to search.
840 @param SectionData A pointer to the discovered section, if successful.
841 @param AuthenticationStatus A pointer to the authentication status for this section.
842
843 @retval EFI_SUCCESS The section was found.
844 @retval EFI_NOT_FOUND The section was not found.
845
846 **/
847 EFI_STATUS
848 EFIAPI
849 PeiFfsFindSectionData3 (
850 IN CONST EFI_PEI_SERVICES **PeiServices,
851 IN EFI_SECTION_TYPE SectionType,
852 IN UINTN SectionInstance,
853 IN EFI_PEI_FILE_HANDLE FileHandle,
854 OUT VOID **SectionData,
855 OUT UINT32 *AuthenticationStatus
856 );
857
858 /**
859 Search the firmware volumes by index
860
861 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
862 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware
863 Volume (BFV).
864 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.
865
866 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL
867 @retval EFI_NOT_FOUND The volume was not found.
868 @retval EFI_SUCCESS The volume was found.
869
870 **/
871 EFI_STATUS
872 EFIAPI
873 PeiFfsFindNextVolume (
874 IN CONST EFI_PEI_SERVICES **PeiServices,
875 IN UINTN Instance,
876 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
877 );
878
879 //
880 // Memory support functions
881 //
882 /**
883
884 Initialize the memory services.
885
886 @param PrivateData PeiCore's private data structure
887 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
888 and location of temporary RAM, the stack location and the BFV location.
889 @param OldCoreData Pointer to the PEI Core data.
890 NULL if being run in non-permament memory mode.
891
892 **/
893 VOID
894 InitializeMemoryServices (
895 IN PEI_CORE_INSTANCE *PrivateData,
896 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
897 IN PEI_CORE_INSTANCE *OldCoreData
898 );
899
900 /**
901
902 Install the permanent memory is now available.
903 Creates HOB (PHIT and Stack).
904
905 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
906 @param MemoryBegin Start of memory address.
907 @param MemoryLength Length of memory.
908
909 @return EFI_SUCCESS Always success.
910
911 **/
912 EFI_STATUS
913 EFIAPI
914 PeiInstallPeiMemory (
915 IN CONST EFI_PEI_SERVICES **PeiServices,
916 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
917 IN UINT64 MemoryLength
918 );
919
920 /**
921 Migrate memory pages allocated in pre-memory phase.
922 Copy memory pages at temporary heap top to permanent heap top.
923
924 @param[in] Private Pointer to the private data passed in from caller.
925 @param[in] TemporaryRamMigrated Temporary memory has been migrated to permanent memory.
926
927 **/
928 VOID
929 MigrateMemoryPages (
930 IN PEI_CORE_INSTANCE *Private,
931 IN BOOLEAN TemporaryRamMigrated
932 );
933
934 /**
935 Migrate MemoryBaseAddress in memory allocation HOBs
936 from the temporary memory to PEI installed memory.
937
938 @param[in] PrivateData Pointer to PeiCore's private data structure.
939
940 **/
941 VOID
942 ConvertMemoryAllocationHobs (
943 IN PEI_CORE_INSTANCE *PrivateData
944 );
945
946 /**
947 The purpose of the service is to publish an interface that allows
948 PEIMs to allocate memory ranges that are managed by the PEI Foundation.
949
950 Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.
951 After InstallPeiMemory() is called, PEI will allocate pages within the region
952 of memory provided by InstallPeiMemory() service in a best-effort fashion.
953 Location-specific allocations are not managed by the PEI foundation code.
954
955 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
956 @param MemoryType The type of memory to allocate.
957 @param Pages The number of contiguous 4 KB pages to allocate.
958 @param Memory Pointer to a physical address. On output, the address is set to the base
959 of the page range that was allocated.
960
961 @retval EFI_SUCCESS The memory range was successfully allocated.
962 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
963 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,
964 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,
965 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.
966
967 **/
968 EFI_STATUS
969 EFIAPI
970 PeiAllocatePages (
971 IN CONST EFI_PEI_SERVICES **PeiServices,
972 IN EFI_MEMORY_TYPE MemoryType,
973 IN UINTN Pages,
974 OUT EFI_PHYSICAL_ADDRESS *Memory
975 );
976
977 /**
978 Frees memory pages.
979
980 @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
981 @param[in] Memory The base physical address of the pages to be freed.
982 @param[in] Pages The number of contiguous 4 KB pages to free.
983
984 @retval EFI_SUCCESS The requested pages were freed.
985 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
986 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
987 AllocatePages().
988
989 **/
990 EFI_STATUS
991 EFIAPI
992 PeiFreePages (
993 IN CONST EFI_PEI_SERVICES **PeiServices,
994 IN EFI_PHYSICAL_ADDRESS Memory,
995 IN UINTN Pages
996 );
997
998 /**
999
1000 Memory allocation service on the temporary memory.
1001
1002
1003 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1004 @param Size Amount of memory required
1005 @param Buffer Address of pointer to the buffer
1006
1007 @retval EFI_SUCCESS The allocation was successful
1008 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1009 to allocate the requested size.
1010
1011 **/
1012 EFI_STATUS
1013 EFIAPI
1014 PeiAllocatePool (
1015 IN CONST EFI_PEI_SERVICES **PeiServices,
1016 IN UINTN Size,
1017 OUT VOID **Buffer
1018 );
1019
1020 /**
1021
1022 Routine for load image file.
1023
1024
1025 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1026 @param FileHandle Pointer to the FFS file header of the image.
1027 @param PeimState The dispatch state of the input PEIM handle.
1028 @param EntryPoint Pointer to entry point of specified image file for output.
1029 @param AuthenticationState Pointer to attestation authentication state of image.
1030
1031 @retval EFI_SUCCESS Image is successfully loaded.
1032 @retval EFI_NOT_FOUND Fail to locate necessary PPI
1033 @retval Others Fail to load file.
1034
1035 **/
1036 EFI_STATUS
1037 PeiLoadImage (
1038 IN CONST EFI_PEI_SERVICES **PeiServices,
1039 IN EFI_PEI_FILE_HANDLE FileHandle,
1040 IN UINT8 PeimState,
1041 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1042 OUT UINT32 *AuthenticationState
1043 );
1044
1045 /**
1046
1047 Core version of the Status Code reporter
1048
1049
1050 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1051 @param CodeType Type of Status Code.
1052 @param Value Value to output for Status Code.
1053 @param Instance Instance Number of this status code.
1054 @param CallerId ID of the caller of this status code.
1055 @param Data Optional data associated with this status code.
1056
1057 @retval EFI_SUCCESS if status code is successfully reported
1058 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1059
1060 **/
1061 EFI_STATUS
1062 EFIAPI
1063 PeiReportStatusCode (
1064 IN CONST EFI_PEI_SERVICES **PeiServices,
1065 IN EFI_STATUS_CODE_TYPE CodeType,
1066 IN EFI_STATUS_CODE_VALUE Value,
1067 IN UINT32 Instance,
1068 IN CONST EFI_GUID *CallerId,
1069 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
1070 );
1071
1072 /**
1073
1074 Core version of the Reset System
1075
1076
1077 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1078
1079 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.
1080 @retval EFI_DEVICE_ERROR Did not reset system.
1081 Otherwise, resets the system.
1082
1083 **/
1084 EFI_STATUS
1085 EFIAPI
1086 PeiResetSystem (
1087 IN CONST EFI_PEI_SERVICES **PeiServices
1088 );
1089
1090 /**
1091 Resets the entire platform.
1092
1093 @param[in] ResetType The type of reset to perform.
1094 @param[in] ResetStatus The status code for the reset.
1095 @param[in] DataSize The size, in bytes, of ResetData.
1096 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
1097 the data buffer starts with a Null-terminated string, optionally
1098 followed by additional binary data. The string is a description
1099 that the caller may use to further indicate the reason for the
1100 system reset.
1101
1102 **/
1103 VOID
1104 EFIAPI
1105 PeiResetSystem2 (
1106 IN EFI_RESET_TYPE ResetType,
1107 IN EFI_STATUS ResetStatus,
1108 IN UINTN DataSize,
1109 IN VOID *ResetData OPTIONAL
1110 );
1111
1112 /**
1113
1114 Initialize PeiCore Fv List.
1115
1116
1117 @param PrivateData - Pointer to PEI_CORE_INSTANCE.
1118 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
1119
1120 **/
1121 VOID
1122 PeiInitializeFv (
1123 IN PEI_CORE_INSTANCE *PrivateData,
1124 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
1125 );
1126
1127 /**
1128 Process Firmware Volum Information once FvInfoPPI install.
1129
1130 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1131 @param NotifyDescriptor Address of the notification descriptor data structure.
1132 @param Ppi Address of the PPI that was installed.
1133
1134 @retval EFI_SUCCESS if the interface could be successfully installed
1135
1136 **/
1137 EFI_STATUS
1138 EFIAPI
1139 FirmwareVolmeInfoPpiNotifyCallback (
1140 IN EFI_PEI_SERVICES **PeiServices,
1141 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1142 IN VOID *Ppi
1143 );
1144
1145 /**
1146
1147 Given the input VolumeHandle, search for the next matching name file.
1148
1149 @param FileName File name to search.
1150 @param VolumeHandle The current FV to search.
1151 @param FileHandle Pointer to the file matching name in VolumeHandle.
1152 NULL if file not found
1153
1154 @retval EFI_NOT_FOUND No files matching the search criteria were found
1155 @retval EFI_SUCCESS Success to search given file
1156
1157 **/
1158 EFI_STATUS
1159 EFIAPI
1160 PeiFfsFindFileByName (
1161 IN CONST EFI_GUID *FileName,
1162 IN EFI_PEI_FV_HANDLE VolumeHandle,
1163 OUT EFI_PEI_FILE_HANDLE *FileHandle
1164 );
1165
1166 /**
1167 Returns information about a specific file.
1168
1169 @param FileHandle Handle of the file.
1170 @param FileInfo Upon exit, points to the file's information.
1171
1172 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
1173 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
1174 @retval EFI_SUCCESS File information returned.
1175
1176 **/
1177 EFI_STATUS
1178 EFIAPI
1179 PeiFfsGetFileInfo (
1180 IN EFI_PEI_FILE_HANDLE FileHandle,
1181 OUT EFI_FV_FILE_INFO *FileInfo
1182 );
1183
1184 /**
1185 Returns information about a specific file.
1186
1187 @param FileHandle Handle of the file.
1188 @param FileInfo Upon exit, points to the file's information.
1189
1190 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
1191 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
1192 @retval EFI_SUCCESS File information returned.
1193
1194 **/
1195 EFI_STATUS
1196 EFIAPI
1197 PeiFfsGetFileInfo2 (
1198 IN EFI_PEI_FILE_HANDLE FileHandle,
1199 OUT EFI_FV_FILE_INFO2 *FileInfo
1200 );
1201
1202 /**
1203 Returns information about the specified volume.
1204
1205 @param VolumeHandle Handle of the volume.
1206 @param VolumeInfo Upon exit, points to the volume's information.
1207
1208 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.
1209 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.
1210 @retval EFI_SUCCESS Volume information returned.
1211 **/
1212 EFI_STATUS
1213 EFIAPI
1214 PeiFfsGetVolumeInfo (
1215 IN EFI_PEI_FV_HANDLE VolumeHandle,
1216 OUT EFI_FV_INFO *VolumeInfo
1217 );
1218
1219 /**
1220 This routine enable a PEIM to register itself to shadow when PEI Foundation
1221 discovery permanent memory.
1222
1223 @param FileHandle File handle of a PEIM.
1224
1225 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
1226 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
1227 @retval EFI_SUCCESS Successfully to register itself.
1228
1229 **/
1230 EFI_STATUS
1231 EFIAPI
1232 PeiRegisterForShadow (
1233 IN EFI_PEI_FILE_HANDLE FileHandle
1234 );
1235
1236 /**
1237 Initialize image service that install PeiLoadFilePpi.
1238
1239 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.
1240 @param OldCoreData Pointer to Old PeiCore's private data.
1241 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.
1242 If not NULL, PeiCore is entered at second time, stack/heap has been moved
1243 to permanent memory.
1244
1245 **/
1246 VOID
1247 InitializeImageServices (
1248 IN PEI_CORE_INSTANCE *PrivateData,
1249 IN PEI_CORE_INSTANCE *OldCoreData
1250 );
1251
1252 /**
1253 The wrapper function of PeiLoadImageLoadImage().
1254
1255 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.
1256 @param FileHandle Pointer to the FFS file header of the image.
1257 @param ImageAddressArg Pointer to PE/TE image.
1258 @param ImageSizeArg Size of PE/TE image.
1259 @param EntryPoint Pointer to entry point of specified image file for output.
1260 @param AuthenticationState Pointer to attestation authentication state of image.
1261
1262 @return Status of PeiLoadImageLoadImage().
1263
1264 **/
1265 EFI_STATUS
1266 EFIAPI
1267 PeiLoadImageLoadImageWrapper (
1268 IN CONST EFI_PEI_LOAD_FILE_PPI *This,
1269 IN EFI_PEI_FILE_HANDLE FileHandle,
1270 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL
1271 OUT UINT64 *ImageSizeArg, OPTIONAL
1272 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1273 OUT UINT32 *AuthenticationState
1274 );
1275
1276 /**
1277
1278 Provide a callback for when the security PPI is installed.
1279
1280 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1281 @param NotifyDescriptor The descriptor for the notification event.
1282 @param Ppi Pointer to the PPI in question.
1283
1284 @return Always success
1285
1286 **/
1287 EFI_STATUS
1288 EFIAPI
1289 SecurityPpiNotifyCallback (
1290 IN EFI_PEI_SERVICES **PeiServices,
1291 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1292 IN VOID *Ppi
1293 );
1294
1295 /**
1296 Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.
1297
1298 @param PrivateData PeiCore's private data structure
1299 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
1300 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.
1301
1302 @retval EFI_NOT_FOUND FV image can't be found.
1303 @retval EFI_SUCCESS Successfully to process it.
1304 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
1305 @retval EFI_SECURITY_VIOLATION Image is illegal
1306 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
1307
1308 **/
1309 EFI_STATUS
1310 ProcessFvFile (
1311 IN PEI_CORE_INSTANCE *PrivateData,
1312 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,
1313 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle
1314 );
1315
1316 /**
1317 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.
1318
1319 This routine also will install FvInfo ppi for FV hob in PI ways.
1320
1321 @param Private Pointer of PEI_CORE_INSTANCE
1322 @param Instance The index of FV want to be searched.
1323
1324 @return Instance of PEI_CORE_FV_HANDLE.
1325 **/
1326 PEI_CORE_FV_HANDLE *
1327 FindNextCoreFvHandle (
1328 IN PEI_CORE_INSTANCE *Private,
1329 IN UINTN Instance
1330 );
1331
1332 //
1333 // Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1334 //
1335
1336 /**
1337 Memory-based read services.
1338
1339 This function is to perform the Memory Access Read service based on installed
1340 instance of the EFI_PEI_CPU_IO_PPI.
1341 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1342 return EFI_NOT_YET_AVAILABLE.
1343
1344 @param PeiServices An indirect pointer to the PEI Services Table
1345 published by the PEI Foundation.
1346 @param This Pointer to local data for the interface.
1347 @param Width The width of the access. Enumerated in bytes.
1348 @param Address The physical address of the access.
1349 @param Count The number of accesses to perform.
1350 @param Buffer A pointer to the buffer of data.
1351
1352 @retval EFI_SUCCESS The function completed successfully.
1353 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1354 **/
1355 EFI_STATUS
1356 EFIAPI
1357 PeiDefaultMemRead (
1358 IN CONST EFI_PEI_SERVICES **PeiServices,
1359 IN CONST EFI_PEI_CPU_IO_PPI *This,
1360 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1361 IN UINT64 Address,
1362 IN UINTN Count,
1363 IN OUT VOID *Buffer
1364 );
1365
1366 /**
1367 Memory-based write services.
1368
1369 This function is to perform the Memory Access Write service based on installed
1370 instance of the EFI_PEI_CPU_IO_PPI.
1371 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1372 return EFI_NOT_YET_AVAILABLE.
1373
1374 @param PeiServices An indirect pointer to the PEI Services Table
1375 published by the PEI Foundation.
1376 @param This Pointer to local data for the interface.
1377 @param Width The width of the access. Enumerated in bytes.
1378 @param Address The physical address of the access.
1379 @param Count The number of accesses to perform.
1380 @param Buffer A pointer to the buffer of data.
1381
1382 @retval EFI_SUCCESS The function completed successfully.
1383 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1384 **/
1385 EFI_STATUS
1386 EFIAPI
1387 PeiDefaultMemWrite (
1388 IN CONST EFI_PEI_SERVICES **PeiServices,
1389 IN CONST EFI_PEI_CPU_IO_PPI *This,
1390 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1391 IN UINT64 Address,
1392 IN UINTN Count,
1393 IN OUT VOID *Buffer
1394 );
1395
1396 /**
1397 IO-based read services.
1398
1399 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.
1400 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1401 return EFI_NOT_YET_AVAILABLE.
1402
1403 @param PeiServices An indirect pointer to the PEI Services Table
1404 published by the PEI Foundation.
1405 @param This Pointer to local data for the interface.
1406 @param Width The width of the access. Enumerated in bytes.
1407 @param Address The physical address of the access.
1408 @param Count The number of accesses to perform.
1409 @param Buffer A pointer to the buffer of data.
1410
1411 @retval EFI_SUCCESS The function completed successfully.
1412 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1413 **/
1414 EFI_STATUS
1415 EFIAPI
1416 PeiDefaultIoRead (
1417 IN CONST EFI_PEI_SERVICES **PeiServices,
1418 IN CONST EFI_PEI_CPU_IO_PPI *This,
1419 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1420 IN UINT64 Address,
1421 IN UINTN Count,
1422 IN OUT VOID *Buffer
1423 );
1424
1425 /**
1426 IO-based write services.
1427
1428 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.
1429 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1430 return EFI_NOT_YET_AVAILABLE.
1431
1432 @param PeiServices An indirect pointer to the PEI Services Table
1433 published by the PEI Foundation.
1434 @param This Pointer to local data for the interface.
1435 @param Width The width of the access. Enumerated in bytes.
1436 @param Address The physical address of the access.
1437 @param Count The number of accesses to perform.
1438 @param Buffer A pointer to the buffer of data.
1439
1440 @retval EFI_SUCCESS The function completed successfully.
1441 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1442 **/
1443 EFI_STATUS
1444 EFIAPI
1445 PeiDefaultIoWrite (
1446 IN CONST EFI_PEI_SERVICES **PeiServices,
1447 IN CONST EFI_PEI_CPU_IO_PPI *This,
1448 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1449 IN UINT64 Address,
1450 IN UINTN Count,
1451 IN OUT VOID *Buffer
1452 );
1453
1454 /**
1455 8-bit I/O read operations.
1456
1457 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1458 return 0.
1459
1460 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1461 @param This Pointer to local data for the interface.
1462 @param Address The physical address of the access.
1463
1464 @return An 8-bit value returned from the I/O space.
1465 **/
1466 UINT8
1467 EFIAPI
1468 PeiDefaultIoRead8 (
1469 IN CONST EFI_PEI_SERVICES **PeiServices,
1470 IN CONST EFI_PEI_CPU_IO_PPI *This,
1471 IN UINT64 Address
1472 );
1473
1474 /**
1475 Reads an 16-bit I/O port.
1476
1477 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1478 return 0.
1479
1480 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1481 @param This Pointer to local data for the interface.
1482 @param Address The physical address of the access.
1483
1484 @return A 16-bit value returned from the I/O space.
1485 **/
1486 UINT16
1487 EFIAPI
1488 PeiDefaultIoRead16 (
1489 IN CONST EFI_PEI_SERVICES **PeiServices,
1490 IN CONST EFI_PEI_CPU_IO_PPI *This,
1491 IN UINT64 Address
1492 );
1493
1494 /**
1495 Reads an 32-bit I/O port.
1496
1497 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1498 return 0.
1499
1500 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1501 @param This Pointer to local data for the interface.
1502 @param Address The physical address of the access.
1503
1504 @return A 32-bit value returned from the I/O space.
1505 **/
1506 UINT32
1507 EFIAPI
1508 PeiDefaultIoRead32 (
1509 IN CONST EFI_PEI_SERVICES **PeiServices,
1510 IN CONST EFI_PEI_CPU_IO_PPI *This,
1511 IN UINT64 Address
1512 );
1513
1514 /**
1515 Reads an 64-bit I/O port.
1516
1517 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1518 return 0.
1519
1520 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1521 @param This Pointer to local data for the interface.
1522 @param Address The physical address of the access.
1523
1524 @return A 64-bit value returned from the I/O space.
1525 **/
1526 UINT64
1527 EFIAPI
1528 PeiDefaultIoRead64 (
1529 IN CONST EFI_PEI_SERVICES **PeiServices,
1530 IN CONST EFI_PEI_CPU_IO_PPI *This,
1531 IN UINT64 Address
1532 );
1533
1534 /**
1535 8-bit I/O write operations.
1536
1537 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1538 @param This Pointer to local data for the interface.
1539 @param Address The physical address of the access.
1540 @param Data The data to write.
1541 **/
1542 VOID
1543 EFIAPI
1544 PeiDefaultIoWrite8 (
1545 IN CONST EFI_PEI_SERVICES **PeiServices,
1546 IN CONST EFI_PEI_CPU_IO_PPI *This,
1547 IN UINT64 Address,
1548 IN UINT8 Data
1549 );
1550
1551 /**
1552 16-bit I/O write operations.
1553
1554 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1555 @param This Pointer to local data for the interface.
1556 @param Address The physical address of the access.
1557 @param Data The data to write.
1558 **/
1559 VOID
1560 EFIAPI
1561 PeiDefaultIoWrite16 (
1562 IN CONST EFI_PEI_SERVICES **PeiServices,
1563 IN CONST EFI_PEI_CPU_IO_PPI *This,
1564 IN UINT64 Address,
1565 IN UINT16 Data
1566 );
1567
1568 /**
1569 32-bit I/O write operations.
1570
1571 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1572 @param This Pointer to local data for the interface.
1573 @param Address The physical address of the access.
1574 @param Data The data to write.
1575 **/
1576 VOID
1577 EFIAPI
1578 PeiDefaultIoWrite32 (
1579 IN CONST EFI_PEI_SERVICES **PeiServices,
1580 IN CONST EFI_PEI_CPU_IO_PPI *This,
1581 IN UINT64 Address,
1582 IN UINT32 Data
1583 );
1584
1585 /**
1586 64-bit I/O write operations.
1587
1588 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1589 @param This Pointer to local data for the interface.
1590 @param Address The physical address of the access.
1591 @param Data The data to write.
1592 **/
1593 VOID
1594 EFIAPI
1595 PeiDefaultIoWrite64 (
1596 IN CONST EFI_PEI_SERVICES **PeiServices,
1597 IN CONST EFI_PEI_CPU_IO_PPI *This,
1598 IN UINT64 Address,
1599 IN UINT64 Data
1600 );
1601
1602 /**
1603 8-bit memory read operations.
1604
1605 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1606 return 0.
1607
1608 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1609 @param This Pointer to local data for the interface.
1610 @param Address The physical address of the access.
1611
1612 @return An 8-bit value returned from the memory space.
1613
1614 **/
1615 UINT8
1616 EFIAPI
1617 PeiDefaultMemRead8 (
1618 IN CONST EFI_PEI_SERVICES **PeiServices,
1619 IN CONST EFI_PEI_CPU_IO_PPI *This,
1620 IN UINT64 Address
1621 );
1622
1623 /**
1624 16-bit memory read operations.
1625
1626 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1627 return 0.
1628
1629 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1630 @param This Pointer to local data for the interface.
1631 @param Address The physical address of the access.
1632
1633 @return An 16-bit value returned from the memory space.
1634
1635 **/
1636 UINT16
1637 EFIAPI
1638 PeiDefaultMemRead16 (
1639 IN CONST EFI_PEI_SERVICES **PeiServices,
1640 IN CONST EFI_PEI_CPU_IO_PPI *This,
1641 IN UINT64 Address
1642 );
1643
1644 /**
1645 32-bit memory read operations.
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 An 32-bit value returned from the memory space.
1655
1656 **/
1657 UINT32
1658 EFIAPI
1659 PeiDefaultMemRead32 (
1660 IN CONST EFI_PEI_SERVICES **PeiServices,
1661 IN CONST EFI_PEI_CPU_IO_PPI *This,
1662 IN UINT64 Address
1663 );
1664
1665 /**
1666 64-bit memory read operations.
1667
1668 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1669 return 0.
1670
1671 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1672 @param This Pointer to local data for the interface.
1673 @param Address The physical address of the access.
1674
1675 @return An 64-bit value returned from the memory space.
1676
1677 **/
1678 UINT64
1679 EFIAPI
1680 PeiDefaultMemRead64 (
1681 IN CONST EFI_PEI_SERVICES **PeiServices,
1682 IN CONST EFI_PEI_CPU_IO_PPI *This,
1683 IN UINT64 Address
1684 );
1685
1686 /**
1687 8-bit memory write operations.
1688
1689 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1690 @param This Pointer to local data for the interface.
1691 @param Address The physical address of the access.
1692 @param Data The data to write.
1693
1694 **/
1695 VOID
1696 EFIAPI
1697 PeiDefaultMemWrite8 (
1698 IN CONST EFI_PEI_SERVICES **PeiServices,
1699 IN CONST EFI_PEI_CPU_IO_PPI *This,
1700 IN UINT64 Address,
1701 IN UINT8 Data
1702 );
1703
1704 /**
1705 16-bit memory 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 **/
1713 VOID
1714 EFIAPI
1715 PeiDefaultMemWrite16 (
1716 IN CONST EFI_PEI_SERVICES **PeiServices,
1717 IN CONST EFI_PEI_CPU_IO_PPI *This,
1718 IN UINT64 Address,
1719 IN UINT16 Data
1720 );
1721
1722 /**
1723 32-bit memory write operations.
1724
1725 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1726 @param This Pointer to local data for the interface.
1727 @param Address The physical address of the access.
1728 @param Data The data to write.
1729
1730 **/
1731 VOID
1732 EFIAPI
1733 PeiDefaultMemWrite32 (
1734 IN CONST EFI_PEI_SERVICES **PeiServices,
1735 IN CONST EFI_PEI_CPU_IO_PPI *This,
1736 IN UINT64 Address,
1737 IN UINT32 Data
1738 );
1739
1740 /**
1741 64-bit memory write operations.
1742
1743 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1744 @param This Pointer to local data for the interface.
1745 @param Address The physical address of the access.
1746 @param Data The data to write.
1747
1748 **/
1749 VOID
1750 EFIAPI
1751 PeiDefaultMemWrite64 (
1752 IN CONST EFI_PEI_SERVICES **PeiServices,
1753 IN CONST EFI_PEI_CPU_IO_PPI *This,
1754 IN UINT64 Address,
1755 IN UINT64 Data
1756 );
1757
1758 extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;
1759
1760 //
1761 // Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1762 //
1763
1764 /**
1765 Reads from a given location in the PCI configuration space.
1766
1767 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1768 return EFI_NOT_YET_AVAILABLE.
1769
1770 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1771 @param This Pointer to local data for the interface.
1772 @param Width The width of the access. Enumerated in bytes.
1773 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1774 @param Address The physical address of the access. The format of
1775 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1776 @param Buffer A pointer to the buffer of data.
1777
1778 @retval EFI_SUCCESS The function completed successfully.
1779 @retval EFI_INVALID_PARAMETER The invalid access width.
1780 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1781
1782 **/
1783 EFI_STATUS
1784 EFIAPI
1785 PeiDefaultPciCfg2Read (
1786 IN CONST EFI_PEI_SERVICES **PeiServices,
1787 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1788 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1789 IN UINT64 Address,
1790 IN OUT VOID *Buffer
1791 );
1792
1793 /**
1794 Write to a given location in the PCI configuration space.
1795
1796 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1797 return EFI_NOT_YET_AVAILABLE.
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 Width The width of the access. Enumerated in bytes.
1802 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1803 @param Address The physical address of the access. The format of
1804 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1805 @param Buffer A pointer to the buffer of data.
1806
1807 @retval EFI_SUCCESS The function completed successfully.
1808 @retval EFI_INVALID_PARAMETER The invalid access width.
1809 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1810 **/
1811 EFI_STATUS
1812 EFIAPI
1813 PeiDefaultPciCfg2Write (
1814 IN CONST EFI_PEI_SERVICES **PeiServices,
1815 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1816 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1817 IN UINT64 Address,
1818 IN OUT VOID *Buffer
1819 );
1820
1821 /**
1822 This function performs a read-modify-write operation on the contents from a given
1823 location in the PCI configuration space.
1824
1825 @param PeiServices An indirect pointer to the PEI Services Table
1826 published by the PEI Foundation.
1827 @param This Pointer to local data for the interface.
1828 @param Width The width of the access. Enumerated in bytes. Type
1829 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
1830 @param Address The physical address of the access.
1831 @param SetBits Points to value to bitwise-OR with the read configuration value.
1832 The size of the value is determined by Width.
1833 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
1834 The size of the value is determined by Width.
1835
1836 @retval EFI_SUCCESS The function completed successfully.
1837 @retval EFI_INVALID_PARAMETER The invalid access width.
1838 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1839 **/
1840 EFI_STATUS
1841 EFIAPI
1842 PeiDefaultPciCfg2Modify (
1843 IN CONST EFI_PEI_SERVICES **PeiServices,
1844 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1845 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1846 IN UINT64 Address,
1847 IN VOID *SetBits,
1848 IN VOID *ClearBits
1849 );
1850
1851 extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;
1852
1853 /**
1854 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should
1855 be re-installed with the instance in permanent memory and all cached FvPpi pointers in
1856 PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent
1857 memory.
1858
1859 @param PrivateData Pointer to PEI_CORE_INSTANCE.
1860 **/
1861 VOID
1862 PeiReinitializeFv (
1863 IN PEI_CORE_INSTANCE *PrivateData
1864 );
1865
1866 #endif