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