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