]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Event/Tpl.c
IntelSiliconPkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Event / Tpl.c
index 7fe9b12600300a99c2836956b70afd50646de6f2..e3caf832b8638124ace38d68f88e290160e7901c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Task priority (TPL) functions.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -65,7 +65,10 @@ CoreRaiseTpl (
   EFI_TPL     OldTpl;\r
 \r
   OldTpl = gEfiCurrentTpl;\r
-  ASSERT (OldTpl <= NewTpl);\r
+  if (OldTpl > NewTpl) {\r
+    DEBUG ((EFI_D_ERROR, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl, NewTpl));\r
+    ASSERT (FALSE);\r
+  }\r
   ASSERT (VALID_TPL (NewTpl));\r
 \r
   //\r
@@ -100,9 +103,13 @@ CoreRestoreTpl (
   )\r
 {\r
   EFI_TPL     OldTpl;\r
+  EFI_TPL     PendingTpl;\r
 \r
   OldTpl = gEfiCurrentTpl;\r
-  ASSERT (NewTpl <= OldTpl);\r
+  if (NewTpl > OldTpl) {\r
+    DEBUG ((EFI_D_ERROR, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl, OldTpl));\r
+    ASSERT (FALSE);\r
+  }\r
   ASSERT (VALID_TPL (NewTpl));\r
 \r
   //\r
@@ -117,8 +124,13 @@ CoreRestoreTpl (
   //\r
   // Dispatch any pending events\r
   //\r
-  while (((-2 << NewTpl) & gEventPending) != 0) {\r
-    gEfiCurrentTpl = HighBitSet64 (gEventPending);\r
+  while (gEventPending != 0) {\r
+    PendingTpl = (UINTN) HighBitSet64 (gEventPending);\r
+    if (PendingTpl <= NewTpl) {\r
+      break;\r
+    }\r
+\r
+    gEfiCurrentTpl = PendingTpl;\r
     if (gEfiCurrentTpl < TPL_HIGH_LEVEL) {\r
       CoreSetInterruptState (TRUE);\r
     }\r