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