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