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