]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
Change the file name case to follow coding style: The first character should be capital.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Dispatcher / Dispatcher.c
CommitLineData
162ed594 1/** @file\r
797a9d67 2 DXE Dispatcher.\r
28a00297 3\r
4 Step #1 - When a FV protocol is added to the system every driver in the FV\r
5 is added to the mDiscoveredList. The SOR, Before, and After Depex are \r
6 pre-processed as drivers are added to the mDiscoveredList. If an Apriori \r
7 file exists in the FV those drivers are addeded to the \r
8 mScheduledQueue. The mFvHandleList is used to make sure a \r
9 FV is only processed once.\r
10\r
11 Step #2 - Dispatch. Remove driver from the mScheduledQueue and load and\r
12 start it. After mScheduledQueue is drained check the \r
13 mDiscoveredList to see if any item has a Depex that is ready to \r
14 be placed on the mScheduledQueue.\r
15\r
16 Step #3 - Adding to the mScheduledQueue requires that you process Before \r
17 and After dependencies. This is done recursively as the call to add\r
18 to the mScheduledQueue checks for Before and recursively adds \r
19 all Befores. It then addes the item that was passed in and then \r
20 processess the After dependecies by recursively calling the routine.\r
21\r
22 Dispatcher Rules:\r
23 The rules for the dispatcher are in chapter 10 of the DXE CIS. Figure 10-3 \r
24 is the state diagram for the DXE dispatcher\r
25\r
26 Depex - Dependency Expresion.\r
27 SOR - Schedule On Request - Don't schedule if this bit is set.\r
28\r
162ed594 29Copyright (c) 2006 - 2008, Intel Corporation \r
797a9d67 30All rights reserved. This program and the accompanying materials \r
31are licensed and made available under the terms and conditions of the BSD License \r
32which accompanies this distribution. The full text of the license may be found at \r
33http://opensource.org/licenses/bsd-license.php \r
34 \r
35THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
36WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
37\r
38**/\r
28a00297 39\r
40#include <DxeMain.h>\r
41\r
42//\r
43// The Driver List contains one copy of every driver that has been discovered.\r
44// Items are never removed from the driver list. List of EFI_CORE_DRIVER_ENTRY\r
45//\r
46LIST_ENTRY mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList); \r
47\r
48//\r
49// Queue of drivers that are ready to dispatch. This queue is a subset of the\r
50// mDiscoveredList.list of EFI_CORE_DRIVER_ENTRY.\r
51//\r
52LIST_ENTRY mScheduledQueue = INITIALIZE_LIST_HEAD_VARIABLE (mScheduledQueue);\r
53\r
54//\r
55// List of handles who's Fv's have been parsed and added to the mFwDriverList.\r
56//\r
57LIST_ENTRY mFvHandleList = INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleList); // list of KNOWN_HANDLE\r
58\r
59//\r
60// Lock for mDiscoveredList, mScheduledQueue, gDispatcherRunning.\r
61//\r
62EFI_LOCK mDispatcherLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL);\r
63\r
64\r
65//\r
66// Flag for the DXE Dispacher. TRUE if dispatcher is execuing.\r
67//\r
68BOOLEAN gDispatcherRunning = FALSE;\r
69\r
70//\r
71// Module globals to manage the FwVol registration notification event\r
72//\r
73EFI_EVENT mFwVolEvent;\r
74VOID *mFwVolEventRegistration;\r
75\r
76//\r
77// List of file types supported by dispatcher\r
78//\r
db405d1b 79STATIC EFI_FV_FILETYPE mDxeFileTypes[] = { \r
28a00297 80 EFI_FV_FILETYPE_DRIVER, \r
81 EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER, \r
82 EFI_FV_FILETYPE_DXE_CORE,\r
83 EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
84};\r
85\r
86typedef struct {\r
87 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH File;\r
88 EFI_DEVICE_PATH_PROTOCOL End;\r
89} FV_FILEPATH_DEVICE_PATH;\r
90\r
91FV_FILEPATH_DEVICE_PATH mFvDevicePath;\r
92\r
93\r
94//\r
95// Function Prototypes\r
96//\r
162ed594 97/**\r
98 Insert InsertedDriverEntry onto the mScheduledQueue. To do this you\r
99 must add any driver with a before dependency on InsertedDriverEntry first.\r
100 You do this by recursively calling this routine. After all the Befores are\r
101 processed you can add InsertedDriverEntry to the mScheduledQueue.\r
102 Then you can add any driver with an After dependency on InsertedDriverEntry\r
103 by recursively calling this routine.\r
104\r
105 @param InsertedDriverEntry The driver to insert on the ScheduledLink Queue\r
106\r
107**/\r
28a00297 108STATIC\r
109VOID\r
110CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r
111 IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry\r
112 );\r
113 \r
162ed594 114/**\r
115 Event notification that is fired every time a FV dispatch protocol is added.\r
116 More than one protocol may have been added when this event is fired, so you\r
117 must loop on CoreLocateHandle () to see how many protocols were added and\r
118 do the following to each FV:\r
119 If the Fv has already been processed, skip it. If the Fv has not been\r
120 processed then mark it as being processed, as we are about to process it.\r
121 Read the Fv and add any driver in the Fv to the mDiscoveredList.The\r
122 mDiscoveredList is never free'ed and contains variables that define\r
123 the other states the DXE driver transitions to..\r
124 While you are at it read the A Priori file into memory.\r
125 Place drivers in the A Priori list onto the mScheduledQueue.\r
126\r
127 @param Event The Event that is being processed, not used. \r
128 @param Context Event Context, not used.\r
129\r
130**/\r
28a00297 131STATIC\r
132VOID\r
133EFIAPI\r
134CoreFwVolEventProtocolNotify (\r
135 IN EFI_EVENT Event,\r
136 IN VOID *Context\r
137 );\r
138\r
162ed594 139/**\r
140 Convert FvHandle and DriverName into an EFI device path\r
141\r
142 @param Fv Fv protocol, needed to read Depex info out of \r
143 FLASH. \r
144 @param FvHandle Handle for Fv, needed in the \r
145 EFI_CORE_DRIVER_ENTRY so that the PE image can be \r
146 read out of the FV at a later time. \r
147 @param DriverName Name of driver to add to mDiscoveredList. \r
148\r
149 @return Pointer to device path constructed from FvHandle and DriverName\r
150\r
151**/\r
28a00297 152STATIC\r
153EFI_DEVICE_PATH_PROTOCOL *\r
154CoreFvToDevicePath (\r
0c2b5da8 155 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
28a00297 156 IN EFI_HANDLE FvHandle,\r
157 IN EFI_GUID *DriverName\r
158 );\r
159\r
162ed594 160/**\r
161 Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r
162 and initilize any state variables. Read the Depex from the FV and store it\r
163 in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.\r
164 The Discovered list is never free'ed and contains booleans that represent the\r
165 other possible DXE driver states.\r
166\r
167 @param Fv Fv protocol, needed to read Depex info out of \r
168 FLASH. \r
169 @param FvHandle Handle for Fv, needed in the \r
170 EFI_CORE_DRIVER_ENTRY so that the PE image can be \r
171 read out of the FV at a later time. \r
172 @param DriverName Name of driver to add to mDiscoveredList. \r
173\r
174 @retval EFI_SUCCESS If driver was added to the mDiscoveredList. \r
175 @retval EFI_ALREADY_STARTED The driver has already been started. Only one \r
176 DriverName may be active in the system at any one \r
177 time.\r
178\r
179**/\r
28a00297 180STATIC \r
181EFI_STATUS\r
182CoreAddToDriverList (\r
0c2b5da8 183 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
28a00297 184 IN EFI_HANDLE FvHandle,\r
185 IN EFI_GUID *DriverName\r
186 );\r
187\r
162ed594 188/**\r
189 Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.\r
190\r
191 @param Fv The FIRMWARE_VOLUME protocol installed on the FV. \r
192 @param FvHandle The handle which FVB protocol installed on. \r
193 @param DriverName The driver guid specified. \r
194\r
195 @retval EFI_OUT_OF_RESOURCES No enough memory or other resource. \r
196 @retval EFI_VOLUME_CORRUPTED Corrupted volume. \r
197 @retval EFI_SUCCESS Function successfully returned.\r
198\r
199**/\r
28a00297 200STATIC\r
201EFI_STATUS \r
202CoreProcessFvImageFile (\r
0c2b5da8 203 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
28a00297 204 IN EFI_HANDLE FvHandle,\r
205 IN EFI_GUID *DriverName\r
206 );\r
207\r
162ed594 208\r
209/**\r
210 Enter critical section by gaining lock on mDispatcherLock.\r
211\r
212**/\r
28a00297 213STATIC\r
214VOID\r
215CoreAcquireDispatcherLock (\r
216 VOID\r
217 )\r
28a00297 218{\r
219 CoreAcquireLock (&mDispatcherLock);\r
220}\r
221\r
162ed594 222\r
223/**\r
224 Exit critical section by releasing lock on mDispatcherLock.\r
225\r
226**/\r
28a00297 227STATIC\r
228VOID\r
229CoreReleaseDispatcherLock (\r
230 VOID\r
231 )\r
28a00297 232{\r
233 CoreReleaseLock (&mDispatcherLock);\r
234}\r
235\r
28a00297 236\r
162ed594 237/**\r
28a00297 238 Read Depex and pre-process the Depex for Before and After. If Section Extraction\r
239 protocol returns an error via ReadSection defer the reading of the Depex.\r
240\r
162ed594 241 @param DriverEntry Driver to work on. \r
28a00297 242\r
162ed594 243 @retval EFI_SUCCESS Depex read and preprossesed \r
244 @retval EFI_PROTOCOL_ERROR The section extraction protocol returned an error \r
245 and Depex reading needs to be retried. \r
246 @retval Error DEPEX not found.\r
28a00297 247\r
162ed594 248**/\r
249STATIC\r
250EFI_STATUS\r
251CoreGetDepexSectionAndPreProccess (\r
252 IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r
253 )\r
28a00297 254{\r
255 EFI_STATUS Status;\r
256 EFI_SECTION_TYPE SectionType;\r
257 UINT32 AuthenticationStatus;\r
0c2b5da8 258 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
28a00297 259\r
260 \r
261 Fv = DriverEntry->Fv;\r
262\r
263 //\r
264 // Grab Depex info, it will never be free'ed.\r
265 //\r
266 SectionType = EFI_SECTION_DXE_DEPEX;\r
267 Status = Fv->ReadSection (\r
268 DriverEntry->Fv, \r
269 &DriverEntry->FileName,\r
270 SectionType, \r
271 0, \r
272 &DriverEntry->Depex, \r
273 (UINTN *)&DriverEntry->DepexSize,\r
274 &AuthenticationStatus\r
275 );\r
276 if (EFI_ERROR (Status)) {\r
277 if (Status == EFI_PROTOCOL_ERROR) {\r
278 //\r
279 // The section extraction protocol failed so set protocol error flag\r
280 //\r
281 DriverEntry->DepexProtocolError = TRUE;\r
282 } else {\r
283 //\r
8a7d75b0 284 // If no Depex assume UEFI 2.0 driver model\r
28a00297 285 //\r
286 DriverEntry->Depex = NULL;\r
287 DriverEntry->Dependent = TRUE;\r
288 DriverEntry->DepexProtocolError = FALSE;\r
289 }\r
290 } else {\r
291 //\r
292 // Set Before, After, and Unrequested state information based on Depex\r
293 // Driver will be put in Dependent or Unrequested state\r
294 //\r
295 CorePreProcessDepex (DriverEntry);\r
296 DriverEntry->DepexProtocolError = FALSE;\r
297 } \r
298\r
299 return Status;\r
300}\r
301\r
162ed594 302\r
303/**\r
304 Check every driver and locate a matching one. If the driver is found, the Unrequested\r
305 state flag is cleared.\r
306\r
307 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains \r
308 the firmware file specified by DriverName. \r
309 @param DriverName The Driver name to put in the Dependent state. \r
310\r
311 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was \r
312 cleared \r
313 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was \r
314 not set. \r
315\r
316**/\r
28a00297 317EFI_DXESERVICE\r
318EFI_STATUS\r
319EFIAPI\r
320CoreSchedule (\r
321 IN EFI_HANDLE FirmwareVolumeHandle,\r
322 IN EFI_GUID *DriverName\r
323 )\r
28a00297 324{\r
325 LIST_ENTRY *Link;\r
326 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
327\r
328 //\r
329 // Check every driver\r
330 //\r
331 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
332 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
333 if (DriverEntry->FvHandle == FirmwareVolumeHandle &&\r
334 DriverEntry->Unrequested && \r
335 CompareGuid (DriverName, &DriverEntry->FileName)) {\r
336 //\r
337 // Move the driver from the Unrequested to the Dependent state\r
338 //\r
339 CoreAcquireDispatcherLock ();\r
340 DriverEntry->Unrequested = FALSE;\r
341 DriverEntry->Dependent = TRUE;\r
342 CoreReleaseDispatcherLock ();\r
343 \r
344 return EFI_SUCCESS;\r
345 }\r
346 }\r
347 return EFI_NOT_FOUND; \r
348}\r
349\r
350\r
162ed594 351\r
352/**\r
353 Convert a driver from the Untrused back to the Scheduled state\r
354\r
355 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains \r
356 the firmware file specified by DriverName. \r
357 @param DriverName The Driver name to put in the Scheduled state \r
358\r
359 @retval EFI_SUCCESS The file was found in the untrusted state, and it \r
360 was promoted to the trusted state. \r
361 @retval EFI_NOT_FOUND The file was not found in the untrusted state. \r
362\r
363**/\r
28a00297 364EFI_DXESERVICE\r
365EFI_STATUS\r
366EFIAPI\r
367CoreTrust (\r
368 IN EFI_HANDLE FirmwareVolumeHandle,\r
369 IN EFI_GUID *DriverName\r
370 )\r
28a00297 371{\r
372 LIST_ENTRY *Link;\r
373 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
374\r
375 //\r
376 // Check every driver\r
377 //\r
378 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
379 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
380 if (DriverEntry->FvHandle == FirmwareVolumeHandle &&\r
381 DriverEntry->Untrusted && \r
382 CompareGuid (DriverName, &DriverEntry->FileName)) {\r
383 //\r
384 // Transition driver from Untrusted to Scheduled state.\r
385 //\r
386 CoreAcquireDispatcherLock ();\r
387 DriverEntry->Untrusted = FALSE;\r
388 DriverEntry->Scheduled = TRUE;\r
389 InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);\r
390 CoreReleaseDispatcherLock ();\r
391 \r
392 return EFI_SUCCESS;\r
393 }\r
394 }\r
395 return EFI_NOT_FOUND; \r
396}\r
397\r
398\r
28a00297 399\r
162ed594 400/**\r
401 This is the main Dispatcher for DXE and it exits when there are no more\r
28a00297 402 drivers to run. Drain the mScheduledQueue and load and start a PE\r
162ed594 403 image for each driver. Search the mDiscoveredList to see if any driver can\r
28a00297 404 be placed on the mScheduledQueue. If no drivers are placed on the\r
405 mScheduledQueue exit the function. On exit it is assumed the Bds()\r
162ed594 406 will be called, and when the Bds() exits the Dispatcher will be called\r
28a00297 407 again.\r
408\r
28a00297 409 NONE\r
410\r
162ed594 411 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running \r
412 @retval EFI_NOT_FOUND No DXE Drivers were dispatched \r
413 @retval EFI_SUCCESS One or more DXE Drivers were dispatched \r
28a00297 414\r
162ed594 415**/\r
416EFI_DXESERVICE\r
417EFI_STATUS\r
418EFIAPI\r
419CoreDispatcher (\r
420 VOID\r
421 )\r
28a00297 422{\r
423 EFI_STATUS Status;\r
424 EFI_STATUS ReturnStatus;\r
425 LIST_ENTRY *Link;\r
426 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
427 BOOLEAN ReadyToRun;\r
428\r
429 if (gDispatcherRunning) {\r
430 //\r
431 // If the dispatcher is running don't let it be restarted.\r
432 //\r
433 return EFI_ALREADY_STARTED;\r
434 }\r
435\r
436 gDispatcherRunning = TRUE;\r
437\r
438\r
439 ReturnStatus = EFI_NOT_FOUND;\r
440 do {\r
441 //\r
442 // Drain the Scheduled Queue\r
443 //\r
444 while (!IsListEmpty (&mScheduledQueue)) {\r
445 DriverEntry = CR (\r
446 mScheduledQueue.ForwardLink,\r
447 EFI_CORE_DRIVER_ENTRY,\r
448 ScheduledLink,\r
449 EFI_CORE_DRIVER_ENTRY_SIGNATURE\r
450 );\r
451\r
452 //\r
453 // Load the DXE Driver image into memory. If the Driver was transitioned from\r
454 // Untrused to Scheduled it would have already been loaded so we may need to\r
455 // skip the LoadImage\r
456 //\r
457 if (DriverEntry->ImageHandle == NULL) {\r
458 Status = CoreLoadImage (\r
459 FALSE, \r
460 gDxeCoreImageHandle, \r
461 DriverEntry->FvFileDevicePath,\r
462 NULL, \r
463 0, \r
464 &DriverEntry->ImageHandle\r
465 );\r
466\r
467 //\r
468 // Update the driver state to reflect that it's been loaded\r
469 //\r
470 if (EFI_ERROR (Status)) {\r
471 CoreAcquireDispatcherLock ();\r
472\r
473 if (Status == EFI_SECURITY_VIOLATION) {\r
474 //\r
475 // Take driver from Scheduled to Untrused state\r
476 //\r
477 DriverEntry->Untrusted = TRUE;\r
478 } else {\r
479 //\r
480 // The DXE Driver could not be loaded, and do not attempt to load or start it again.\r
481 // Take driver from Scheduled to Initialized. \r
482 //\r
483 // This case include the Never Trusted state if EFI_ACCESS_DENIED is returned\r
484 //\r
485 DriverEntry->Initialized = TRUE;\r
486 }\r
487\r
488 DriverEntry->Scheduled = FALSE;\r
489 RemoveEntryList (&DriverEntry->ScheduledLink);\r
490 \r
491 CoreReleaseDispatcherLock ();\r
492 \r
493 //\r
494 // If it's an error don't try the StartImage\r
495 //\r
496 continue;\r
497 }\r
498 }\r
499\r
500 CoreAcquireDispatcherLock ();\r
501\r
502 DriverEntry->Scheduled = FALSE;\r
503 DriverEntry->Initialized = TRUE;\r
504 RemoveEntryList (&DriverEntry->ScheduledLink);\r
505 \r
506 CoreReleaseDispatcherLock ();\r
507\r
797a9d67 508 CoreReportProgressCodeSpecific (\r
509 FixedPcdGet32(PcdStatusCodeValueDxeDriverBegin), \r
510 DriverEntry->ImageHandle\r
511 );\r
28a00297 512 Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);\r
797a9d67 513 CoreReportProgressCodeSpecific (\r
514 FixedPcdGet32(PcdStatusCodeValueDxeDriverEnd), \r
515 DriverEntry->ImageHandle\r
516 );\r
28a00297 517\r
518 ReturnStatus = EFI_SUCCESS;\r
519 }\r
520\r
521 //\r
522 // Search DriverList for items to place on Scheduled Queue\r
523 //\r
524 ReadyToRun = FALSE;\r
525 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
526 DriverEntry = CR (Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
527\r
528 if (DriverEntry->DepexProtocolError){\r
529 //\r
530 // If Section Extraction Protocol did not let the Depex be read before retry the read\r
531 //\r
532 Status = CoreGetDepexSectionAndPreProccess (DriverEntry);\r
533 } \r
534\r
535 if (DriverEntry->Dependent) {\r
536 if (CoreIsSchedulable (DriverEntry)) {\r
537 CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); \r
538 ReadyToRun = TRUE;\r
539 } \r
540 }\r
541 }\r
542 } while (ReadyToRun);\r
543\r
544 gDispatcherRunning = FALSE;\r
545\r
546 return ReturnStatus;\r
547}\r
548\r
28a00297 549\r
162ed594 550/**\r
551 Insert InsertedDriverEntry onto the mScheduledQueue. To do this you\r
28a00297 552 must add any driver with a before dependency on InsertedDriverEntry first.\r
553 You do this by recursively calling this routine. After all the Befores are\r
162ed594 554 processed you can add InsertedDriverEntry to the mScheduledQueue.\r
555 Then you can add any driver with an After dependency on InsertedDriverEntry\r
28a00297 556 by recursively calling this routine.\r
557\r
162ed594 558 @param InsertedDriverEntry The driver to insert on the ScheduledLink Queue\r
28a00297 559\r
162ed594 560**/\r
561STATIC\r
562VOID\r
563CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r
564 IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry\r
565 )\r
28a00297 566{\r
567 LIST_ENTRY *Link;\r
568 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
569\r
570 //\r
571 // Process Before Dependency\r
572 //\r
573 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
574 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
575 if (DriverEntry->Before && DriverEntry->Dependent) {\r
576 if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r
577 //\r
578 // Recursively process BEFORE\r
579 //\r
580 CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r
581 }\r
582 }\r
583 }\r
584\r
585 //\r
586 // Convert driver from Dependent to Scheduled state\r
587 //\r
588 CoreAcquireDispatcherLock ();\r
589\r
590 InsertedDriverEntry->Dependent = FALSE;\r
591 InsertedDriverEntry->Scheduled = TRUE;\r
592 InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);\r
593 \r
594 CoreReleaseDispatcherLock ();\r
595\r
596 //\r
597 // Process After Dependency\r
598 //\r
599 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
600 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
601 if (DriverEntry->After && DriverEntry->Dependent) {\r
602 if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r
603 //\r
604 // Recursively process AFTER\r
605 //\r
606 CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r
607 }\r
608 }\r
609 }\r
610}\r
611\r
28a00297 612\r
162ed594 613/**\r
28a00297 614 Return TRUE if the Fv has been processed, FALSE if not.\r
615\r
162ed594 616 @param FvHandle The handle of a FV that's being tested \r
28a00297 617\r
162ed594 618 @retval TRUE Fv protocol on FvHandle has been processed \r
619 @retval FALSE Fv protocol on FvHandle has not yet been \r
620 processed\r
28a00297 621\r
162ed594 622**/\r
623STATIC\r
624BOOLEAN\r
625FvHasBeenProcessed (\r
626 IN EFI_HANDLE FvHandle\r
627 )\r
28a00297 628{\r
629 LIST_ENTRY *Link;\r
630 KNOWN_HANDLE *KnownHandle;\r
631\r
632 for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {\r
633 KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);\r
634 if (KnownHandle->Handle == FvHandle) {\r
635 return TRUE;\r
636 }\r
637 }\r
638 return FALSE;\r
639}\r
640\r
28a00297 641\r
162ed594 642/**\r
28a00297 643 Remember that Fv protocol on FvHandle has had it's drivers placed on the\r
644 mDiscoveredList. This fucntion adds entries on the mFvHandleList. Items are\r
645 never removed/freed from the mFvHandleList.\r
646\r
162ed594 647 @param FvHandle The handle of a FV that has been processed\r
28a00297 648\r
162ed594 649**/\r
650STATIC\r
651VOID\r
652FvIsBeingProcesssed (\r
653 IN EFI_HANDLE FvHandle\r
654 )\r
28a00297 655{\r
656 KNOWN_HANDLE *KnownHandle;\r
657\r
658 KnownHandle = CoreAllocateBootServicesPool (sizeof (KNOWN_HANDLE));\r
659 ASSERT (KnownHandle != NULL);\r
660\r
661 KnownHandle->Signature = KNOWN_HANDLE_SIGNATURE;\r
662 KnownHandle->Handle = FvHandle;\r
663 InsertTailList (&mFvHandleList, &KnownHandle->Link);\r
664}\r
665\r
666\r
667\r
162ed594 668\r
669/**\r
670 Convert FvHandle and DriverName into an EFI device path\r
671\r
672 @param Fv Fv protocol, needed to read Depex info out of \r
673 FLASH. \r
674 @param FvHandle Handle for Fv, needed in the \r
675 EFI_CORE_DRIVER_ENTRY so that the PE image can be \r
676 read out of the FV at a later time. \r
677 @param DriverName Name of driver to add to mDiscoveredList. \r
678\r
679 @return Pointer to device path constructed from FvHandle and DriverName\r
680\r
681**/\r
28a00297 682STATIC\r
683EFI_DEVICE_PATH_PROTOCOL *\r
684CoreFvToDevicePath (\r
0c2b5da8 685 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
28a00297 686 IN EFI_HANDLE FvHandle,\r
687 IN EFI_GUID *DriverName\r
688 )\r
28a00297 689{\r
690 EFI_STATUS Status;\r
691 EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;\r
692 EFI_DEVICE_PATH_PROTOCOL *FileNameDevicePath;\r
693\r
694 //\r
695 // Remember the device path of the FV\r
696 //\r
697 Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);\r
698 if (EFI_ERROR (Status)) {\r
699 FileNameDevicePath = NULL;\r
700 } else {\r
701 //\r
702 // Build a device path to the file in the FV to pass into gBS->LoadImage\r
703 //\r
704 EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);\r
705 mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;\r
706 mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
707 SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
708\r
709 FileNameDevicePath = CoreAppendDevicePath (\r
710 FvDevicePath, \r
711 (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath\r
712 );\r
713 }\r
714\r
715 return FileNameDevicePath;\r
716}\r
717\r
718\r
719\r
28a00297 720\r
162ed594 721/**\r
722 Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r
28a00297 723 and initilize any state variables. Read the Depex from the FV and store it\r
724 in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.\r
725 The Discovered list is never free'ed and contains booleans that represent the\r
726 other possible DXE driver states.\r
727\r
162ed594 728 @param Fv Fv protocol, needed to read Depex info out of \r
729 FLASH. \r
730 @param FvHandle Handle for Fv, needed in the \r
731 EFI_CORE_DRIVER_ENTRY so that the PE image can be \r
732 read out of the FV at a later time. \r
733 @param DriverName Name of driver to add to mDiscoveredList. \r
28a00297 734\r
162ed594 735 @retval EFI_SUCCESS If driver was added to the mDiscoveredList. \r
736 @retval EFI_ALREADY_STARTED The driver has already been started. Only one \r
737 DriverName may be active in the system at any one \r
738 time.\r
28a00297 739\r
162ed594 740**/\r
741EFI_STATUS\r
742CoreAddToDriverList (\r
743 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
744 IN EFI_HANDLE FvHandle,\r
745 IN EFI_GUID *DriverName\r
746 )\r
28a00297 747{\r
748 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
749\r
750 \r
751 //\r
752 // Create the Driver Entry for the list. ZeroPool initializes lots of variables to \r
753 // NULL or FALSE.\r
754 //\r
755 DriverEntry = CoreAllocateZeroBootServicesPool (sizeof (EFI_CORE_DRIVER_ENTRY));\r
756 ASSERT (DriverEntry != NULL);\r
757\r
758 DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE;\r
759 CopyMem (&DriverEntry->FileName, DriverName, sizeof (EFI_GUID));\r
760 DriverEntry->FvHandle = FvHandle;\r
761 DriverEntry->Fv = Fv;\r
762 DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);\r
763\r
764 CoreGetDepexSectionAndPreProccess (DriverEntry);\r
765 \r
766 CoreAcquireDispatcherLock ();\r
767 \r
768 InsertTailList (&mDiscoveredList, &DriverEntry->Link);\r
769\r
770 CoreReleaseDispatcherLock ();\r
771\r
772 return EFI_SUCCESS;\r
773}\r
774\r
bbc0f1bb 775\r
162ed594 776/**\r
bbc0f1bb 777 Check if a FV Image type file (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) is\r
778 described by a EFI_HOB_FIRMWARE_VOLUME2 Hob.\r
779\r
162ed594 780 @param FvHandle The handle which FVB protocol installed on. \r
781 @param DriverName The driver guid specified. \r
bbc0f1bb 782\r
162ed594 783 @retval TRUE This file is found in a EFI_HOB_FIRMWARE_VOLUME2 \r
784 Hob. \r
785 @retval FALSE Not found.\r
bbc0f1bb 786\r
162ed594 787**/\r
788STATIC\r
789BOOLEAN\r
790FvFoundInHobFv2 (\r
791 IN EFI_HANDLE FvHandle,\r
792 IN CONST EFI_GUID *DriverName\r
793 )\r
bbc0f1bb 794{\r
795 EFI_PEI_HOB_POINTERS HobFv2;\r
bbc0f1bb 796 \r
797 HobFv2.Raw = GetHobList ();\r
798 \r
799 while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {\r
800 if (CompareGuid (DriverName, &HobFv2.FirmwareVolume2->FileName)) {\r
b0d803fe 801 return TRUE;\r
bbc0f1bb 802 }\r
803 HobFv2.Raw = GET_NEXT_HOB (HobFv2);\r
804 }\r
805\r
806 return FALSE;\r
807}\r
28a00297 808\r
809\r
162ed594 810\r
811/**\r
812 Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.\r
813\r
814 @param Fv The FIRMWARE_VOLUME protocol installed on the FV. \r
815 @param FvHandle The handle which FVB protocol installed on. \r
816 @param DriverName The driver guid specified. \r
817\r
818 @retval EFI_OUT_OF_RESOURCES No enough memory or other resource. \r
819 @retval EFI_VOLUME_CORRUPTED Corrupted volume. \r
820 @retval EFI_SUCCESS Function successfully returned.\r
821\r
822**/\r
28a00297 823EFI_STATUS \r
824CoreProcessFvImageFile (\r
0c2b5da8 825 IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
28a00297 826 IN EFI_HANDLE FvHandle,\r
827 IN EFI_GUID *DriverName\r
828 )\r
28a00297 829{\r
830 EFI_STATUS Status;\r
831 EFI_SECTION_TYPE SectionType;\r
832 UINT32 AuthenticationStatus;\r
833 VOID *Buffer;\r
38837959 834 VOID *AlignedBuffer;\r
28a00297 835 UINTN BufferSize;\r
38837959
LG
836 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
837 UINT32 FvAlignment; \r
28a00297 838\r
839 //\r
840 // Read the first (and only the first) firmware volume section\r
841 //\r
842 SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
38837959
LG
843 FvHeader = NULL;\r
844 FvAlignment = 0;\r
28a00297 845 Buffer = NULL;\r
846 BufferSize = 0;\r
38837959 847 AlignedBuffer = NULL;\r
28a00297 848 Status = Fv->ReadSection (\r
849 Fv, \r
850 DriverName, \r
851 SectionType, \r
852 0, \r
853 &Buffer, \r
854 &BufferSize,\r
855 &AuthenticationStatus\r
856 );\r
857 if (!EFI_ERROR (Status)) {\r
858 //\r
38837959 859 // FvImage should be at its required alignment.\r
28a00297 860 //\r
38837959
LG
861 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r
862 FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
863 //\r
864 // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
865 // \r
866 if (FvAlignment < 8) {\r
867 FvAlignment = 8;\r
868 }\r
b2c5e194 869 AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r
38837959
LG
870 if (AlignedBuffer == NULL) {\r
871 Status = EFI_OUT_OF_RESOURCES;\r
872 } else {\r
873 //\r
874 // Move FvImage into the aligned buffer and release the original buffer.\r
875 //\r
876 CopyMem (AlignedBuffer, Buffer, BufferSize);\r
877 CoreFreePool (Buffer);\r
878 Buffer = NULL;\r
879 //\r
880 // Produce a FVB protocol for the file\r
881 //\r
882 Status = ProduceFVBProtocolOnBuffer (\r
883 (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,\r
884 (UINT64)BufferSize,\r
885 FvHandle,\r
886 NULL\r
887 );\r
888 }\r
28a00297 889 }\r
890\r
38837959
LG
891 if (EFI_ERROR (Status)) { \r
892 //\r
893 // ReadSection or Produce FVB failed, Free data buffer\r
894 //\r
895 if (Buffer != NULL) {\r
896 CoreFreePool (Buffer); \r
897 }\r
898 \r
899 if (AlignedBuffer != NULL) {\r
b2c5e194 900 FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));\r
38837959 901 }\r
28a00297 902 }\r
903\r
904 return Status;\r
905}\r
906\r
28a00297 907\r
162ed594 908/**\r
909 Event notification that is fired every time a FV dispatch protocol is added.\r
28a00297 910 More than one protocol may have been added when this event is fired, so you\r
911 must loop on CoreLocateHandle () to see how many protocols were added and\r
912 do the following to each FV:\r
162ed594 913 If the Fv has already been processed, skip it. If the Fv has not been\r
28a00297 914 processed then mark it as being processed, as we are about to process it.\r
162ed594 915 Read the Fv and add any driver in the Fv to the mDiscoveredList.The\r
28a00297 916 mDiscoveredList is never free'ed and contains variables that define\r
162ed594 917 the other states the DXE driver transitions to..\r
28a00297 918 While you are at it read the A Priori file into memory.\r
919 Place drivers in the A Priori list onto the mScheduledQueue.\r
920\r
162ed594 921 @param Event The Event that is being processed, not used. \r
922 @param Context Event Context, not used.\r
28a00297 923\r
162ed594 924**/\r
925STATIC\r
926VOID\r
927EFIAPI\r
928CoreFwVolEventProtocolNotify (\r
929 IN EFI_EVENT Event,\r
930 IN VOID *Context\r
931 )\r
28a00297 932{\r
933 EFI_STATUS Status;\r
934 EFI_STATUS GetNextFileStatus;\r
935 EFI_STATUS SecurityStatus;\r
0c2b5da8 936 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
28a00297 937 EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;\r
938 EFI_HANDLE FvHandle;\r
939 UINTN BufferSize;\r
940 EFI_GUID NameGuid;\r
941 UINTN Key;\r
942 EFI_FV_FILETYPE Type;\r
943 EFI_FV_FILE_ATTRIBUTES Attributes;\r
944 UINTN Size;\r
945 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
946 EFI_GUID *AprioriFile;\r
947 UINTN AprioriEntryCount;\r
948 UINTN Index;\r
949 LIST_ENTRY *Link;\r
950 UINT32 AuthenticationStatus;\r
951 UINTN SizeOfBuffer;\r
952\r
953\r
954 while (TRUE) {\r
955 BufferSize = sizeof (EFI_HANDLE);\r
956 Status = CoreLocateHandle (\r
957 ByRegisterNotify,\r
958 NULL,\r
959 mFwVolEventRegistration,\r
960 &BufferSize,\r
961 &FvHandle\r
962 );\r
963 if (EFI_ERROR (Status)) {\r
964 //\r
965 // If no more notification events exit\r
966 //\r
967 return;\r
968 }\r
969\r
970 if (FvHasBeenProcessed (FvHandle)) {\r
971 //\r
972 // This Fv has already been processed so lets skip it!\r
973 //\r
974 continue;\r
975 }\r
976\r
977 Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolumeDispatchProtocolGuid, (VOID **)&Fv);\r
978 if (EFI_ERROR (Status)) {\r
979 //\r
980 // If no dispatch protocol then skip, but do not marked as being processed as it\r
981 // may show up later.\r
982 //\r
983 continue;\r
984 }\r
985\r
986 //\r
987 // Since we are about to process this Fv mark it as processed.\r
988 //\r
989 FvIsBeingProcesssed (FvHandle);\r
990\r
991\r
0c2b5da8 992 Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);\r
28a00297 993 if (EFI_ERROR (Status)) {\r
994 //\r
995 // The Handle has a FirmwareVolumeDispatch protocol and should also contiain\r
996 // a FirmwareVolume protocol thus we should never get here.\r
997 //\r
998 ASSERT (FALSE);\r
999 continue;\r
1000 }\r
1001 \r
1002 Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);\r
1003 if (EFI_ERROR (Status)) {\r
1004 //\r
1005 // The Firmware volume doesn't have device path, can't be dispatched.\r
1006 //\r
1007 continue;\r
1008 }\r
1009 \r
1010 //\r
1011 // Evaluate the authentication status of the Firmware Volume through \r
1012 // Security Architectural Protocol\r
1013 //\r
1014 if (gSecurity != NULL) {\r
1015 SecurityStatus = gSecurity->FileAuthenticationState (\r
1016 gSecurity, \r
1017 0, \r
1018 FvDevicePath\r
1019 );\r
1020 if (SecurityStatus != EFI_SUCCESS) {\r
1021 //\r
1022 // Security check failed. The firmware volume should not be used for any purpose.\r
1023 //\r
1024 continue;\r
1025 }\r
1026 } \r
1027 \r
1028 //\r
1029 // Discover Drivers in FV and add them to the Discovered Driver List. \r
1030 // Process EFI_FV_FILETYPE_DRIVER type and then EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER \r
1031 // EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core\r
1032 // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb\r
1033 //\r
1034 for (Index = 0; Index < sizeof (mDxeFileTypes)/sizeof (EFI_FV_FILETYPE); Index++) {\r
1035 //\r
1036 // Initialize the search key\r
1037 //\r
1038 Key = 0;\r
1039 do {\r
1040 Type = mDxeFileTypes[Index];\r
1041 GetNextFileStatus = Fv->GetNextFile (\r
1042 Fv, \r
1043 &Key,\r
1044 &Type, \r
1045 &NameGuid, \r
1046 &Attributes, \r
1047 &Size\r
1048 );\r
1049 if (!EFI_ERROR (GetNextFileStatus)) {\r
1050 if (Type == EFI_FV_FILETYPE_DXE_CORE) {\r
1051 //\r
1052 // If this is the DXE core fill in it's DevicePath & DeviceHandle\r
1053 //\r
1054 if (gDxeCoreLoadedImage->FilePath == NULL) {\r
1055 if (CompareGuid (&NameGuid, gDxeCoreFileName)) {\r
1056 //\r
1057 // Maybe One specail Fv cantains only one DXE_CORE module, so its device path must\r
1058 // be initialized completely.\r
1059 //\r
1060 EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);\r
1061 mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;\r
1062 mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
1063 SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
1064\r
1065 gDxeCoreLoadedImage->FilePath = CoreDuplicateDevicePath (\r
1066 (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath\r
1067 );\r
1068 gDxeCoreLoadedImage->DeviceHandle = FvHandle;\r
1069 }\r
1070 }\r
1071 } else if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
bbc0f1bb 1072 //\r
1073 // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already \r
1074 // been extracted.\r
1075 //\r
1076 if (FvFoundInHobFv2 (FvHandle, &NameGuid)) {\r
1077 continue;\r
1078 }\r
28a00297 1079 //\r
1080 // Found a firmware volume image. Produce a firmware volume block\r
1081 // protocol for it so it gets dispatched from. This is usually a \r
1082 // capsule.\r
1083 //\r
1084 CoreProcessFvImageFile (Fv, FvHandle, &NameGuid);\r
1085 } else {\r
1086 //\r
1087 // Transition driver from Undiscovered to Discovered state\r
1088 //\r
1089 CoreAddToDriverList (Fv, FvHandle, &NameGuid);\r
1090 }\r
1091 }\r
1092 } while (!EFI_ERROR (GetNextFileStatus));\r
1093 }\r
1094 \r
1095 //\r
1096 // Read the array of GUIDs from the Apriori file if it is present in the firmware volume\r
1097 //\r
1098 AprioriFile = NULL;\r
1099 Status = Fv->ReadSection (\r
1100 Fv,\r
1101 &gAprioriGuid,\r
1102 EFI_SECTION_RAW,\r
1103 0,\r
1104 (VOID **)&AprioriFile,\r
1105 &SizeOfBuffer,\r
1106 &AuthenticationStatus\r
1107 );\r
1108 if (!EFI_ERROR (Status)) {\r
1109 AprioriEntryCount = SizeOfBuffer / sizeof (EFI_GUID);\r
1110 } else {\r
1111 AprioriEntryCount = 0;\r
1112 }\r
1113\r
1114 //\r
1115 // Put drivers on Apriori List on the Scheduled queue. The Discovered List includes\r
1116 // drivers not in the current FV and these must be skipped since the a priori list\r
1117 // is only valid for the FV that it resided in.\r
1118 //\r
1119 CoreAcquireDispatcherLock ();\r
1120 \r
1121 for (Index = 0; Index < AprioriEntryCount; Index++) {\r
1122 for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
1123 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
1124 if (CompareGuid (&DriverEntry->FileName, &AprioriFile[Index]) &&\r
1125 (FvHandle == DriverEntry->FvHandle)) {\r
1126 DriverEntry->Dependent = FALSE;\r
1127 DriverEntry->Scheduled = TRUE;\r
1128 InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);\r
1129 break;\r
1130 }\r
1131 }\r
1132 }\r
1133\r
1134 CoreReleaseDispatcherLock ();\r
1135\r
1136 //\r
1137 // Free data allocated by Fv->ReadSection () \r
1138 //\r
1139 CoreFreePool (AprioriFile); \r
1140 }\r
1141}\r
1142\r
1143\r
28a00297 1144\r
162ed594 1145/**\r
28a00297 1146 Initialize the dispatcher. Initialize the notification function that runs when\r
1147 a FV protocol is added to the system.\r
1148\r
162ed594 1149**/\r
1150VOID\r
1151CoreInitializeDispatcher (\r
1152 VOID\r
1153 )\r
28a00297 1154{\r
1155 mFwVolEvent = CoreCreateProtocolNotifyEvent (\r
0c2b5da8 1156 &gEfiFirmwareVolume2ProtocolGuid, \r
28a00297 1157 TPL_CALLBACK,\r
1158 CoreFwVolEventProtocolNotify,\r
1159 NULL,\r
1160 &mFwVolEventRegistration,\r
1161 TRUE\r
1162 );\r
1163}\r
1164\r
1165//\r
1166// Function only used in debug builds\r
1167//\r
162ed594 1168\r
1169/**\r
1170 Traverse the discovered list for any drivers that were discovered but not loaded\r
1171 because the dependency experessions evaluated to false.\r
1172\r
1173**/\r
28a00297 1174VOID\r
1175CoreDisplayDiscoveredNotDispatched (\r
1176 VOID\r
1177 )\r
28a00297 1178{\r
1179 LIST_ENTRY *Link;\r
1180 EFI_CORE_DRIVER_ENTRY *DriverEntry;\r
1181\r
1182 for (Link = mDiscoveredList.ForwardLink;Link !=&mDiscoveredList; Link = Link->ForwardLink) {\r
1183 DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r
1184 if (DriverEntry->Dependent) {\r
162ed594 1185 DEBUG ((DEBUG_LOAD, "Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));\r
28a00297 1186 }\r
1187 }\r
1188}\r