Only include SAL related definitions if the CPU Arch is IPF
[mirror_edk2.git] / EdkModulePkg / Core / Pei / PeiMain.h
1 /*++
2
3 Copyright (c) 2006, 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 //#ifdef EFI64
28 //#include "SalApi.h"
29 //#endif
30
31 //
32 //Build private HOB to PEI core to transfer old NEM-range data to new NEM-range
33 //
34 #define EFI_PEI_CORE_PRIVATE_GUID \
35 {0xd641a0f5, 0xcb7c, 0x4846, { 0xa3, 0x80, 0x1d, 0x01, 0xb4, 0xd9, 0xe3, 0xb9 } }
36
37 //
38 // Pei Core private data structures
39 //
40 typedef union {
41 EFI_PEI_PPI_DESCRIPTOR *Ppi;
42 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
43 VOID *Raw;
44 } PEI_PPI_LIST_POINTERS;
45
46 #define PEI_STACK_SIZE 0x20000
47
48 #define MAX_PPI_DESCRIPTORS 64
49
50 typedef struct {
51 INTN PpiListEnd;
52 INTN NotifyListEnd;
53 INTN DispatchListEnd;
54 INTN LastDispatchedInstall;
55 INTN LastDispatchedNotify;
56 PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];
57 } PEI_PPI_DATABASE;
58
59 typedef struct {
60 UINT8 CurrentPeim;
61 UINT8 CurrentFv;
62 UINT32 DispatchedPeimBitMap;
63 UINT32 PreviousPeimBitMap;
64 EFI_FFS_FILE_HEADER *CurrentPeimAddress;
65 EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress;
66 EFI_FIRMWARE_VOLUME_HEADER *BootFvAddress;
67 EFI_PEI_FIND_FV_PPI *FindFv;
68 } PEI_CORE_DISPATCH_DATA;
69
70
71 //
72 // Pei Core private data structure instance
73 //
74
75 #define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
76
77 typedef struct{
78 UINTN Signature;
79 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
80 PEI_PPI_DATABASE PpiData;
81 PEI_CORE_DISPATCH_DATA DispatchData;
82 EFI_PEI_HOB_POINTERS HobList;
83 BOOLEAN SwitchStackSignal;
84 BOOLEAN PeiMemoryInstalled;
85 EFI_PHYSICAL_ADDRESS StackBase;
86 UINT64 StackSize;
87 VOID *BottomOfCarHeap;
88 VOID *TopOfCarHeap;
89 VOID *CpuIo;
90 EFI_PEI_SECURITY_PPI *PrivateSecurityPpi;
91 EFI_PEI_SERVICES ServiceTableShadow;
92 UINTN SizeOfCacheAsRam;
93 VOID *MaxTopOfCarHeap;
94 } PEI_CORE_INSTANCE;
95
96 //
97 // Pei Core Instance Data Macros
98 //
99
100 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
101 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
102
103 //
104 // BUGBUG: Where does this go really?
105 //
106 typedef
107 EFI_STATUS
108 (EFIAPI *PEI_CORE_ENTRY_POINT)(
109 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
110 IN PEI_CORE_INSTANCE *OldCoreData
111 );
112
113 //
114 // Union of temporarily used function pointers (to save stack space)
115 //
116 typedef union {
117 PEI_CORE_ENTRY_POINT PeiCore;
118 EFI_PEIM_ENTRY_POINT PeimEntry;
119 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;
120 EFI_DXE_IPL_PPI *DxeIpl;
121 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
122 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
123 VOID *Raw;
124 } PEI_CORE_TEMP_POINTERS;
125
126
127 //
128 // Main PEI entry
129 //
130
131 EFI_STATUS
132 EFIAPI
133 PeiCore (
134 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
135 IN PEI_CORE_INSTANCE *OldCoreData
136 )
137 /*++
138
139 Routine Description:
140
141 Main entry point to Pei Core. After switching stack in the PEI core,
142 it will restart with the old core data.
143
144 Arguments:
145
146 PeiStartupDescriptor - Information and services provided by SEC phase.
147 OldCoreData - Pointer to old core data that is used to initialize the
148 core's data areas.
149
150 Returns:
151
152 This function never returns
153
154 --*/
155 ;
156
157
158 //
159 // Dispatcher support functions
160 //
161
162 EFI_STATUS
163 PeimDispatchReadiness (
164 IN EFI_PEI_SERVICES **PeiServices,
165 IN VOID *DependencyExpression,
166 IN OUT BOOLEAN *Runnable
167 )
168 /*++
169
170 Routine Description:
171
172 This is the POSTFIX version of the dependency evaluator. When a
173 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
174 the evaluation stack. When that entry is poped from the evaluation
175 stack, the PPI is checked if it is installed. This method allows
176 some time savings as not all PPIs must be checked for certain
177 operation types (AND, OR).
178
179 Arguments:
180
181 PeiServices - Calling context.
182
183 DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
184 the BNF described above and is stored in postfix notation.
185 Runnable - is True if the driver can be scheduled and False if the driver
186 cannot be scheduled. This is the value that the schedulers
187 should use for deciding the state of the driver.
188
189 Returns:
190
191 Status = EFI_SUCCESS if it is a well-formed Grammar
192 EFI_INVALID_PARAMETER if the dependency expression overflows
193 the evaluation stack
194 EFI_INVALID_PARAMETER if the dependency expression underflows
195 the evaluation stack
196 EFI_INVALID_PARAMETER if the dependency expression is not a
197 well-formed Grammar.
198 --*/
199 ;
200
201
202 EFI_STATUS
203 PeiDispatcher (
204 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
205 IN PEI_CORE_INSTANCE *PrivateData,
206 IN PEI_CORE_DISPATCH_DATA *DispatchData
207 )
208
209 /*++
210
211 Routine Description:
212
213 Conduct PEIM dispatch.
214
215 Arguments:
216
217 PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
218 PrivateData - Pointer to the private data passed in from caller
219 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
220
221 Returns:
222
223 EFI_SUCCESS - Successfully dispatched PEIM.
224 EFI_NOT_FOUND - The dispatch failed.
225
226 --*/
227 ;
228
229
230 VOID
231 InitializeDispatcherData (
232 IN EFI_PEI_SERVICES **PeiServices,
233 IN PEI_CORE_INSTANCE *OldCoreData,
234 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
235 )
236 /*++
237
238 Routine Description:
239
240 Initialize the Dispatcher's data members
241
242 Arguments:
243
244 PeiServices - The PEI core services table.
245 OldCoreData - Pointer to old core data (before switching stack).
246 NULL if being run in non-permament memory mode.
247 PeiStartupDescriptor - Information and services provided by SEC phase.
248
249
250 Returns:
251
252 None
253
254 --*/
255 ;
256
257
258 EFI_STATUS
259 FindNextPeim (
260 IN EFI_PEI_SERVICES **PeiServices,
261 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
262 IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
263 )
264 /*++
265
266 Routine Description:
267 Given the input file pointer, search for the next matching file in the
268 FFS volume. The search starts from FileHeader inside
269 the Firmware Volume defined by FwVolHeader.
270
271 Arguments:
272 PeiServices - Pointer to the PEI Core Services Table.
273
274 FwVolHeader - Pointer to the FV header of the volume to search.
275 This parameter must point to a valid FFS volume.
276
277 PeimFileHeader - Pointer to the current file from which to begin searching.
278 This pointer will be updated upon return to reflect the file found.
279
280 Returns:
281 EFI_NOT_FOUND - No files matching the search criteria were found
282 EFI_SUCCESS
283
284 --*/
285 ;
286
287 BOOLEAN
288 Dispatched (
289 IN UINT8 CurrentPeim,
290 IN UINT32 DispatchedPeimBitMap
291 )
292 /*++
293
294 Routine Description:
295
296 This routine checks to see if a particular PEIM has been dispatched during
297 the PEI core dispatch.
298
299 Arguments:
300 CurrentPeim - The PEIM/FV in the bit array to check.
301 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
302
303 Returns:
304 TRUE if PEIM already dispatched
305 FALSE if not
306
307 --*/
308 ;
309
310 VOID
311 SetDispatched (
312 IN EFI_PEI_SERVICES **PeiServices,
313 IN UINT8 CurrentPeim,
314 OUT UINT32 *DispatchedPeimBitMap
315 )
316 /*++
317
318 Routine Description:
319
320 This routine sets a PEIM as having been dispatched once its entry
321 point has been invoked.
322
323 Arguments:
324
325 PeiServices - The PEI core services table.
326 CurrentPeim - The PEIM/FV in the bit array to check.
327 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
328
329 Returns:
330 None
331
332 --*/
333 ;
334
335 BOOLEAN
336 DepexSatisfied (
337 IN EFI_PEI_SERVICES **PeiServices,
338 IN VOID *CurrentPeimAddress
339 )
340 /*++
341
342 Routine Description:
343
344 This routine parses the Dependency Expression, if available, and
345 decides if the module can be executed.
346
347 Arguments:
348 PeiServices - The PEI Service Table
349 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
350
351 Returns:
352 TRUE - Can be dispatched
353 FALSE - Cannot be dispatched
354
355 --*/
356 ;
357
358 #ifdef EFI64
359 //
360 // In Ipf we should make special changes for the PHIT pointers to support
361 // recovery boot in cache mode.
362 //
363 #define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)
364 #define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL
365 VOID
366 SwitchToCacheMode (
367 IN PEI_CORE_INSTANCE *CoreData
368 )
369 /*++
370
371 Routine Description:
372
373 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
374
375 Arguments:
376
377 CoreData - The PEI core Private Data
378
379 Returns:
380
381 --*/
382 ;
383
384 #else
385
386 #define SWITCH_TO_CACHE_MODE(CoreData)
387
388 #endif
389
390 //
391 // PPI support functions
392 //
393 VOID
394 InitializePpiServices (
395 IN EFI_PEI_SERVICES **PeiServices,
396 IN PEI_CORE_INSTANCE *OldCoreData
397 )
398 /*++
399
400 Routine Description:
401
402 Initialize PPI services.
403
404 Arguments:
405
406 PeiServices - The PEI core services table.
407 OldCoreData - Pointer to the PEI Core data.
408 NULL if being run in non-permament memory mode.
409
410 Returns:
411 Nothing
412
413 --*/
414 ;
415
416 VOID
417 ConvertPpiPointers (
418 IN EFI_PEI_SERVICES **PeiServices,
419 IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
420 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
421 )
422 /*++
423
424 Routine Description:
425
426 Migrate the Hob list from the CAR stack to PEI installed memory.
427
428 Arguments:
429
430 PeiServices - The PEI core services table.
431 OldHandOffHob - The old handoff HOB list.
432 NewHandOffHob - The new handoff HOB list.
433
434 Returns:
435
436 --*/
437 ;
438
439 EFI_STATUS
440 EFIAPI
441 PeiInstallPpi (
442 IN EFI_PEI_SERVICES **PeiServices,
443 IN EFI_PEI_PPI_DESCRIPTOR *PpiList
444 )
445 /*++
446
447 Routine Description:
448
449 Install PPI services.
450
451 Arguments:
452
453 PeiServices - Pointer to the PEI Service Table
454 PpiList - Pointer to a list of PEI PPI Descriptors.
455
456 Returns:
457
458 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
459 EFI_INVALID_PARAMETER - if PpiList is NULL pointer
460 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
461 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
462
463 --*/
464 ;
465
466 EFI_STATUS
467 EFIAPI
468 PeiReInstallPpi (
469 IN EFI_PEI_SERVICES **PeiServices,
470 IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
471 IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
472 )
473 /*++
474
475 Routine Description:
476
477 Re-Install PPI services.
478
479 Arguments:
480
481 PeiServices - Pointer to the PEI Service Table
482 OldPpi - Pointer to the old PEI PPI Descriptors.
483 NewPpi - Pointer to the new PEI PPI Descriptors.
484
485 Returns:
486
487 EFI_SUCCESS - if the operation was successful
488 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
489 EFI_INVALID_PARAMETER - if NewPpi is not valid
490 EFI_NOT_FOUND - if the PPI was not in the database
491
492 --*/
493 ;
494
495 EFI_STATUS
496 EFIAPI
497 PeiLocatePpi (
498 IN EFI_PEI_SERVICES **PeiServices,
499 IN EFI_GUID *Guid,
500 IN UINTN Instance,
501 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
502 IN OUT VOID **Ppi
503 )
504 /*++
505
506 Routine Description:
507
508 Locate a given named PPI.
509
510 Arguments:
511
512 PeiServices - Pointer to the PEI Service Table
513 Guid - Pointer to GUID of the PPI.
514 Instance - Instance Number to discover.
515 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
516 returns a pointer to the descriptor (includes flags, etc)
517 Ppi - Pointer to reference the found PPI
518
519 Returns:
520
521 Status - EFI_SUCCESS if the PPI is in the database
522 EFI_NOT_FOUND if the PPI is not in the database
523 --*/
524 ;
525
526 EFI_STATUS
527 EFIAPI
528 PeiNotifyPpi (
529 IN EFI_PEI_SERVICES **PeiServices,
530 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
531 )
532 /*++
533
534 Routine Description:
535
536 Install a notification for a given PPI.
537
538 Arguments:
539
540 PeiServices - Pointer to the PEI Service Table
541 NotifyList - Pointer to list of Descriptors to notify upon.
542
543 Returns:
544
545 Status - EFI_SUCCESS if successful
546 EFI_OUT_OF_RESOURCES if no space in the database
547 EFI_INVALID_PARAMETER if not a good decriptor
548
549 --*/
550 ;
551
552 VOID
553 ProcessNotifyList (
554 IN EFI_PEI_SERVICES **PeiServices
555 )
556 /*++
557
558 Routine Description:
559
560 Process the Notify List at dispatch level.
561
562 Arguments:
563
564 PeiServices - Pointer to the PEI Service Table
565
566 Returns:
567
568 --*/
569 ;
570
571 VOID
572 DispatchNotify (
573 IN EFI_PEI_SERVICES **PeiServices,
574 IN UINTN NotifyType,
575 IN INTN InstallStartIndex,
576 IN INTN InstallStopIndex,
577 IN INTN NotifyStartIndex,
578 IN INTN NotifyStopIndex
579 )
580 /*++
581
582 Routine Description:
583
584 Dispatch notifications.
585
586 Arguments:
587
588 PeiServices - Pointer to the PEI Service Table
589 NotifyType - Type of notify to fire.
590 InstallStartIndex - Install Beginning index.
591 InstallStopIndex - Install Ending index.
592 NotifyStartIndex - Notify Beginning index.
593 NotifyStopIndex - Notify Ending index.
594
595 Returns: None
596
597 --*/
598 ;
599
600 //
601 // Boot mode support functions
602 //
603 EFI_STATUS
604 EFIAPI
605 PeiGetBootMode (
606 IN EFI_PEI_SERVICES **PeiServices,
607 IN OUT EFI_BOOT_MODE *BootMode
608 )
609 /*++
610
611 Routine Description:
612
613 This service enables PEIMs to ascertain the present value of the boot mode.
614
615 Arguments:
616
617 PeiServices - The PEI core services table.
618 BootMode - A pointer to contain the value of the boot mode.
619
620 Returns:
621
622 EFI_SUCCESS - The boot mode was returned successfully.
623 EFI_INVALID_PARAMETER - BootMode is NULL.
624
625 --*/
626 ;
627
628 EFI_STATUS
629 EFIAPI
630 PeiSetBootMode (
631 IN EFI_PEI_SERVICES **PeiServices,
632 IN EFI_BOOT_MODE BootMode
633 )
634 /*++
635
636 Routine Description:
637
638 This service enables PEIMs to update the boot mode variable.
639
640 Arguments:
641
642 PeiServices - The PEI core services table.
643 BootMode - The value of the boot mode to set.
644
645 Returns:
646
647 EFI_SUCCESS - The value was successfully updated
648
649 --*/
650 ;
651
652 //
653 // Security support functions
654 //
655 VOID
656 InitializeSecurityServices (
657 IN EFI_PEI_SERVICES **PeiServices,
658 IN PEI_CORE_INSTANCE *OldCoreData
659 )
660 /*++
661
662 Routine Description:
663
664 Initialize the security services.
665
666 Arguments:
667
668 PeiServices - The PEI core services table.
669 OldCoreData - Pointer to the old core data.
670 NULL if being run in non-permament memory mode.
671 Returns:
672
673 None
674
675 --*/
676 ;
677
678 EFI_STATUS
679 VerifyFv (
680 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
681 )
682 /*++
683
684 Routine Description:
685
686 Provide a callout to the OEM FV verification service.
687
688 Arguments:
689
690 CurrentFvAddress - Pointer to the FV under investigation.
691
692 Returns:
693
694 Status - EFI_SUCCESS
695
696 --*/
697 ;
698
699
700 EFI_STATUS
701 VerifyPeim (
702 IN EFI_PEI_SERVICES **PeiServices,
703 IN EFI_FFS_FILE_HEADER *CurrentPeimAddress
704 )
705 /*++
706
707 Routine Description:
708
709 Provide a callout to the security verification service.
710
711 Arguments:
712
713 PeiServices - The PEI core services table.
714 CurrentPeimAddress - Pointer to the Firmware File under investigation.
715
716 Returns:
717
718 EFI_SUCCESS - Image is OK
719 EFI_SECURITY_VIOLATION - Image is illegal
720
721 --*/
722 ;
723
724
725 EFI_STATUS
726 EFIAPI
727 PeiGetHobList (
728 IN EFI_PEI_SERVICES **PeiServices,
729 IN OUT VOID **HobList
730 )
731 /*++
732
733 Routine Description:
734
735 Gets the pointer to the HOB List.
736
737 Arguments:
738
739 PeiServices - The PEI core services table.
740 HobList - Pointer to the HOB List.
741
742 Returns:
743
744 EFI_SUCCESS - Get the pointer of HOB List
745 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
746 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
747
748 --*/
749 ;
750
751 EFI_STATUS
752 EFIAPI
753 PeiCreateHob (
754 IN EFI_PEI_SERVICES **PeiServices,
755 IN UINT16 Type,
756 IN UINT16 Length,
757 IN OUT VOID **Hob
758 )
759 /*++
760
761 Routine Description:
762
763 Add a new HOB to the HOB List.
764
765 Arguments:
766
767 PeiServices - The PEI core services table.
768 Type - Type of the new HOB.
769 Length - Length of the new HOB to allocate.
770 Hob - Pointer to the new HOB.
771
772 Returns:
773
774 Status - EFI_SUCCESS
775 - EFI_INVALID_PARAMETER if Hob is NULL
776 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
777 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
778
779 --*/
780 ;
781
782 EFI_STATUS
783 PeiCoreBuildHobHandoffInfoTable (
784 IN EFI_BOOT_MODE BootMode,
785 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
786 IN UINT64 MemoryLength
787 )
788 /*++
789
790 Routine Description:
791
792 Builds a Handoff Information Table HOB
793
794 Arguments:
795
796 BootMode - Current Bootmode
797 MemoryBegin - Start Memory Address.
798 MemoryLength - Length of Memory.
799
800 Returns:
801
802 EFI_SUCCESS
803
804 --*/
805 ;
806
807
808 //
809 // FFS Fw Volume support functions
810 //
811 EFI_STATUS
812 EFIAPI
813 PeiFfsFindNextFile (
814 IN EFI_PEI_SERVICES **PeiServices,
815 IN UINT8 SearchType,
816 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
817 IN OUT EFI_FFS_FILE_HEADER **FileHeader
818 )
819 /*++
820
821 Routine Description:
822 Given the input file pointer, search for the next matching file in the
823 FFS volume as defined by SearchType. The search starts from FileHeader inside
824 the Firmware Volume defined by FwVolHeader.
825
826 Arguments:
827 PeiServices - Pointer to the PEI Core Services Table.
828
829 SearchType - Filter to find only files of this type.
830 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
831
832 FwVolHeader - Pointer to the FV header of the volume to search.
833 This parameter must point to a valid FFS volume.
834
835 FileHeader - Pointer to the current file from which to begin searching.
836 This pointer will be updated upon return to reflect the file found.
837
838 Returns:
839 EFI_NOT_FOUND - No files matching the search criteria were found
840 EFI_SUCCESS
841
842 --*/
843 ;
844
845 EFI_STATUS
846 EFIAPI
847 PeiFfsFindSectionData (
848 IN EFI_PEI_SERVICES **PeiServices,
849 IN EFI_SECTION_TYPE SectionType,
850 IN EFI_FFS_FILE_HEADER *FfsFileHeader,
851 IN OUT VOID **SectionData
852 )
853 /*++
854
855 Routine Description:
856 Given the input file pointer, search for the next matching section in the
857 FFS volume.
858
859 Arguments:
860 PeiServices - Pointer to the PEI Core Services Table.
861 SearchType - Filter to find only sections of this type.
862 FfsFileHeader - Pointer to the current file to search.
863 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
864 - NULL if section not found
865
866 Returns:
867 EFI_NOT_FOUND - No files matching the search criteria were found
868 EFI_SUCCESS
869
870 --*/
871 ;
872
873 EFI_STATUS
874 EFIAPI
875 PeiFvFindNextVolume (
876 IN EFI_PEI_SERVICES **PeiServices,
877 IN UINTN Instance,
878 IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
879 )
880 /*++
881
882 Routine Description:
883
884 Return the BFV location
885
886 BugBug -- Move this to the location of this code to where the
887 other FV and FFS support code lives.
888 Also, update to use FindFV for instances #'s >= 1.
889
890 Arguments:
891
892 PeiServices - The PEI core services table.
893 Instance - Instance of FV to find
894 FwVolHeader - Pointer to contain the data to return
895
896 Returns:
897 Pointer to the Firmware Volume instance requested
898
899 EFI_INVALID_PARAMETER - FwVolHeader is NULL
900
901 EFI_SUCCESS - Firmware volume instance successfully found.
902
903 --*/
904 ;
905
906 //
907 // Memory support functions
908 //
909 VOID
910 InitializeMemoryServices (
911 IN EFI_PEI_SERVICES **PeiServices,
912 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
913 IN PEI_CORE_INSTANCE *OldCoreData
914 )
915 /*++
916
917 Routine Description:
918
919 Initialize the memory services.
920
921 Arguments:
922
923 PeiServices - The PEI core services table.
924 PeiStartupDescriptor - Information and services provided by SEC phase.
925 OldCoreData - Pointer to the PEI Core data.
926 NULL if being run in non-permament memory mode.
927
928 Returns:
929
930 None
931
932 --*/
933 ;
934
935 EFI_STATUS
936 EFIAPI
937 PeiInstallPeiMemory (
938 IN EFI_PEI_SERVICES **PeiServices,
939 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
940 IN UINT64 MemoryLength
941 )
942 /*++
943
944 Routine Description:
945
946 Install the permanent memory is now available.
947 Creates HOB (PHIT and Stack).
948
949 Arguments:
950
951 PeiServices - The PEI core services table.
952 MemoryBegin - Start of memory address.
953 MemoryLength - Length of memory.
954
955 Returns:
956
957 Status - EFI_SUCCESS
958
959 --*/
960 ;
961
962 EFI_STATUS
963 EFIAPI
964 PeiAllocatePages (
965 IN EFI_PEI_SERVICES **PeiServices,
966 IN EFI_MEMORY_TYPE MemoryType,
967 IN UINTN Pages,
968 OUT EFI_PHYSICAL_ADDRESS *Memory
969 )
970 /*++
971
972 Routine Description:
973
974 Memory allocation service on permanent memory,
975 not usable prior to the memory installation.
976
977 Arguments:
978
979 PeiServices - The PEI core services table.
980 Type - Type of allocation.
981 MemoryType - Type of memory to allocate.
982 Pages - Number of pages to allocate.
983 Memory - Pointer of memory allocated.
984
985 Returns:
986
987 Status - EFI_SUCCESS The allocation was successful
988 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
989 EFI_NOT_AVAILABLE_YET Called with permanent memory not available
990 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
991 to allocate the number of pages.
992
993 --*/
994 ;
995
996 EFI_STATUS
997 EFIAPI
998 PeiAllocatePool (
999 IN EFI_PEI_SERVICES **PeiServices,
1000 IN UINTN Size,
1001 OUT VOID **Buffer
1002 )
1003 /*++
1004
1005 Routine Description:
1006
1007 Memory allocation service on the CAR.
1008
1009 Arguments:
1010
1011 PeiServices - The PEI core services table.
1012
1013 Size - Amount of memory required
1014
1015 Buffer - Address of pointer to the buffer
1016
1017 Returns:
1018
1019 Status - EFI_SUCCESS The allocation was successful
1020 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1021 to allocate the requested size.
1022
1023 --*/
1024 ;
1025
1026 EFI_STATUS
1027 PeiLoadImage (
1028 IN EFI_PEI_SERVICES **PeiServices,
1029 IN EFI_FFS_FILE_HEADER *PeimFileHeader,
1030 OUT VOID **EntryPoint
1031 )
1032 /*++
1033
1034 Routine Description:
1035
1036 Get entry point of a Peim file.
1037
1038 Arguments:
1039
1040 PeiServices - Calling context.
1041
1042 PeimFileHeader - Peim file's header.
1043
1044 EntryPoint - Entry point of that Peim file.
1045
1046 Returns:
1047
1048 Status code.
1049
1050 --*/
1051 ;
1052
1053
1054 EFI_STATUS
1055 EFIAPI
1056 PeiReportStatusCode (
1057 IN EFI_PEI_SERVICES **PeiServices,
1058 IN EFI_STATUS_CODE_TYPE CodeType,
1059 IN EFI_STATUS_CODE_VALUE Value,
1060 IN UINT32 Instance,
1061 IN EFI_GUID *CallerId,
1062 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
1063 )
1064 /*++
1065
1066 Routine Description:
1067
1068 Core version of the Status Code reporter
1069
1070 Arguments:
1071
1072 PeiServices - The PEI core services table.
1073
1074 CodeType - Type of Status Code.
1075
1076 Value - Value to output for Status Code.
1077
1078 Instance - Instance Number of this status code.
1079
1080 CallerId - ID of the caller of this status code.
1081
1082 Data - Optional data associated with this status code.
1083
1084 Returns:
1085
1086 Status - EFI_SUCCESS if status code is successfully reported
1087 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1088
1089 --*/
1090 ;
1091
1092
1093 EFI_STATUS
1094 EFIAPI
1095 PeiResetSystem (
1096 IN EFI_PEI_SERVICES **PeiServices
1097 )
1098 /*++
1099
1100 Routine Description:
1101
1102 Core version of the Reset System
1103
1104 Arguments:
1105
1106 PeiServices - The PEI core services table.
1107
1108 Returns:
1109
1110 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
1111 - EFI_DEVICE_ERROR. Did not reset system.
1112
1113 Otherwise, resets the system.
1114
1115 --*/
1116 ;
1117
1118 /**
1119 Transfers control to a function starting with a new stack.
1120
1121 Transfers control to the function specified by EntryPoint using the new stack
1122 specified by NewStack and passing in the parameters specified by Context1 and
1123 Context2. Context1 and Context2 are optional and may be NULL. The function
1124 EntryPoint must never return.
1125
1126 If EntryPoint is NULL, then ASSERT().
1127 If NewStack is NULL, then ASSERT().
1128
1129 @param EntryPoint A pointer to function to call with the new stack.
1130 @param Context1 A pointer to the context to pass into the EntryPoint
1131 function.
1132 @param Context2 A pointer to the context to pass into the EntryPoint
1133 function.
1134 @param NewStack A pointer to the new stack to use for the EntryPoint
1135 function.
1136 @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
1137 Reserved on other architectures.
1138
1139 **/
1140 VOID
1141 EFIAPI
1142 PeiSwitchStacks (
1143 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
1144 IN VOID *Context1, OPTIONAL
1145 IN VOID *Context2, OPTIONAL
1146 IN VOID *NewStack,
1147 IN VOID *NewBsp
1148 );
1149
1150 #endif