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