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