From nobody Mon Apr 29 05:55:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1510829247299519.0810340723386; Thu, 16 Nov 2017 02:47:27 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 407FF20359A61; Thu, 16 Nov 2017 02:43:16 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 974C121B00DEC for ; Thu, 16 Nov 2017 02:43:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C47D381DE2; Thu, 16 Nov 2017 10:47:23 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-65.ams2.redhat.com [10.36.117.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 683B260602; Thu, 16 Nov 2017 10:47:21 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=pbonzini@redhat.com; receiver=edk2-devel@lists.01.org From: Paolo Bonzini To: edk2-devel@lists.01.org Date: Thu, 16 Nov 2017 11:47:15 +0100 Message-Id: <20171116104716.15144-2-pbonzini@redhat.com> In-Reply-To: <20171116104716.15144-1-pbonzini@redhat.com> References: <20171116104716.15144-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 16 Nov 2017 10:47:23 +0000 (UTC) Subject: [edk2] [PATCH 1/2] OvmfPkg: create a separate PlatformDebugLibIoPort instance for SEC X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The next patch will want to add a global variable to PlatformDebugLibIoPort, but this is not suitable for the SEC phase, because SEC runs from read-only flash. The solution is to have two library instances, one for SEC and another for all other firmware phases. This patch adds the "plumbing" for the SEC library instance, separating the INF files and moving the constructor to a separate C source file. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen (Intel address) Signed-off-by: Paolo Bonzini --- OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 15 ------- .../PlatformDebugLibIoPort/DebugLibDetect.c | 32 +++++++++++++ .../PlatformDebugLibIoPort/DebugLibDetectRom.c | 32 +++++++++++++ .../PlatformDebugLibIoPort.inf | 1 + .../PlatformRomDebugLibIoPort.inf | 52 ++++++++++++++++++= ++++ OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- 8 files changed, 120 insertions(+), 18 deletions(-) create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRo= m.c create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebug= LibIoPort.inf diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Li= brary/PlatformDebugLibIoPort/DebugLib.c index 5435767c1c..a5572a8eeb 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c @@ -29,21 +29,6 @@ // #define MAX_DEBUG_MESSAGE_LENGTH 0x100 =20 -/** - This constructor function does not have to do anything. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -PlatformDebugLibIoPortConstructor ( - VOID - ) -{ - return EFI_SUCCESS; -} - /** Prints a debug message to the debug output device if the specified error= level is enabled. =20 diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/Ovmf= Pkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c new file mode 100644 index 0000000000..fee908861b --- /dev/null +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c @@ -0,0 +1,32 @@ +/** @file + Constructor code for QEMU debug port library. + Non-SEC instance. + + Copyright (c) 2017, Red Hat, Inc.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include + +/** + This constructor function does not have anything to do. + + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + +**/ +RETURN_STATUS +EFIAPI +PlatformDebugLibIoPortConstructor ( + VOID + ) +{ + return EFI_SUCCESS; +} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c b/O= vmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c new file mode 100644 index 0000000000..407fe613ff --- /dev/null +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c @@ -0,0 +1,32 @@ +/** @file + Constructor code for QEMU debug port library. + SEC instance. + + Copyright (c) 2017, Red Hat, Inc.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include + +/** + This constructor function does not have to do anything. + + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + +**/ +RETURN_STATUS +EFIAPI +PlatformRomDebugLibIoPortConstructor ( + VOID + ) +{ + return EFI_SUCCESS; +} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.= inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf index 0e74fe94cb..65d8683f1f 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf @@ -30,6 +30,7 @@ =20 [Sources] DebugLib.c + DebugLibDetect.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPo= rt.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.i= nf new file mode 100644 index 0000000000..93763d47dd --- /dev/null +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf @@ -0,0 +1,52 @@ +## @file +# Instance of Debug Library for the QEMU debug console port. +# It uses Print Library to produce formatted output strings. +# +# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, Red Hat, Inc.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PlatformRomDebugLibIoPort + FILE_GUID =3D CEB0D9D3-328F-4C24-8C02-28FA1986AE1B + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DebugLib + CONSTRUCTOR =3D PlatformRomDebugLibIoPortConstructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + DebugLib.c + DebugLibDetectRom.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseMemoryLib + IoLib + PcdLib + PrintLib + BaseLib + DebugPrintErrorLevelLib + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES + diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index c2f534fdbf..7ccb61147f 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -207,7 +207,7 @@ !ifdef $(DEBUG_ON_SERIAL_PORT) DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf !else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.i= nf + DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPor= t.inf !endif ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRepor= tStatusCodeLib.inf ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseE= xtractGuidedSectionLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 9f300a2e6f..237ec71b5e 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -212,7 +212,7 @@ !ifdef $(DEBUG_ON_SERIAL_PORT) DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf !else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.i= nf + DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPor= t.inf !endif ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRepor= tStatusCodeLib.inf ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseE= xtractGuidedSectionLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 1ffcf37f8b..a5047fa38e 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -212,7 +212,7 @@ !ifdef $(DEBUG_ON_SERIAL_PORT) DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf !else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.i= nf + DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPor= t.inf !endif ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRepor= tStatusCodeLib.inf ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseE= xtractGuidedSectionLib.inf --=20 2.14.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 05:55:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1510829249127737.9137152094239; Thu, 16 Nov 2017 02:47:29 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 75A4120359A62; Thu, 16 Nov 2017 02:43:18 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8E13921B00DEF for ; Thu, 16 Nov 2017 02:43:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA57481DEB; Thu, 16 Nov 2017 10:47:25 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-65.ams2.redhat.com [10.36.117.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87B2460602; Thu, 16 Nov 2017 10:47:24 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=pbonzini@redhat.com; receiver=edk2-devel@lists.01.org From: Paolo Bonzini To: edk2-devel@lists.01.org Date: Thu, 16 Nov 2017 11:47:16 +0100 Message-Id: <20171116104716.15144-3-pbonzini@redhat.com> In-Reply-To: <20171116104716.15144-1-pbonzini@redhat.com> References: <20171116104716.15144-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 16 Nov 2017 10:47:25 +0000 (UTC) Subject: [edk2] [PATCH 2/2] OvmfPkg: save on I/O port accesses when the debug port is not in use X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When SEV is enabled, every debug message printed by OVMF to the QEMU debug port traps from the guest to QEMU character by character because "REP OUTSB" cannot be used by IoWriteFifo8. Furthermore, when OVMF is built with the DEBUG_VERBOSE bit (value 0x00400000) enabled in "gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel", then the OvmfPkg/IoMmuDxe driver, and the OvmfPkg/Library/BaseMemEncryptSevLib library instance that is built into it, produce a huge amount of log messages. Therefore, in SEV guests, the boot time impact is huge (about 45 seconds _additional_ time spent writing to the debug port). While these messages are very useful for analyzing guest behavior, most of the time the user won't be capturing the OVMF debug log. In fact libvirt does not provide a method for configuring log capture; users that wish to do this (or are instructed to do this) have to resort to . The debug console device provides a handy detection mechanism; when read, it returns 0xE9 (which is very much unlike the 0xFF that is returned by an unused port). Use it to skip the possibly expensive OUT instructions when the debug I/O port isn't plugged anywhere. For SEC, the debug port has to be read before each full message. However: - if the debug port is available, then reading one byte before writing a full message isn't tragic, especially because SEC doesn't print many messages - if the debug port is not available, then reading one byte instead of writing a full message is still a win. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen (Intel address) Signed-off-by: Paolo Bonzini Tested-by: Laszlo Ersek --- OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 26 ++++++++-- .../PlatformDebugLibIoPort/DebugLibDetect.c | 29 +++++++++-- .../PlatformDebugLibIoPort/DebugLibDetect.h | 56 ++++++++++++++++++= ++++ .../PlatformDebugLibIoPort/DebugLibDetectRom.c | 20 +++++++- 4 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Li= brary/PlatformDebugLibIoPort/DebugLib.c index a5572a8eeb..79486ac8a6 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c @@ -23,6 +23,7 @@ #include #include #include +#include "DebugLibDetect.h" =20 // // Define the maximum debug and assert message length that this library su= pports @@ -62,9 +63,9 @@ DebugPrint ( ASSERT (Format !=3D NULL); =20 // - // Check driver debug mask value and global mask + // Do nothing if the global mask disables this message or the device is = inactive // - if ((ErrorLevel & GetDebugPrintErrorLevel ()) =3D=3D 0) { + if ((ErrorLevel & GetDebugPrintErrorLevel ()) =3D=3D 0 || !PlatformDebug= LibIoPortFound ()) { return; } =20 @@ -121,9 +122,11 @@ DebugAssert ( FileName, (UINT64)LineNumber, Description); =20 // - // Send the print string to the debug I/O port + // Send the print string to the debug I/O port, if present // - IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer); + if (PlatformDebugLibIoPortFound ()) { + IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer); + } =20 // // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings @@ -266,3 +269,18 @@ DebugPrintLevelEnabled ( { return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) = !=3D 0); } + +/** + Return the result of detecting the debug I/O port device. + + @retval BOOLEAN TRUE if the debug I/O port device was detected. + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortDetect ( + VOID + ) +{ + return IoRead8 (PcdGet16 (PcdDebugIoPort)) =3D=3D BOCHS_DEBUG_PORT_MAGIC; +} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/Ovmf= Pkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c index fee908861b..610987aca9 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c @@ -1,6 +1,6 @@ /** @file - Constructor code for QEMU debug port library. - Non-SEC instance. + Detection code for QEMU debug port. + Non-SEC instance, caches the result of detection. =20 Copyright (c) 2017, Red Hat, Inc.
This program and the accompanying materials @@ -15,9 +15,16 @@ =20 #include #include +#include "DebugLibDetect.h" + +// +// Set to TRUE if the debug I/O port is enabled +// +STATIC BOOLEAN mDebugIoPortFound =3D FALSE; =20 /** - This constructor function does not have anything to do. + This constructor function checks if the debug I/O port device is present, + caching the result for later use. =20 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. =20 @@ -28,5 +35,21 @@ PlatformDebugLibIoPortConstructor ( VOID ) { + mDebugIoPortFound =3D PlatformDebugLibIoPortDetect(); return EFI_SUCCESS; } + +/** + Return the cached result of detecting the debug I/O port device. + + @retval BOOLEAN TRUE if the debug I/O port device was detected. + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortFound ( + VOID + ) +{ + return mDebugIoPortFound; +} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h b/Ovmf= Pkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h new file mode 100644 index 0000000000..c34ca9c72b --- /dev/null +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h @@ -0,0 +1,56 @@ +/** @file + Base Debug library instance for QEMU debug port. + It uses PrintLib to send debug messages to a fixed I/O port. + + Copyright (c) 2017, Red Hat, Inc.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#ifndef __DEBUG_IO_PORT_DETECT_H__ +#define __DEBUG_IO_PORT_DETECT_H__ + +#include +#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 po= rt. + PlatformDebugLibIoPortFound can call this function directly or cache the + result. + + @retval BOOLEAN TRUE if the debug I/O port device was detected. + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortDetect ( + VOID + ); + +/** + Return whether the virtual machine has a debug I/O port. DebugLib.c + calls this function instead of PlatformDebugLibIoPortDetect, to allow + caching if possible. + + @retval BOOLEAN TRUE if the debug I/O port device was detected. + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortFound ( + VOID + ); + +#endif diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c b/O= vmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c index 407fe613ff..f71b6567dc 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c @@ -1,6 +1,6 @@ /** @file - Constructor code for QEMU debug port library. - SEC instance. + Detection code for QEMU debug port. + SEC instance, cannot cache the result of detection. =20 Copyright (c) 2017, Red Hat, Inc.
This program and the accompanying materials @@ -15,6 +15,7 @@ =20 #include #include +#include "DebugLibDetect.h" =20 /** This constructor function does not have to do anything. @@ -30,3 +31,18 @@ PlatformRomDebugLibIoPortConstructor ( { return EFI_SUCCESS; } + +/** + Return the result of detecting the debug I/O port device. + + @retval BOOLEAN TRUE if the debug I/O port device was detected. + +**/ +BOOLEAN +EFIAPI +PlatformDebugLibIoPortFound ( + VOID + ) +{ + return PlatformDebugLibIoPortDetect (); +} --=20 2.14.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel