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