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