From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.1981.1587750746633824162 for ; Fri, 24 Apr 2020 10:52:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XjQTuZlo; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587750745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aQinpMZ6/P7broks1+CGCvNz+MaSxwSKwOZLnn9DJIA=; b=XjQTuZloyg2+oNFjkVzkXt8VgqK0sUbKwh/hCsBXf11FaClOeHKueQBaXD041XWaevkSac KVfM5Oq3OLHeCNUbLl2jh+6J9FrDsQxJUdcDTNGbIV77ssL6bmyWuZ9xuU3TK3Ucru35R/ /Smq/UWW/AgjGbtNbPYh5GnyeHRhLl4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-hqIf4yTtN6OAbGU6jyVX3A-1; Fri, 24 Apr 2020 13:52:24 -0400 X-MC-Unique: hqIf4yTtN6OAbGU6jyVX3A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC2F8107ACCA; Fri, 24 Apr 2020 17:52:22 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-159.ams2.redhat.com [10.36.113.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9910860300; Fri, 24 Apr 2020 17:52:21 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 3/5] OvmfPkg/PlatformDebugLibIoPort: factor out debug port detection To: devel@edk2.groups.io, anthony.perard@citrix.com Cc: Ard Biesheuvel , Jordan Justen , Julien Grall References: <20200423095358.2518197-1-anthony.perard@citrix.com> <20200423095358.2518197-4-anthony.perard@citrix.com> From: "Laszlo Ersek" Message-ID: <7f0b0fcc-ea23-76a5-ec66-8427270f397e@redhat.com> Date: Fri, 24 Apr 2020 19:52:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200423095358.2518197-4-anthony.perard@citrix.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 04/23/20 11:53, Anthony PERARD wrote: > Factor out debug port detection in PlatformDebugLibIoPort. > > Signed-off-by: Anthony PERARD > --- > .../PlatformDebugLibIoPort.inf | 1 + > .../PlatformRomDebugLibIoPort.inf | 1 + > .../PlatformDebugLibIoPort/DebugLibDetect.h | 6 ---- > .../PlatformDebugLibIoPort/DebugIoPortQemu.c | 34 +++++++++++++++++++ > .../Library/PlatformDebugLibIoPort/DebugLib.c | 16 --------- > 5 files changed, 36 insertions(+), 22 deletions(-) > create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c > > diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf > index c09f312ffb1d..94ab9105077a 100644 > --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf > +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf > @@ -24,6 +24,7 @@ [Defines] > # > > [Sources] > + DebugIoPortQemu.c > DebugLib.c > DebugLibDetect.c > DebugLibDetect.h > diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf > index ab27f6327a38..8f721d249dd5 100644 > --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf > +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf > @@ -24,6 +24,7 @@ [Defines] > # > > [Sources] > + DebugIoPortQemu.c > DebugLib.c > DebugLibDetect.h > DebugLibDetectRom.c > diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h > index 4677c85ac3c4..6d08909dbc58 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/DebugIoPortQemu.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c > new file mode 100644 > index 000000000000..bf9119807a6c > --- /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 ec2e677afd8d..dffb20822d18 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; > -} > Reviewed-by: Laszlo Ersek