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