[edk2-devel] [PATCH 11/12] BaseDebugLibSerialPort: Emit messages to boot log

Alexander Graf via groups.io posted 12 patches 3 years, 8 months ago
[edk2-devel] [PATCH 11/12] BaseDebugLibSerialPort: Emit messages to boot log
Posted by Alexander Graf via groups.io 3 years, 8 months ago
Now that we have the bootlog infrastructure in place and link against it
with all in tree consumers of BaseDebugLibSerialPort, let's emit log lines
to the bootlog in addition to serial.

The existing PcdDebugBootlogErrorLevel still defines which messages end up
on serial. However, in addition the new PcdDebugBootlogErrorLevel defines
which ones go into the bootlog. The latter may be more verbose.

Signed-off-by: Alexander Graf <graf@amazon.com>
---
 .../BaseDebugLibSerialPort.inf                |  1 +
 .../Library/BaseDebugLibSerialPort/DebugLib.c | 22 +++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf b/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
index 7504faee67..dd22fbeb4a 100644
--- a/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+++ b/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -36,6 +36,7 @@
   PrintLib
   BaseLib
   DebugPrintErrorLevelLib
+  DebugBootlogLib
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue  ## SOMETIMES_CONSUMES
diff --git a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
index bd56869477..ea2611228d 100644
--- a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
+++ b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
@@ -20,6 +20,7 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/SerialPortLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
+#include <Library/DebugBootlog.h>
 
 //
 // Define the maximum debug and assert message length that this library supports
@@ -103,16 +104,20 @@ DebugPrintMarker (
   )
 {
   CHAR8  Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+  UINT32 DebugPrintLevel, DebugBootlogLevel, Length;
 
   //
   // If Format is NULL, then ASSERT().
   //
   ASSERT (Format != NULL);
 
+  DebugPrintLevel = GetDebugPrintErrorLevel ();
+  DebugBootlogLevel = GetDebugBootlogErrorLevel ();
+
   //
   // Check driver debug mask value and global mask
   //
-  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {
+  if ((ErrorLevel & (DebugPrintLevel | DebugBootlogLevel)) == 0) {
     return;
   }
 
@@ -120,15 +125,24 @@ DebugPrintMarker (
   // Convert the DEBUG() message to an ASCII String
   //
   if (BaseListMarker == NULL) {
-    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+    Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
   } else {
-    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+    Length = AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
   }
 
   //
   // Send the print string to a Serial Port
   //
-  SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
+  if (ErrorLevel & DebugPrintLevel) {
+    SerialPortWrite ((UINT8 *)Buffer, Length);
+  }
+
+  //
+  // Append the print string to the Boot Log
+  //
+  if (ErrorLevel & DebugBootlogLevel) {
+    DebugBootlogAppend (Buffer, Length, ErrorLevel);
+  }
 }
 
 /**
-- 
2.28.0.394.ge197136389




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90075): https://edk2.groups.io/g/devel/message/90075
Mute This Topic: https://groups.io/mt/91368917/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-