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