From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by mx.groups.io with SMTP id smtpd.web09.3215.1653619430953251872 for ; Thu, 26 May 2022 19:43:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@amazon.com header.s=amazon201209 header.b=X0dUgkuq; spf=pass (domain: amazon.de, ip: 99.78.197.218, 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=1653619430; x=1685155430; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l+f6bQR/aBM7uHUoRNFtAxNedCxjAow1SI8xc321g0U=; b=X0dUgkuqtAHuzJk7vMJlQiyn9UsSwOujhZ61i39azRwG1t+F7D2AhpOH c58f069Kbe1Dpg/uva4N5AbpC4YcQdQzCr4oxSj7lpdv9QBR7eJhoN86z 514fzrVLQDY+47W6csUpKqLkUKyemMcLgFvizijQ20Y8zXLjm7GY0B1tF M=; X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="92454050" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-b27d4a00.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP; 27 May 2022 02:43:46 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-b27d4a00.us-east-1.amazon.com (Postfix) with ESMTPS id 468DD80364; Fri, 27 May 2022 02:43:45 +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:43:44 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.161.125) 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:42 +0000 From: "Alexander Graf" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [PATCH 06/12] MdePkg: Add Pei phase BaseDebugBootlog Date: Fri, 27 May 2022 04:43:11 +0200 Message-ID: <20220527024317.13476-7-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.161.125] X-ClientProxiedBy: EX13D06UWC001.ant.amazon.com (10.43.162.91) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch adds all logic required to collect bootlog data during the PEI phase. During PEI, we create a HOB entry for every log line. Later, when we emit the first DXE bootlog line, we automatically collect all bootlog HOB entries into the actual bootlog. Signed-off-by: Alexander Graf --- .../BaseDebugBootlog/BaseDebugBootlog.h | 43 +++++++++++++ .../BaseDebugBootlogLibPei.inf | 60 +++++++++++++++++++ .../Library/BaseDebugBootlog/DebugBootlog.c | 22 +++++++ .../BaseDebugBootlog/DebugBootlogPei.c | 36 +++++++++++ MdePkg/MdePkg.dec | 29 +++++++++ 5 files changed, 190 insertions(+) create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlog.h create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogLibPei.= inf create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlog.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogPei.c diff --git a/MdePkg/Library/BaseDebugBootlog/BaseDebugBootlog.h b/MdePkg/Li= brary/BaseDebugBootlog/BaseDebugBootlog.h new file mode 100644 index 0000000000..6bba4a5c30 --- /dev/null +++ b/MdePkg/Library/BaseDebugBootlog/BaseDebugBootlog.h @@ -0,0 +1,43 @@ +/** @file + Base Debug library instance for a RAM based boot log + It provides functions to store debug messages in RAM and make them avail= able as + Bootlog Configuration Table. + + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2012, Red Hat, Inc.
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// Starting size of the log buffer +// +#define BOOTLOG_MIN_SIZE 0x80000 + +// +// Maximum number of parallel boot logs +// +#define MAX_LOGS 16 + +UINT64 +EFIAPI +BaseDebugLibBootlogTicksPerSecond ( + VOID + ); + +UINT64 +EFIAPI +BaseDebugLibBootlogTicks ( + VOID + ); diff --git a/MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogLibPei.inf b/M= dePkg/Library/BaseDebugBootlog/BaseDebugBootlogLibPei.inf new file mode 100644 index 0000000000..abc66a953f --- /dev/null +++ b/MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogLibPei.inf @@ -0,0 +1,60 @@ +## @file +# Base Debug library instance for a RAM based boot log +# It provides functions to store debug messages in RAM and make them avai= lable as +# Bootlog Configuration Table. +# +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2012, Red Hat, Inc.
+# Copyright (c) 2022, Amazon Development Center Germany GmbH. All rights = reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseDebugBootlog + FILE_GUID =3D DF934DA3-CD31-49FE-AF50-B3C87C79325D + MODULE_TYPE =3D PEI_CORE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DebugBootlogLib|PEI_CORE PEIM + +[Sources] + DebugBootlog.c + DebugBootlogPei.c + +[Sources.IA32, Sources.X64] + DebugBootlogX86.c + +[Sources.ARM, Sources.AARCH64] + DebugBootlogArm.c + +[Sources.EBC, Sources.RISCV64] + DebugBootlogNotime.c + +[Packages] + MdePkg/MdePkg.dec + +[Packages.AARCH64] + ArmPkg/ArmPkg.dec + +[LibraryClasses] + BaseMemoryLib + PcdLib + PrintLib + BaseLib + DebugPrintErrorLevelLib + PeiServicesLib + +[LibraryClasses.AARCH64] + ArmGenericTimerCounterLib + +[LibraryClasses.ARM] + ArmGenericTimerCounterLib + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdDebugBootlogErrorLevel ## CONSUMES + +[Guids] + gBootlogConfigTableGuid ## CONSUMES diff --git a/MdePkg/Library/BaseDebugBootlog/DebugBootlog.c b/MdePkg/Librar= y/BaseDebugBootlog/DebugBootlog.c new file mode 100644 index 0000000000..bceb1c96da --- /dev/null +++ b/MdePkg/Library/BaseDebugBootlog/DebugBootlog.c @@ -0,0 +1,22 @@ +/** @file + Base Debug library instance for a RAM based boot log + It provides functions to store debug messages in RAM and make them avail= able as + Bootlog Configuration Table. + + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2012, Red Hat, Inc.
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +UINT32 +EFIAPI +GetDebugBootlogErrorLevel ( + VOID + ) +{ + return PcdGet32 (PcdDebugBootlogErrorLevel); +} diff --git a/MdePkg/Library/BaseDebugBootlog/DebugBootlogPei.c b/MdePkg/Lib= rary/BaseDebugBootlog/DebugBootlogPei.c new file mode 100644 index 0000000000..2106e8190a --- /dev/null +++ b/MdePkg/Library/BaseDebugBootlog/DebugBootlogPei.c @@ -0,0 +1,36 @@ +/** @file + Base Debug library instance for a RAM based boot log + It provides functions to store debug messages in RAM and make them avail= able as + Bootlog Configuration Table. + + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2012, Red Hat, Inc.
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BaseDebugBootlog.h" +#include + +RETURN_STATUS +EFIAPI +DebugBootlogAppend ( + IN CONST CHAR8 *String, + IN UINTN Length, + IN UINTN ErrorLevel + ) +{ + BOOTLOG_ENTRY_EDK2 *Entry; + + Entry =3D BuildGuidHob (&gBootlogConfigTableGuid, sizeof(*Entry) + Lengt= h + 1); + if (Entry =3D=3D NULL) + return EFI_NOT_FOUND; + + Entry->ErrorLevel =3D ErrorLevel; + Entry->Log.Ticks =3D BaseDebugLibBootlogTicks(); + CopyMem (&Entry->Log.String, String, Length); + Entry->Log.String[Length] =3D '\0'; + + return EFI_SUCCESS; +} diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f1ebf9e251..8e68324028 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -837,6 +837,11 @@ ## Include/Protocol/CcMeasurement.h gEfiCcFinalEventsTableGuid =3D { 0xdd4a4648, 0x2de7, 0x4665, { 0x96,= 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4, 0x46 }} = + # + # GUID to identify Bootlog data + # + gBootlogConfigTableGuid =3D {0xd6128add, 0x85fa, 0x4428, {= 0x96, 0x5b, 0x26, 0xfd, 0xab, 0xad, 0xfb, 0x26}} + [Guids.IA32, Guids.X64] ## Include/Guid/Cper.h gEfiIa32X64ErrorTypeCacheCheckGuid =3D { 0xA55701F5, 0xE3EF, 0x43de, { 0= xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }} @@ -2257,6 +2262,30 @@ # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPrintError= Level & 0x7F84AA00) =3D=3D 0 gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000|UINT32|0x000= 00006 = + ## This flag is used to control the boot log Debug message.

+ # BIT0 - Initialization message.
+ # BIT1 - Warning message.
+ # BIT2 - Load Event message.
+ # BIT3 - File System message.
+ # BIT4 - Allocate or Free Pool message.
+ # BIT5 - Allocate or Free Page message.
+ # BIT6 - Information message.
+ # BIT7 - Dispatcher message.
+ # BIT8 - Variable message.
+ # BIT10 - Boot Manager message.
+ # BIT12 - BlockIo Driver message.
+ # BIT14 - Network Driver message.
+ # BIT16 - UNDI Driver message.
+ # BIT17 - LoadFile message.
+ # BIT19 - Event message.
+ # BIT20 - Global Coherency Database changes message.
+ # BIT21 - Memory range cachability changes message.
+ # BIT22 - Detailed debug message.
+ # BIT31 - Error message.
+ # @Prompt Debug Message Bootlog Level. + # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugBootlogErr= orLevel & 0x7F84AA00) =3D=3D 0 + gEfiMdePkgTokenSpaceGuid.PcdDebugBootlogErrorLevel|0x8000004F|UINT32|0x0= 0000031 + ## The mask is used to control ReportStatusCodeLib behavior.

# BIT0 - Enable Progress Code.
# BIT1 - Enable Error Code.
-- = 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