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