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