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