From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.3888.1587639051582025745 for ; Thu, 23 Apr 2020 03:50:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U31Ki4vX; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587639050; 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=9oBJDmWzJJA4GoHKrcOKTdP47FxWfocO3hVfghuZuOg=; b=U31Ki4vXREwXa0PYSVV+gdD2gBh5oWlpr7xKr05ocYtHezaSsCtHDLeKn5uuAXbiCDxRVS /TXea4Uu95gH1lUYSjAYP3Pun6jR8Fvf5PE9pS9Hv8W1B3AM3UEkN/w03dWzJVW2BUjWU6 sklxi3oxCvNZqJFHen5h2p2aMPzbcFA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-j1GynB32NkWgLERKCEwbew-1; Thu, 23 Apr 2020 06:50:49 -0400 X-MC-Unique: j1GynB32NkWgLERKCEwbew-1 Received: by mail-wr1-f72.google.com with SMTP id v9so2648815wrt.7 for ; Thu, 23 Apr 2020 03:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9oBJDmWzJJA4GoHKrcOKTdP47FxWfocO3hVfghuZuOg=; b=n7q3PMBA3H9RGQGHOn6YodTKHAnxjGib0SOqJ/hk3+W/HLDbHrDqXh3icIWeVqfYOn 3dNV44VFl+J2fWkCqqnBa7An1jqRIGqN2sNgYuaf17C6JEAUHMEuFZdi/Auep+5Nh9K+ AJpWdIwpRBo0Uo31dTgvTTs7xqBxzXQalpPK9WhdrzHxqEZHFTCCOMsyeJAeY3F7fMjv XXgfvzuy1sZck9WDdd7A4Dc3DH4GCro+fkyVWQiH3YW55zqdoSzU1tAR1AnDHrR60B1I 6FbfvyF1v9HMsn97HoR1o60f7r6ICKA80YOhlMc0lnmexKyXEDyNnT5dysIK3nzjX05Q 6oQg== X-Gm-Message-State: AGi0PuYBemcnwCvWFLiJLWTyCgl2zM8HoYUlgbsS8vsr3gdmCXgKeD3o oAv8dlkDCSGtJ7eaYenQeoVtM1XJlXzD98J3tfGKh2vRwnThugVSar88w5ts2/NQFssiuYUj3l7 Fjo95lRtvSti+rw== X-Received: by 2002:a05:600c:210c:: with SMTP id u12mr3604082wml.135.1587639048051; Thu, 23 Apr 2020 03:50:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJh0vmjPupIu/KrodZKpLrK4AfIdvpXWixuVJCvI88QkulXLQFJuK9mcW0Fz+8iODGrqpooKQ== X-Received: by 2002:a05:600c:210c:: with SMTP id u12mr3604062wml.135.1587639047796; Thu, 23 Apr 2020 03:50:47 -0700 (PDT) Return-Path: Received: from [192.168.1.39] (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id r2sm3244086wmg.2.2020.04.23.03.50.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Apr 2020 03:50:47 -0700 (PDT) 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: Laszlo Ersek , Ard Biesheuvel , Jordan Justen , Julien Grall References: <20200423095358.2518197-1-anthony.perard@citrix.com> <20200423095358.2518197-4-anthony.perard@citrix.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <83d0b431-bca5-5bfd-3b70-b69eae95818d@redhat.com> Date: Thu, 23 Apr 2020 12:50:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200423095358.2518197-4-anthony.perard@citrix.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 4/23/20 11:53 AM, 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: Philippe Mathieu-Daude