From 52f012129ac497a3abd4aae0dc75f2a32acfd918 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Thu, 23 Apr 2020 10:53:56 +0100 Subject: OvmfPkg/PlatformDebugLibIoPort: factor out debug port detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Factor out debug port detection in PlatformDebugLibIoPort. Signed-off-by: Anthony PERARD Message-Id: <20200423095358.2518197-4-anthony.perard@citrix.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek --- .../PlatformDebugLibIoPort/DebugIoPortQemu.c | 34 ++++++++++++++++++++++ OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 16 ---------- .../PlatformDebugLibIoPort/DebugLibDetect.h | 6 ---- .../PlatformDebugLibIoPort.inf | 1 + .../PlatformRomDebugLibIoPort.inf | 1 + 5 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c new file mode 100644 index 0000000000..bf9119807a --- /dev/null +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c @@ -0,0 +1,34 @@ +/** @file + Detection code for QEMU debug port. + + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2012, Red Hat, Inc.
+ Copyright (c) 2020, Citrix Systems, Inc. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include "DebugLibDetect.h" + +// +// The constant value that is read from the debug I/O port +// +#define BOCHS_DEBUG_PORT_MAGIC 0xE9 + +/** + Return the result of detecting the debug I/O port device. + + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortDetect ( + VOID + ) +{ + return IoRead8 (PcdGet16 (PcdDebugIoPort)) == BOCHS_DEBUG_PORT_MAGIC; +} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c index ec2e677afd..dffb20822d 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c @@ -359,19 +359,3 @@ DebugPrintLevelEnabled ( { return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0); } - -/** - Return the result of detecting the debug I/O port device. - - @retval TRUE if the debug I/O port device was detected. - @retval FALSE otherwise - -**/ -BOOLEAN -EFIAPI -PlatformDebugLibIoPortDetect ( - VOID - ) -{ - return IoRead8 (PcdGet16 (PcdDebugIoPort)) == BOCHS_DEBUG_PORT_MAGIC; -} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h index 4677c85ac3..6d08909dbc 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h @@ -12,12 +12,6 @@ #include -// -// The constant value that is read from the debug I/O port -// -#define BOCHS_DEBUG_PORT_MAGIC 0xE9 - - /** Helper function to return whether the virtual machine has a debug I/O port. PlatformDebugLibIoPortFound can call this function directly or cache the diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf index c09f312ffb..94ab910507 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf @@ -24,6 +24,7 @@ # [Sources] + DebugIoPortQemu.c DebugLib.c DebugLibDetect.c DebugLibDetect.h diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf index ab27f6327a..8f721d249d 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf @@ -24,6 +24,7 @@ # [Sources] + DebugIoPortQemu.c DebugLib.c DebugLibDetect.h DebugLibDetectRom.c -- cgit v1.2.3