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