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