MdePkg: introduce DxeRuntimeDebugLibSerialPort

Introduce a variant of BaseDebugLibSerialPort that behaves correctly with
regards to the use of the serial port after ExitBootServices(). At boot
time, all DEBUG() prints and ASSERT() invocations are executed normally.
At runtime, DEBUG() prints are dropped entirely, and ASSERT()s omit the
serial output as well, and only perform the configured post-ASSERT()
action, i.e., issue a CPU breakpoint or enter a deadloop.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Ard Biesheuvel
2018-02-20 10:53:10 +00:00
parent 8bdb022115
commit 7f029e1b31
3 changed files with 422 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
## @file
# DXE runtime Debug library instance based on Serial Port library.
# It takes care not to call into SerialPortLib after ExitBootServices() has
# been called, to prevent touching hardware that is no longer owned by the
# firmware.
#
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##
[Defines]
INF_VERSION = 0x0001001A
BASE_NAME = DxeRuntimeDebugLibSerialPort
MODULE_UNI_FILE = DxeRuntimeDebugLibSerialPort.uni
FILE_GUID = 9D914E2F-7CCB-41DB-8E74-9AFF8F3BBFBF
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = DebugLib|DXE_RUNTIME_DRIVER
CONSTRUCTOR = DxeRuntimeDebugLibSerialPortConstructor
DESTRUCTOR = DxeRuntimeDebugLibSerialPortDestructor
#
# VALID_ARCHITECTURES = AARCH64 ARM IA32 X64 IPF EBC
#
[Sources]
DebugLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugPrintErrorLevelLib
PcdLib
PrintLib
SerialPortLib
[Guids]
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue ## SOMETIMES_CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES