From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by mx.groups.io with SMTP id smtpd.web08.3197.1653619443043458813 for ; Thu, 26 May 2022 19:44:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=J3WOIcj2; spf=pass (domain: amazon.de, ip: 99.78.197.217, mailfrom: prvs=139655964=graf@amazon.de) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1653619443; x=1685155443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0J1zCSSC2IBwOi0Fyul27UoA4gQGOpZ8O8ZZ+VMxBPI=; b=J3WOIcj2QTU3xRt8hkXuwe/3hDOFwOvpLYOXzmAFHcqwqHAjnWpX9l6i Ymokrsgskz/5MZvW9t0bzMDw/i7GoVbyg3aJAkrG3XIjfivhvpw96dvYq kSCM21fRIYv4+p58YvTtuGsv4Kze2nseg+tl45149zv8cYxG6zfDQwObl g=; X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="92377818" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-b69ea591.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP; 27 May 2022 02:44:02 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-b69ea591.us-east-1.amazon.com (Postfix) with ESMTPS id 8000FC098D; Fri, 27 May 2022 02:44:01 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:44:00 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.160.26) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:58 +0000 From: "Alexander Graf" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [PATCH 11/12] BaseDebugLibSerialPort: Emit messages to boot log Date: Fri, 27 May 2022 04:43:16 +0200 Message-ID: <20220527024317.13476-12-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 In-Reply-To: <20220527024317.13476-1-graf@amazon.com> References: <20220527024317.13476-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.160.26] X-ClientProxiedBy: EX13D38UWB004.ant.amazon.com (10.43.161.30) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 --- .../BaseDebugLibSerialPort.inf | 1 + .../Library/BaseDebugLibSerialPort/DebugLib.c | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.i= nf 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/Libr= ary/BaseDebugLibSerialPort/DebugLib.c index bd56869477..ea2611228d 100644 --- a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c +++ b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c @@ -20,6 +20,7 @@ #include #include #include +#include = // // Define the maximum debug and assert message length that this library su= pports @@ -103,16 +104,20 @@ DebugPrintMarker ( ) { CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + UINT32 DebugPrintLevel, DebugBootlogLevel, Length; = // // If Format is NULL, then ASSERT(). // ASSERT (Format !=3D NULL); = + DebugPrintLevel =3D GetDebugPrintErrorLevel (); + DebugBootlogLevel =3D GetDebugBootlogErrorLevel (); + // // Check driver debug mask value and global mask // - if ((ErrorLevel & GetDebugPrintErrorLevel ()) =3D=3D 0) { + if ((ErrorLevel & (DebugPrintLevel | DebugBootlogLevel)) =3D=3D 0) { return; } = @@ -120,15 +125,24 @@ DebugPrintMarker ( // Convert the DEBUG() message to an ASCII String // if (BaseListMarker =3D=3D NULL) { - AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker); + Length =3D AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker= ); } else { - AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker); + Length =3D AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMark= er); } = // // 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