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