mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] ARM: qemu: add support for qemu virt platform
Date: Wed, 4 Nov 2020 11:48:45 +0100	[thread overview]
Message-ID: <20201104104845.dviotc2zy3vlo5nz@pengutronix.de> (raw)
In-Reply-To: <20201103114948.31021-2-r.czerwinski@pengutronix.de>

On Tue, Nov 03, 2020 at 12:49:48PM +0100, Rouven Czerwinski wrote:
> Necessary support to boot barebox on ARM qemu virt platforms.
> No internal device tree, since it is passed by qemu. Also currently
> expects -m 1024M because of the hard set memsize.
> Future improvements to read the memory size directly from the dtb
> welcome.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  arch/arm/boards/Makefile                  |  1 +
>  arch/arm/boards/qemu-virt/Makefile        |  2 ++
>  arch/arm/boards/qemu-virt/board.c         | 25 +++++++++++++
>  arch/arm/boards/qemu-virt/lowlevel.c      | 43 +++++++++++++++++++++++
>  arch/arm/boards/qemu-virt/lowlevel_init.S | 10 ++++++
>  arch/arm/mach-qemu/Kconfig                |  7 ++++
>  arch/arm/mach-qemu/Makefile               |  2 +-
>  7 files changed, 89 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/boards/qemu-virt/Makefile
>  create mode 100644 arch/arm/boards/qemu-virt/board.c
>  create mode 100644 arch/arm/boards/qemu-virt/lowlevel.c
>  create mode 100644 arch/arm/boards/qemu-virt/lowlevel_init.S
> 
> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
> index a02d80d2da..8d191f97aa 100644
> --- a/arch/arm/boards/Makefile
> +++ b/arch/arm/boards/Makefile
> @@ -164,6 +164,7 @@ obj-$(CONFIG_MACH_ZYLONITE)			+= zylonite/
>  obj-$(CONFIG_MACH_VARISCITE_MX6)		+= variscite-mx6/
>  obj-$(CONFIG_MACH_VSCOM_BALTOS)			+= vscom-baltos/
>  obj-$(CONFIG_MACH_QEMU_VIRT64)			+= qemu-virt64/
> +obj-$(CONFIG_MACH_QEMU_VIRT)			+= qemu-virt/
>  obj-$(CONFIG_MACH_WARP7)			+= element14-warp7/
>  obj-$(CONFIG_MACH_WEBASTO_CCBV2)		+= webasto-ccbv2/
>  obj-$(CONFIG_MACH_VF610_TWR)			+= freescale-vf610-twr/
> diff --git a/arch/arm/boards/qemu-virt/Makefile b/arch/arm/boards/qemu-virt/Makefile
> new file mode 100644
> index 0000000000..03def2a918
> --- /dev/null
> +++ b/arch/arm/boards/qemu-virt/Makefile
> @@ -0,0 +1,2 @@
> +lwl-y += lowlevel.o lowlevel_init.o
> +obj-y += board.o
> diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c
> new file mode 100644
> index 0000000000..e39b104705
> --- /dev/null
> +++ b/arch/arm/boards/qemu-virt/board.c
> @@ -0,0 +1,25 @@
> +// SPDX-License-Identifier: GPL-2.0+

Here you're also using the deprecated identifiers. Please use
GPL-2.0-or-later instead.

> +/*
> + * Copyright (C) 2020 Pengutronix e.K.
> + *
> + */
> +#include <common.h>
> +#include <init.h>
> +#include <asm/armlinux.h>
> +#include <asm/system_info.h>
> +#include <asm/pgtable64.h>
> +#include <mach/devices.h>
> +#include <environment.h>
> +#include <linux/sizes.h>
> +#include <io.h>
> +#include <envfs.h>
> +#include <globalvar.h>
> +#include <asm/mmu.h>
> +
> +static int virt_console_init(void)
> +{
> +	virt_register_uart(0);
> +
> +	return 0;
> +}
> +console_initcall(virt_console_init);
> diff --git a/arch/arm/boards/qemu-virt/lowlevel.c b/arch/arm/boards/qemu-virt/lowlevel.c
> new file mode 100644
> index 0000000000..9024eed5f9
> --- /dev/null
> +++ b/arch/arm/boards/qemu-virt/lowlevel.c
> @@ -0,0 +1,43 @@
> +// SPDX-License-Identifier: GPL-2.0+

