]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg PeiCore: Improve comment semantics
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
1 /** @file
2 Definition of Pei Core Structures and Services
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _PEI_MAIN_H_
10 #define _PEI_MAIN_H_
11
12 #include <PiPei.h>
13 #include <Ppi/DxeIpl.h>
14 #include <Ppi/MemoryDiscovered.h>
15 #include <Ppi/StatusCode.h>
16 #include <Ppi/Reset.h>
17 #include <Ppi/Reset2.h>
18 #include <Ppi/FirmwareVolume.h>
19 #include <Ppi/FirmwareVolumeInfo.h>
20 #include <Ppi/FirmwareVolumeInfo2.h>
21 #include <Ppi/Decompress.h>
22 #include <Ppi/GuidedSectionExtraction.h>
23 #include <Ppi/LoadFile.h>
24 #include <Ppi/Security2.h>
25 #include <Ppi/TemporaryRamSupport.h>
26 #include <Ppi/TemporaryRamDone.h>
27 #include <Ppi/SecHobData.h>
28 #include <Ppi/PeiCoreFvLocation.h>
29 #include <Library/DebugLib.h>
30 #include <Library/PeiCoreEntryPoint.h>
31 #include <Library/BaseLib.h>
32 #include <Library/HobLib.h>
33 #include <Library/PerformanceLib.h>
34 #include <Library/PeiServicesLib.h>
35 #include <Library/ReportStatusCodeLib.h>
36 #include <Library/PeCoffLib.h>
37 #include <Library/PeCoffGetEntryPointLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/CacheMaintenanceLib.h>
40 #include <Library/PcdLib.h>
41 #include <IndustryStandard/PeImage.h>
42 #include <Library/PeiServicesTablePointerLib.h>
43 #include <Library/MemoryAllocationLib.h>
44 #include <Guid/FirmwareFileSystem2.h>
45 #include <Guid/FirmwareFileSystem3.h>
46 #include <Guid/AprioriFileName.h>
47
48 ///
49 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
50 /// FFS searching is for all PEIMs can be dispatched by PeiCore.
51 ///
52 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff
53
54 ///
55 /// Pei Core private data structures
56 ///
57 typedef union {
58 EFI_PEI_PPI_DESCRIPTOR *Ppi;
59 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
60 VOID *Raw;
61 } PEI_PPI_LIST_POINTERS;
62
63 ///
64 /// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of room
65 ///
66 #define PPI_GROWTH_STEP 64
67 #define CALLBACK_NOTIFY_GROWTH_STEP 32
68 #define DISPATCH_NOTIFY_GROWTH_STEP 8
69
70 typedef struct {
71 UINTN CurrentCount;
72 UINTN MaxCount;
73 UINTN LastDispatchedCount;
74 ///
75 /// MaxCount number of entries.
76 ///
77 PEI_PPI_LIST_POINTERS *PpiPtrs;
78 } PEI_PPI_LIST;
79
80 typedef struct {
81 UINTN CurrentCount;
82 UINTN MaxCount;
83 ///
84 /// MaxCount number of entries.
85 ///
86 PEI_PPI_LIST_POINTERS *NotifyPtrs;
87 } PEI_CALLBACK_NOTIFY_LIST;
88
89 typedef struct {
90 UINTN CurrentCount;
91 UINTN MaxCount;
92 UINTN LastDispatchedCount;
93 ///
94 /// MaxCount number of entries.
95 ///
96 PEI_PPI_LIST_POINTERS *NotifyPtrs;
97 } PEI_DISPATCH_NOTIFY_LIST;
98
99 ///
100 /// PPI database structure which contains three links:
101 /// PpiList, CallbackNotifyList and DispatchNotifyList.
102 ///
103 typedef struct {
104 ///
105 /// PPI List.
106 ///
107 PEI_PPI_LIST PpiList;
108 ///
109 /// Notify List at dispatch level.
110 ///
111 PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;
112 ///
113 /// Notify List at callback level.
114 ///
115 PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;
116 } PEI_PPI_DATABASE;
117
118 //
119 // PEI_CORE_FV_HANDLE.PeimState
120 // Do not change these values as there is code doing math to change states.
121 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;
122 //
123 #define PEIM_STATE_NOT_DISPATCHED 0x00
124 #define PEIM_STATE_DISPATCHED 0x01
125 #define PEIM_STATE_REGISTER_FOR_SHADOW 0x02
126 #define PEIM_STATE_DONE 0x03
127
128 //
129 // Number of FV instances to grow by each time we run out of room
130 //
131 #define FV_GROWTH_STEP 8
132
133 typedef struct {
134 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
135 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
136 EFI_PEI_FV_HANDLE FvHandle;
137 UINTN PeimCount;
138 //
139 // Pointer to the buffer with the PeimCount number of Entries.
140 //
141 UINT8 *PeimState;
142 //
143 // Pointer to the buffer with the PeimCount number of Entries.
144 //
145 EFI_PEI_FILE_HANDLE *FvFileHandles;
146 BOOLEAN ScanFv;
147 UINT32 AuthenticationStatus;
148 } PEI_CORE_FV_HANDLE;
149
150 typedef struct {
151 EFI_GUID FvFormat;
152 VOID *FvInfo;
153 UINT32 FvInfoSize;
154 UINT32 AuthenticationStatus;
155 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;
156 } PEI_CORE_UNKNOW_FORMAT_FV_INFO;
157
158 #define CACHE_SETION_MAX_NUMBER 0x10
159 typedef struct {
160 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];
161 VOID* SectionData[CACHE_SETION_MAX_NUMBER];
162 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];
163 UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER];
164 UINTN AllSectionCount;
165 UINTN SectionIndex;
166 } CACHE_SECTION_DATA;
167
168 #define HOLE_MAX_NUMBER 0x3
169 typedef struct {
170 EFI_PHYSICAL_ADDRESS Base;
171 UINTN Size;
172 UINTN Offset;
173 BOOLEAN OffsetPositive;
174 } HOLE_MEMORY_DATA;
175
176 ///
177 /// Forward declaration for PEI_CORE_INSTANCE
178 ///
179 typedef struct _PEI_CORE_INSTANCE PEI_CORE_INSTANCE;
180
181
182 /**
183 Function Pointer type for PeiCore function.
184 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
185 and location of temporary RAM, the stack location and the BFV location.
186 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
187 An empty PPI list consists of a single descriptor with the end-tag
188 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
189 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
190 that both the PEI Foundation and any modules can leverage the associated service
191 calls and/or code in these early PPIs
192 @param OldCoreData Pointer to old core data that is used to initialize the
193 core's data areas.
194 **/
195 typedef
196 EFI_STATUS
197 (EFIAPI *PEICORE_FUNCTION_POINTER)(
198 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
199 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
200 IN PEI_CORE_INSTANCE *OldCoreData
201 );
202
203 //
204 // Number of files to grow by each time we run out of room
205 //
206 #define TEMP_FILE_GROWTH_STEP 32
207
208 #define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')
209
210 ///
211 /// Pei Core private data structure instance
212 ///
213 struct _PEI_CORE_INSTANCE {
214 UINTN Signature;
215
216 ///
217 /// Point to ServiceTableShadow
218 ///
219 EFI_PEI_SERVICES *Ps;
220 PEI_PPI_DATABASE PpiData;
221
222 ///
223 /// The count of FVs which contains FFS and could be dispatched by PeiCore.
224 ///
225 UINTN FvCount;
226
227 ///
228 /// The max count of FVs which contains FFS and could be dispatched by PeiCore.
229 ///
230 UINTN MaxFvCount;
231
232 ///
233 /// Pointer to the buffer with the MaxFvCount number of entries.
234 /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.
235 ///
236 PEI_CORE_FV_HANDLE *Fv;
237
238 ///
239 /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.
240 /// Each entry is for one FV which could not be dispatched by PeiCore.
241 ///
242 PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;
243 UINTN MaxUnknownFvInfoCount;
244 UINTN UnknownFvInfoCount;
245
246 ///
247 /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.
248 ///
249 EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;
250 UINTN AprioriCount;
251 UINTN CurrentPeimFvCount;
252 UINTN CurrentPeimCount;
253 EFI_PEI_FILE_HANDLE CurrentFileHandle;
254 BOOLEAN PeimNeedingDispatch;
255 BOOLEAN PeimDispatchOnThisPass;
256 BOOLEAN PeimDispatcherReenter;
257 EFI_PEI_HOB_POINTERS HobList;
258 BOOLEAN SwitchStackSignal;
259 BOOLEAN PeiMemoryInstalled;
260 VOID *CpuIo;
261 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;
262 EFI_PEI_SERVICES ServiceTableShadow;
263 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;
264 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;
265 UINT64 PhysicalMemoryLength;
266 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;
267 UINTN HeapOffset;
268 BOOLEAN HeapOffsetPositive;
269 UINTN StackOffset;
270 BOOLEAN StackOffsetPositive;
271 //
272 // Information for migrating memory pages allocated in pre-memory phase.
273 //
274 HOLE_MEMORY_DATA MemoryPages;
275 PEICORE_FUNCTION_POINTER ShadowedPeiCore;
276 CACHE_SECTION_DATA CacheSection;
277 //
278 // For Loading modules at fixed address feature to cache the top address below which the
279 // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field
280 // and Ps should not be changed since maybe user could get this top address by using the offset to Ps.
281 //
282 EFI_PHYSICAL_ADDRESS LoadModuleAtFixAddressTopAddress;
283 //
284 // The field is define for Loading modules at fixed address feature to tracker the PEI code
285 // memory range usage. It is a bit mapped array in which every bit indicates the 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 popped from the evaluation
376 stack, the PPI is checked if it is installed. This method allows
377 some time savings as not all PPIs must be checked for certain
378 operation types (AND, OR).
379
380
381 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
382 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to
383 the BNF described above and is stored in postfix notation.
384
385 @retval TRUE if it is a well-formed Grammar
386 @retval FALSE if the dependency expression overflows the evaluation stack
387 if the dependency expression underflows the evaluation stack
388 if the dependency expression is not a well-formed Grammar.
389
390 **/
391 BOOLEAN
392 PeimDispatchReadiness (
393 IN EFI_PEI_SERVICES **PeiServices,
394 IN VOID *DependencyExpression
395 );
396
397 /**
398 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-permanent 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-permanent 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-permanent 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-permanent 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 Volume 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 FirmwareVolumeInfoPpiNotifyCallback (
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 enables a PEIM to register itself for shadow when the PEI Foundation
1221 discovers 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 Gets a PEI_CORE_FV_HANDLE instance for the next volume according to the given index.
1318
1319 This routine also will install an instance of the FvInfo PPI for the FV HOB
1320 as defined in the PI specification.
1321
1322 @param Private Pointer of PEI_CORE_INSTANCE
1323 @param Instance Index of the FV to search
1324
1325 @return Instance of PEI_CORE_FV_HANDLE.
1326 **/
1327 PEI_CORE_FV_HANDLE *
1328 FindNextCoreFvHandle (
1329 IN PEI_CORE_INSTANCE *Private,
1330 IN UINTN Instance
1331 );
1332
1333 //
1334 // Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1335 //
1336
1337 /**
1338 Memory-based read services.
1339
1340 This function is to perform the Memory Access Read service based on installed
1341 instance of the EFI_PEI_CPU_IO_PPI.
1342 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1343 return EFI_NOT_YET_AVAILABLE.
1344
1345 @param PeiServices An indirect pointer to the PEI Services Table
1346 published by the PEI Foundation.
1347 @param This Pointer to local data for the interface.
1348 @param Width The width of the access. Enumerated in bytes.
1349 @param Address The physical address of the access.
1350 @param Count The number of accesses to perform.
1351 @param Buffer A pointer to the buffer of data.
1352
1353 @retval EFI_SUCCESS The function completed successfully.
1354 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1355 **/
1356 EFI_STATUS
1357 EFIAPI
1358 PeiDefaultMemRead (
1359 IN CONST EFI_PEI_SERVICES **PeiServices,
1360 IN CONST EFI_PEI_CPU_IO_PPI *This,
1361 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1362 IN UINT64 Address,
1363 IN UINTN Count,
1364 IN OUT VOID *Buffer
1365 );
1366
1367 /**
1368 Memory-based write services.
1369
1370 This function is to perform the Memory Access Write service based on installed
1371 instance of the EFI_PEI_CPU_IO_PPI.
1372 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1373 return EFI_NOT_YET_AVAILABLE.
1374
1375 @param PeiServices An indirect pointer to the PEI Services Table
1376 published by the PEI Foundation.
1377 @param This Pointer to local data for the interface.
1378 @param Width The width of the access. Enumerated in bytes.
1379 @param Address The physical address of the access.
1380 @param Count The number of accesses to perform.
1381 @param Buffer A pointer to the buffer of data.
1382
1383 @retval EFI_SUCCESS The function completed successfully.
1384 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1385 **/
1386 EFI_STATUS
1387 EFIAPI
1388 PeiDefaultMemWrite (
1389 IN CONST EFI_PEI_SERVICES **PeiServices,
1390 IN CONST EFI_PEI_CPU_IO_PPI *This,
1391 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1392 IN UINT64 Address,
1393 IN UINTN Count,
1394 IN OUT VOID *Buffer
1395 );
1396
1397 /**
1398 IO-based read services.
1399
1400 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.
1401 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1402 return EFI_NOT_YET_AVAILABLE.
1403
1404 @param PeiServices An indirect pointer to the PEI Services Table
1405 published by the PEI Foundation.
1406 @param This Pointer to local data for the interface.
1407 @param Width The width of the access. Enumerated in bytes.
1408 @param Address The physical address of the access.
1409 @param Count The number of accesses to perform.
1410 @param Buffer A pointer to the buffer of data.
1411
1412 @retval EFI_SUCCESS The function completed successfully.
1413 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1414 **/
1415 EFI_STATUS
1416 EFIAPI
1417 PeiDefaultIoRead (
1418 IN CONST EFI_PEI_SERVICES **PeiServices,
1419 IN CONST EFI_PEI_CPU_IO_PPI *This,
1420 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1421 IN UINT64 Address,
1422 IN UINTN Count,
1423 IN OUT VOID *Buffer
1424 );
1425
1426 /**
1427 IO-based write services.
1428
1429 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.
1430 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1431 return EFI_NOT_YET_AVAILABLE.
1432
1433 @param PeiServices An indirect pointer to the PEI Services Table
1434 published by the PEI Foundation.
1435 @param This Pointer to local data for the interface.
1436 @param Width The width of the access. Enumerated in bytes.
1437 @param Address The physical address of the access.
1438 @param Count The number of accesses to perform.
1439 @param Buffer A pointer to the buffer of data.
1440
1441 @retval EFI_SUCCESS The function completed successfully.
1442 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
1443 **/
1444 EFI_STATUS
1445 EFIAPI
1446 PeiDefaultIoWrite (
1447 IN CONST EFI_PEI_SERVICES **PeiServices,
1448 IN CONST EFI_PEI_CPU_IO_PPI *This,
1449 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
1450 IN UINT64 Address,
1451 IN UINTN Count,
1452 IN OUT VOID *Buffer
1453 );
1454
1455 /**
1456 8-bit I/O read operations.
1457
1458 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1459 return 0.
1460
1461 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1462 @param This Pointer to local data for the interface.
1463 @param Address The physical address of the access.
1464
1465 @return An 8-bit value returned from the I/O space.
1466 **/
1467 UINT8
1468 EFIAPI
1469 PeiDefaultIoRead8 (
1470 IN CONST EFI_PEI_SERVICES **PeiServices,
1471 IN CONST EFI_PEI_CPU_IO_PPI *This,
1472 IN UINT64 Address
1473 );
1474
1475 /**
1476 Reads an 16-bit I/O port.
1477
1478 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1479 return 0.
1480
1481 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1482 @param This Pointer to local data for the interface.
1483 @param Address The physical address of the access.
1484
1485 @return A 16-bit value returned from the I/O space.
1486 **/
1487 UINT16
1488 EFIAPI
1489 PeiDefaultIoRead16 (
1490 IN CONST EFI_PEI_SERVICES **PeiServices,
1491 IN CONST EFI_PEI_CPU_IO_PPI *This,
1492 IN UINT64 Address
1493 );
1494
1495 /**
1496 Reads an 32-bit I/O port.
1497
1498 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1499 return 0.
1500
1501 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1502 @param This Pointer to local data for the interface.
1503 @param Address The physical address of the access.
1504
1505 @return A 32-bit value returned from the I/O space.
1506 **/
1507 UINT32
1508 EFIAPI
1509 PeiDefaultIoRead32 (
1510 IN CONST EFI_PEI_SERVICES **PeiServices,
1511 IN CONST EFI_PEI_CPU_IO_PPI *This,
1512 IN UINT64 Address
1513 );
1514
1515 /**
1516 Reads an 64-bit I/O port.
1517
1518 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1519 return 0.
1520
1521 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1522 @param This Pointer to local data for the interface.
1523 @param Address The physical address of the access.
1524
1525 @return A 64-bit value returned from the I/O space.
1526 **/
1527 UINT64
1528 EFIAPI
1529 PeiDefaultIoRead64 (
1530 IN CONST EFI_PEI_SERVICES **PeiServices,
1531 IN CONST EFI_PEI_CPU_IO_PPI *This,
1532 IN UINT64 Address
1533 );
1534
1535 /**
1536 8-bit I/O write operations.
1537
1538 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1539 @param This Pointer to local data for the interface.
1540 @param Address The physical address of the access.
1541 @param Data The data to write.
1542 **/
1543 VOID
1544 EFIAPI
1545 PeiDefaultIoWrite8 (
1546 IN CONST EFI_PEI_SERVICES **PeiServices,
1547 IN CONST EFI_PEI_CPU_IO_PPI *This,
1548 IN UINT64 Address,
1549 IN UINT8 Data
1550 );
1551
1552 /**
1553 16-bit I/O write operations.
1554
1555 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1556 @param This Pointer to local data for the interface.
1557 @param Address The physical address of the access.
1558 @param Data The data to write.
1559 **/
1560 VOID
1561 EFIAPI
1562 PeiDefaultIoWrite16 (
1563 IN CONST EFI_PEI_SERVICES **PeiServices,
1564 IN CONST EFI_PEI_CPU_IO_PPI *This,
1565 IN UINT64 Address,
1566 IN UINT16 Data
1567 );
1568
1569 /**
1570 32-bit I/O write operations.
1571
1572 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1573 @param This Pointer to local data for the interface.
1574 @param Address The physical address of the access.
1575 @param Data The data to write.
1576 **/
1577 VOID
1578 EFIAPI
1579 PeiDefaultIoWrite32 (
1580 IN CONST EFI_PEI_SERVICES **PeiServices,
1581 IN CONST EFI_PEI_CPU_IO_PPI *This,
1582 IN UINT64 Address,
1583 IN UINT32 Data
1584 );
1585
1586 /**
1587 64-bit I/O write operations.
1588
1589 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1590 @param This Pointer to local data for the interface.
1591 @param Address The physical address of the access.
1592 @param Data The data to write.
1593 **/
1594 VOID
1595 EFIAPI
1596 PeiDefaultIoWrite64 (
1597 IN CONST EFI_PEI_SERVICES **PeiServices,
1598 IN CONST EFI_PEI_CPU_IO_PPI *This,
1599 IN UINT64 Address,
1600 IN UINT64 Data
1601 );
1602
1603 /**
1604 8-bit memory read operations.
1605
1606 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1607 return 0.
1608
1609 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1610 @param This Pointer to local data for the interface.
1611 @param Address The physical address of the access.
1612
1613 @return An 8-bit value returned from the memory space.
1614
1615 **/
1616 UINT8
1617 EFIAPI
1618 PeiDefaultMemRead8 (
1619 IN CONST EFI_PEI_SERVICES **PeiServices,
1620 IN CONST EFI_PEI_CPU_IO_PPI *This,
1621 IN UINT64 Address
1622 );
1623
1624 /**
1625 16-bit memory read operations.
1626
1627 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1628 return 0.
1629
1630 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1631 @param This Pointer to local data for the interface.
1632 @param Address The physical address of the access.
1633
1634 @return An 16-bit value returned from the memory space.
1635
1636 **/
1637 UINT16
1638 EFIAPI
1639 PeiDefaultMemRead16 (
1640 IN CONST EFI_PEI_SERVICES **PeiServices,
1641 IN CONST EFI_PEI_CPU_IO_PPI *This,
1642 IN UINT64 Address
1643 );
1644
1645 /**
1646 32-bit memory read operations.
1647
1648 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1649 return 0.
1650
1651 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1652 @param This Pointer to local data for the interface.
1653 @param Address The physical address of the access.
1654
1655 @return An 32-bit value returned from the memory space.
1656
1657 **/
1658 UINT32
1659 EFIAPI
1660 PeiDefaultMemRead32 (
1661 IN CONST EFI_PEI_SERVICES **PeiServices,
1662 IN CONST EFI_PEI_CPU_IO_PPI *This,
1663 IN UINT64 Address
1664 );
1665
1666 /**
1667 64-bit memory read operations.
1668
1669 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
1670 return 0.
1671
1672 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1673 @param This Pointer to local data for the interface.
1674 @param Address The physical address of the access.
1675
1676 @return An 64-bit value returned from the memory space.
1677
1678 **/
1679 UINT64
1680 EFIAPI
1681 PeiDefaultMemRead64 (
1682 IN CONST EFI_PEI_SERVICES **PeiServices,
1683 IN CONST EFI_PEI_CPU_IO_PPI *This,
1684 IN UINT64 Address
1685 );
1686
1687 /**
1688 8-bit memory write operations.
1689
1690 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1691 @param This Pointer to local data for the interface.
1692 @param Address The physical address of the access.
1693 @param Data The data to write.
1694
1695 **/
1696 VOID
1697 EFIAPI
1698 PeiDefaultMemWrite8 (
1699 IN CONST EFI_PEI_SERVICES **PeiServices,
1700 IN CONST EFI_PEI_CPU_IO_PPI *This,
1701 IN UINT64 Address,
1702 IN UINT8 Data
1703 );
1704
1705 /**
1706 16-bit memory write operations.
1707
1708 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1709 @param This Pointer to local data for the interface.
1710 @param Address The physical address of the access.
1711 @param Data The data to write.
1712
1713 **/
1714 VOID
1715 EFIAPI
1716 PeiDefaultMemWrite16 (
1717 IN CONST EFI_PEI_SERVICES **PeiServices,
1718 IN CONST EFI_PEI_CPU_IO_PPI *This,
1719 IN UINT64 Address,
1720 IN UINT16 Data
1721 );
1722
1723 /**
1724 32-bit memory write operations.
1725
1726 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1727 @param This Pointer to local data for the interface.
1728 @param Address The physical address of the access.
1729 @param Data The data to write.
1730
1731 **/
1732 VOID
1733 EFIAPI
1734 PeiDefaultMemWrite32 (
1735 IN CONST EFI_PEI_SERVICES **PeiServices,
1736 IN CONST EFI_PEI_CPU_IO_PPI *This,
1737 IN UINT64 Address,
1738 IN UINT32 Data
1739 );
1740
1741 /**
1742 64-bit memory write operations.
1743
1744 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1745 @param This Pointer to local data for the interface.
1746 @param Address The physical address of the access.
1747 @param Data The data to write.
1748
1749 **/
1750 VOID
1751 EFIAPI
1752 PeiDefaultMemWrite64 (
1753 IN CONST EFI_PEI_SERVICES **PeiServices,
1754 IN CONST EFI_PEI_CPU_IO_PPI *This,
1755 IN UINT64 Address,
1756 IN UINT64 Data
1757 );
1758
1759 extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;
1760
1761 //
1762 // Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.
1763 //
1764
1765 /**
1766 Reads from a given location in the PCI configuration space.
1767
1768 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1769 return EFI_NOT_YET_AVAILABLE.
1770
1771 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1772 @param This Pointer to local data for the interface.
1773 @param Width The width of the access. Enumerated in bytes.
1774 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1775 @param Address The physical address of the access. The format of
1776 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1777 @param Buffer A pointer to the buffer of data.
1778
1779 @retval EFI_SUCCESS The function completed successfully.
1780 @retval EFI_INVALID_PARAMETER The invalid access width.
1781 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1782
1783 **/
1784 EFI_STATUS
1785 EFIAPI
1786 PeiDefaultPciCfg2Read (
1787 IN CONST EFI_PEI_SERVICES **PeiServices,
1788 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1789 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1790 IN UINT64 Address,
1791 IN OUT VOID *Buffer
1792 );
1793
1794 /**
1795 Write to a given location in the PCI configuration space.
1796
1797 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then
1798 return EFI_NOT_YET_AVAILABLE.
1799
1800 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
1801 @param This Pointer to local data for the interface.
1802 @param Width The width of the access. Enumerated in bytes.
1803 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
1804 @param Address The physical address of the access. The format of
1805 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
1806 @param Buffer A pointer to the buffer of data.
1807
1808 @retval EFI_SUCCESS The function completed successfully.
1809 @retval EFI_INVALID_PARAMETER The invalid access width.
1810 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1811 **/
1812 EFI_STATUS
1813 EFIAPI
1814 PeiDefaultPciCfg2Write (
1815 IN CONST EFI_PEI_SERVICES **PeiServices,
1816 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1817 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1818 IN UINT64 Address,
1819 IN OUT VOID *Buffer
1820 );
1821
1822 /**
1823 This function performs a read-modify-write operation on the contents from a given
1824 location in the PCI configuration space.
1825
1826 @param PeiServices An indirect pointer to the PEI Services Table
1827 published by the PEI Foundation.
1828 @param This Pointer to local data for the interface.
1829 @param Width The width of the access. Enumerated in bytes. Type
1830 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
1831 @param Address The physical address of the access.
1832 @param SetBits Points to value to bitwise-OR with the read configuration value.
1833 The size of the value is determined by Width.
1834 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
1835 The size of the value is determined by Width.
1836
1837 @retval EFI_SUCCESS The function completed successfully.
1838 @retval EFI_INVALID_PARAMETER The invalid access width.
1839 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.
1840 **/
1841 EFI_STATUS
1842 EFIAPI
1843 PeiDefaultPciCfg2Modify (
1844 IN CONST EFI_PEI_SERVICES **PeiServices,
1845 IN CONST EFI_PEI_PCI_CFG2_PPI *This,
1846 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
1847 IN UINT64 Address,
1848 IN VOID *SetBits,
1849 IN VOID *ClearBits
1850 );
1851
1852 extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;
1853
1854 /**
1855 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should
1856 be re-installed with the instance in permanent memory and all cached FvPpi pointers in
1857 PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent
1858 memory.
1859
1860 @param PrivateData Pointer to PEI_CORE_INSTANCE.
1861 **/
1862 VOID
1863 PeiReinitializeFv (
1864 IN PEI_CORE_INSTANCE *PrivateData
1865 );
1866
1867 #endif