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