All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: andre.przywara@arm.com, kvmarm@lists.cs.columbia.edu,
	kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v3 1/5] lib: arm: Use UART address from generated config.h
Date: Mon, 4 Feb 2019 15:00:01 +0100	[thread overview]
Message-ID: <20190204140001.tollipaxeiom2ug6@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20190204134412.47877-2-alexandru.elisei@arm.com>

On Mon, Feb 04, 2019 at 01:44:08PM +0000, Alexandru Elisei wrote:
> Generate lib/config.h when configuring kvm-unit-tests. The file is empty
> for all architectures except for arm and arm64, where it is used to store
> the UART base address. This removes the hardcoded address from lib/arm/io.c
> and provides a mechanism for using different UART addresses in the future.
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  configure    | 17 +++++++++++++++++
>  Makefile     |  2 +-
>  lib/arm/io.c | 12 ++++++------
>  .gitignore   |  1 +
>  4 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index df8581e3a906..b4732c6c04e4 100755
> --- a/configure
> +++ b/configure
> @@ -198,3 +198,20 @@ ENVIRON_DEFAULT=$environ_default
>  ERRATATXT=errata.txt
>  U32_LONG_FMT=$u32_long
>  EOF
> +
> +cat <<EOF > lib/config.h
> +#ifndef CONFIG_H
> +#define CONFIG_H 1
> +/*
> + * Generated file. DO NOT MODIFY.
> + *
> + */
> +EOF
> +if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
> +cat <<EOF >> lib/config.h
> +
> +#define CONFIG_UART_EARLY_BASE 0x09000000
> +
> +EOF
> +fi
> +echo "#endif" >> lib/config.h
> diff --git a/Makefile b/Makefile
> index e9f02272e156..643af05678ad 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -115,7 +115,7 @@ libfdt_clean:
>  	$(LIBFDT_objdir)/.*.d
>  
>  distclean: clean libfdt_clean
> -	$(RM) lib/asm config.mak $(TEST_DIR)-run msr.out cscope.* build-head
> +	$(RM) lib/asm lib/config.h config.mak $(TEST_DIR)-run msr.out cscope.* build-head
>  	$(RM) -r tests logs logs.old
>  
>  cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/asm-generic
> diff --git a/lib/arm/io.c b/lib/arm/io.c
> index d2c1a07c19ee..e84a5c89fcb1 100644
> --- a/lib/arm/io.c
> +++ b/lib/arm/io.c
> @@ -11,6 +11,7 @@
>  #include <libcflat.h>
>  #include <devicetree.h>
>  #include <chr-testdev.h>
> +#include <config.h>
>  #include <asm/spinlock.h>
>  #include <asm/io.h>
>  
> @@ -18,6 +19,7 @@
>  
>  extern void halt(int code);
>  
> +static struct spinlock uart_lock;
>  /*
>   * Use this guess for the pl011 base in order to make an attempt at
>   * having earlier printf support. We'll overwrite it with the real
> @@ -25,10 +27,8 @@ extern void halt(int code);
>   * the address we expect QEMU's mach-virt machine type to put in
>   * its generated device tree.
>   */
> -#define UART_EARLY_BASE 0x09000000UL
> -
> -static struct spinlock uart_lock;
> -static volatile u8 *uart0_base = (u8 *)UART_EARLY_BASE;
> +#define UART_EARLY_BASE (u8 *)(unsigned long)CONFIG_UART_EARLY_BASE
> +static volatile u8 *uart0_base = UART_EARLY_BASE;
>  
>  static void uart0_init(void)
>  {
> @@ -58,10 +58,10 @@ static void uart0_init(void)
>  
>  	uart0_base = ioremap(base.addr, base.size);
>  
> -	if (uart0_base != (u8 *)UART_EARLY_BASE) {
> +	if (uart0_base != UART_EARLY_BASE) {
>  		printf("WARNING: early print support may not work. "
>  		       "Found uart at %p, but early base is %p.\n",
> -			uart0_base, (u8 *)UART_EARLY_BASE);
> +			uart0_base, UART_EARLY_BASE);
>  	}
>  }
>  
> diff --git a/.gitignore b/.gitignore
> index 2405a8087ae5..483f7c7a09ea 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -10,6 +10,7 @@ patches
>  cscope.*
>  *.swp
>  /lib/asm
> +/lib/config.h
>  /config.mak
>  /*-run
>  /msr.out
> -- 
> 2.17.0
>

Reviewed-by: Andrew Jones <drjones@redhat.com>

  reply	other threads:[~2019-02-04 14:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 13:44 [kvm-unit-tests PATCH v3 0/5] arm/arm64: Add support for running under kvmtool Alexandru Elisei
2019-02-04 13:44 ` [kvm-unit-tests PATCH v3 1/5] lib: arm: Use UART address from generated config.h Alexandru Elisei
2019-02-04 14:00   ` Andrew Jones [this message]
2019-02-04 14:17     ` Alexandru Elisei
2019-02-04 14:40       ` Andrew Jones
2019-02-20 13:14         ` Alexandru Elisei
2019-02-26  9:29           ` Vladimir Murzin
2019-02-04 13:44 ` [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Add --vmm option with no effect Alexandru Elisei
2019-02-04 13:44 ` [kvm-unit-tests PATCH v3 3/5] lib: arm: Use ns16550a UART when --vmm=kvmtool Alexandru Elisei
2019-02-04 13:44 ` [kvm-unit-tests PATCH v3 4/5] lib: arm: Implement PSCI SYSTEM_OFF in psci_system_off() Alexandru Elisei
2019-02-04 13:44 ` [kvm-unit-tests PATCH v3 5/5] lib: arm: Fallback to psci_system_off() in exit() Alexandru Elisei
2019-02-04 14:39 ` [kvm-unit-tests PATCH v3 0/5] arm/arm64: Add support for running under kvmtool Andrew Jones
2019-02-05 12:05   ` Alexandru Elisei
2019-02-05 12:38     ` Andrew Jones
2019-02-05 13:26       ` Alexandru Elisei
2019-02-05 14:29 ` [PATCH 6/5] arm/arm64: selftest.vectors-user: clean up PSCI exit Andrew Jones

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-all 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=20190204140001.tollipaxeiom2ug6@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.