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