public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Alexander Graf" <graf@amazon.com>
To: <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Dandan Bi <dandan.bi@intel.com>,
	Zhichao Gao <zhichao.gao@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH 11/12] BaseDebugLibSerialPort: Emit messages to boot log
Date: Fri, 27 May 2022 04:43:16 +0200	[thread overview]
Message-ID: <20220527024317.13476-12-graf@amazon.com> (raw)
In-Reply-To: <20220527024317.13476-1-graf@amazon.com>

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




  parent reply	other threads:[~2022-05-27  2:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27  2:43 [PATCH 00/12] Introduce Bootlog DEBUG() output Alexander Graf
2022-05-27  2:43 ` [PATCH 01/12] MdePkg: Add DebugBootlog header Alexander Graf
2022-05-27  2:43 ` [PATCH 02/12] MdePkg: Add Null BaseDebugBootlog Alexander Graf
2022-05-27  2:43 ` [PATCH 03/12] MdePkg: Add Fallback timer support for BaseDebugBootlog Alexander Graf
2022-05-27  2:43 ` [PATCH 04/12] MdePkg: Add X86 " Alexander Graf
2022-05-27  2:43 ` [PATCH 05/12] MdePkg: Add ARM " Alexander Graf
2022-05-27  2:43 ` [PATCH 06/12] MdePkg: Add Pei phase BaseDebugBootlog Alexander Graf
2022-05-27  2:43 ` [PATCH 07/12] MdePkg: Add Dxe " Alexander Graf
2022-05-27  2:43 ` [PATCH 08/12] MdePkg: Add BaseDebugLibBootlog Alexander Graf
2022-05-27  2:43 ` [PATCH 09/12] Scripts: Add bootlog decyphering script Alexander Graf
2022-05-27  2:43 ` [PATCH 10/12] BaseDebugLibSerialPort: Include BaseDebugBootlog in all dscs Alexander Graf
2022-05-27  2:43 ` Alexander Graf [this message]
2022-05-27  2:43 ` [PATCH 12/12] OvmfPkg/PlatformDebugLibIoPort: Add Bootlog support Alexander Graf
2022-06-01  9:33 ` [edk2-devel] [PATCH 00/12] Introduce Bootlog DEBUG() output Gerd Hoffmann
2022-06-01 16:58   ` Benjamin Doron
2022-06-02  8:35     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220527024317.13476-12-graf@amazon.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox