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