]>
Commit | Line | Data |
---|---|---|
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 | |
022c6d45 | 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 | |
28a00297 | 9 | FV is only processed once.\r |
10 | \r | |
11 | Step #2 - Dispatch. Remove driver from the mScheduledQueue and load and\r | |
022c6d45 | 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 | |
28a00297 | 14 | be placed on the mScheduledQueue.\r |
15 | \r | |
022c6d45 | 16 | Step #3 - Adding to the mScheduledQueue requires that you process Before\r |
28a00297 | 17 | and After dependencies. This is done recursively as the call to add\r |
022c6d45 | 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 | |
28a00297 | 20 | processess the After dependecies by recursively calling the routine.\r |
21 | \r | |
22 | Dispatcher Rules:\r | |
022c6d45 | 23 | The rules for the dispatcher are in chapter 10 of the DXE CIS. Figure 10-3\r |
28a00297 | 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 | |
54cd17e9 | 29 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 30 | This program and the accompanying materials\r |
23c98c94 | 31 | are licensed and made available under the terms and conditions of the BSD License\r |
32 | which accompanies this distribution. The full text of the license may be found at\r | |
33 | http://opensource.org/licenses/bsd-license.php\r | |
34 | \r | |
35 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
36 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
797a9d67 | 37 | \r |
38 | **/\r | |
28a00297 | 39 | \r |
9c4ac31c | 40 | #include "DxeMain.h"\r |
28a00297 | 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 | |
022c6d45 | 46 | LIST_ENTRY mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList);\r |
28a00297 | 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 | |
52 | LIST_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 | |
57 | LIST_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 | |
62 | EFI_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 | |
68 | BOOLEAN gDispatcherRunning = FALSE;\r | |
69 | \r | |
70 | //\r | |
71 | // Module globals to manage the FwVol registration notification event\r | |
72 | //\r | |
73 | EFI_EVENT mFwVolEvent;\r | |
74 | VOID *mFwVolEventRegistration;\r | |
75 | \r | |
76 | //\r | |
77 | // List of file types supported by dispatcher\r | |
78 | //\r | |
022c6d45 | 79 | EFI_FV_FILETYPE mDxeFileTypes[] = {\r |
80 | EFI_FV_FILETYPE_DRIVER,\r | |
202c3279 | 81 | EFI_FV_FILETYPE_COMBINED_SMM_DXE,\r |
022c6d45 | 82 | EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,\r |
28a00297 | 83 | EFI_FV_FILETYPE_DXE_CORE,\r |
84 | EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r | |
85 | };\r | |
86 | \r | |
87 | typedef struct {\r | |
88 | MEDIA_FW_VOL_FILEPATH_DEVICE_PATH File;\r | |
89 | EFI_DEVICE_PATH_PROTOCOL End;\r | |
90 | } FV_FILEPATH_DEVICE_PATH;\r | |
91 | \r | |
92 | FV_FILEPATH_DEVICE_PATH mFvDevicePath;\r | |
93 | \r | |
94 | \r | |
95 | //\r | |
96 | // Function Prototypes\r | |
97 | //\r | |
162ed594 | 98 | /**\r |
99 | Insert InsertedDriverEntry onto the mScheduledQueue. To do this you\r | |
100 | must add any driver with a before dependency on InsertedDriverEntry first.\r | |
101 | You do this by recursively calling this routine. After all the Befores are\r | |
102 | processed you can add InsertedDriverEntry to the mScheduledQueue.\r | |
103 | Then you can add any driver with an After dependency on InsertedDriverEntry\r | |
104 | by recursively calling this routine.\r | |
105 | \r | |
106 | @param InsertedDriverEntry The driver to insert on the ScheduledLink Queue\r | |
107 | \r | |
108 | **/\r | |
28a00297 | 109 | VOID\r |
110 | CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r | |
111 | IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry\r | |
112 | );\r | |
022c6d45 | 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 | |
022c6d45 | 127 | @param Event The Event that is being processed, not used.\r |
162ed594 | 128 | @param Context Event Context, not used.\r |
129 | \r | |
130 | **/\r | |
28a00297 | 131 | VOID\r |
132 | EFIAPI\r | |
133 | CoreFwVolEventProtocolNotify (\r | |
134 | IN EFI_EVENT Event,\r | |
135 | IN VOID *Context\r | |
136 | );\r | |
137 | \r | |
162ed594 | 138 | /**\r |
022c6d45 | 139 | Convert FvHandle and DriverName into an EFI device path\r |
162ed594 | 140 | \r |
022c6d45 | 141 | @param Fv Fv protocol, needed to read Depex info out of\r |
142 | FLASH.\r | |
143 | @param FvHandle Handle for Fv, needed in the\r | |
144 | EFI_CORE_DRIVER_ENTRY so that the PE image can be\r | |
145 | read out of the FV at a later time.\r | |
146 | @param DriverName Name of driver to add to mDiscoveredList.\r | |
162ed594 | 147 | \r |
148 | @return Pointer to device path constructed from FvHandle and DriverName\r | |
149 | \r | |
150 | **/\r | |
28a00297 | 151 | EFI_DEVICE_PATH_PROTOCOL *\r |
152 | CoreFvToDevicePath (\r | |
0c2b5da8 | 153 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r |
28a00297 | 154 | IN EFI_HANDLE FvHandle,\r |
155 | IN EFI_GUID *DriverName\r | |
156 | );\r | |
157 | \r | |
162ed594 | 158 | /**\r |
159 | Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r | |
160 | and initilize any state variables. Read the Depex from the FV and store it\r | |
161 | in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.\r | |
162 | The Discovered list is never free'ed and contains booleans that represent the\r | |
163 | other possible DXE driver states.\r | |
164 | \r | |
022c6d45 | 165 | @param Fv Fv protocol, needed to read Depex info out of\r |
166 | FLASH.\r | |
167 | @param FvHandle Handle for Fv, needed in the\r | |
168 | EFI_CORE_DRIVER_ENTRY so that the PE image can be\r | |
169 | read out of the FV at a later time.\r | |
170 | @param DriverName Name of driver to add to mDiscoveredList.\r | |
d3592549 | 171 | @param Type Fv File Type of file to add to mDiscoveredList.\r |
162ed594 | 172 | \r |
022c6d45 | 173 | @retval EFI_SUCCESS If driver was added to the mDiscoveredList.\r |
174 | @retval EFI_ALREADY_STARTED The driver has already been started. Only one\r | |
175 | DriverName may be active in the system at any one\r | |
162ed594 | 176 | time.\r |
177 | \r | |
178 | **/\r | |
28a00297 | 179 | EFI_STATUS\r |
180 | CoreAddToDriverList (\r | |
23c98c94 | 181 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r |
182 | IN EFI_HANDLE FvHandle,\r | |
d3592549 LG |
183 | IN EFI_GUID *DriverName,\r |
184 | IN EFI_FV_FILETYPE Type\r | |
28a00297 | 185 | );\r |
186 | \r | |
162ed594 | 187 | /**\r |
188 | Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.\r | |
189 | \r | |
022c6d45 | 190 | @param Fv The FIRMWARE_VOLUME protocol installed on the FV.\r |
191 | @param FvHandle The handle which FVB protocol installed on.\r | |
192 | @param DriverName The driver guid specified.\r | |
162ed594 | 193 | \r |
022c6d45 | 194 | @retval EFI_OUT_OF_RESOURCES No enough memory or other resource.\r |
195 | @retval EFI_VOLUME_CORRUPTED Corrupted volume.\r | |
162ed594 | 196 | @retval EFI_SUCCESS Function successfully returned.\r |
197 | \r | |
198 | **/\r | |
022c6d45 | 199 | EFI_STATUS\r |
28a00297 | 200 | CoreProcessFvImageFile (\r |
0c2b5da8 | 201 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r |
28a00297 | 202 | IN EFI_HANDLE FvHandle,\r |
203 | IN EFI_GUID *DriverName\r | |
204 | );\r | |
205 | \r | |
162ed594 | 206 | \r |
207 | /**\r | |
208 | Enter critical section by gaining lock on mDispatcherLock.\r | |
209 | \r | |
210 | **/\r | |
28a00297 | 211 | VOID\r |
212 | CoreAcquireDispatcherLock (\r | |
213 | VOID\r | |
214 | )\r | |
28a00297 | 215 | {\r |
216 | CoreAcquireLock (&mDispatcherLock);\r | |
217 | }\r | |
218 | \r | |
162ed594 | 219 | \r |
220 | /**\r | |
221 | Exit critical section by releasing lock on mDispatcherLock.\r | |
222 | \r | |
223 | **/\r | |
28a00297 | 224 | VOID\r |
225 | CoreReleaseDispatcherLock (\r | |
226 | VOID\r | |
227 | )\r | |
28a00297 | 228 | {\r |
229 | CoreReleaseLock (&mDispatcherLock);\r | |
230 | }\r | |
231 | \r | |
28a00297 | 232 | \r |
162ed594 | 233 | /**\r |
28a00297 | 234 | Read Depex and pre-process the Depex for Before and After. If Section Extraction\r |
235 | protocol returns an error via ReadSection defer the reading of the Depex.\r | |
236 | \r | |
022c6d45 | 237 | @param DriverEntry Driver to work on.\r |
28a00297 | 238 | \r |
022c6d45 | 239 | @retval EFI_SUCCESS Depex read and preprossesed\r |
240 | @retval EFI_PROTOCOL_ERROR The section extraction protocol returned an error\r | |
241 | and Depex reading needs to be retried.\r | |
162ed594 | 242 | @retval Error DEPEX not found.\r |
28a00297 | 243 | \r |
162ed594 | 244 | **/\r |
162ed594 | 245 | EFI_STATUS\r |
246 | CoreGetDepexSectionAndPreProccess (\r | |
247 | IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r | |
248 | )\r | |
28a00297 | 249 | {\r |
250 | EFI_STATUS Status;\r | |
251 | EFI_SECTION_TYPE SectionType;\r | |
252 | UINT32 AuthenticationStatus;\r | |
0c2b5da8 | 253 | EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r |
28a00297 | 254 | \r |
022c6d45 | 255 | \r |
28a00297 | 256 | Fv = DriverEntry->Fv;\r |
257 | \r | |
258 | //\r | |
259 | // Grab Depex info, it will never be free'ed.\r | |
260 | //\r | |
261 | SectionType = EFI_SECTION_DXE_DEPEX;\r | |
262 | Status = Fv->ReadSection (\r | |
022c6d45 | 263 | DriverEntry->Fv,\r |
28a00297 | 264 | &DriverEntry->FileName,\r |
022c6d45 | 265 | SectionType,\r |
266 | 0,\r | |
267 | &DriverEntry->Depex,\r | |
28a00297 | 268 | (UINTN *)&DriverEntry->DepexSize,\r |
269 | &AuthenticationStatus\r | |
270 | );\r | |
271 | if (EFI_ERROR (Status)) {\r | |
272 | if (Status == EFI_PROTOCOL_ERROR) {\r | |
273 | //\r | |
274 | // The section extraction protocol failed so set protocol error flag\r | |
275 | //\r | |
276 | DriverEntry->DepexProtocolError = TRUE;\r | |
277 | } else {\r | |
278 | //\r | |
8a7d75b0 | 279 | // If no Depex assume UEFI 2.0 driver model\r |
28a00297 | 280 | //\r |
281 | DriverEntry->Depex = NULL;\r | |
282 | DriverEntry->Dependent = TRUE;\r | |
283 | DriverEntry->DepexProtocolError = FALSE;\r | |
284 | }\r | |
285 | } else {\r | |
286 | //\r | |
287 | // Set Before, After, and Unrequested state information based on Depex\r | |
288 | // Driver will be put in Dependent or Unrequested state\r | |
289 | //\r | |
290 | CorePreProcessDepex (DriverEntry);\r | |
291 | DriverEntry->DepexProtocolError = FALSE;\r | |
022c6d45 | 292 | }\r |
28a00297 | 293 | \r |
294 | return Status;\r | |
295 | }\r | |
296 | \r | |
162ed594 | 297 | \r |
298 | /**\r | |
299 | Check every driver and locate a matching one. If the driver is found, the Unrequested\r | |
300 | state flag is cleared.\r | |
301 | \r | |
022c6d45 | 302 | @param FirmwareVolumeHandle The handle of the Firmware Volume that contains\r |
303 | the firmware file specified by DriverName.\r | |
304 | @param DriverName The Driver name to put in the Dependent state.\r | |
162ed594 | 305 | \r |
022c6d45 | 306 | @retval EFI_SUCCESS The DriverName was found and it's SOR bit was\r |
307 | cleared\r | |
308 | @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was\r | |
309 | not set.\r | |
162ed594 | 310 | \r |
311 | **/\r | |
28a00297 | 312 | EFI_STATUS\r |
313 | EFIAPI\r | |
314 | CoreSchedule (\r | |
315 | IN EFI_HANDLE FirmwareVolumeHandle,\r | |
316 | IN EFI_GUID *DriverName\r | |
317 | )\r | |
28a00297 | 318 | {\r |
319 | LIST_ENTRY *Link;\r | |
320 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
321 | \r | |
322 | //\r | |
323 | // Check every driver\r | |
324 | //\r | |
325 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
326 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
327 | if (DriverEntry->FvHandle == FirmwareVolumeHandle &&\r | |
022c6d45 | 328 | DriverEntry->Unrequested &&\r |
28a00297 | 329 | CompareGuid (DriverName, &DriverEntry->FileName)) {\r |
330 | //\r | |
331 | // Move the driver from the Unrequested to the Dependent state\r | |
332 | //\r | |
333 | CoreAcquireDispatcherLock ();\r | |
334 | DriverEntry->Unrequested = FALSE;\r | |
335 | DriverEntry->Dependent = TRUE;\r | |
336 | CoreReleaseDispatcherLock ();\r | |
022c6d45 | 337 | \r |
6a55eea3 | 338 | DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_SUCCESS\n", DriverName));\r |
339 | \r | |
28a00297 | 340 | return EFI_SUCCESS;\r |
341 | }\r | |
342 | }\r | |
6a55eea3 | 343 | \r |
344 | DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_NOT_FOUND\n", DriverName));\r | |
345 | \r | |
022c6d45 | 346 | return EFI_NOT_FOUND;\r |
28a00297 | 347 | }\r |
348 | \r | |
349 | \r | |
162ed594 | 350 | \r |
351 | /**\r | |
e94a9ff7 | 352 | Convert a driver from the Untrused back to the Scheduled state.\r |
162ed594 | 353 | \r |
022c6d45 | 354 | @param FirmwareVolumeHandle The handle of the Firmware Volume that contains\r |
355 | the firmware file specified by DriverName.\r | |
356 | @param DriverName The Driver name to put in the Scheduled state\r | |
162ed594 | 357 | \r |
022c6d45 | 358 | @retval EFI_SUCCESS The file was found in the untrusted state, and it\r |
359 | was promoted to the trusted state.\r | |
360 | @retval EFI_NOT_FOUND The file was not found in the untrusted state.\r | |
162ed594 | 361 | \r |
362 | **/\r | |
28a00297 | 363 | EFI_STATUS\r |
364 | EFIAPI\r | |
365 | CoreTrust (\r | |
366 | IN EFI_HANDLE FirmwareVolumeHandle,\r | |
367 | IN EFI_GUID *DriverName\r | |
368 | )\r | |
28a00297 | 369 | {\r |
370 | LIST_ENTRY *Link;\r | |
371 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
372 | \r | |
373 | //\r | |
374 | // Check every driver\r | |
375 | //\r | |
376 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
377 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
378 | if (DriverEntry->FvHandle == FirmwareVolumeHandle &&\r | |
022c6d45 | 379 | DriverEntry->Untrusted &&\r |
28a00297 | 380 | CompareGuid (DriverName, &DriverEntry->FileName)) {\r |
381 | //\r | |
382 | // Transition driver from Untrusted to Scheduled state.\r | |
383 | //\r | |
384 | CoreAcquireDispatcherLock ();\r | |
385 | DriverEntry->Untrusted = FALSE;\r | |
386 | DriverEntry->Scheduled = TRUE;\r | |
387 | InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);\r | |
388 | CoreReleaseDispatcherLock ();\r | |
022c6d45 | 389 | \r |
28a00297 | 390 | return EFI_SUCCESS;\r |
391 | }\r | |
392 | }\r | |
022c6d45 | 393 | return EFI_NOT_FOUND;\r |
28a00297 | 394 | }\r |
395 | \r | |
396 | \r | |
202c3279 | 397 | /**\r |
398 | An empty function to pass error checking of CreateEventEx ().\r | |
399 | \r | |
400 | @param Event Event whose notification function is being invoked.\r | |
401 | @param Context Pointer to the notification function's context,\r | |
402 | which is implementation-dependent.\r | |
403 | \r | |
404 | **/\r | |
405 | VOID\r | |
406 | EFIAPI\r | |
54cd17e9 | 407 | CoreEmptyCallbackFunction (\r |
202c3279 | 408 | IN EFI_EVENT Event,\r |
409 | IN VOID *Context\r | |
410 | )\r | |
411 | {\r | |
412 | return;\r | |
413 | }\r | |
28a00297 | 414 | \r |
162ed594 | 415 | /**\r |
416 | This is the main Dispatcher for DXE and it exits when there are no more\r | |
28a00297 | 417 | drivers to run. Drain the mScheduledQueue and load and start a PE\r |
162ed594 | 418 | image for each driver. Search the mDiscoveredList to see if any driver can\r |
28a00297 | 419 | be placed on the mScheduledQueue. If no drivers are placed on the\r |
420 | mScheduledQueue exit the function. On exit it is assumed the Bds()\r | |
162ed594 | 421 | will be called, and when the Bds() exits the Dispatcher will be called\r |
28a00297 | 422 | again.\r |
423 | \r | |
022c6d45 | 424 | @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running\r |
425 | @retval EFI_NOT_FOUND No DXE Drivers were dispatched\r | |
426 | @retval EFI_SUCCESS One or more DXE Drivers were dispatched\r | |
28a00297 | 427 | \r |
162ed594 | 428 | **/\r |
162ed594 | 429 | EFI_STATUS\r |
430 | EFIAPI\r | |
431 | CoreDispatcher (\r | |
432 | VOID\r | |
433 | )\r | |
28a00297 | 434 | {\r |
435 | EFI_STATUS Status;\r | |
436 | EFI_STATUS ReturnStatus;\r | |
437 | LIST_ENTRY *Link;\r | |
438 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
439 | BOOLEAN ReadyToRun;\r | |
202c3279 | 440 | EFI_EVENT DxeDispatchEvent;\r |
441 | \r | |
28a00297 | 442 | \r |
443 | if (gDispatcherRunning) {\r | |
444 | //\r | |
445 | // If the dispatcher is running don't let it be restarted.\r | |
446 | //\r | |
447 | return EFI_ALREADY_STARTED;\r | |
448 | }\r | |
449 | \r | |
450 | gDispatcherRunning = TRUE;\r | |
451 | \r | |
202c3279 | 452 | Status = CoreCreateEventEx (\r |
453 | EVT_NOTIFY_SIGNAL,\r | |
454 | TPL_NOTIFY,\r | |
54cd17e9 | 455 | CoreEmptyCallbackFunction,\r |
202c3279 | 456 | NULL,\r |
457 | &gEfiEventDxeDispatchGuid,\r | |
458 | &DxeDispatchEvent\r | |
459 | );\r | |
460 | if (EFI_ERROR (Status)) {\r | |
461 | return Status;\r | |
462 | }\r | |
28a00297 | 463 | \r |
464 | ReturnStatus = EFI_NOT_FOUND;\r | |
465 | do {\r | |
466 | //\r | |
467 | // Drain the Scheduled Queue\r | |
468 | //\r | |
469 | while (!IsListEmpty (&mScheduledQueue)) {\r | |
470 | DriverEntry = CR (\r | |
471 | mScheduledQueue.ForwardLink,\r | |
472 | EFI_CORE_DRIVER_ENTRY,\r | |
473 | ScheduledLink,\r | |
474 | EFI_CORE_DRIVER_ENTRY_SIGNATURE\r | |
475 | );\r | |
476 | \r | |
477 | //\r | |
478 | // Load the DXE Driver image into memory. If the Driver was transitioned from\r | |
479 | // Untrused to Scheduled it would have already been loaded so we may need to\r | |
480 | // skip the LoadImage\r | |
481 | //\r | |
d3592549 | 482 | if (DriverEntry->ImageHandle == NULL && !DriverEntry->IsFvImage) {\r |
94903510 | 483 | DEBUG ((DEBUG_INFO, "Loading driver %g\n", &DriverEntry->FileName));\r |
28a00297 | 484 | Status = CoreLoadImage (\r |
022c6d45 | 485 | FALSE,\r |
486 | gDxeCoreImageHandle,\r | |
28a00297 | 487 | DriverEntry->FvFileDevicePath,\r |
022c6d45 | 488 | NULL,\r |
489 | 0,\r | |
28a00297 | 490 | &DriverEntry->ImageHandle\r |
491 | );\r | |
492 | \r | |
493 | //\r | |
494 | // Update the driver state to reflect that it's been loaded\r | |
495 | //\r | |
496 | if (EFI_ERROR (Status)) {\r | |
497 | CoreAcquireDispatcherLock ();\r | |
498 | \r | |
499 | if (Status == EFI_SECURITY_VIOLATION) {\r | |
500 | //\r | |
501 | // Take driver from Scheduled to Untrused state\r | |
502 | //\r | |
503 | DriverEntry->Untrusted = TRUE;\r | |
504 | } else {\r | |
505 | //\r | |
506 | // The DXE Driver could not be loaded, and do not attempt to load or start it again.\r | |
022c6d45 | 507 | // Take driver from Scheduled to Initialized.\r |
28a00297 | 508 | //\r |
509 | // This case include the Never Trusted state if EFI_ACCESS_DENIED is returned\r | |
510 | //\r | |
511 | DriverEntry->Initialized = TRUE;\r | |
512 | }\r | |
513 | \r | |
514 | DriverEntry->Scheduled = FALSE;\r | |
515 | RemoveEntryList (&DriverEntry->ScheduledLink);\r | |
022c6d45 | 516 | \r |
28a00297 | 517 | CoreReleaseDispatcherLock ();\r |
022c6d45 | 518 | \r |
28a00297 | 519 | //\r |
520 | // If it's an error don't try the StartImage\r | |
521 | //\r | |
522 | continue;\r | |
523 | }\r | |
524 | }\r | |
525 | \r | |
526 | CoreAcquireDispatcherLock ();\r | |
527 | \r | |
528 | DriverEntry->Scheduled = FALSE;\r | |
529 | DriverEntry->Initialized = TRUE;\r | |
530 | RemoveEntryList (&DriverEntry->ScheduledLink);\r | |
022c6d45 | 531 | \r |
28a00297 | 532 | CoreReleaseDispatcherLock ();\r |
533 | \r | |
2680a308 | 534 | \r |
d3592549 LG |
535 | if (DriverEntry->IsFvImage) {\r |
536 | //\r | |
537 | // Produce a firmware volume block protocol for FvImage so it gets dispatched from. \r | |
538 | //\r | |
539 | Status = CoreProcessFvImageFile (DriverEntry->Fv, DriverEntry->FvHandle, &DriverEntry->FileName);\r | |
540 | } else {\r | |
541 | REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r | |
542 | EFI_PROGRESS_CODE,\r | |
543 | (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_BEGIN),\r | |
544 | &DriverEntry->ImageHandle,\r | |
545 | sizeof (DriverEntry->ImageHandle)\r | |
546 | );\r | |
547 | \r | |
548 | Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);\r | |
549 | \r | |
550 | REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r | |
551 | EFI_PROGRESS_CODE,\r | |
552 | (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_END),\r | |
553 | &DriverEntry->ImageHandle,\r | |
554 | sizeof (DriverEntry->ImageHandle)\r | |
555 | );\r | |
556 | }\r | |
28a00297 | 557 | \r |
558 | ReturnStatus = EFI_SUCCESS;\r | |
559 | }\r | |
560 | \r | |
0e4483bc LG |
561 | //\r |
562 | // Now DXE Dispatcher finished one round of dispatch, signal an event group\r | |
563 | // so that SMM Dispatcher get chance to dispatch SMM Drivers which depend\r | |
564 | // on UEFI protocols\r | |
565 | //\r | |
566 | if (!EFI_ERROR (ReturnStatus)) {\r | |
567 | CoreSignalEvent (DxeDispatchEvent);\r | |
568 | }\r | |
569 | \r | |
28a00297 | 570 | //\r |
571 | // Search DriverList for items to place on Scheduled Queue\r | |
572 | //\r | |
573 | ReadyToRun = FALSE;\r | |
574 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
575 | DriverEntry = CR (Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
576 | \r | |
577 | if (DriverEntry->DepexProtocolError){\r | |
578 | //\r | |
579 | // If Section Extraction Protocol did not let the Depex be read before retry the read\r | |
580 | //\r | |
581 | Status = CoreGetDepexSectionAndPreProccess (DriverEntry);\r | |
022c6d45 | 582 | }\r |
28a00297 | 583 | \r |
584 | if (DriverEntry->Dependent) {\r | |
585 | if (CoreIsSchedulable (DriverEntry)) {\r | |
022c6d45 | 586 | CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r |
28a00297 | 587 | ReadyToRun = TRUE;\r |
022c6d45 | 588 | }\r |
6a55eea3 | 589 | } else {\r |
590 | if (DriverEntry->Unrequested) {\r | |
591 | DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r | |
592 | DEBUG ((DEBUG_DISPATCH, " SOR = Not Requested\n"));\r | |
593 | DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE\n"));\r | |
594 | }\r | |
28a00297 | 595 | }\r |
596 | }\r | |
597 | } while (ReadyToRun);\r | |
598 | \r | |
202c3279 | 599 | //\r |
600 | // Close DXE dispatch Event\r | |
601 | //\r | |
602 | CoreCloseEvent (DxeDispatchEvent);\r | |
603 | \r | |
28a00297 | 604 | gDispatcherRunning = FALSE;\r |
605 | \r | |
606 | return ReturnStatus;\r | |
607 | }\r | |
608 | \r | |
28a00297 | 609 | \r |
162ed594 | 610 | /**\r |
611 | Insert InsertedDriverEntry onto the mScheduledQueue. To do this you\r | |
28a00297 | 612 | must add any driver with a before dependency on InsertedDriverEntry first.\r |
613 | You do this by recursively calling this routine. After all the Befores are\r | |
162ed594 | 614 | processed you can add InsertedDriverEntry to the mScheduledQueue.\r |
615 | Then you can add any driver with an After dependency on InsertedDriverEntry\r | |
28a00297 | 616 | by recursively calling this routine.\r |
617 | \r | |
162ed594 | 618 | @param InsertedDriverEntry The driver to insert on the ScheduledLink Queue\r |
28a00297 | 619 | \r |
162ed594 | 620 | **/\r |
162ed594 | 621 | VOID\r |
622 | CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r | |
623 | IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry\r | |
624 | )\r | |
28a00297 | 625 | {\r |
626 | LIST_ENTRY *Link;\r | |
627 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
628 | \r | |
629 | //\r | |
630 | // Process Before Dependency\r | |
631 | //\r | |
632 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
633 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
6a55eea3 | 634 | if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {\r |
635 | DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r | |
636 | DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));\r | |
28a00297 | 637 | if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r |
638 | //\r | |
639 | // Recursively process BEFORE\r | |
640 | //\r | |
6a55eea3 | 641 | DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));\r |
28a00297 | 642 | CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r |
6a55eea3 | 643 | } else {\r |
644 | DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));\r | |
28a00297 | 645 | }\r |
646 | }\r | |
647 | }\r | |
648 | \r | |
649 | //\r | |
650 | // Convert driver from Dependent to Scheduled state\r | |
651 | //\r | |
652 | CoreAcquireDispatcherLock ();\r | |
653 | \r | |
654 | InsertedDriverEntry->Dependent = FALSE;\r | |
655 | InsertedDriverEntry->Scheduled = TRUE;\r | |
656 | InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);\r | |
022c6d45 | 657 | \r |
28a00297 | 658 | CoreReleaseDispatcherLock ();\r |
659 | \r | |
660 | //\r | |
661 | // Process After Dependency\r | |
662 | //\r | |
663 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
664 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
6a55eea3 | 665 | if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {\r |
666 | DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r | |
667 | DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));\r | |
28a00297 | 668 | if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r |
669 | //\r | |
670 | // Recursively process AFTER\r | |
671 | //\r | |
6a55eea3 | 672 | DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));\r |
28a00297 | 673 | CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r |
6a55eea3 | 674 | } else {\r |
675 | DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));\r | |
28a00297 | 676 | }\r |
677 | }\r | |
678 | }\r | |
679 | }\r | |
680 | \r | |
28a00297 | 681 | \r |
162ed594 | 682 | /**\r |
28a00297 | 683 | Return TRUE if the Fv has been processed, FALSE if not.\r |
684 | \r | |
022c6d45 | 685 | @param FvHandle The handle of a FV that's being tested\r |
28a00297 | 686 | \r |
022c6d45 | 687 | @retval TRUE Fv protocol on FvHandle has been processed\r |
e94a9ff7 | 688 | @retval FALSE Fv protocol on FvHandle has not yet been processed\r |
28a00297 | 689 | \r |
162ed594 | 690 | **/\r |
162ed594 | 691 | BOOLEAN\r |
692 | FvHasBeenProcessed (\r | |
693 | IN EFI_HANDLE FvHandle\r | |
694 | )\r | |
28a00297 | 695 | {\r |
696 | LIST_ENTRY *Link;\r | |
697 | KNOWN_HANDLE *KnownHandle;\r | |
698 | \r | |
699 | for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {\r | |
700 | KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);\r | |
701 | if (KnownHandle->Handle == FvHandle) {\r | |
702 | return TRUE;\r | |
703 | }\r | |
704 | }\r | |
705 | return FALSE;\r | |
706 | }\r | |
707 | \r | |
28a00297 | 708 | \r |
162ed594 | 709 | /**\r |
28a00297 | 710 | Remember that Fv protocol on FvHandle has had it's drivers placed on the\r |
2fc46f86 LG |
711 | mDiscoveredList. This fucntion adds entries on the mFvHandleList if new \r |
712 | entry is different from one in mFvHandleList by checking FvImage Guid.\r | |
713 | Items are never removed/freed from the mFvHandleList.\r | |
28a00297 | 714 | \r |
162ed594 | 715 | @param FvHandle The handle of a FV that has been processed\r |
28a00297 | 716 | \r |
2fc46f86 LG |
717 | @return A point to new added FvHandle entry. If FvHandle with the same FvImage guid\r |
718 | has been added, NULL will return. \r | |
719 | \r | |
162ed594 | 720 | **/\r |
2fc46f86 | 721 | KNOWN_HANDLE * \r |
162ed594 | 722 | FvIsBeingProcesssed (\r |
723 | IN EFI_HANDLE FvHandle\r | |
724 | )\r | |
28a00297 | 725 | {\r |
2fc46f86 LG |
726 | EFI_STATUS Status;\r |
727 | EFI_GUID FvNameGuid;\r | |
728 | BOOLEAN FvNameGuidIsFound;\r | |
729 | UINT32 ExtHeaderOffset;\r | |
730 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r | |
731 | EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r | |
732 | EFI_FV_BLOCK_MAP_ENTRY *BlockMap;\r | |
733 | UINTN LbaOffset;\r | |
734 | UINTN Index;\r | |
735 | EFI_LBA LbaIndex;\r | |
736 | LIST_ENTRY *Link;\r | |
737 | KNOWN_HANDLE *KnownHandle;\r | |
738 | \r | |
739 | //\r | |
740 | // Get the FirmwareVolumeBlock protocol on that handle\r | |
741 | //\r | |
742 | FvNameGuidIsFound = FALSE;\r | |
743 | Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);\r | |
744 | if (!EFI_ERROR (Status)) {\r | |
745 | //\r | |
746 | // Get the full FV header based on FVB protocol.\r | |
747 | //\r | |
748 | Status = GetFwVolHeader (Fvb, &FwVolHeader);\r | |
749 | if (EFI_ERROR (Status)) {\r | |
750 | FwVolHeader = NULL;\r | |
751 | } else if (VerifyFvHeaderChecksum (FwVolHeader) && FwVolHeader->ExtHeaderOffset != 0) {\r | |
752 | ExtHeaderOffset = (UINT32) FwVolHeader->ExtHeaderOffset;\r | |
753 | BlockMap = FwVolHeader->BlockMap;\r | |
754 | LbaIndex = 0;\r | |
755 | LbaOffset = 0;\r | |
756 | //\r | |
757 | // Find LbaIndex and LbaOffset for FV extension header based on BlockMap.\r | |
758 | //\r | |
759 | while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {\r | |
760 | for (Index = 0; Index < BlockMap->NumBlocks && ExtHeaderOffset >= BlockMap->Length; Index ++) {\r | |
761 | ExtHeaderOffset -= BlockMap->Length;\r | |
762 | LbaIndex ++;\r | |
763 | }\r | |
764 | //\r | |
765 | // Check whether FvExtHeader is crossing the multi block range.\r | |
766 | //\r | |
767 | if (Index < BlockMap->NumBlocks) {\r | |
768 | LbaOffset = ExtHeaderOffset;\r | |
769 | break;\r | |
770 | }\r | |
771 | BlockMap++;\r | |
772 | }\r | |
773 | //\r | |
774 | // Read FvNameGuid from FV extension header.\r | |
775 | //\r | |
776 | Status = ReadFvbData (Fvb, &LbaIndex, &LbaOffset, sizeof (FvNameGuid), (UINT8 *) &FvNameGuid);\r | |
777 | if (!EFI_ERROR (Status)) {\r | |
778 | FvNameGuidIsFound = TRUE;\r | |
779 | }\r | |
780 | }\r | |
781 | CoreFreePool (FwVolHeader);\r | |
782 | }\r | |
783 | \r | |
784 | if (FvNameGuidIsFound) {\r | |
785 | //\r | |
786 | // Check whether the FV image with the found FvNameGuid has been processed.\r | |
787 | //\r | |
788 | for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {\r | |
789 | KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);\r | |
790 | if (CompareGuid (&FvNameGuid, &KnownHandle->FvNameGuid)) {\r | |
791 | DEBUG ((EFI_D_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, FvNameGuid));\r | |
792 | return NULL;\r | |
793 | }\r | |
794 | }\r | |
795 | }\r | |
28a00297 | 796 | \r |
2fc46f86 | 797 | KnownHandle = AllocateZeroPool (sizeof (KNOWN_HANDLE));\r |
28a00297 | 798 | ASSERT (KnownHandle != NULL);\r |
799 | \r | |
800 | KnownHandle->Signature = KNOWN_HANDLE_SIGNATURE;\r | |
801 | KnownHandle->Handle = FvHandle;\r | |
2fc46f86 LG |
802 | if (FvNameGuidIsFound) {\r |
803 | CopyGuid (&KnownHandle->FvNameGuid, &FvNameGuid);\r | |
804 | }\r | |
28a00297 | 805 | InsertTailList (&mFvHandleList, &KnownHandle->Link);\r |
2fc46f86 | 806 | return KnownHandle;\r |
28a00297 | 807 | }\r |
808 | \r | |
809 | \r | |
810 | \r | |
162ed594 | 811 | \r |
812 | /**\r | |
813 | Convert FvHandle and DriverName into an EFI device path\r | |
814 | \r | |
022c6d45 | 815 | @param Fv Fv protocol, needed to read Depex info out of\r |
816 | FLASH.\r | |
817 | @param FvHandle Handle for Fv, needed in the\r | |
818 | EFI_CORE_DRIVER_ENTRY so that the PE image can be\r | |
819 | read out of the FV at a later time.\r | |
820 | @param DriverName Name of driver to add to mDiscoveredList.\r | |
162ed594 | 821 | \r |
822 | @return Pointer to device path constructed from FvHandle and DriverName\r | |
823 | \r | |
824 | **/\r | |
28a00297 | 825 | EFI_DEVICE_PATH_PROTOCOL *\r |
826 | CoreFvToDevicePath (\r | |
0c2b5da8 | 827 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r |
28a00297 | 828 | IN EFI_HANDLE FvHandle,\r |
829 | IN EFI_GUID *DriverName\r | |
830 | )\r | |
28a00297 | 831 | {\r |
832 | EFI_STATUS Status;\r | |
833 | EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;\r | |
834 | EFI_DEVICE_PATH_PROTOCOL *FileNameDevicePath;\r | |
835 | \r | |
836 | //\r | |
837 | // Remember the device path of the FV\r | |
838 | //\r | |
839 | Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);\r | |
840 | if (EFI_ERROR (Status)) {\r | |
841 | FileNameDevicePath = NULL;\r | |
842 | } else {\r | |
843 | //\r | |
844 | // Build a device path to the file in the FV to pass into gBS->LoadImage\r | |
845 | //\r | |
846 | EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);\r | |
1232b214 | 847 | SetDevicePathEndNode (&mFvDevicePath.End);\r |
28a00297 | 848 | \r |
9c4ac31c | 849 | FileNameDevicePath = AppendDevicePath (\r |
022c6d45 | 850 | FvDevicePath,\r |
28a00297 | 851 | (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath\r |
852 | );\r | |
853 | }\r | |
854 | \r | |
855 | return FileNameDevicePath;\r | |
856 | }\r | |
857 | \r | |
858 | \r | |
859 | \r | |
162ed594 | 860 | /**\r |
861 | Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r | |
28a00297 | 862 | and initilize any state variables. Read the Depex from the FV and store it\r |
863 | in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.\r | |
864 | The Discovered list is never free'ed and contains booleans that represent the\r | |
865 | other possible DXE driver states.\r | |
866 | \r | |
022c6d45 | 867 | @param Fv Fv protocol, needed to read Depex info out of\r |
868 | FLASH.\r | |
869 | @param FvHandle Handle for Fv, needed in the\r | |
870 | EFI_CORE_DRIVER_ENTRY so that the PE image can be\r | |
871 | read out of the FV at a later time.\r | |
872 | @param DriverName Name of driver to add to mDiscoveredList.\r | |
d3592549 | 873 | @param Type Fv File Type of file to add to mDiscoveredList.\r |
28a00297 | 874 | \r |
022c6d45 | 875 | @retval EFI_SUCCESS If driver was added to the mDiscoveredList.\r |
876 | @retval EFI_ALREADY_STARTED The driver has already been started. Only one\r | |
877 | DriverName may be active in the system at any one\r | |
162ed594 | 878 | time.\r |
28a00297 | 879 | \r |
162ed594 | 880 | **/\r |
881 | EFI_STATUS\r | |
882 | CoreAddToDriverList (\r | |
883 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r | |
884 | IN EFI_HANDLE FvHandle,\r | |
d3592549 LG |
885 | IN EFI_GUID *DriverName,\r |
886 | IN EFI_FV_FILETYPE Type\r | |
162ed594 | 887 | )\r |
28a00297 | 888 | {\r |
889 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
890 | \r | |
022c6d45 | 891 | \r |
28a00297 | 892 | //\r |
022c6d45 | 893 | // Create the Driver Entry for the list. ZeroPool initializes lots of variables to\r |
28a00297 | 894 | // NULL or FALSE.\r |
895 | //\r | |
9c4ac31c | 896 | DriverEntry = AllocateZeroPool (sizeof (EFI_CORE_DRIVER_ENTRY));\r |
28a00297 | 897 | ASSERT (DriverEntry != NULL);\r |
d3592549 LG |
898 | if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r |
899 | DriverEntry->IsFvImage = TRUE;\r | |
900 | }\r | |
28a00297 | 901 | \r |
902 | DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE;\r | |
e94a9ff7 | 903 | CopyGuid (&DriverEntry->FileName, DriverName);\r |
28a00297 | 904 | DriverEntry->FvHandle = FvHandle;\r |
905 | DriverEntry->Fv = Fv;\r | |
906 | DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);\r | |
907 | \r | |
908 | CoreGetDepexSectionAndPreProccess (DriverEntry);\r | |
022c6d45 | 909 | \r |
28a00297 | 910 | CoreAcquireDispatcherLock ();\r |
022c6d45 | 911 | \r |
28a00297 | 912 | InsertTailList (&mDiscoveredList, &DriverEntry->Link);\r |
913 | \r | |
914 | CoreReleaseDispatcherLock ();\r | |
915 | \r | |
916 | return EFI_SUCCESS;\r | |
917 | }\r | |
918 | \r | |
bbc0f1bb | 919 | \r |
162ed594 | 920 | /**\r |
bbc0f1bb | 921 | Check if a FV Image type file (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) is\r |
922 | described by a EFI_HOB_FIRMWARE_VOLUME2 Hob.\r | |
923 | \r | |
2fc46f86 | 924 | @param FvNameGuid The FV image guid specified.\r |
022c6d45 | 925 | @param DriverName The driver guid specified.\r |
bbc0f1bb | 926 | \r |
022c6d45 | 927 | @retval TRUE This file is found in a EFI_HOB_FIRMWARE_VOLUME2\r |
928 | Hob.\r | |
162ed594 | 929 | @retval FALSE Not found.\r |
bbc0f1bb | 930 | \r |
162ed594 | 931 | **/\r |
162ed594 | 932 | BOOLEAN\r |
933 | FvFoundInHobFv2 (\r | |
2fc46f86 | 934 | IN CONST EFI_GUID *FvNameGuid,\r |
162ed594 | 935 | IN CONST EFI_GUID *DriverName\r |
936 | )\r | |
bbc0f1bb | 937 | {\r |
938 | EFI_PEI_HOB_POINTERS HobFv2;\r | |
022c6d45 | 939 | \r |
bbc0f1bb | 940 | HobFv2.Raw = GetHobList ();\r |
022c6d45 | 941 | \r |
bbc0f1bb | 942 | while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {\r |
2fc46f86 LG |
943 | //\r |
944 | // Compare parent FvNameGuid and FileGuid both.\r | |
945 | //\r | |
946 | if (CompareGuid (DriverName, &HobFv2.FirmwareVolume2->FileName) &&\r | |
947 | CompareGuid (FvNameGuid, &HobFv2.FirmwareVolume2->FvName)) {\r | |
b0d803fe | 948 | return TRUE;\r |
bbc0f1bb | 949 | }\r |
950 | HobFv2.Raw = GET_NEXT_HOB (HobFv2);\r | |
951 | }\r | |
952 | \r | |
953 | return FALSE;\r | |
954 | }\r | |
28a00297 | 955 | \r |
956 | \r | |
162ed594 | 957 | \r |
958 | /**\r | |
959 | Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.\r | |
960 | \r | |
022c6d45 | 961 | @param Fv The FIRMWARE_VOLUME protocol installed on the FV.\r |
962 | @param FvHandle The handle which FVB protocol installed on.\r | |
963 | @param DriverName The driver guid specified.\r | |
162ed594 | 964 | \r |
022c6d45 | 965 | @retval EFI_OUT_OF_RESOURCES No enough memory or other resource.\r |
966 | @retval EFI_VOLUME_CORRUPTED Corrupted volume.\r | |
162ed594 | 967 | @retval EFI_SUCCESS Function successfully returned.\r |
968 | \r | |
969 | **/\r | |
022c6d45 | 970 | EFI_STATUS\r |
28a00297 | 971 | CoreProcessFvImageFile (\r |
0c2b5da8 | 972 | IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r |
28a00297 | 973 | IN EFI_HANDLE FvHandle,\r |
974 | IN EFI_GUID *DriverName\r | |
975 | )\r | |
28a00297 | 976 | {\r |
977 | EFI_STATUS Status;\r | |
978 | EFI_SECTION_TYPE SectionType;\r | |
979 | UINT32 AuthenticationStatus;\r | |
980 | VOID *Buffer;\r | |
38837959 | 981 | VOID *AlignedBuffer;\r |
28a00297 | 982 | UINTN BufferSize;\r |
38837959 | 983 | EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r |
022c6d45 | 984 | UINT32 FvAlignment;\r |
28a00297 | 985 | \r |
986 | //\r | |
987 | // Read the first (and only the first) firmware volume section\r | |
988 | //\r | |
e94a9ff7 | 989 | SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r |
990 | FvHeader = NULL;\r | |
991 | FvAlignment = 0;\r | |
992 | Buffer = NULL;\r | |
993 | BufferSize = 0;\r | |
38837959 | 994 | AlignedBuffer = NULL;\r |
28a00297 | 995 | Status = Fv->ReadSection (\r |
022c6d45 | 996 | Fv,\r |
997 | DriverName,\r | |
998 | SectionType,\r | |
999 | 0,\r | |
1000 | &Buffer,\r | |
e94a9ff7 | 1001 | &BufferSize,\r |
1002 | &AuthenticationStatus\r | |
1003 | );\r | |
28a00297 | 1004 | if (!EFI_ERROR (Status)) {\r |
1005 | //\r | |
38837959 | 1006 | // FvImage should be at its required alignment.\r |
28a00297 | 1007 | //\r |
38837959 | 1008 | FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r |
6d9a0f28 LG |
1009 | //\r |
1010 | // Get FvHeader alignment\r | |
1011 | //\r | |
38837959 LG |
1012 | FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r |
1013 | //\r | |
6d9a0f28 | 1014 | // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value. \r |
022c6d45 | 1015 | //\r |
38837959 LG |
1016 | if (FvAlignment < 8) {\r |
1017 | FvAlignment = 8;\r | |
1018 | }\r | |
e94a9ff7 | 1019 | //\r |
1020 | // Allocate the aligned buffer for the FvImage.\r | |
1021 | //\r | |
b2c5e194 | 1022 | AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r |
38837959 LG |
1023 | if (AlignedBuffer == NULL) {\r |
1024 | Status = EFI_OUT_OF_RESOURCES;\r | |
1025 | } else {\r | |
1026 | //\r | |
1027 | // Move FvImage into the aligned buffer and release the original buffer.\r | |
1028 | //\r | |
1029 | CopyMem (AlignedBuffer, Buffer, BufferSize);\r | |
1030 | CoreFreePool (Buffer);\r | |
1031 | Buffer = NULL;\r | |
1032 | //\r | |
1033 | // Produce a FVB protocol for the file\r | |
1034 | //\r | |
1035 | Status = ProduceFVBProtocolOnBuffer (\r | |
1036 | (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,\r | |
1037 | (UINT64)BufferSize,\r | |
1038 | FvHandle,\r | |
1039 | NULL\r | |
1040 | );\r | |
1041 | }\r | |
28a00297 | 1042 | }\r |
1043 | \r | |
022c6d45 | 1044 | if (EFI_ERROR (Status)) {\r |
38837959 LG |
1045 | //\r |
1046 | // ReadSection or Produce FVB failed, Free data buffer\r | |
1047 | //\r | |
1048 | if (Buffer != NULL) {\r | |
9c4ac31c | 1049 | FreePool (Buffer);\r |
38837959 | 1050 | }\r |
022c6d45 | 1051 | \r |
38837959 | 1052 | if (AlignedBuffer != NULL) {\r |
b2c5e194 | 1053 | FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));\r |
38837959 | 1054 | }\r |
28a00297 | 1055 | }\r |
1056 | \r | |
1057 | return Status;\r | |
1058 | }\r | |
1059 | \r | |
28a00297 | 1060 | \r |
162ed594 | 1061 | /**\r |
1062 | Event notification that is fired every time a FV dispatch protocol is added.\r | |
28a00297 | 1063 | More than one protocol may have been added when this event is fired, so you\r |
1064 | must loop on CoreLocateHandle () to see how many protocols were added and\r | |
1065 | do the following to each FV:\r | |
162ed594 | 1066 | If the Fv has already been processed, skip it. If the Fv has not been\r |
28a00297 | 1067 | processed then mark it as being processed, as we are about to process it.\r |
162ed594 | 1068 | Read the Fv and add any driver in the Fv to the mDiscoveredList.The\r |
28a00297 | 1069 | mDiscoveredList is never free'ed and contains variables that define\r |
162ed594 | 1070 | the other states the DXE driver transitions to..\r |
28a00297 | 1071 | While you are at it read the A Priori file into memory.\r |
1072 | Place drivers in the A Priori list onto the mScheduledQueue.\r | |
1073 | \r | |
022c6d45 | 1074 | @param Event The Event that is being processed, not used.\r |
162ed594 | 1075 | @param Context Event Context, not used.\r |
28a00297 | 1076 | \r |
162ed594 | 1077 | **/\r |
162ed594 | 1078 | VOID\r |
1079 | EFIAPI\r | |
1080 | CoreFwVolEventProtocolNotify (\r | |
1081 | IN EFI_EVENT Event,\r | |
1082 | IN VOID *Context\r | |
1083 | )\r | |
28a00297 | 1084 | {\r |
1085 | EFI_STATUS Status;\r | |
1086 | EFI_STATUS GetNextFileStatus;\r | |
1087 | EFI_STATUS SecurityStatus;\r | |
0c2b5da8 | 1088 | EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r |
28a00297 | 1089 | EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;\r |
1090 | EFI_HANDLE FvHandle;\r | |
1091 | UINTN BufferSize;\r | |
1092 | EFI_GUID NameGuid;\r | |
1093 | UINTN Key;\r | |
1094 | EFI_FV_FILETYPE Type;\r | |
1095 | EFI_FV_FILE_ATTRIBUTES Attributes;\r | |
1096 | UINTN Size;\r | |
1097 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
1098 | EFI_GUID *AprioriFile;\r | |
1099 | UINTN AprioriEntryCount;\r | |
1100 | UINTN Index;\r | |
1101 | LIST_ENTRY *Link;\r | |
1102 | UINT32 AuthenticationStatus;\r | |
1103 | UINTN SizeOfBuffer;\r | |
d3592549 | 1104 | VOID *DepexBuffer;\r |
2fc46f86 | 1105 | KNOWN_HANDLE *KnownHandle;\r |
28a00297 | 1106 | \r |
1107 | while (TRUE) {\r | |
1108 | BufferSize = sizeof (EFI_HANDLE);\r | |
1109 | Status = CoreLocateHandle (\r | |
e94a9ff7 | 1110 | ByRegisterNotify,\r |
1111 | NULL,\r | |
1112 | mFwVolEventRegistration,\r | |
1113 | &BufferSize,\r | |
1114 | &FvHandle\r | |
1115 | );\r | |
28a00297 | 1116 | if (EFI_ERROR (Status)) {\r |
1117 | //\r | |
1118 | // If no more notification events exit\r | |
1119 | //\r | |
1120 | return;\r | |
1121 | }\r | |
1122 | \r | |
1123 | if (FvHasBeenProcessed (FvHandle)) {\r | |
1124 | //\r | |
1125 | // This Fv has already been processed so lets skip it!\r | |
1126 | //\r | |
1127 | continue;\r | |
1128 | }\r | |
1129 | \r | |
28a00297 | 1130 | //\r |
1131 | // Since we are about to process this Fv mark it as processed.\r | |
1132 | //\r | |
2fc46f86 LG |
1133 | KnownHandle = FvIsBeingProcesssed (FvHandle);\r |
1134 | if (KnownHandle == NULL) {\r | |
1135 | //\r | |
1136 | // The FV with the same FV name guid has already been processed. \r | |
1137 | // So lets skip it!\r | |
1138 | //\r | |
1139 | continue;\r | |
1140 | }\r | |
28a00297 | 1141 | \r |
0c2b5da8 | 1142 | Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);\r |
d2fbaaab | 1143 | if (EFI_ERROR (Status) || Fv == NULL) {\r |
28a00297 | 1144 | //\r |
cd539d48 | 1145 | // FvHandle must have Firmware Volume2 protocol thus we should never get here.\r |
28a00297 | 1146 | //\r |
1147 | ASSERT (FALSE);\r | |
1148 | continue;\r | |
1149 | }\r | |
022c6d45 | 1150 | \r |
28a00297 | 1151 | Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);\r |
1152 | if (EFI_ERROR (Status)) {\r | |
1153 | //\r | |
1154 | // The Firmware volume doesn't have device path, can't be dispatched.\r | |
1155 | //\r | |
1156 | continue;\r | |
1157 | }\r | |
022c6d45 | 1158 | \r |
28a00297 | 1159 | //\r |
022c6d45 | 1160 | // Evaluate the authentication status of the Firmware Volume through\r |
28a00297 | 1161 | // Security Architectural Protocol\r |
1162 | //\r | |
1163 | if (gSecurity != NULL) {\r | |
1164 | SecurityStatus = gSecurity->FileAuthenticationState (\r | |
022c6d45 | 1165 | gSecurity,\r |
1166 | 0,\r | |
28a00297 | 1167 | FvDevicePath\r |
1168 | );\r | |
1169 | if (SecurityStatus != EFI_SUCCESS) {\r | |
1170 | //\r | |
1171 | // Security check failed. The firmware volume should not be used for any purpose.\r | |
1172 | //\r | |
1173 | continue;\r | |
1174 | }\r | |
022c6d45 | 1175 | }\r |
1176 | \r | |
28a00297 | 1177 | //\r |
022c6d45 | 1178 | // Discover Drivers in FV and add them to the Discovered Driver List.\r |
1179 | // Process EFI_FV_FILETYPE_DRIVER type and then EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r | |
28a00297 | 1180 | // EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core\r |
1181 | // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb\r | |
1182 | //\r | |
e94a9ff7 | 1183 | for (Index = 0; Index < sizeof (mDxeFileTypes) / sizeof (EFI_FV_FILETYPE); Index++) {\r |
28a00297 | 1184 | //\r |
1185 | // Initialize the search key\r | |
1186 | //\r | |
1187 | Key = 0;\r | |
1188 | do {\r | |
1189 | Type = mDxeFileTypes[Index];\r | |
1190 | GetNextFileStatus = Fv->GetNextFile (\r | |
022c6d45 | 1191 | Fv,\r |
28a00297 | 1192 | &Key,\r |
022c6d45 | 1193 | &Type,\r |
1194 | &NameGuid,\r | |
1195 | &Attributes,\r | |
28a00297 | 1196 | &Size\r |
1197 | );\r | |
1198 | if (!EFI_ERROR (GetNextFileStatus)) {\r | |
1199 | if (Type == EFI_FV_FILETYPE_DXE_CORE) {\r | |
1200 | //\r | |
1201 | // If this is the DXE core fill in it's DevicePath & DeviceHandle\r | |
1202 | //\r | |
1203 | if (gDxeCoreLoadedImage->FilePath == NULL) {\r | |
1204 | if (CompareGuid (&NameGuid, gDxeCoreFileName)) {\r | |
1205 | //\r | |
1206 | // Maybe One specail Fv cantains only one DXE_CORE module, so its device path must\r | |
1207 | // be initialized completely.\r | |
1208 | //\r | |
1209 | EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);\r | |
1232b214 | 1210 | SetDevicePathEndNode (&mFvDevicePath.End);\r |
28a00297 | 1211 | \r |
9c4ac31c | 1212 | gDxeCoreLoadedImage->FilePath = DuplicateDevicePath (\r |
28a00297 | 1213 | (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath\r |
1214 | );\r | |
1215 | gDxeCoreLoadedImage->DeviceHandle = FvHandle;\r | |
1216 | }\r | |
1217 | }\r | |
1218 | } else if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r | |
bbc0f1bb | 1219 | //\r |
022c6d45 | 1220 | // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r |
bbc0f1bb | 1221 | // been extracted.\r |
1222 | //\r | |
2fc46f86 | 1223 | if (FvFoundInHobFv2 (&KnownHandle->FvNameGuid, &NameGuid)) {\r |
bbc0f1bb | 1224 | continue;\r |
1225 | }\r | |
d3592549 LG |
1226 | \r |
1227 | //\r | |
1228 | // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has PEI depex section.\r | |
1229 | //\r | |
1230 | DepexBuffer = NULL;\r | |
1231 | SizeOfBuffer = 0;\r | |
1232 | Status = Fv->ReadSection (\r | |
1233 | Fv,\r | |
1234 | &NameGuid,\r | |
1235 | EFI_SECTION_PEI_DEPEX,\r | |
1236 | 0,\r | |
1237 | &DepexBuffer,\r | |
1238 | &SizeOfBuffer,\r | |
1239 | &AuthenticationStatus\r | |
1240 | );\r | |
1241 | if (!EFI_ERROR (Status)) {\r | |
1242 | //\r | |
1243 | // If PEI depex section is found, this FV image will be ignored in DXE phase.\r | |
1244 | // Now, DxeCore doesn't support FV image with more one type DEPEX section.\r | |
1245 | //\r | |
1246 | FreePool (DepexBuffer);\r | |
1247 | continue;\r | |
1248 | }\r | |
1249 | \r | |
28a00297 | 1250 | //\r |
d3592549 | 1251 | // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has SMM depex section.\r |
28a00297 | 1252 | //\r |
d3592549 LG |
1253 | DepexBuffer = NULL;\r |
1254 | SizeOfBuffer = 0;\r | |
1255 | Status = Fv->ReadSection (\r | |
1256 | Fv,\r | |
1257 | &NameGuid,\r | |
1258 | EFI_SECTION_SMM_DEPEX,\r | |
1259 | 0,\r | |
1260 | &DepexBuffer,\r | |
1261 | &SizeOfBuffer,\r | |
1262 | &AuthenticationStatus\r | |
1263 | );\r | |
1264 | if (!EFI_ERROR (Status)) {\r | |
1265 | //\r | |
1266 | // If SMM depex section is found, this FV image will be ignored in DXE phase.\r | |
1267 | // Now, DxeCore doesn't support FV image with more one type DEPEX section.\r | |
1268 | //\r | |
1269 | FreePool (DepexBuffer);\r | |
1270 | continue;\r | |
1271 | }\r | |
1272 | \r | |
1273 | //\r | |
1274 | // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has DXE depex section.\r | |
1275 | //\r | |
1276 | DepexBuffer = NULL;\r | |
1277 | SizeOfBuffer = 0;\r | |
1278 | Status = Fv->ReadSection (\r | |
1279 | Fv,\r | |
1280 | &NameGuid,\r | |
1281 | EFI_SECTION_DXE_DEPEX,\r | |
1282 | 0,\r | |
1283 | &DepexBuffer,\r | |
1284 | &SizeOfBuffer,\r | |
1285 | &AuthenticationStatus\r | |
1286 | );\r | |
1287 | if (EFI_ERROR (Status)) {\r | |
1288 | //\r | |
1289 | // If no depex section, produce a firmware volume block protocol for it so it gets dispatched from. \r | |
1290 | //\r | |
1291 | CoreProcessFvImageFile (Fv, FvHandle, &NameGuid);\r | |
1292 | } else {\r | |
1293 | //\r | |
1294 | // If depex section is found, this FV image will be dispatched until its depex is evaluated to TRUE.\r | |
1295 | //\r | |
1296 | FreePool (DepexBuffer);\r | |
1297 | CoreAddToDriverList (Fv, FvHandle, &NameGuid, Type);\r | |
1298 | }\r | |
28a00297 | 1299 | } else {\r |
1300 | //\r | |
1301 | // Transition driver from Undiscovered to Discovered state\r | |
1302 | //\r | |
d3592549 | 1303 | CoreAddToDriverList (Fv, FvHandle, &NameGuid, Type);\r |
28a00297 | 1304 | }\r |
1305 | }\r | |
1306 | } while (!EFI_ERROR (GetNextFileStatus));\r | |
1307 | }\r | |
022c6d45 | 1308 | \r |
28a00297 | 1309 | //\r |
1310 | // Read the array of GUIDs from the Apriori file if it is present in the firmware volume\r | |
1311 | //\r | |
1312 | AprioriFile = NULL;\r | |
1313 | Status = Fv->ReadSection (\r | |
1314 | Fv,\r | |
1315 | &gAprioriGuid,\r | |
1316 | EFI_SECTION_RAW,\r | |
1317 | 0,\r | |
1318 | (VOID **)&AprioriFile,\r | |
1319 | &SizeOfBuffer,\r | |
1320 | &AuthenticationStatus\r | |
1321 | );\r | |
1322 | if (!EFI_ERROR (Status)) {\r | |
1323 | AprioriEntryCount = SizeOfBuffer / sizeof (EFI_GUID);\r | |
1324 | } else {\r | |
1325 | AprioriEntryCount = 0;\r | |
1326 | }\r | |
1327 | \r | |
1328 | //\r | |
1329 | // Put drivers on Apriori List on the Scheduled queue. The Discovered List includes\r | |
1330 | // drivers not in the current FV and these must be skipped since the a priori list\r | |
1331 | // is only valid for the FV that it resided in.\r | |
1332 | //\r | |
022c6d45 | 1333 | \r |
28a00297 | 1334 | for (Index = 0; Index < AprioriEntryCount; Index++) {\r |
1335 | for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r | |
1336 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
1337 | if (CompareGuid (&DriverEntry->FileName, &AprioriFile[Index]) &&\r | |
1338 | (FvHandle == DriverEntry->FvHandle)) {\r | |
6a55eea3 | 1339 | CoreAcquireDispatcherLock ();\r |
28a00297 | 1340 | DriverEntry->Dependent = FALSE;\r |
1341 | DriverEntry->Scheduled = TRUE;\r | |
1342 | InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);\r | |
6a55eea3 | 1343 | CoreReleaseDispatcherLock ();\r |
1344 | DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r | |
1345 | DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));\r | |
28a00297 | 1346 | break;\r |
1347 | }\r | |
1348 | }\r | |
1349 | }\r | |
1350 | \r | |
28a00297 | 1351 | //\r |
022c6d45 | 1352 | // Free data allocated by Fv->ReadSection ()\r |
28a00297 | 1353 | //\r |
022c6d45 | 1354 | CoreFreePool (AprioriFile);\r |
28a00297 | 1355 | }\r |
1356 | }\r | |
1357 | \r | |
1358 | \r | |
28a00297 | 1359 | \r |
162ed594 | 1360 | /**\r |
28a00297 | 1361 | Initialize the dispatcher. Initialize the notification function that runs when\r |
e94a9ff7 | 1362 | an FV2 protocol is added to the system.\r |
28a00297 | 1363 | \r |
162ed594 | 1364 | **/\r |
1365 | VOID\r | |
1366 | CoreInitializeDispatcher (\r | |
1367 | VOID\r | |
1368 | )\r | |
28a00297 | 1369 | {\r |
7899b797 | 1370 | mFwVolEvent = EfiCreateProtocolNotifyEvent (\r |
022c6d45 | 1371 | &gEfiFirmwareVolume2ProtocolGuid,\r |
28a00297 | 1372 | TPL_CALLBACK,\r |
1373 | CoreFwVolEventProtocolNotify,\r | |
1374 | NULL,\r | |
7899b797 | 1375 | &mFwVolEventRegistration\r |
28a00297 | 1376 | );\r |
1377 | }\r | |
1378 | \r | |
1379 | //\r | |
1380 | // Function only used in debug builds\r | |
1381 | //\r | |
162ed594 | 1382 | \r |
1383 | /**\r | |
1384 | Traverse the discovered list for any drivers that were discovered but not loaded\r | |
1385 | because the dependency experessions evaluated to false.\r | |
1386 | \r | |
1387 | **/\r | |
28a00297 | 1388 | VOID\r |
1389 | CoreDisplayDiscoveredNotDispatched (\r | |
1390 | VOID\r | |
1391 | )\r | |
28a00297 | 1392 | {\r |
1393 | LIST_ENTRY *Link;\r | |
1394 | EFI_CORE_DRIVER_ENTRY *DriverEntry;\r | |
1395 | \r | |
1396 | for (Link = mDiscoveredList.ForwardLink;Link !=&mDiscoveredList; Link = Link->ForwardLink) {\r | |
1397 | DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);\r | |
1398 | if (DriverEntry->Dependent) {\r | |
162ed594 | 1399 | DEBUG ((DEBUG_LOAD, "Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));\r |
28a00297 | 1400 | }\r |
1401 | }\r | |
1402 | }\r |