]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
Enable PeiCore to dispatch the encapsulated fv images with depex expression. This...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PeiMain.h
15
16 Abstract:
17
18 Definition of Pei Core Structures and Services
19
20 Revision History
21
22 --*/
23
24 #ifndef _PEI_MAIN_H_
25 #define _PEI_MAIN_H_
26
27 #include <PiPei.h>
28 #include <FrameworkPei.h>
29 #include <Guid/StatusCodeDataTypeId.h>
30 #include <Ppi/DxeIpl.h>
31 #include <Ppi/MemoryDiscovered.h>
32 #include <Ppi/StatusCode.h>
33 #include <Ppi/Reset.h>
34 #include <Ppi/FirmwareVolume.h>
35 #include <Ppi/FirmwareVolumeInfo.h>
36 #include <Ppi/Decompress.h>
37 #include <Ppi/GuidedSectionExtraction.h>
38 #include <Ppi/LoadFile.h>
39 #include <Ppi/Security2.h>
40 #include <Library/DebugLib.h>
41 #include <Library/PeiCoreEntryPoint.h>
42 #include <Library/BaseLib.h>
43 #include <Library/HobLib.h>
44 #include <Library/PerformanceLib.h>
45 #include <Library/PeiServicesLib.h>
46 #include <Library/ReportStatusCodeLib.h>
47 #include <Library/PeCoffLib.h>
48 #include <Library/PeCoffGetEntryPointLib.h>
49 #include <Library/BaseMemoryLib.h>
50 #include <Library/CacheMaintenanceLib.h>
51 #include <Library/TimerLib.h>
52 #include <Library/PcdLib.h>
53 #include <IndustryStandard/PeImage.h>
54 #include <Library/PeiServicesTablePointerLib.h>
55 #include <Library/MemoryAllocationLib.h>
56 #include <Library/PeiPiLib.h>
57 #include <Guid/FirmwareFileSystem2.h>
58 #include <Guid/AprioriFileName.h>
59
60 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff
61
62 //
63 // Pei Core private data structures
64 //
65 typedef union {
66 EFI_PEI_PPI_DESCRIPTOR *Ppi;
67 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
68 VOID *Raw;
69 } PEI_PPI_LIST_POINTERS;
70
71 #define PEI_STACK_SIZE 0x20000
72
73 #define MAX_PPI_DESCRIPTORS 64
74
75 typedef struct {
76 INTN PpiListEnd;
77 INTN NotifyListEnd;
78 INTN DispatchListEnd;
79 INTN LastDispatchedInstall;
80 INTN LastDispatchedNotify;
81 PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];
82 } PEI_PPI_DATABASE;
83
84
85 //
86 // PEI_CORE_FV_HANDE.PeimState
87 // Do not change these values as there is code doing math to change states.
88 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;
89 //
90 #define PEIM_STATE_NOT_DISPATCHED 0x00
91 #define PEIM_STATE_DISPATCHED 0x01
92 #define PEIM_STATE_REGISITER_FOR_SHADOW 0x02
93 #define PEIM_STATE_DONE 0x03
94
95 typedef struct {
96 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
97 UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
98 EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
99 BOOLEAN ScanFv;
100 } PEI_CORE_FV_HANDLE;
101
102 #define CACHE_SETION_MAX_NUMBER 0x10
103 typedef struct {
104 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];
105 VOID* SectionData[CACHE_SETION_MAX_NUMBER];
106 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];
107 UINTN AllSectionCount;
108 UINTN SectionIndex;
109 } CACHE_SECTION_DATA;
110
111 //
112 // Pei Core private data structure instance
113 //
114
115 #define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
116
117 typedef struct{
118 UINTN Signature;
119 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
120 PEI_PPI_DATABASE PpiData;
121 UINTN FvCount;
122 PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
123 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
124 UINTN AprioriCount;
125 UINTN CurrentPeimFvCount;
126 UINTN CurrentPeimCount;
127 EFI_PEI_FILE_HANDLE CurrentFileHandle;
128 UINTN AllFvCount;
129 EFI_PEI_FV_HANDLE AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
130 EFI_PEI_HOB_POINTERS HobList;
131 BOOLEAN SwitchStackSignal;
132 BOOLEAN PeiMemoryInstalled;
133 EFI_PHYSICAL_ADDRESS StackBase;
134 UINT64 StackSize;
135 VOID *BottomOfCarHeap;
136 VOID *TopOfCarHeap;
137 VOID *CpuIo;
138 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;
139 EFI_PEI_SERVICES ServiceTableShadow;
140 UINTN SizeOfCacheAsRam;
141 VOID *MaxTopOfCarHeap;
142 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;
143 CACHE_SECTION_DATA CacheSection;
144 } PEI_CORE_INSTANCE;
145
146 //
147 // Pei Core Instance Data Macros
148 //
149
150 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
151 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
152
153 //
154 // BUGBUG: Where does this go really?
155 //
156 typedef
157 EFI_STATUS
158 (EFIAPI *PEI_CORE_ENTRY_POINT)(
159 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
160 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
161 IN PEI_CORE_INSTANCE *OldCoreData
162 );
163
164 //
165 // Union of temporarily used function pointers (to save stack space)
166 //
167 typedef union {
168 PEI_CORE_ENTRY_POINT PeiCore;
169 EFI_PEIM_ENTRY_POINT2 PeimEntry;
170 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;
171 EFI_DXE_IPL_PPI *DxeIpl;
172 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
173 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
174 VOID *Raw;
175 } PEI_CORE_TEMP_POINTERS;
176
177
178
179 typedef struct {
180 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;
181 EFI_PEI_PPI_DESCRIPTOR *PpiList;
182 VOID *Data;
183 } PEI_CORE_PARAMETERS;
184
185 //
186 // PeiCore function
187 //
188 EFI_STATUS
189 EFIAPI
190 PeiCore (
191 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
192 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,
193 IN VOID *Data
194 )
195 /*++
196
197 Routine Description:
198
199 The entry routine to Pei Core, invoked by PeiMain during transition
200 from SEC to PEI. After switching stack in the PEI core, it will restart
201 with the old core data.
202
203 Arguments:
204
205 PeiStartupDescriptor - Information and services provided by SEC phase.
206 OldCoreData - Pointer to old core data that is used to initialize the
207 core's data areas.
208
209 Returns:
210
211 This function never returns
212 EFI_NOT_FOUND - Never reach
213
214 --*/
215 ;
216
217 //
218 // Dispatcher support functions
219 //
220
221 BOOLEAN
222 PeimDispatchReadiness (
223 IN EFI_PEI_SERVICES **PeiServices,
224 IN VOID *DependencyExpression
225 )
226 /*++
227
228 Routine Description:
229
230 This is the POSTFIX version of the dependency evaluator. When a
231 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
232 the evaluation stack. When that entry is poped from the evaluation
233 stack, the PPI is checked if it is installed. This method allows
234 some time savings as not all PPIs must be checked for certain
235 operation types (AND, OR).
236
237 Arguments:
238
239 PeiServices - Calling context.
240
241 DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
242 the BNF described above and is stored in postfix notation.
243
244 Returns:
245
246 Status = EFI_SUCCESS if it is a well-formed Grammar
247 EFI_INVALID_PARAMETER if the dependency expression overflows
248 the evaluation stack
249 EFI_INVALID_PARAMETER if the dependency expression underflows
250 the evaluation stack
251 EFI_INVALID_PARAMETER if the dependency expression is not a
252 well-formed Grammar.
253 --*/
254 ;
255
256
257 VOID
258 PeiDispatcher (
259 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
260 IN PEI_CORE_INSTANCE *PrivateData
261 )
262
263 /*++
264
265 Routine Description:
266
267 Conduct PEIM dispatch.
268
269 Arguments:
270
271 PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
272 PrivateData - Pointer to the private data passed in from caller
273 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
274
275 Returns:
276
277 EFI_SUCCESS - Successfully dispatched PEIM.
278 EFI_NOT_FOUND - The dispatch failed.
279
280 --*/
281 ;
282
283
284 VOID
285 InitializeDispatcherData (
286 IN PEI_CORE_INSTANCE *PrivateData,
287 IN PEI_CORE_INSTANCE *OldCoreData,
288 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
289 )
290 /*++
291
292 Routine Description:
293
294 Initialize the Dispatcher's data members
295
296 Arguments:
297
298 PeiServices - The PEI core services table.
299 OldCoreData - Pointer to old core data (before switching stack).
300 NULL if being run in non-permament memory mode.
301 PeiStartupDescriptor - Information and services provided by SEC phase.
302
303
304 Returns:
305
306 None
307
308 --*/
309 ;
310
311
312 BOOLEAN
313 Dispatched (
314 IN UINT8 CurrentPeim,
315 IN UINT32 DispatchedPeimBitMap
316 )
317 /*++
318
319 Routine Description:
320
321 This routine checks to see if a particular PEIM has been dispatched during
322 the PEI core dispatch.
323
324 Arguments:
325 CurrentPeim - The PEIM/FV in the bit array to check.
326 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
327
328 Returns:
329 TRUE if PEIM already dispatched
330 FALSE if not
331
332 --*/
333 ;
334
335 VOID
336 SetDispatched (
337 IN EFI_PEI_SERVICES **PeiServices,
338 IN UINT8 CurrentPeim,
339 OUT UINT32 *DispatchedPeimBitMap
340 )
341 /*++
342
343 Routine Description:
344
345 This routine sets a PEIM as having been dispatched once its entry
346 point has been invoked.
347
348 Arguments:
349
350 PeiServices - The PEI core services table.
351 CurrentPeim - The PEIM/FV in the bit array to check.
352 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
353
354 Returns:
355 None
356
357 --*/
358 ;
359
360 BOOLEAN
361 DepexSatisfied (
362 IN PEI_CORE_INSTANCE *Private,
363 IN EFI_PEI_FILE_HANDLE FileHandle,
364 IN UINTN PeimCount
365 )
366 /*++
367
368 Routine Description:
369
370 This routine parses the Dependency Expression, if available, and
371 decides if the module can be executed.
372
373 Arguments:
374 PeiServices - The PEI Service Table
375 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
376
377 Returns:
378 TRUE - Can be dispatched
379 FALSE - Cannot be dispatched
380
381 --*/
382 ;
383
384 #if defined (MDE_CPU_IPF)
385 //
386 // In Ipf we should make special changes for the PHIT pointers to support
387 // recovery boot in cache mode.
388 //
389 #define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)
390 #define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL
391 VOID
392 SwitchToCacheMode (
393 IN PEI_CORE_INSTANCE *CoreData
394 )
395 /*++
396
397 Routine Description:
398
399 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
400
401 Arguments:
402
403 CoreData - The PEI core Private Data
404
405 Returns:
406
407 --*/
408 ;
409
410 #else
411
412 #define SWITCH_TO_CACHE_MODE(CoreData)
413
414 #endif
415
416 //
417 // PPI support functions
418 //
419 VOID
420 InitializePpiServices (
421 IN PEI_CORE_INSTANCE *PrivateData,
422 IN PEI_CORE_INSTANCE *OldCoreData
423 )
424 /*++
425
426 Routine Description:
427
428 Initialize PPI services.
429
430 Arguments:
431
432 PeiServices - The PEI core services table.
433 OldCoreData - Pointer to the PEI Core data.
434 NULL if being run in non-permament memory mode.
435
436 Returns:
437 Nothing
438
439 --*/
440 ;
441
442 VOID
443 ConvertPpiPointers (
444 IN CONST EFI_PEI_SERVICES **PeiServices,
445 IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
446 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
447 )
448 /*++
449
450 Routine Description:
451
452 Migrate the Hob list from the CAR stack to PEI installed memory.
453
454 Arguments:
455
456 PeiServices - The PEI core services table.
457 OldHandOffHob - The old handoff HOB list.
458 NewHandOffHob - The new handoff HOB list.
459
460 Returns:
461
462 --*/
463 ;
464
465 EFI_STATUS
466 EFIAPI
467 PeiInstallPpi (
468 IN CONST EFI_PEI_SERVICES **PeiServices,
469 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
470 )
471 /*++
472
473 Routine Description:
474
475 Install PPI services.
476
477 Arguments:
478
479 PeiServices - Pointer to the PEI Service Table
480 PpiList - Pointer to a list of PEI PPI Descriptors.
481
482 Returns:
483
484 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
485 EFI_INVALID_PARAMETER - if PpiList is NULL pointer
486 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
487 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
488
489 --*/
490 ;
491
492 EFI_STATUS
493 EFIAPI
494 PeiReInstallPpi (
495 IN CONST EFI_PEI_SERVICES **PeiServices,
496 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
497 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
498 )
499 /*++
500
501 Routine Description:
502
503 Re-Install PPI services.
504
505 Arguments:
506
507 PeiServices - Pointer to the PEI Service Table
508 OldPpi - Pointer to the old PEI PPI Descriptors.
509 NewPpi - Pointer to the new PEI PPI Descriptors.
510
511 Returns:
512
513 EFI_SUCCESS - if the operation was successful
514 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
515 EFI_INVALID_PARAMETER - if NewPpi is not valid
516 EFI_NOT_FOUND - if the PPI was not in the database
517
518 --*/
519 ;
520
521 EFI_STATUS
522 EFIAPI
523 PeiLocatePpi (
524 IN CONST EFI_PEI_SERVICES **PeiServices,
525 IN CONST EFI_GUID *Guid,
526 IN UINTN Instance,
527 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
528 IN OUT VOID **Ppi
529 )
530 /*++
531
532 Routine Description:
533
534 Locate a given named PPI.
535
536 Arguments:
537
538 PeiServices - Pointer to the PEI Service Table
539 Guid - Pointer to GUID of the PPI.
540 Instance - Instance Number to discover.
541 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
542 returns a pointer to the descriptor (includes flags, etc)
543 Ppi - Pointer to reference the found PPI
544
545 Returns:
546
547 Status - EFI_SUCCESS if the PPI is in the database
548 EFI_NOT_FOUND if the PPI is not in the database
549 --*/
550 ;
551
552 EFI_STATUS
553 EFIAPI
554 PeiNotifyPpi (
555 IN CONST EFI_PEI_SERVICES **PeiServices,
556 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
557 )
558 /*++
559
560 Routine Description:
561
562 Install a notification for a given PPI.
563
564 Arguments:
565
566 PeiServices - Pointer to the PEI Service Table
567 NotifyList - Pointer to list of Descriptors to notify upon.
568
569 Returns:
570
571 Status - EFI_SUCCESS if successful
572 EFI_OUT_OF_RESOURCES if no space in the database
573 EFI_INVALID_PARAMETER if not a good decriptor
574
575 --*/
576 ;
577
578 VOID
579 ProcessNotifyList (
580 IN PEI_CORE_INSTANCE *PrivateData
581 )
582 /*++
583
584 Routine Description:
585
586 Process the Notify List at dispatch level.
587
588 Arguments:
589
590 PeiServices - Pointer to the PEI Service Table
591
592 Returns:
593
594 --*/
595 ;
596
597 VOID
598 DispatchNotify (
599 IN PEI_CORE_INSTANCE *PrivateData,
600 IN UINTN NotifyType,
601 IN INTN InstallStartIndex,
602 IN INTN InstallStopIndex,
603 IN INTN NotifyStartIndex,
604 IN INTN NotifyStopIndex
605 )
606 /*++
607
608 Routine Description:
609
610 Dispatch notifications.
611
612 Arguments:
613
614 PeiServices - Pointer to the PEI Service Table
615 NotifyType - Type of notify to fire.
616 InstallStartIndex - Install Beginning index.
617 InstallStopIndex - Install Ending index.
618 NotifyStartIndex - Notify Beginning index.
619 NotifyStopIndex - Notify Ending index.
620
621 Returns: None
622
623 --*/
624 ;
625
626 //
627 // Boot mode support functions
628 //
629 EFI_STATUS
630 EFIAPI
631 PeiGetBootMode (
632 IN CONST EFI_PEI_SERVICES **PeiServices,
633 IN OUT EFI_BOOT_MODE *BootMode
634 )
635 /*++
636
637 Routine Description:
638
639 This service enables PEIMs to ascertain the present value of the boot mode.
640
641 Arguments:
642
643 PeiServices - The PEI core services table.
644 BootMode - A pointer to contain the value of the boot mode.
645
646 Returns:
647
648 EFI_SUCCESS - The boot mode was returned successfully.
649 EFI_INVALID_PARAMETER - BootMode is NULL.
650
651 --*/
652 ;
653
654 EFI_STATUS
655 EFIAPI
656 PeiSetBootMode (
657 IN CONST EFI_PEI_SERVICES **PeiServices,
658 IN EFI_BOOT_MODE BootMode
659 )
660 /*++
661
662 Routine Description:
663
664 This service enables PEIMs to update the boot mode variable.
665
666 Arguments:
667
668 PeiServices - The PEI core services table.
669 BootMode - The value of the boot mode to set.
670
671 Returns:
672
673 EFI_SUCCESS - The value was successfully updated
674
675 --*/
676 ;
677
678 //
679 // Security support functions
680 //
681 VOID
682 InitializeSecurityServices (
683 IN EFI_PEI_SERVICES **PeiServices,
684 IN PEI_CORE_INSTANCE *OldCoreData
685 )
686 /*++
687
688 Routine Description:
689
690 Initialize the security services.
691
692 Arguments:
693
694 PeiServices - The PEI core services table.
695 OldCoreData - Pointer to the old core data.
696 NULL if being run in non-permament memory mode.
697 Returns:
698
699 None
700
701 --*/
702 ;
703
704 EFI_STATUS
705 VerifyFv (
706 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
707 )
708 /*++
709
710 Routine Description:
711
712 Provide a callout to the OEM FV verification service.
713
714 Arguments:
715
716 CurrentFvAddress - Pointer to the FV under investigation.
717
718 Returns:
719
720 Status - EFI_SUCCESS
721
722 --*/
723 ;
724
725
726 EFI_STATUS
727 VerifyPeim (
728 IN PEI_CORE_INSTANCE *PrivateData,
729 IN EFI_PEI_FV_HANDLE VolumeHandle,
730 IN EFI_PEI_FILE_HANDLE FileHandle
731 )
732 /*++
733
734 Routine Description:
735
736 Provide a callout to the security verification service.
737
738 Arguments:
739
740 PeiServices - The PEI core services table.
741 CurrentPeimAddress - Pointer to the Firmware File under investigation.
742
743 Returns:
744
745 EFI_SUCCESS - Image is OK
746 EFI_SECURITY_VIOLATION - Image is illegal
747
748 --*/
749 ;
750
751
752 EFI_STATUS
753 EFIAPI
754 PeiGetHobList (
755 IN CONST EFI_PEI_SERVICES **PeiServices,
756 IN OUT VOID **HobList
757 )
758 /*++
759
760 Routine Description:
761
762 Gets the pointer to the HOB List.
763
764 Arguments:
765
766 PeiServices - The PEI core services table.
767 HobList - Pointer to the HOB List.
768
769 Returns:
770
771 EFI_SUCCESS - Get the pointer of HOB List
772 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
773 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
774
775 --*/
776 ;
777
778 EFI_STATUS
779 EFIAPI
780 PeiCreateHob (
781 IN CONST EFI_PEI_SERVICES **PeiServices,
782 IN UINT16 Type,
783 IN UINT16 Length,
784 IN OUT VOID **Hob
785 )
786 /*++
787
788 Routine Description:
789
790 Add a new HOB to the HOB List.
791
792 Arguments:
793
794 PeiServices - The PEI core services table.
795 Type - Type of the new HOB.
796 Length - Length of the new HOB to allocate.
797 Hob - Pointer to the new HOB.
798
799 Returns:
800
801 Status - EFI_SUCCESS
802 - EFI_INVALID_PARAMETER if Hob is NULL
803 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
804 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
805
806 --*/
807 ;
808
809 EFI_STATUS
810 PeiCoreBuildHobHandoffInfoTable (
811 IN EFI_BOOT_MODE BootMode,
812 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
813 IN UINT64 MemoryLength
814 )
815 /*++
816
817 Routine Description:
818
819 Builds a Handoff Information Table HOB
820
821 Arguments:
822
823 BootMode - Current Bootmode
824 MemoryBegin - Start Memory Address.
825 MemoryLength - Length of Memory.
826
827 Returns:
828
829 EFI_SUCCESS
830
831 --*/
832 ;
833
834
835 //
836 // FFS Fw Volume support functions
837 //
838 EFI_STATUS
839 EFIAPI
840 PeiFfsFindNextFile (
841 IN CONST EFI_PEI_SERVICES **PeiServices,
842 IN UINT8 SearchType,
843 IN EFI_PEI_FV_HANDLE FwVolHeader,
844 IN OUT EFI_PEI_FILE_HANDLE *FileHeader
845 )
846 /*++
847
848 Routine Description:
849 Given the input file pointer, search for the next matching file in the
850 FFS volume as defined by SearchType. The search starts from FileHeader inside
851 the Firmware Volume defined by FwVolHeader.
852
853 Arguments:
854 PeiServices - Pointer to the PEI Core Services Table.
855
856 SearchType - Filter to find only files of this type.
857 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
858
859 FwVolHeader - Pointer to the FV header of the volume to search.
860 This parameter must point to a valid FFS volume.
861
862 FileHeader - Pointer to the current file from which to begin searching.
863 This pointer will be updated upon return to reflect the file found.
864
865 Returns:
866 EFI_NOT_FOUND - No files matching the search criteria were found
867 EFI_SUCCESS
868
869 --*/
870 ;
871
872 EFI_STATUS
873 EFIAPI
874 PeiFfsFindSectionData (
875 IN CONST EFI_PEI_SERVICES **PeiServices,
876 IN EFI_SECTION_TYPE SectionType,
877 IN EFI_PEI_FILE_HANDLE FfsFileHeader,
878 IN OUT VOID **SectionData
879 )
880 /*++
881
882 Routine Description:
883 Given the input file pointer, search for the next matching section in the
884 FFS volume.
885
886 Arguments:
887 PeiServices - Pointer to the PEI Core Services Table.
888 SearchType - Filter to find only sections of this type.
889 FfsFileHeader - Pointer to the current file to search.
890 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
891 - NULL if section not found
892
893 Returns:
894 EFI_NOT_FOUND - No files matching the search criteria were found
895 EFI_SUCCESS
896
897 --*/
898 ;
899
900 EFI_STATUS
901 EFIAPI
902 PeiFvFindNextVolume (
903 IN CONST EFI_PEI_SERVICES **PeiServices,
904 IN UINTN Instance,
905 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader
906 )
907 /*++
908
909 Routine Description:
910
911 Return the BFV location
912
913 BugBug -- Move this to the location of this code to where the
914 other FV and FFS support code lives.
915 Also, update to use FindFV for instances #'s >= 1.
916
917 Arguments:
918
919 PeiServices - The PEI core services table.
920 Instance - Instance of FV to find
921 FwVolHeader - Pointer to contain the data to return
922
923 Returns:
924 Pointer to the Firmware Volume instance requested
925
926 EFI_INVALID_PARAMETER - FwVolHeader is NULL
927
928 EFI_SUCCESS - Firmware volume instance successfully found.
929
930 --*/
931 ;
932
933 //
934 // Memory support functions
935 //
936 VOID
937 InitializeMemoryServices (
938 IN PEI_CORE_INSTANCE *PrivateData,
939 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
940 IN PEI_CORE_INSTANCE *OldCoreData
941 )
942 /*++
943
944 Routine Description:
945
946 Initialize the memory services.
947
948 Arguments:
949
950 PeiServices - The PEI core services table.
951 PeiStartupDescriptor - Information and services provided by SEC phase.
952 OldCoreData - Pointer to the PEI Core data.
953 NULL if being run in non-permament memory mode.
954
955 Returns:
956
957 None
958
959 --*/
960 ;
961
962 EFI_STATUS
963 EFIAPI
964 PeiInstallPeiMemory (
965 IN CONST EFI_PEI_SERVICES **PeiServices,
966 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
967 IN UINT64 MemoryLength
968 )
969 /*++
970
971 Routine Description:
972
973 Install the permanent memory is now available.
974 Creates HOB (PHIT and Stack).
975
976 Arguments:
977
978 PeiServices - The PEI core services table.
979 MemoryBegin - Start of memory address.
980 MemoryLength - Length of memory.
981
982 Returns:
983
984 Status - EFI_SUCCESS
985
986 --*/
987 ;
988
989 EFI_STATUS
990 EFIAPI
991 PeiAllocatePages (
992 IN CONST EFI_PEI_SERVICES **PeiServices,
993 IN EFI_MEMORY_TYPE MemoryType,
994 IN UINTN Pages,
995 OUT EFI_PHYSICAL_ADDRESS *Memory
996 )
997 /*++
998
999 Routine Description:
1000
1001 Memory allocation service on permanent memory,
1002 not usable prior to the memory installation.
1003
1004 Arguments:
1005
1006 PeiServices - The PEI core services table.
1007 Type - Type of allocation.
1008 MemoryType - Type of memory to allocate.
1009 Pages - Number of pages to allocate.
1010 Memory - Pointer of memory allocated.
1011
1012 Returns:
1013
1014 Status - EFI_SUCCESS The allocation was successful
1015 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
1016 EFI_NOT_AVAILABLE_YET Called with permanent memory not available
1017 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
1018 to allocate the number of pages.
1019
1020 --*/
1021 ;
1022
1023 EFI_STATUS
1024 EFIAPI
1025 PeiAllocatePool (
1026 IN CONST EFI_PEI_SERVICES **PeiServices,
1027 IN UINTN Size,
1028 OUT VOID **Buffer
1029 )
1030 /*++
1031
1032 Routine Description:
1033
1034 Memory allocation service on the CAR.
1035
1036 Arguments:
1037
1038 PeiServices - The PEI core services table.
1039
1040 Size - Amount of memory required
1041
1042 Buffer - Address of pointer to the buffer
1043
1044 Returns:
1045
1046 Status - EFI_SUCCESS The allocation was successful
1047 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1048 to allocate the requested size.
1049
1050 --*/
1051 ;
1052
1053 EFI_STATUS
1054 PeiLoadImage (
1055 IN EFI_PEI_SERVICES **PeiServices,
1056 IN EFI_PEI_FILE_HANDLE FileHandle,
1057 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1058 OUT UINT32 *AuthenticationState
1059 )
1060 /*++
1061
1062 Routine Description:
1063
1064 Get entry point of a Peim file.
1065
1066 Arguments:
1067
1068 PeiServices - Calling context.
1069
1070 PeimFileHeader - Peim file's header.
1071
1072 EntryPoint - Entry point of that Peim file.
1073
1074 Returns:
1075
1076 Status code.
1077
1078 --*/
1079 ;
1080
1081
1082 EFI_STATUS
1083 EFIAPI
1084 PeiReportStatusCode (
1085 IN CONST EFI_PEI_SERVICES **PeiServices,
1086 IN EFI_STATUS_CODE_TYPE CodeType,
1087 IN EFI_STATUS_CODE_VALUE Value,
1088 IN UINT32 Instance,
1089 IN CONST EFI_GUID *CallerId,
1090 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
1091 )
1092 /*++
1093
1094 Routine Description:
1095
1096 Core version of the Status Code reporter
1097
1098 Arguments:
1099
1100 PeiServices - The PEI core services table.
1101
1102 CodeType - Type of Status Code.
1103
1104 Value - Value to output for Status Code.
1105
1106 Instance - Instance Number of this status code.
1107
1108 CallerId - ID of the caller of this status code.
1109
1110 Data - Optional data associated with this status code.
1111
1112 Returns:
1113
1114 Status - EFI_SUCCESS if status code is successfully reported
1115 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1116
1117 --*/
1118 ;
1119
1120
1121 EFI_STATUS
1122 EFIAPI
1123 PeiResetSystem (
1124 IN CONST EFI_PEI_SERVICES **PeiServices
1125 )
1126 /*++
1127
1128 Routine Description:
1129
1130 Core version of the Reset System
1131
1132 Arguments:
1133
1134 PeiServices - The PEI core services table.
1135
1136 Returns:
1137
1138 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
1139 - EFI_DEVICE_ERROR. Did not reset system.
1140
1141 Otherwise, resets the system.
1142
1143 --*/
1144 ;
1145
1146 VOID
1147 PeiInitializeFv (
1148 IN PEI_CORE_INSTANCE *PrivateData,
1149 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
1150 )
1151 /*++
1152
1153 Routine Description:
1154
1155 Initialize PeiCore Fv List.
1156
1157 Arguments:
1158 PrivateData - Pointer to PEI_CORE_INSTANCE.
1159 SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
1160
1161 Returns:
1162 NONE
1163
1164 --*/
1165 ;
1166
1167 EFI_STATUS
1168 EFIAPI
1169 FirmwareVolmeInfoPpiNotifyCallback (
1170 IN EFI_PEI_SERVICES **PeiServices,
1171 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1172 IN VOID *Ppi
1173 )
1174 /*++
1175
1176 Routine Description:
1177
1178 Process Firmware Volum Information once FvInfoPPI install.
1179
1180 Arguments:
1181
1182 PeiServices - General purpose services available to every PEIM.
1183
1184 Returns:
1185
1186 Status - EFI_SUCCESS if the interface could be successfully
1187 installed
1188
1189 --*/
1190 ;
1191
1192
1193 EFI_STATUS
1194 EFIAPI
1195 PeiFfsFindFileByName (
1196 IN CONST EFI_GUID *FileName,
1197 IN EFI_PEI_FV_HANDLE VolumeHandle,
1198 OUT EFI_PEI_FILE_HANDLE *FileHandle
1199 )
1200 /*++
1201
1202 Routine Description:
1203
1204 Given the input VolumeHandle, search for the next matching name file.
1205
1206 Arguments:
1207
1208 FileName - File name to search.
1209 VolumeHandle - The current FV to search.
1210 FileHandle - Pointer to the file matching name in VolumeHandle.
1211 - NULL if file not found
1212 Returns:
1213 EFI_STATUS
1214
1215 --*/
1216 ;
1217
1218
1219 EFI_STATUS
1220 EFIAPI
1221 PeiFfsGetFileInfo (
1222 IN EFI_PEI_FILE_HANDLE FileHandle,
1223 OUT EFI_FV_FILE_INFO *FileInfo
1224 )
1225 /*++
1226
1227 Routine Description:
1228
1229 Collect information of given file.
1230
1231 Arguments:
1232 FileHandle - The handle to file.
1233 FileInfo - Pointer to the file information.
1234
1235 Returns:
1236 EFI_STATUS
1237
1238 --*/
1239 ;
1240
1241 EFI_STATUS
1242 EFIAPI
1243 PeiFfsGetVolumeInfo (
1244 IN EFI_PEI_FV_HANDLE VolumeHandle,
1245 OUT EFI_FV_INFO *VolumeInfo
1246 )
1247 /*++
1248
1249 Routine Description:
1250
1251 Collect information of given Fv Volume.
1252
1253 Arguments:
1254 VolumeHandle - The handle to Fv Volume.
1255 VolumeInfo - The pointer to volume information.
1256
1257 Returns:
1258 EFI_STATUS
1259
1260 --*/
1261 ;
1262
1263
1264 EFI_STATUS
1265 EFIAPI
1266 PeiRegisterForShadow (
1267 IN EFI_PEI_FILE_HANDLE FileHandle
1268 )
1269 /*++
1270
1271 Routine Description:
1272
1273 This routine enable a PEIM to register itself to shadow when PEI Foundation
1274 discovery permanent memory.
1275
1276 Arguments:
1277 FileHandle - File handle of a PEIM.
1278
1279 Returns:
1280 EFI_NOT_FOUND - The file handle doesn't point to PEIM itself.
1281 EFI_ALREADY_STARTED - Indicate that the PEIM has been registered itself.
1282 EFI_SUCCESS - Successfully to register itself.
1283
1284 --*/
1285 ;
1286
1287
1288 /**
1289 This routine enable a PEIM to register itself to shadow when PEI Foundation
1290 discovery permanent memory.
1291
1292 @param FileHandle File handle of a PEIM.
1293
1294 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
1295 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
1296 @retval EFI_SUCCESS Successfully to register itself.
1297
1298 **/
1299 EFI_STATUS
1300 EFIAPI
1301 PeiRegisterForShadow (
1302 IN EFI_PEI_FILE_HANDLE FileHandle
1303 )
1304 ;
1305
1306 /**
1307 Transfers control to a function starting with a new stack.
1308
1309 Transfers control to the function specified by EntryPoint using the new stack
1310 specified by NewStack and passing in the parameters specified by Context1 and
1311 Context2. Context1 and Context2 are optional and may be NULL. The function
1312 EntryPoint must never return.
1313
1314 If EntryPoint is NULL, then ASSERT().
1315 If NewStack is NULL, then ASSERT().
1316
1317 @param EntryPoint A pointer to function to call with the new stack.
1318 @param Context1 A pointer to the context to pass into the EntryPoint
1319 function.
1320 @param Context2 A pointer to the context to pass into the EntryPoint
1321 function.
1322 @param NewStack A pointer to the new stack to use for the EntryPoint
1323 function.
1324 @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
1325 Reserved on other architectures.
1326
1327 **/
1328 VOID
1329 EFIAPI
1330 PeiSwitchStacks (
1331 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
1332 IN VOID *Context1, OPTIONAL
1333 IN VOID *Context2, OPTIONAL
1334 IN VOID *NewStack,
1335 IN VOID *NewBsp
1336 );
1337
1338 EFI_STATUS
1339 PeiFindFileEx (
1340 IN CONST EFI_PEI_FV_HANDLE FvHandle,
1341 IN CONST EFI_GUID *FileName, OPTIONAL
1342 IN EFI_FV_FILETYPE SearchType,
1343 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
1344 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
1345 )
1346 /*++
1347
1348 Routine Description:
1349 Given the input file pointer, search for the next matching file in the
1350 FFS volume as defined by SearchType. The search starts from FileHeader inside
1351 the Firmware Volume defined by FwVolHeader.
1352
1353 Arguments:
1354 PeiServices - Pointer to the PEI Core Services Table.
1355 SearchType - Filter to find only files of this type.
1356 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
1357 FwVolHeader - Pointer to the FV header of the volume to search.
1358 This parameter must point to a valid FFS volume.
1359 FileHeader - Pointer to the current file from which to begin searching.
1360 This pointer will be updated upon return to reflect the file found.
1361 Flag - Indicator for if this is for PEI Dispath search
1362
1363 Returns:
1364 EFI_NOT_FOUND - No files matching the search criteria were found
1365 EFI_SUCCESS
1366
1367 --*/
1368 ;
1369
1370 VOID
1371 InitializeImageServices (
1372 IN PEI_CORE_INSTANCE *PrivateData,
1373 IN PEI_CORE_INSTANCE *OldCoreData
1374 )
1375 /*++
1376
1377 Routine Description:
1378
1379 Install Pei Load File PPI.
1380
1381 Arguments:
1382
1383 PrivateData - Pointer to PEI_CORE_INSTANCE.
1384 OldCoreData - Pointer to PEI_CORE_INSTANCE.
1385
1386 Returns:
1387
1388 NONE.
1389
1390 --*/
1391 ;
1392
1393 /**
1394 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
1395
1396 @param PeiServices Pointer to the PEI Core Services Table.
1397 @param FileHandle File handle of a Fv type file.
1398 @param AuthenticationState Pointer to attestation authentication state of image.
1399
1400
1401 @retval EFI_NOT_FOUND FV image can't be found.
1402 @retval EFI_SUCCESS Successfully to process it.
1403
1404 **/
1405 EFI_STATUS
1406 ProcessFvFile (
1407 IN EFI_PEI_SERVICES **PeiServices,
1408 IN EFI_PEI_FILE_HANDLE FvFileHandle,
1409 OUT UINT32 *AuthenticationState
1410 );
1411
1412 #endif