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