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