]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
MdePkg/UefiDebugLibStdErr: Make it runtime safe
[mirror_edk2.git] / MdePkg / Library / UefiDebugLibStdErr / DebugLib.c
index 29f93cf3e3fba3dba635f5ef1af699b2bfd57a55..40eb697e7e2cab2e1762d1e7904b0a7c782e14d0 100644 (file)
@@ -10,7 +10,6 @@
 #include <Uefi.h>\r
 \r
 #include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -29,6 +28,8 @@
 //\r
 VA_LIST     mVaListNull;\r
 \r
+extern BOOLEAN                mPostEBS;\r
+extern EFI_SYSTEM_TABLE       *mDebugST;\r
 \r
 /**\r
   Prints a debug message to the debug output device if the specified error level is enabled.\r
@@ -88,32 +89,34 @@ DebugPrintMarker (
 {\r
   CHAR16   Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
 \r
-  //\r
-  // If Format is NULL, then ASSERT().\r
-  //\r
-  ASSERT (Format != NULL);\r
-\r
-  //\r
-  // Check driver debug mask value and global mask\r
-  //\r
-  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Convert the DEBUG() message to a Unicode String\r
-  //\r
-  if (BaseListMarker == NULL) {\r
-    UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);\r
-  } else {\r
-    UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, BaseListMarker);\r
-  }\r
-\r
-  //\r
-  // Send the print string to the Standard Error device\r
-  //\r
-  if ((gST != NULL) && (gST->StdErr != NULL)) {\r
-    gST->StdErr->OutputString (gST->StdErr, Buffer);\r
+  if (!mPostEBS) {\r
+    //\r
+    // If Format is NULL, then ASSERT().\r
+    //\r
+    ASSERT (Format != NULL);\r
+\r
+    //\r
+    // Check driver debug mask value and global mask\r
+    //\r
+    if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r
+      return;\r
+    }\r
+\r
+    //\r
+    // Convert the DEBUG() message to a Unicode String\r
+    //\r
+    if (BaseListMarker == NULL) {\r
+      UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);\r
+    } else {\r
+      UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, BaseListMarker);\r
+    }\r
+\r
+    //\r
+    // Send the print string to the Standard Error device\r
+    //\r
+    if ((mDebugST != NULL) && (mDebugST->StdErr != NULL)) {\r
+      mDebugST->StdErr->OutputString (mDebugST->StdErr, Buffer);\r
+    }\r
   }\r
 }\r
 \r
@@ -207,33 +210,35 @@ DebugAssert (
 {\r
   CHAR16  Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
 \r
-  //\r
-  // Generate the ASSERT() message in Unicode format\r
-  //\r
-  UnicodeSPrintAsciiFormat (\r
-    Buffer,\r
-    sizeof (Buffer),\r
-    "ASSERT [%a] %a(%d): %a\n",\r
-    gEfiCallerBaseName,\r
-    FileName,\r
-    LineNumber,\r
-    Description\r
-    );\r
-\r
-  //\r
-  // Send the print string to the Standard Error device\r
-  //\r
-  if ((gST != NULL) && (gST->StdErr != NULL)) {\r
-    gST->StdErr->OutputString (gST->StdErr, Buffer);\r
-  }\r
-\r
-  //\r
-  // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
-  //\r
-  if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r
-    CpuBreakpoint ();\r
-  } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r
-    CpuDeadLoop ();\r
+  if (!mPostEBS) {\r
+    //\r
+    // Generate the ASSERT() message in Unicode format\r
+    //\r
+    UnicodeSPrintAsciiFormat (\r
+      Buffer,\r
+      sizeof (Buffer),\r
+      "ASSERT [%a] %a(%d): %a\n",\r
+      gEfiCallerBaseName,\r
+      FileName,\r
+      LineNumber,\r
+      Description\r
+      );\r
+\r
+    //\r
+    // Send the print string to the Standard Error device\r
+    //\r
+    if ((mDebugST != NULL) && (mDebugST->StdErr != NULL)) {\r
+      mDebugST->StdErr->OutputString (mDebugST->StdErr, Buffer);\r
+    }\r
+\r
+    //\r
+    // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
+    //\r
+    if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r
+      CpuBreakpoint ();\r
+    } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r
+      CpuDeadLoop ();\r
+    }\r
   }\r
 }\r
 \r