[U-Boot] [PATCH] part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.

Scott Wood scottwood at freescale.com
Wed Aug 14 01:06:36 CEST 2013


On Mon, 2013-08-12 at 00:05 +0800, fenghua at phytium.com.cn wrote:
> From: fenghua <fenghua at ligen-virtual-machine.(none)>
> 
> This patch provide u-boot with arm64 support. Currently, it works on
> Foundation Model for armv8 or Fast Model for armv8.
> 
> Signed-off-by: fenghua <fenghua at ligen-virtual-machine.(none)>

Could you provide a proper signoff (full name and valid e-mail address)?

> ---
>  arch/arm64/config.mk                 |   32 +++
>  arch/arm64/lib/Makefile              |   64 +++++
>  arch/arm64/lib/board.c               |  456 ++++++++++++++++++++++++++++++++++
>  arch/arm64/lib/bootm.c               |  211 ++++++++++++++++
>  arch/arm64/lib/cache.c               |  282 +++++++++++++++++++++
>  arch/arm64/lib/crt0.S                |  129 ++++++++++
>  arch/arm64/lib/interrupts.c          |  109 ++++++++
>  arch/arm64/lib/relocate.S            |   72 ++++++
>  arch/arm64/lib/reset.c               |   37 +++
>  arch/arm64/lib/timer.c               |   95 +++++++
>  board/armltd/dts/vexpress64.dts      |  215 ++++++++++++++++
>  board/armltd/vexpress64/Makefile     |   43 ++++
>  board/armltd/vexpress64/vexpress64.c |   63 +++++
>  boards.cfg                           |    1 +
>  common/cmd_bdinfo.c                  |   32 +++
>  common/fdt_support.c                 |   66 ++---
>  common/image.c                       |    5 +-
>  doc/README.arm64                     |   10 +
>  examples/standalone/stubs.c          |   13 +
>  include/configs/vexpress_aemv8a.h    |  200 +++++++++++++++
>  include/image.h                      |    1 +
>  lib/asm-offsets.c                    |    2 +-
>  22 files changed, 2103 insertions(+), 35 deletions(-)
>  create mode 100644 arch/arm64/config.mk
>  create mode 100644 arch/arm64/lib/Makefile
>  create mode 100644 arch/arm64/lib/board.c
>  create mode 100644 arch/arm64/lib/bootm.c
>  create mode 100644 arch/arm64/lib/cache.c
>  create mode 100644 arch/arm64/lib/crt0.S
>  create mode 100644 arch/arm64/lib/interrupts.c
>  create mode 100644 arch/arm64/lib/relocate.S
>  create mode 100644 arch/arm64/lib/reset.c
>  create mode 100644 arch/arm64/lib/timer.c
>  create mode 100644 board/armltd/dts/vexpress64.dts
>  create mode 100644 board/armltd/vexpress64/Makefile
>  create mode 100644 board/armltd/vexpress64/vexpress64.c
>  create mode 100644 doc/README.arm64
>  create mode 100644 include/configs/vexpress_aemv8a.h

It would be nice if the patches were separated into arch support, core
support, board support, anything specific to the foundation/fast models,
etc.

> 
> diff --git a/arch/arm64/config.mk b/arch/arm64/config.mk
> new file mode 100644
> index 0000000..e40e983
> --- /dev/null
> +++ b/arch/arm64/config.mk

Does there really need to be a separate arch/arm64?  I know this is what
Linux does, but on every other 32/64 architecture that decision has been
eventually reversed (even on x86, which has about as much difference
between 32 and 64 bit as ARM does).

We started working on armv8 U-Boot using a unified arch/arm, and at
least got to the point of something that builds, so it doesn't seem
impractical.  Besides making maintenance easier, it would also make it
much easier to review what is being done differently for arm64 (and for
any files that do need to be moved or copied, be sure to pass -M -C to
git format-patch).

> @@ -0,0 +1,32 @@
> +#
> +# Copyright (c) 2013	FengHua <fenghua at phytium.com.cn>
> +#
> +# See file CREDITS for list of people who contributed to this
> +# project.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation; either version 2 of
> +# the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> +# MA 02111-1307 USA
> +#
> +
> +CROSS_COMPILE ?= /home/fenghua/DS-5-Workspace/gcc-linaro-aarch64-linux-gnu-4.8-2013.05_linux/bin/aarch64-linux-gnu-

Please don't insert references to paths that only work on your computer.

Plus, what about native builds that don't need a cross compiler?

> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index b034c98..9bc5821 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -21,6 +21,34 @@
>   */
>  DECLARE_GLOBAL_DATA_PTR;
>  
> +/*
> + * Get cells len in bytes
> + *     if #NNNN-cells property is 2 then len is 8
> + *     otherwise len is 4
> + */
> +static int get_cells_len(void *blob, char *nr_cells_name)
> +{
> +	const fdt32_t *cell;
> +
> +	cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
> +	if (cell && fdt32_to_cpu(*cell) == 2)
> +		return 8;
> +
> +	return 4;
> +}
> +
> +/*
> + * Write a 4 or 8 byte big endian cell
> + */
> +static void write_cell(u8 *addr, u64 val, int size)
> +{
> +	int shift = (size - 1) * 8;
> +	while (size-- > 0) {
> +		*addr++ = (val >> shift) & 0xff;
> +		shift -= 8;
> +	}
> +}
> +
>  /**
>   * fdt_getprop_u32_default - Find a node and return it's property or a default
>   *
> @@ -131,9 +159,9 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff)
>  
>  int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force)
>  {
> -	int   nodeoffset;
> +	int   nodeoffset, addr_cell_len;
>  	int   err, j, total;
> -	fdt32_t  tmp;
> +	fdt64_t  tmp;
>  	const char *path;
>  	uint64_t addr, size;
>  
> @@ -170,9 +198,11 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force)
>  		return err;
>  	}
>  
> +	addr_cell_len = get_cells_len(fdt, "#address-cells");
> +
>  	path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL);
>  	if ((path == NULL) || force) {
> -		tmp = cpu_to_fdt32(initrd_start);
> +		write_cell((u8 *)&tmp, initrd_start, addr_cell_len);
>  		err = fdt_setprop(fdt, nodeoffset,
>  			"linux,initrd-start", &tmp, sizeof(tmp));
>  		if (err < 0) {
> @@ -181,7 +211,7 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force)
>  				fdt_strerror(err));
>  			return err;
>  		}
> -		tmp = cpu_to_fdt32(initrd_end);
> +		write_cell((u8 *)&tmp, initrd_end, addr_cell_len);
>  		err = fdt_setprop(fdt, nodeoffset,
>  			"linux,initrd-end", &tmp, sizeof(tmp));
>  		if (err < 0) {
> @@ -343,34 +373,6 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,
>  	do_fixup_by_compat(fdt, compat, prop, &tmp, 4, create);
>  }
>  
> -/*
> - * Get cells len in bytes
> - *     if #NNNN-cells property is 2 then len is 8
> - *     otherwise len is 4
> - */
> -static int get_cells_len(void *blob, char *nr_cells_name)
> -{
> -	const fdt32_t *cell;
> -
> -	cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
> -	if (cell && fdt32_to_cpu(*cell) == 2)
> -		return 8;
> -
> -	return 4;
> -}
> -
> -/*
> - * Write a 4 or 8 byte big endian cell
> - */
> -static void write_cell(u8 *addr, u64 val, int size)
> -{
> -	int shift = (size - 1) * 8;
> -	while (size-- > 0) {
> -		*addr++ = (val >> shift) & 0xff;
> -		shift -= 8;
> -	}
> -}
> -
>  #ifdef CONFIG_NR_DRAM_BANKS
>  #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS
>  #else

What's going on here?

> @@ -422,7 +423,7 @@ ulong getenv_bootm_low(void)
>  
>  #if defined(CONFIG_SYS_SDRAM_BASE)
>  	return CONFIG_SYS_SDRAM_BASE;
> -#elif defined(CONFIG_ARM)
> +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
>  	return gd->bd->bi_dram[0].start;
>  #else
>  	return 0;
> @@ -444,7 +445,7 @@ phys_size_t getenv_bootm_size(void)
>  		tmp = 0;
>  
> 
> -#if defined(CONFIG_ARM)
> +#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
>  	return gd->bd->bi_dram[0].size - tmp;
>  #else
>  	return gd->bd->bi_memsize - tmp;

Ignoring the issue of why CONFIG_ARM is not defined here, why is ARM
special?

> diff --git a/doc/README.arm64 b/doc/README.arm64
> new file mode 100644
> index 0000000..8fef26d
> --- /dev/null
> +++ b/doc/README.arm64
> @@ -0,0 +1,10 @@
> +Notes:
> +
> +1. Currenly, u-boot running at EL2.
> +
> +2. Currently, gcc-aarch64 produce error when compiling with pie and rel_dyn.

arm64 uses rela, not rel.  This requires a small change to the
relocation code and the linker script.

> +   So, GOT is used to relocate u-boot and CONFIG_NEEDS_MANUAL_RELOC is needed.

:-(

> +3. Currently, fdt should be in the first 512MB of RAM, so, fdt_high should be handled specially.
> +   I define fdt_high as 0xa0000000 when CONFIG_SYS_SDRAM_BASE is 0x80000000.
> +
> diff --git a/examples/standalone/stubs.c b/examples/standalone/stubs.c
> index 8fb1765..4e39b1b 100644
> --- a/examples/standalone/stubs.c
> +++ b/examples/standalone/stubs.c
> @@ -195,6 +195,19 @@ gd_t *global_data;
>  "	l.jr	r13\n"		\
>  "	l.nop\n"				\
>  	: : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r13");
> +#elif defined(CONFIG_ARM64)
> +/*
> + * x18 holds the pointer to the global_data, ip is a call-clobbered
> + * register
> + */
> +#define EXPORT_FUNC(x) \
> +	asm volatile (			\
> +"	.globl " #x "\n"		\
> +#x ":\n"				\
> +"	ldr	x19, [x18, %0]\n"		\
> +"	ldr	x19, [x19, %1]\n"		\
> +"	br	x19\n"		\
> +	: : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "x19");

Why use a nonvolate register here?

>  #else
>  /*"	addi	$sp, $sp, -24\n"	\
>  "	br	$r16\n"			\*/
> diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h
> new file mode 100644
> index 0000000..3c96987
> --- /dev/null
> +++ b/include/configs/vexpress_aemv8a.h
> @@ -0,0 +1,200 @@
> +/*
> + * Configuration for Versatile Express. Parts were derived from other ARM
> + *   configurations.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#ifndef __VEXPRESS_AEMV8A_H
> +#define __VEXPRESS_AEMV8A_H
> +
> +#define DEBUG
> +
> +#define CONFIG_SYS_NO_FLASH
> +
> +#define CONFIG_SUPPORT_RAW_INITRD
> +
> +#define CONFIG_SKIP_LOWLEVEL_INIT
> +
> +/* Cache Definitions */
> +//#define CONFIG_SYS_DCACHE_OFF
> +//#define CONFIG_SYS_ICACHE_OFF
> +
> +#define CONFIG_IDENT_STRING		" aarch64"

Shouldn't CONFIG_IDENT_STRING be the target name (i.e. the board name)?

-Scott





More information about the U-Boot mailing list