From nobody Tue Feb 10 19:14:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90068+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90068+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1653619431; cv=none; d=zohomail.com; s=zohoarc; b=EsPOd2YrPl7DVRm/aNlN0j8kbt/FSqL8Y8oIKGbukwkxJVy8NjmiO84V1tEGDlaN8/Zf7qMuHZyAiGx3jjDj2AuP0qCt4UVUEqRUPPWWmIDaltspFTlW5nYODKhJ+Uiw49sBtl9ikqfjjj9K4SnetoRtLaK9e9Fsv6edpn7onb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653619431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=j3Ur7Rvdnehhptbj3dfweZdViYAR+fx+c4PGSHMgkWc=; b=Yucm9Dukw8OqWyKyFNJDBDrIorFVr4laJhzy0EXozSgGCH6jqbdJ2gJs499IvUQx7KJnnyuzfTTQ3mzDBCILtRVwqnl63J0h0Dh489iqMHSk59Zehpr0HNCpwj29yMdsgFXQahkaS3Mm03sBsRPNpyo04QMS3KSiGumWq1a7Xdo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90068+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1653619431973321.821793643348; Thu, 26 May 2022 19:43:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id cat1YY1788612xxboZocAohh; Thu, 26 May 2022 19:43:51 -0700 X-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 X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="92454050" X-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 X-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) X-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 X-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 via groups.io" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [edk2-devel] [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> 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) Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,graf@amazon.com X-Gm-Message-State: ddPRY19f6Y8qlYA92WPwgNBEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1653619431; bh=IKGcwccq9h5ZL75za3fi+kdTKkZrB7cK8wrDBjFZfHM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=xEIxernazOqocanPqBadQGsl4RFirJJEnPrym9/FtA1t/sUAIX7ueIDmB4yIVsmBz90 oAH5ZcQtPvZqQBGNkcEDQc6WZ5b1j3OzSE893fkQPdRfS0sFeYiaaIBDrYq5QCrzwcDro qr8SCB85cjgzqkgYlKpZbclMR6/6/MGcfek= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1653619432634100013 Content-Type: text/plain; charset="utf-8" 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 }} =20 + # + # 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 =20 + ## 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.
--=20 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90068): https://edk2.groups.io/g/devel/message/90068 Mute This Topic: https://groups.io/mt/91368907/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-