From: "Anthony PERARD" <anthony.perard@citrix.com>
To: <devel@edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>,
Anthony Perard <anthony.perard@citrix.com>,
Ard Biesheuvel <ard.biesheuvel@arm.com>,
"Jordan Justen" <jordan.l.justen@intel.com>,
Julien Grall <julien@xen.org>
Subject: [PATCH 2/2] OvmfPkg/OvmfXen: Introduce XenDebugLibIoPort
Date: Mon, 20 Apr 2020 17:29:18 +0100 [thread overview]
Message-ID: <20200420162918.2312514-3-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200420162918.2312514-1-anthony.perard@citrix.com>
Introduce XenDebugLibIoPort which is enabled with
DEBUG_ON_HYPERVISOR_CONSOLE which send the debug output to Xen's
console.
It's a copy PlatformDebugLibIoPort which always write to the IO port.
It works with both Xen HVM guest and Xen PVH guest whereas the default
PlatformDebugLibIoPort works only in HVM when QEMU is present.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
Notes:
Do you think it would be better to introduce a PCD to
PlatformDebugLibIoPort where we can disable the check
for the debug port and simply always write to it?
OvmfPkg/OvmfXen.dsc | 13 ++++++++++++
.../PlatformDebugLibIoPort.inf | 6 +++---
.../DebugLibDetect.h | 20 -------------------
.../DebugLib.c | 16 ---------------
.../DebugLibDetect.c | 20 ++-----------------
5 files changed, 18 insertions(+), 57 deletions(-)
copy OvmfPkg/Library/{PlatformDebugLibIoPort => XenDebugLibIoPort}/PlatformDebugLibIoPort.inf (76%)
copy OvmfPkg/Library/{PlatformDebugLibIoPort => XenDebugLibIoPort}/DebugLibDetect.h (57%)
copy OvmfPkg/Library/{PlatformDebugLibIoPort => XenDebugLibIoPort}/DebugLib.c (94%)
copy OvmfPkg/Library/{PlatformDebugLibIoPort => XenDebugLibIoPort}/DebugLibDetect.c (61%)
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 4859faf1bff7..8e4d70f21fc8 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -205,14 +205,22 @@ [LibraryClasses]
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
+!ifdef $(DEBUG_ON_HYPERVISOR_CONSOLE)
+ DebugLib|OvmfPkg/Library/XenDebugLibIoPort/PlatformDebugLibIoPort.inf
+!else
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
[LibraryClasses.common]
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
[LibraryClasses.common.SEC]
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
+!ifdef $(DEBUG_ON_HYPERVISOR_CONSOLE)
+ DebugLib|OvmfPkg/Library/XenDebugLibIoPort/PlatformDebugLibIoPort.inf
+!else
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
+!endif
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE
@@ -405,6 +413,11 @@ [PcdsFixedAtBuild]
#
!include NetworkPkg/NetworkPcds.dsc.inc
+!ifdef $(DEBUG_ON_HYPERVISOR_CONSOLE)
+ ## This flag is used to control the destination port for PlatformDebugLibIoPort
+ gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0xe9
+!endif
+
# IRQs 5, 9, 10, 11 are level-triggered
gUefiOvmfPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/XenDebugLibIoPort/PlatformDebugLibIoPort.inf
similarity index 76%
copy from OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
copy to OvmfPkg/Library/XenDebugLibIoPort/PlatformDebugLibIoPort.inf
index c09f312ffb1d..141fe7498335 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+++ b/OvmfPkg/Library/XenDebugLibIoPort/PlatformDebugLibIoPort.inf
@@ -12,11 +12,11 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = PlatformDebugLibIoPort
- FILE_GUID = DF934DA3-CD31-49FE-AF50-B3C87C79325F
+ BASE_NAME = XenDebugLibIoPort
+ FILE_GUID = 201EE63F-79DC-4B8E-953C-FA794C0883A3
MODULE_TYPE = BASE
VERSION_STRING = 1.0
- LIBRARY_CLASS = DebugLib|PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION
+ LIBRARY_CLASS = DebugLib|SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION
CONSTRUCTOR = PlatformDebugLibIoPortConstructor
#
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h b/OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.h
similarity index 57%
copy from OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h
copy to OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.h
index 71a7f33aaf17..d5ec4063c5be 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h
+++ b/OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.h
@@ -12,26 +12,6 @@
#include <Base.h>
-//
-// 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
- result.
-
- @retval TRUE if the debug I/O port device was detected.
- @retval FALSE otherwise
-
-**/
-BOOLEAN
-EFIAPI
-PlatformDebugLibIoPortDetect (
- VOID
- );
/**
Return whether the virtual machine has a debug I/O port. DebugLib.c
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/XenDebugLibIoPort/DebugLib.c
similarity index 94%
copy from OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
copy to OvmfPkg/Library/XenDebugLibIoPort/DebugLib.c
index 3dfa3126c3d0..b3952c9936da 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
+++ b/OvmfPkg/Library/XenDebugLibIoPort/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.c b/OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.c
similarity index 61%
copy from OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
copy to OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.c
index 2c659e7aea0a..04de924f3fa2 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
+++ b/OvmfPkg/Library/XenDebugLibIoPort/DebugLibDetect.c
@@ -1,6 +1,5 @@
/** @file
Detection code for QEMU debug port.
- Non-SEC instance, caches the result of detection.
Copyright (c) 2017, Red Hat, Inc.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -10,16 +9,6 @@
#include <Base.h>
#include "DebugLibDetect.h"
-//
-// Set to TRUE if the debug I/O port has been checked
-//
-STATIC BOOLEAN mDebugIoPortChecked = FALSE;
-
-//
-// Set to TRUE if the debug I/O port is enabled
-//
-STATIC BOOLEAN mDebugIoPortFound = FALSE;
-
/**
This constructor function must not do anything.
@@ -44,8 +33,7 @@ PlatformDebugLibIoPortConstructor (
}
/**
- At the first call, check if the debug I/O port device is present, and cache
- the result for later use. At subsequent calls, return the cached result.
+ 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
@@ -57,9 +45,5 @@ PlatformDebugLibIoPortFound (
VOID
)
{
- if (!mDebugIoPortChecked) {
- mDebugIoPortFound = PlatformDebugLibIoPortDetect ();
- mDebugIoPortChecked = TRUE;
- }
- return mDebugIoPortFound;
+ return TRUE;
}
--
Anthony PERARD
next prev parent reply other threads:[~2020-04-20 16:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 16:29 [PATCH 0/2] OvmfXen: Cleanup debug options Anthony PERARD
2020-04-20 16:29 ` [PATCH 1/2] OvmfPkg/OvmfXen: Remove DEBUG_ON_SERIAL_PORT Anthony PERARD
2020-04-21 13:22 ` Laszlo Ersek
2020-04-20 16:29 ` Anthony PERARD [this message]
2020-04-21 13:54 ` [PATCH 2/2] OvmfPkg/OvmfXen: Introduce XenDebugLibIoPort Laszlo Ersek
2020-04-22 10:18 ` Anthony PERARD
2020-04-22 16:10 ` Laszlo Ersek
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=20200420162918.2312514-3-anthony.perard@citrix.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