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