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