here too

> +/*
> + * Copyright (C) 2020 Pengutronix e.K.
> + *
> + */
> +
> +#include <common.h>
> +#include <linux/sizes.h>
> +#include <asm/barebox-arm-head.h>
> +#include <asm/barebox-arm.h>
> +#include <asm/system_info.h>
> +#include <asm/unaligned.h>
> +
> +void qemu_virt_start(uint32_t, uint32_t, uint32_t);
> +
> +static void virt_entry(uint32_t r2) {
> +	void *fdt = NULL;
> +    	unsigned long membase = 0x40000000;
> +	unsigned long memsize = SZ_512M;
> +
> +	if (IS_ENABLED(CONFIG_OFDEVICE) &&
> +	    get_unaligned_be32((void*)r2) == FDT_MAGIC) {
> +		fdt = (void*)r2;
> +		/*
> +		 * Need to move membase a bit as the PBL wants to relocate
> +		 * to the start of RAM, which would overwrite the DTB.
> +		 */
> +	}
> +
> +	barebox_arm_entry(membase, memsize, fdt);
> +}
> +
> +void noinline qemu_virt_start(uint32_t r0, uint32_t r1, uint32_t r2)
> +{
> +	arm_cpu_lowlevel_init();
> +
> +	relocate_to_current_adr();
> +	setup_c();
> +	barrier();
> +
> +	virt_entry(r2);
> +}
> +
> diff --git a/arch/arm/boards/qemu-virt/lowlevel_init.S b/arch/arm/boards/qemu-virt/lowlevel_init.S
> new file mode 100644
> index 0000000000..3558df0591
> --- /dev/null
> +++ b/arch/arm/boards/qemu-virt/lowlevel_init.S
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */

and here.

 - Roland

> +
> +/* The DRAM is already setup */
> +#define STACK_TOP 0x50000000
> +
> +.globl barebox_arm_reset_vector
> +barebox_arm_reset_vector:
> +	mov r0, #STACK_TOP
> +	mov sp, r0
> +	b qemu_virt_start
> diff --git a/arch/arm/mach-qemu/Kconfig b/arch/arm/mach-qemu/Kconfig
> index d30bae4c6f..dd3ccd8740 100644
> --- a/arch/arm/mach-qemu/Kconfig
> +++ b/arch/arm/mach-qemu/Kconfig
> @@ -14,5 +14,12 @@ config MACH_QEMU_VIRT64
>  	select ARM_AMBA
>  	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
>  
> +config MACH_QEMU_VIRT
> +	bool "QEMU arm virt machine"
> +	select CPU_V7
> +	select ARM_AMBA
> +	select RELOCATABLE
> +	select ARM_PSCI_CLIENT
> +
>  endchoice
>  endif
> diff --git a/arch/arm/mach-qemu/Makefile b/arch/arm/mach-qemu/Makefile
> index ece277ce0e..8f73aa41a5 100644
> --- a/arch/arm/mach-qemu/Makefile
> +++ b/arch/arm/mach-qemu/Makefile
> @@ -1 +1 @@
> -obj-$(CONFIG_MACH_QEMU_VIRT64) += virt_devices.o
> +obj-$(CONFIG_ARCH_QEMU) += virt_devices.o
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-11-04 10:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 11:49 [PATCH 1/2] ARM: boards: qemu-virt64: use SPDX-License Ids Rouven Czerwinski
2020-11-03 11:49 ` [PATCH 2/2] ARM: qemu: add support for qemu virt platform Rouven Czerwinski
2020-11-04 10:48   ` Roland Hieber [this message]
2020-11-04  8:00 ` [PATCH 1/2] ARM: boards: qemu-virt64: use SPDX-License Ids Sascha Hauer

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=20201104104845.dviotc2zy3vlo5nz@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox