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