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