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