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