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