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