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