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