]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Dispatcher.c
1) Change location of DEBUG() macro that prints the name of the FFS file being evalua...
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Dispatcher.c
index 405f6dea481675725c55f9eef13695f2ae8b1ff7..3ed464e938399d982958b4f535070e5d48ee65cd 100644 (file)
@@ -2,7 +2,7 @@
   SMM Driver Dispatcher.\r
 \r
   Step #1 - When a FV protocol is added to the system every driver in the FV\r
-            is added to the mDiscoveredList. The SOR, Before, and After Depex are\r
+            is added to the mDiscoveredList. The Before, and After Depex are\r
             pre-processed as drivers are added to the mDiscoveredList. If an Apriori\r
             file exists in the FV those drivers are addeded to the\r
             mScheduledQueue. The mFvHandleList is used to make sure a\r
@@ -26,7 +26,6 @@
   is the state diagram for the DXE dispatcher\r
 \r
   Depex - Dependency Expresion.\r
-  SOR   - Schedule On Request - Don't schedule if this bit is set.\r
 \r
   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
@@ -644,10 +643,8 @@ SmmLoadImage (
 \r
 /**\r
   Preprocess dependency expression and update DriverEntry to reflect the\r
-  state of  Before, After, and SOR dependencies. If DriverEntry->Before\r
-  or DriverEntry->After is set it will never be cleared. If SOR is set\r
-  it will be cleared by SmmSchedule(), and then the driver can be\r
-  dispatched.\r
+  state of  Before and After dependencies. If DriverEntry->Before\r
+  or DriverEntry->After is set it will never be cleared. \r
 \r
   @param  DriverEntry           DriverEntry element to update .\r
 \r
@@ -662,11 +659,7 @@ SmmPreProcessDepex (
   UINT8  *Iterator;\r
 \r
   Iterator = DriverEntry->Depex;\r
-  if (*Iterator == EFI_DEP_SOR) {\r
-    DriverEntry->Unrequested = TRUE;\r
-  } else {\r
-    DriverEntry->Dependent = TRUE;\r
-  }\r
+  DriverEntry->Dependent = TRUE;\r
 \r
   if (*Iterator == EFI_DEP_BEFORE) {\r
     DriverEntry->Before = TRUE;\r
@@ -735,8 +728,8 @@ SmmGetDepexSectionAndPreProccess (
     }\r
   } else {\r
     //\r
-    // Set Before, After, and Unrequested state information based on Depex\r
-    // Driver will be put in Dependent or Unrequested state\r
+    // Set Before and After state information based on Depex\r
+    // Driver will be put in Dependent state\r
     //\r
     SmmPreProcessDepex (DriverEntry);\r
     DriverEntry->DepexProtocolError = FALSE;\r
@@ -745,49 +738,6 @@ SmmGetDepexSectionAndPreProccess (
   return Status;\r
 }\r
 \r
-/**\r
-  Check every driver and locate a matching one. If the driver is found, the Unrequested\r
-  state flag is cleared.\r
-\r
-  @param  FirmwareVolumeHandle  The handle of the Firmware Volume that contains\r
-                                the firmware  file specified by DriverName.\r
-  @param  DriverName            The Driver name to put in the Dependent state.\r
-\r
-  @retval EFI_SUCCESS           The DriverName was found and it's SOR bit was\r
-                                cleared\r
-  @retval EFI_NOT_FOUND         The DriverName does not exist or it's SOR bit was\r
-                                not set.\r
-\r
-**/\r
-EFI_STATUS\r
-SmmSchedule (\r
-  IN  EFI_HANDLE  FirmwareVolumeHandle,\r
-  IN  EFI_GUID    *DriverName\r
-  )\r
-{\r
-  LIST_ENTRY            *Link;\r
-  EFI_SMM_DRIVER_ENTRY  *DriverEntry;\r
-\r
-  //\r
-  // Check every driver\r
-  //\r
-  for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
-    DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE);\r
-    if (DriverEntry->FvHandle == FirmwareVolumeHandle &&\r
-        DriverEntry->Unrequested &&\r
-        CompareGuid (DriverName, &DriverEntry->FileName)) {\r
-      //\r
-      // Move the driver from the Unrequested to the Dependent state\r
-      //\r
-      DriverEntry->Unrequested  = FALSE;\r
-      DriverEntry->Dependent    = TRUE;\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
 /**\r
   This is the main Dispatcher for SMM and it exits when there are no more\r
   drivers to run. Drain the mScheduledQueue and load and start a PE\r
@@ -851,22 +801,11 @@ SmmDispatcher (
         // Update the driver state to reflect that it's been loaded\r
         //\r
         if (EFI_ERROR (Status)) {\r
-\r
-          if (Status == EFI_SECURITY_VIOLATION) {\r
-            //\r
-            // Take driver from Scheduled to Untrused state\r
-            //\r
-            DriverEntry->Untrusted = TRUE;\r
-          } else {\r
-            //\r
-            // The SMM Driver could not be loaded, and do not attempt to load or start it again.\r
-            // Take driver from Scheduled to Initialized.\r
-            //\r
-            // This case include the Never Trusted state if EFI_ACCESS_DENIED is returned\r
-            //\r
-            DriverEntry->Initialized  = TRUE;\r
-          }\r
-\r
+          //\r
+          // The SMM Driver could not be loaded, and do not attempt to load or start it again.\r
+          // Take driver from Scheduled to Initialized.\r
+          //\r
+          DriverEntry->Initialized  = TRUE;\r
           DriverEntry->Scheduled = FALSE;\r
           RemoveEntryList (&DriverEntry->ScheduledLink);\r
 \r
@@ -974,12 +913,17 @@ SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
   //\r
   for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
     DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE);\r
-    if (DriverEntry->Before && DriverEntry->Dependent) {\r
+    if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {\r
+      DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r
+      DEBUG ((DEBUG_DISPATCH, "  BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));\r
       if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r
         //\r
         // Recursively process BEFORE\r
         //\r
+        DEBUG ((DEBUG_DISPATCH, "TRUE\n  END\n  RESULT = TRUE\n"));\r
         SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r
+      } else {\r
+        DEBUG ((DEBUG_DISPATCH, "FALSE\n  END\n  RESULT = FALSE\n"));\r
       }\r
     }\r
   }\r
@@ -998,12 +942,17 @@ SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
   //\r
   for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {\r
     DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE);\r
-    if (DriverEntry->After && DriverEntry->Dependent) {\r
+    if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {\r
+      DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r
+      DEBUG ((DEBUG_DISPATCH, "  AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));\r
       if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {\r
         //\r
         // Recursively process AFTER\r
         //\r
+        DEBUG ((DEBUG_DISPATCH, "TRUE\n  END\n  RESULT = TRUE\n"));\r
         SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);\r
+      } else {\r
+        DEBUG ((DEBUG_DISPATCH, "FALSE\n  END\n  RESULT = FALSE\n"));\r
       }\r
     }\r
   }\r
@@ -1110,7 +1059,7 @@ SmmFvToDevicePath (
 /**\r
   Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r
   and initilize any state variables. Read the Depex from the FV and store it\r
-  in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.\r
+  in DriverEntry. Pre-process the Depex to set the Before and After state.\r
   The Discovered list is never free'ed and contains booleans that represent the\r
   other possible SMM driver states.\r
 \r
@@ -1340,6 +1289,8 @@ SmmDriverDispatchHandler (
           DriverEntry->Dependent = FALSE;\r
           DriverEntry->Scheduled = TRUE;\r
           InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);\r
+          DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r
+          DEBUG ((DEBUG_DISPATCH, "  RESULT = TRUE (Apriori)\n"));\r
           break;\r
         }\r
       }\r