]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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. ResetData is only valid if ResetStatus is something
1101 other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific
1102 where a minimum amount of ResetData is always required.
1103
1104 **/
1105 VOID
1106 EFIAPI
1107 PeiResetSystem2 (
1108 IN EFI_RESET_TYPE ResetType,
1109 IN EFI_STATUS ResetStatus,
1110 IN UINTN DataSize,
1111 IN VOID *ResetData OPTIONAL
1112 );
1113
1114 /**
1115
1116 Initialize PeiCore Fv List.
1117
1118
1119 @param PrivateData - Pointer to PEI_CORE_INSTANCE.
1120 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
1121
1122 **/
1123 VOID
1124 PeiInitializeFv (
1125 IN PEI_CORE_INSTANCE *PrivateData,
1126 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
1127 );
1128
1129 /**
1130 Process Firmware Volum Information once FvInfoPPI install.
1131
1132 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1133 @param NotifyDescriptor Address of the notification descriptor data structure.
1134 @param Ppi Address of the PPI that was installed.
1135
1136 @retval EFI_SUCCESS if the interface could be successfully installed
1137
1138 **/
1139 EFI_STATUS
1140 EFIAPI
1141 FirmwareVolmeInfoPpiNotifyCallback (
1142 IN EFI_PEI_SERVICES **PeiServices,
1143 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1144 IN VOID *Ppi
1145 );
1146
1147 /**
1148
1149 Given the input VolumeHandle, search for the next matching name file.
1150
1151 @param FileName File name to search.
1152 @param VolumeHandle The current FV to search.
1153 @param FileHandle Pointer to the file matching name in VolumeHandle.
1154 NULL if file not found
1155
1156 @retval EFI_NOT_FOUND No files matching the search criteria were found
1157 @retval EFI_SUCCESS Success to search given file
1158
1159 **/
1160 EFI_STATUS
1161 EFIAPI
1162 PeiFfsFindFileByName (
1163 IN CONST EFI_GUID *FileName,
1164 IN EFI_PEI_FV_HANDLE VolumeHandle,
1165 OUT EFI_PEI_FILE_HANDLE *FileHandle
1166 );
1167
1168 /**
1169 Returns information about a specific file.
1170
1171 @param FileHandle Handle of the file.
1172 @param FileInfo Upon exit, points to the file's information.
1173
1174 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
1175 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
1176 @retval EFI_SUCCESS File information returned.
1177
1178 **/
1179 EFI_STATUS
1180 EFIAPI
1181 PeiFfsGetFileInfo (
1182 IN EFI_PEI_FILE_HANDLE FileHandle,
1183 OUT EFI_FV_FILE_INFO *FileInfo
1184 );
1185
1186 /**
1187 Returns information about a specific file.
1188
1189 @param FileHandle Handle of the file.
1190 @param FileInfo Upon exit, points to the file's information.
1191
1192 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
1193 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
1194 @retval EFI_SUCCESS File information returned.
1195
1196 **/
1197 EFI_STATUS
1198 EFIAPI
1199 PeiFfsGetFileInfo2 (
1200 IN EFI_PEI_FILE_HANDLE FileHandle,
1201 OUT EFI_FV_FILE_INFO2 *FileInfo
1202 );
1203
1204 /**
1205 Returns information about the specified volume.
1206
1207 @param VolumeHandle Handle of the volume.
1208 @param VolumeInfo Upon exit, points to the volume's information.
1209
1210 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.
1211 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.
1212 @retval EFI_SUCCESS Volume information returned.
1213 **/
1214 EFI_STATUS
1215 EFIAPI
1216 PeiFfsGetVolumeInfo (
1217 IN EFI_PEI_FV_HANDLE VolumeHandle,
1218 OUT EFI_FV_INFO *VolumeInfo
1219 );
1220
1221 /**
1222 This routine enable a PEIM to register itself to shadow when PEI Foundation
1223 discovery permanent memory.
1224
1225 @param FileHandle File handle of a PEIM.
1226
1227 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
1228 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
1229 @retval EFI_SUCCESS Successfully to register itself.
1230
1231 **/
1232 EFI_STATUS
1233 EFIAPI
1234 PeiRegisterForShadow (
1235 IN EFI_PEI_FILE_HANDLE FileHandle
1236 );
1237
1238 /**
1239 Initialize image service that install PeiLoadFilePpi.
1240
1241 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.
1242 @param OldCoreData Pointer to Old PeiCore's private data.
1243 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.
1244 If not NULL, PeiCore is entered at second time, stack/heap has been moved
1245 to permanent memory.
1246
1247 **/
1248 VOID
1249 InitializeImageServices (
1250 IN PEI_CORE_INSTANCE *PrivateData,
1251 IN PEI_CORE_INSTANCE *OldCoreData
1252 );
1253
1254 /**
1255 The wrapper function of PeiLoadImageLoadImage().
1256
1257 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.
1258 @param FileHandle Pointer to the FFS file header of the image.
1259 @param ImageAddressArg Pointer to PE/TE image.
1260 @param ImageSizeArg Size of PE/TE image.
1261 @param EntryPoint Pointer to entry point of specified image file for output.
1262 @param AuthenticationState Pointer to attestation authentication state of image.
1263
1264 @return Status of PeiLoadImageLoadImage().
1265
1266 **/
1267 EFI_STATUS
1268 EFIAPI
1269 PeiLoadImageLoadImageWrapper (
1270 IN CONST EFI_PEI_LOAD_FILE_PPI *This,
1271 IN EFI_PEI_FILE_HANDLE FileHandle,
1272 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL
1273 OUT UINT64 *ImageSizeArg, OPTIONAL
1274 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1275 OUT UINT32 *AuthenticationState
1276 );
1277
1278 /**
1279
1280 Provide a callback for when the security PPI is installed.
1281
1282 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1283 @param NotifyDescriptor The descriptor for the notification event.
1284 @param Ppi Pointer to the PPI in question.
1285
1286 @return Always success
1287
1288 **/
1289 EFI_STATUS
1290 EFIAPI
1291 SecurityPpiNotifyCallback (
1292 IN EFI_PEI_SERVICES **PeiServices,
1293 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1294 IN VOID *Ppi
1295 );
1296
1297 /**
1298 Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.
1299
1300 @param PrivateData PeiCore's private data structure
1301 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
1302 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.
1303
1304 @retval EFI_NOT_FOUND FV image can't be found.
1305 @retval EFI_SUCCESS Successfully to process it.
1306 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
1307 @retval EFI_SECURITY_VIOLATION Image is illegal
1308 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
1309
1310 **/
1311 EFI_STATUS
1312 ProcessFvFile (
1313 IN PEI_CORE_INSTANCE *PrivateData,
1314 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,
1315 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle
1316 );
1317
1318 /**
1319 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.
1320
1321 This routine also will install FvInfo ppi for FV hob in PI ways.
1322
1323 @param Private Pointer of PEI_CORE_INSTANCE
1324 @param Instance The index of FV want to be searched.
1325
1326 @return Instance of PEI_CORE_FV_HANDLE.
1327 **/
1328 PEI_CORE_FV_HANDLE *
1329 FindNextCoreFvHandle (
1330 IN PEI_CORE_INSTANCE *Private,
1331 IN UINTN Instance
1332 );
1333
1334 //
1335 // Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1336 //
1337
1338 /**
1339 Memory-based read services.
1340
1341 This function is to perform the Memory Access Read service based on installed
1342 instance of the EFI_PEI_CPU_IO_PPI.
1343 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1344 return EFI_NOT_YET_AVAILABLE.
1345
1346 @param PeiServices An indirect pointer to the PEI Services Table
1347 published by the PEI Foundation.
1348 @param This Pointer to local data for the interface.
1349 @param Width The width of the access. Enumerated in bytes.
1350 @param Address The physical address of the access.
1351 @param Count The number of accesses to perform.
1352 @param Buffer A pointer to the buffer of data.
1353
1354 @retval EFI_SUCCESS The function completed successfully.
1355 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1356 **/
1357 EFI_STATUS
1358 EFIAPI
1359 PeiDefaultMemRead (
1360 IN CONST EFI_PEI_SERVICES **PeiServices,
1361 IN CONST EFI_PEI_CPU_IO_PPI *This,
1362 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1363 IN UINT64 Address,
1364 IN UINTN Count,
1365 IN OUT VOID *Buffer
1366 );
1367
1368 /**
1369 Memory-based write services.
1370
1371 This function is to perform the Memory Access Write service based on installed
1372 instance of the EFI_PEI_CPU_IO_PPI.
1373 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1374 return EFI_NOT_YET_AVAILABLE.
1375
1376 @param PeiServices An indirect pointer to the PEI Services Table
1377 published by the PEI Foundation.
1378 @param This Pointer to local data for the interface.
1379 @param Width The width of the access. Enumerated in bytes.
1380 @param Address The physical address of the access.
1381 @param Count The number of accesses to perform.
1382 @param Buffer A pointer to the buffer of data.
1383
1384 @retval EFI_SUCCESS The function completed successfully.
1385 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1386 **/
1387 EFI_STATUS
1388 EFIAPI
1389 PeiDefaultMemWrite (
1390 IN CONST EFI_PEI_SERVICES **PeiServices,
1391 IN CONST EFI_PEI_CPU_IO_PPI *This,
1392 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1393 IN UINT64 Address,
1394 IN UINTN Count,
1395 IN OUT VOID *Buffer
1396 );
1397
1398 /**
1399 IO-based read services.
1400
1401 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.
1402 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1403 return EFI_NOT_YET_AVAILABLE.
1404
1405 @param PeiServices An indirect pointer to the PEI Services Table
1406 published by the PEI Foundation.
1407 @param This Pointer to local data for the interface.
1408 @param Width The width of the access. Enumerated in bytes.
1409 @param Address The physical address of the access.
1410 @param Count The number of accesses to perform.
1411 @param Buffer A pointer to the buffer of data.
1412
1413 @retval EFI_SUCCESS The function completed successfully.
1414 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1415 **/
1416 EFI_STATUS
1417 EFIAPI
1418 PeiDefaultIoRead (
1419 IN CONST EFI_PEI_SERVICES **PeiServices,
1420 IN CONST EFI_PEI_CPU_IO_PPI *This,
1421 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1422 IN UINT64 Address,
1423 IN UINTN Count,
1424 IN OUT VOID *Buffer
1425 );
1426
1427 /**
1428 IO-based write services.
1429
1430 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.
1431 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1432 return EFI_NOT_YET_AVAILABLE.
1433
1434 @param PeiServices An indirect pointer to the PEI Services Table
1435 published by the PEI Foundation.
1436 @param This Pointer to local data for the interface.
1437 @param Width The width of the access. Enumerated in bytes.
1438 @param Address The physical address of the access.
1439 @param Count The number of accesses to perform.
1440 @param Buffer A pointer to the buffer of data.
1441
1442 @retval EFI_SUCCESS The function completed successfully.
1443 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1444 **/
1445 EFI_STATUS
1446 EFIAPI
1447 PeiDefaultIoWrite (
1448 IN CONST EFI_PEI_SERVICES **PeiServices,
1449 IN CONST EFI_PEI_CPU_IO_PPI *This,
1450 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1451 IN UINT64 Address,
1452 IN UINTN Count,
1453 IN OUT VOID *Buffer
1454 );
1455
1456 /**
1457 8-bit I/O read operations.
1458
1459 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1460 return 0.
1461
1462 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1463 @param This Pointer to local data for the interface.
1464 @param Address The physical address of the access.
1465
1466 @return An 8-bit value returned from the I/O space.
1467 **/
1468 UINT8
1469 EFIAPI
1470 PeiDefaultIoRead8 (
1471 IN CONST EFI_PEI_SERVICES **PeiServices,
1472 IN CONST EFI_PEI_CPU_IO_PPI *This,
1473 IN UINT64 Address
1474 );
1475
1476 /**
1477 Reads an 16-bit I/O port.
1478
1479 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1480 return 0.
1481
1482 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1483 @param This Pointer to local data for the interface.
1484 @param Address The physical address of the access.
1485
1486 @return A 16-bit value returned from the I/O space.
1487 **/
1488 UINT16
1489 EFIAPI
1490 PeiDefaultIoRead16 (
1491 IN CONST EFI_PEI_SERVICES **PeiServices,
1492 IN CONST EFI_PEI_CPU_IO_PPI *This,
1493 IN UINT64 Address
1494 );
1495
1496 /**
1497 Reads an 32-bit I/O port.
1498
1499 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1500 return 0.
1501
1502 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1503 @param This Pointer to local data for the interface.
1504 @param Address The physical address of the access.
1505
1506 @return A 32-bit value returned from the I/O space.
1507 **/
1508 UINT32
1509 EFIAPI
1510 PeiDefaultIoRead32 (
1511 IN CONST EFI_PEI_SERVICES **PeiServices,
1512 IN CONST EFI_PEI_CPU_IO_PPI *This,
1513 IN UINT64 Address
1514 );
1515
1516 /**
1517 Reads an 64-bit I/O port.
1518
1519 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1520 return 0.
1521
1522 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1523 @param This Pointer to local data for the interface.
1524 @param Address The physical address of the access.
1525
1526 @return A 64-bit value returned from the I/O space.
1527 **/
1528 UINT64
1529 EFIAPI
1530 PeiDefaultIoRead64 (
1531 IN CONST EFI_PEI_SERVICES **PeiServices,
1532 IN CONST EFI_PEI_CPU_IO_PPI *This,
1533 IN UINT64 Address
1534 );
1535
1536 /**
1537 8-bit I/O write operations.
1538
1539 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1540 @param This Pointer to local data for the interface.
1541 @param Address The physical address of the access.
1542 @param Data The data to write.
1543 **/
1544 VOID
1545 EFIAPI
1546 PeiDefaultIoWrite8 (
1547 IN CONST EFI_PEI_SERVICES **PeiServices,
1548 IN CONST EFI_PEI_CPU_IO_PPI *This,
1549 IN UINT64 Address,
1550 IN UINT8 Data
1551 );
1552
1553 /**
1554 16-bit I/O write operations.
1555
1556 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1557 @param This Pointer to local data for the interface.
1558 @param Address The physical address of the access.
1559 @param Data The data to write.
1560 **/
1561 VOID
1562 EFIAPI
1563 PeiDefaultIoWrite16 (
1564 IN CONST EFI_PEI_SERVICES **PeiServices,
1565 IN CONST EFI_PEI_CPU_IO_PPI *This,
1566 IN UINT64 Address,
1567 IN UINT16 Data
1568 );
1569
1570 /**
1571 32-bit I/O write operations.
1572
1573 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1574 @param This Pointer to local data for the interface.
1575 @param Address The physical address of the access.
1576 @param Data The data to write.
1577 **/
1578 VOID
1579 EFIAPI
1580 PeiDefaultIoWrite32 (
1581 IN CONST EFI_PEI_SERVICES **PeiServices,
1582 IN CONST EFI_PEI_CPU_IO_PPI *This,
1583 IN UINT64 Address,
1584 IN UINT32 Data
1585 );
1586
1587 /**
1588 64-bit I/O write operations.
1589
1590 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1591 @param This Pointer to local data for the interface.
1592 @param Address The physical address of the access.
1593 @param Data The data to write.
1594 **/
1595 VOID
1596 EFIAPI
1597 PeiDefaultIoWrite64 (
1598 IN CONST EFI_PEI_SERVICES **PeiServices,
1599 IN CONST EFI_PEI_CPU_IO_PPI *This,
1600 IN UINT64 Address,
1601 IN UINT64 Data
1602 );
1603
1604 /**
1605 8-bit memory read operations.
1606
1607 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1608 return 0.
1609
1610 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1611 @param This Pointer to local data for the interface.
1612 @param Address The physical address of the access.
1613
1614 @return An 8-bit value returned from the memory space.
1615
1616 **/
1617 UINT8
1618 EFIAPI
1619 PeiDefaultMemRead8 (
1620 IN CONST EFI_PEI_SERVICES **PeiServices,
1621 IN CONST EFI_PEI_CPU_IO_PPI *This,
1622 IN UINT64 Address
1623 );
1624
1625 /**
1626 16-bit memory read operations.
1627
1628 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1629 return 0.
1630
1631 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1632 @param This Pointer to local data for the interface.
1633 @param Address The physical address of the access.
1634
1635 @return An 16-bit value returned from the memory space.
1636
1637 **/
1638 UINT16
1639 EFIAPI
1640 PeiDefaultMemRead16 (
1641 IN CONST EFI_PEI_SERVICES **PeiServices,
1642 IN CONST EFI_PEI_CPU_IO_PPI *This,
1643 IN UINT64 Address
1644 );
1645
1646 /**
1647 32-bit memory read operations.
1648
1649 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1650 return 0.
1651
1652 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1653 @param This Pointer to local data for the interface.
1654 @param Address The physical address of the access.
1655
1656 @return An 32-bit value returned from the memory space.
1657
1658 **/
1659 UINT32
1660 EFIAPI
1661 PeiDefaultMemRead32 (
1662 IN CONST EFI_PEI_SERVICES **PeiServices,
1663 IN CONST EFI_PEI_CPU_IO_PPI *This,
1664 IN UINT64 Address
1665 );
1666
1667 /**
1668 64-bit memory read operations.
1669
1670 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1671 return 0.
1672
1673 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1674 @param This Pointer to local data for the interface.
1675 @param Address The physical address of the access.
1676
1677 @return An 64-bit value returned from the memory space.
1678
1679 **/
1680 UINT64
1681 EFIAPI
1682 PeiDefaultMemRead64 (
1683 IN CONST EFI_PEI_SERVICES **PeiServices,
1684 IN CONST EFI_PEI_CPU_IO_PPI *This,
1685 IN UINT64 Address
1686 );
1687
1688 /**
1689 8-bit memory write operations.
1690
1691 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1692 @param This Pointer to local data for the interface.
1693 @param Address The physical address of the access.
1694 @param Data The data to write.
1695
1696 **/
1697 VOID
1698 EFIAPI
1699 PeiDefaultMemWrite8 (
1700 IN CONST EFI_PEI_SERVICES **PeiServices,
1701 IN CONST EFI_PEI_CPU_IO_PPI *This,
1702 IN UINT64 Address,
1703 IN UINT8 Data
1704 );
1705
1706 /**
1707 16-bit memory write operations.
1708
1709 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1710 @param This Pointer to local data for the interface.
1711 @param Address The physical address of the access.
1712 @param Data The data to write.
1713
1714 **/
1715 VOID
1716 EFIAPI
1717 PeiDefaultMemWrite16 (
1718 IN CONST EFI_PEI_SERVICES **PeiServices,
1719 IN CONST EFI_PEI_CPU_IO_PPI *This,
1720 IN UINT64 Address,
1721 IN UINT16 Data
1722 );
1723
1724 /**
1725 32-bit memory write operations.
1726
1727 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1728 @param This Pointer to local data for the interface.
1729 @param Address The physical address of the access.
1730 @param Data The data to write.
1731
1732 **/
1733 VOID
1734 EFIAPI
1735 PeiDefaultMemWrite32 (
1736 IN CONST EFI_PEI_SERVICES **PeiServices,
1737 IN CONST EFI_PEI_CPU_IO_PPI *This,
1738 IN UINT64 Address,
1739 IN UINT32 Data
1740 );
1741
1742 /**
1743 64-bit memory write operations.
1744
1745 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1746 @param This Pointer to local data for the interface.
1747 @param Address The physical address of the access.
1748 @param Data The data to write.
1749
1750 **/
1751 VOID
1752 EFIAPI
1753 PeiDefaultMemWrite64 (
1754 IN CONST EFI_PEI_SERVICES **PeiServices,
1755 IN CONST EFI_PEI_CPU_IO_PPI *This,
1756 IN UINT64 Address,
1757 IN UINT64 Data
1758 );
1759
1760 extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;
1761
1762 //
1763 // Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1764 //
1765
1766 /**
1767 Reads from a given location in the PCI configuration space.
1768
1769 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1770 return EFI_NOT_YET_AVAILABLE.
1771
1772 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1773 @param This Pointer to local data for the interface.
1774 @param Width The width of the access. Enumerated in bytes.
1775 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1776 @param Address The physical address of the access. The format of
1777 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1778 @param Buffer A pointer to the buffer of data.
1779
1780 @retval EFI_SUCCESS The function completed successfully.
1781 @retval EFI_INVALID_PARAMETER The invalid access width.
1782 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1783
1784 **/
1785 EFI_STATUS
1786 EFIAPI
1787 PeiDefaultPciCfg2Read (
1788 IN CONST EFI_PEI_SERVICES **PeiServices,
1789 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1790 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1791 IN UINT64 Address,
1792 IN OUT VOID *Buffer
1793 );
1794
1795 /**
1796 Write to a given location in the PCI configuration space.
1797
1798 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1799 return EFI_NOT_YET_AVAILABLE.
1800
1801 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1802 @param This Pointer to local data for the interface.
1803 @param Width The width of the access. Enumerated in bytes.
1804 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1805 @param Address The physical address of the access. The format of
1806 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1807 @param Buffer A pointer to the buffer of data.
1808
1809 @retval EFI_SUCCESS The function completed successfully.
1810 @retval EFI_INVALID_PARAMETER The invalid access width.
1811 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1812 **/
1813 EFI_STATUS
1814 EFIAPI
1815 PeiDefaultPciCfg2Write (
1816 IN CONST EFI_PEI_SERVICES **PeiServices,
1817 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1818 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1819 IN UINT64 Address,
1820 IN OUT VOID *Buffer
1821 );
1822
1823 /**
1824 This function performs a read-modify-write operation on the contents from a given
1825 location in the PCI configuration space.
1826
1827 @param PeiServices An indirect pointer to the PEI Services Table
1828 published by the PEI Foundation.
1829 @param This Pointer to local data for the interface.
1830 @param Width The width of the access. Enumerated in bytes. Type
1831 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
1832 @param Address The physical address of the access.
1833 @param SetBits Points to value to bitwise-OR with the read configuration value.
1834 The size of the value is determined by Width.
1835 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
1836 The size of the value is determined by Width.
1837
1838 @retval EFI_SUCCESS The function completed successfully.
1839 @retval EFI_INVALID_PARAMETER The invalid access width.
1840 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1841 **/
1842 EFI_STATUS
1843 EFIAPI
1844 PeiDefaultPciCfg2Modify (
1845 IN CONST EFI_PEI_SERVICES **PeiServices,
1846 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1847 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1848 IN UINT64 Address,
1849 IN VOID *SetBits,
1850 IN VOID *ClearBits
1851 );
1852
1853 extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;
1854
1855 /**
1856 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should
1857 be re-installed with the instance in permanent memory and all cached FvPpi pointers in
1858 PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent
1859 memory.
1860
1861 @param PrivateData Pointer to PEI_CORE_INSTANCE.
1862 **/
1863 VOID
1864 PeiReinitializeFv (
1865 IN PEI_CORE_INSTANCE *PrivateData
1866 );
1867
1868 #endif