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