On 04/23/20 11:53, Anthony PERARD wrote:
> Factor out debug port detection in PlatformDebugLibIoPort.
> 
> Signed-off-by: Anthony PERARD <anthony.per...@citrix.com>
> ---
>  .../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 <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
> 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.<BR>
> +  Copyright (c) 2012, Red Hat, Inc.<BR>
> +  Copyright (c) 2020, Citrix Systems, Inc.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/IoLib.h>
> +#include <Library/PcdLib.h>
> +#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 <ler...@redhat.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58078): https://edk2.groups.io/g/devel/message/58078
Mute This Topic: https://groups.io/mt/73215166/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to