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 06/12] MdePkg: Add Pei phase BaseDebugBootlog
Date: Fri, 27 May 2022 04:43:11 +0200 [thread overview]
Message-ID: <20220527024317.13476-7-graf@amazon.com> (raw)
In-Reply-To: <20220527024317.13476-1-graf@amazon.com>
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 <graf@amazon.com>
---
.../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/Library/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 available as
+ Bootlog Configuration Table.
+
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012, Red Hat, Inc.<BR>
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugPrintErrorLevelLib.h>
+#include <Library/DebugBootlog.h>
+
+//
+// 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/MdePkg/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 available as
+# Bootlog Configuration Table.
+#
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2012, Red Hat, Inc.<BR>
+# Copyright (c) 2022, Amazon Development Center Germany GmbH. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseDebugBootlog
+ FILE_GUID = DF934DA3-CD31-49FE-AF50-B3C87C79325D
+ MODULE_TYPE = PEI_CORE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = 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/Library/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 available as
+ Bootlog Configuration Table.
+
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012, Red Hat, Inc.<BR>
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/PcdLib.h>
+
+UINT32
+EFIAPI
+GetDebugBootlogErrorLevel (
+ VOID
+ )
+{
+ return PcdGet32 (PcdDebugBootlogErrorLevel);
+}
diff --git a/MdePkg/Library/BaseDebugBootlog/DebugBootlogPei.c b/MdePkg/Library/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 available as
+ Bootlog Configuration Table.
+
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012, Red Hat, Inc.<BR>
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "BaseDebugBootlog.h"
+#include <Library/PeiServicesLib.h>
+
+RETURN_STATUS
+EFIAPI
+DebugBootlogAppend (
+ IN CONST CHAR8 *String,
+ IN UINTN Length,
+ IN UINTN ErrorLevel
+ )
+{
+ BOOTLOG_ENTRY_EDK2 *Entry;
+
+ Entry = BuildGuidHob (&gBootlogConfigTableGuid, sizeof(*Entry) + Length + 1);
+ if (Entry == NULL)
+ return EFI_NOT_FOUND;
+
+ Entry->ErrorLevel = ErrorLevel;
+ Entry->Log.Ticks = BaseDebugLibBootlogTicks();
+ CopyMem (&Entry->Log.String, String, Length);
+ Entry->Log.String[Length] = '\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 = { 0xdd4a4648, 0x2de7, 0x4665, { 0x96, 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4, 0x46 }}
+ #
+ # GUID to identify Bootlog data
+ #
+ gBootlogConfigTableGuid = {0xd6128add, 0x85fa, 0x4428, {0x96, 0x5b, 0x26, 0xfd, 0xab, 0xad, 0xfb, 0x26}}
+
[Guids.IA32, Guids.X64]
## Include/Guid/Cper.h
gEfiIa32X64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, { 0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }}
@@ -2257,6 +2262,30 @@
# @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel & 0x7F84AA00) == 0
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000|UINT32|0x00000006
+ ## This flag is used to control the boot log Debug message.<BR><BR>
+ # BIT0 - Initialization message.<BR>
+ # BIT1 - Warning message.<BR>
+ # BIT2 - Load Event message.<BR>
+ # BIT3 - File System message.<BR>
+ # BIT4 - Allocate or Free Pool message.<BR>
+ # BIT5 - Allocate or Free Page message.<BR>
+ # BIT6 - Information message.<BR>
+ # BIT7 - Dispatcher message.<BR>
+ # BIT8 - Variable message.<BR>
+ # BIT10 - Boot Manager message.<BR>
+ # BIT12 - BlockIo Driver message.<BR>
+ # BIT14 - Network Driver message.<BR>
+ # BIT16 - UNDI Driver message.<BR>
+ # BIT17 - LoadFile message.<BR>
+ # BIT19 - Event message.<BR>
+ # BIT20 - Global Coherency Database changes message.<BR>
+ # BIT21 - Memory range cachability changes message.<BR>
+ # BIT22 - Detailed debug message.<BR>
+ # BIT31 - Error message.<BR>
+ # @Prompt Debug Message Bootlog Level.
+ # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugBootlogErrorLevel & 0x7F84AA00) == 0
+ gEfiMdePkgTokenSpaceGuid.PcdDebugBootlogErrorLevel|0x8000004F|UINT32|0x00000031
+
## The mask is used to control ReportStatusCodeLib behavior.<BR><BR>
# BIT0 - Enable Progress Code.<BR>
# BIT1 - Enable Error Code.<BR>
--
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
next prev parent reply other threads:[~2022-05-27 2:43 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 ` Alexander Graf [this message]
2022-05-27 2:43 ` [PATCH 07/12] MdePkg: Add Dxe phase BaseDebugBootlog 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 ` [PATCH 11/12] BaseDebugLibSerialPort: Emit messages to boot log Alexander Graf
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-7-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