]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Dependency.c
EDK II Packages: Add Contributions.txt and License.txt files
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Dependency.c
index 800892dc44a2adc57c735036b18dc22e73c030eb..44f693ac83ad25216b9a9baf2117ff986fec4f88 100644 (file)
@@ -5,7 +5,7 @@
   if a driver can be scheduled for execution.  The criteria for\r
   schedulability is that the dependency expression is satisfied.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation.  All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -161,8 +161,7 @@ PopBool (
 /**\r
   This is the POSTFIX version of the dependency evaluator.  This code does\r
   not need to handle Before or After, as it is not valid to call this\r
-  routine in this case. The SOR is just ignored and is a nop in the grammer.\r
-  POSTFIX means all the math is done on top of the stack.\r
+  routine in this case. POSTFIX means all the math is done on top of the stack.\r
 \r
   @param  DriverEntry           DriverEntry element to update.\r
 \r
@@ -194,11 +193,14 @@ SmmIsSchedulable (
     return FALSE;\r
   }\r
 \r
+  DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));\r
+  \r
   if (DriverEntry->Depex == NULL) {\r
     //\r
     // A NULL Depex means that the SMM driver is not built correctly.  \r
     // All SMM drivers must have a valid depex expressiion.\r
     //\r
+    DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Depex is empty)\n"));\r
     ASSERT (FALSE);\r
     return FALSE;\r
   }\r
@@ -218,6 +220,7 @@ SmmIsSchedulable (
     // past the end of the dependency expression.\r
     //\r
     if (((UINTN)Iterator - (UINTN)DriverEntry->Depex) >= DriverEntry->DepexSize) {\r
+      DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Attempt to fetch past end of depex)\n"));\r
       return FALSE;\r
     }\r
 \r
@@ -233,19 +236,8 @@ SmmIsSchedulable (
       // If the code flow arrives at this point, there was a BEFORE or AFTER\r
       // that were not the first opcodes.\r
       //\r
+      DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));\r
       ASSERT (FALSE);\r
-    case EFI_DEP_SOR:\r
-      //\r
-      // These opcodes can only appear once as the first opcode.  If it is found\r
-      // at any other location, then the dependency expression evaluates to FALSE\r
-      //\r
-      if (Iterator != DriverEntry->Depex) {\r
-        return FALSE;\r
-      }\r
-      //\r
-      // Otherwise, it is the first opcode and should be treated as a NOP.\r
-      //\r
-      break;\r
 \r
     case EFI_DEP_PUSH:\r
       //\r
@@ -263,12 +255,15 @@ SmmIsSchedulable (
       }\r
 \r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  PUSH GUID(%g) = FALSE\n", &DriverGuid));\r
         Status = PushBool (FALSE);\r
       } else {\r
+        DEBUG ((DEBUG_DISPATCH, "  PUSH GUID(%g) = TRUE\n", &DriverGuid));\r
         *Iterator = EFI_DEP_REPLACE_TRUE;\r
         Status = PushBool (TRUE);\r
       }\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
@@ -276,75 +271,96 @@ SmmIsSchedulable (
       break;\r
 \r
     case EFI_DEP_AND:\r
+      DEBUG ((DEBUG_DISPATCH, "  AND\n"));\r
       Status = PopBool (&Operator);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
       Status = PopBool (&Operator2);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
       Status = PushBool ((BOOLEAN)(Operator && Operator2));\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
       break;\r
 \r
     case EFI_DEP_OR:\r
+      DEBUG ((DEBUG_DISPATCH, "  OR\n"));\r
       Status = PopBool (&Operator);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
       Status = PopBool (&Operator2);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
       Status = PushBool ((BOOLEAN)(Operator || Operator2));\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
       break;\r
 \r
     case EFI_DEP_NOT:\r
+      DEBUG ((DEBUG_DISPATCH, "  NOT\n"));\r
       Status = PopBool (&Operator);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
       Status = PushBool ((BOOLEAN)(!Operator));\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
       break;\r
 \r
     case EFI_DEP_TRUE:\r
+      DEBUG ((DEBUG_DISPATCH, "  TRUE\n"));\r
       Status = PushBool (TRUE);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
       break;\r
 \r
     case EFI_DEP_FALSE:\r
+      DEBUG ((DEBUG_DISPATCH, "  FALSE\n"));\r
       Status = PushBool (FALSE);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
       break;\r
 \r
     case EFI_DEP_END:\r
+      DEBUG ((DEBUG_DISPATCH, "  END\n"));\r
       Status = PopBool (&Operator);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
+      DEBUG ((DEBUG_DISPATCH, "  RESULT = %a\n", Operator ? "TRUE" : "FALSE"));\r
       return Operator;\r
 \r
     case EFI_DEP_REPLACE_TRUE:\r
+      CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));\r
+      DEBUG ((DEBUG_DISPATCH, "  PUSH GUID(%g) = TRUE\n", &DriverGuid));\r
       Status = PushBool (TRUE);\r
       if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unexpected error)\n"));\r
         return FALSE;\r
       }\r
 \r
@@ -352,6 +368,7 @@ SmmIsSchedulable (
       break;\r
 \r
     default:\r
+      DEBUG ((DEBUG_DISPATCH, "  RESULT = FALSE (Unknown opcode)\n"));\r
       goto Done;\r
     }\r
 \r