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