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