part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
Subsystems (3)
PATCH 1/1 part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
From: fenghua <fenghua@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.
--- 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
arch/arm64/config.mk new file +32 -0
@@ -0,0 +1,32 @@ +# +# Copyright (c) 2013 FengHua <[email protected]> +# +# 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- + +ifndef CONFIG_STANDALONE_LOAD_ADDR +CONFIG_STANDALONE_LOAD_ADDR = 0x81000000 +endif + +PLATFORM_CPPFLAGS += -DCONFIG_ARM64 -fpic -mstrict-align + +# needed for relocation +LDFLAGS_u-boot +=
arch/arm64/lib/Makefile new file +64 -0
64 lines not on this page · raw message
arch/arm64/lib/board.c new file +456 -0
456 lines not on this page · raw message
arch/arm64/lib/bootm.c new file +211 -0
211 lines not on this page · raw message
arch/arm64/lib/cache.c new file +282 -0
282 lines not on this page · raw message
arch/arm64/lib/crt0.S new file +129 -0
129 lines not on this page · raw message
arch/arm64/lib/interrupts.c new file +109 -0
109 lines not on this page · raw message
arch/arm64/lib/relocate.S new file +72 -0
72 lines not on this page · raw message
arch/arm64/lib/reset.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2013 David Feng <[email protected]> +* +* 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 +*/ + +#include <common.h> + +int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +puts ("Resetting system ...\n" ); + +udelay (50000 );/* wait 50 ms */ + +disable_interrupts (); + +reset_cpu (0 ); + +/*NOTREACHED*/ +return 0 ; +}
arch/arm64/lib/timer.c new file +95 -0
95 lines not on this page · raw message
board/armltd/dts/vexpress64.dts new file +215 -0
215 lines not on this page · raw message
board/armltd/vexpress64/Makefile new file +43 -0
43 lines not on this page · raw message
board/armltd/vexpress64/vexpress64.c new file +63 -0
63 lines not on this page · raw message
boards.cfg +1 -0
@@ -1182,5 +1182,6 @@ gr_ep2s60 sparc leon3 - gaisler grsim sparc leon3 - gaisler gr_xc3s_1500 sparc leon3 - gaisler coreboot-x86 x86 x86 coreboot chromebook-x86 coreboot coreboot:SYS_TEXT_BASE=0x01110000 +vexpress_aemv8a arm64 armv8 vexpress64 armltd # Target ARCH CPU Board name Vendor SoC Options ########################################################################################################################
common/cmd_bdinfo.c +32 -0
@@ -517,6 +517,38 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 0 ; } +#elif defined(CONFIG_ARM64 ) + +int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +int i; + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) { +print_num ("DRAM bank" , i); +print_num (" -> start" , gd->bd->bi_dram[i].start); +print_num (" -> size" , gd->bd->bi_dram[i].size); + } + +printf ("baudrate = %ld bps\n" , gd->bd->bi_baudrate); + +print_num ("relocaddr" , gd->relocaddr); +print_num ("reloc off" , gd->reloc_off); +print_num ("sp start " , gd->start_addr_sp); +#ifndef CONFIG_SYS_DCACHE_OFF +print_num ("TLB addr" , gd->arch.tlb_addr); +#endif + +printf ("CPU frequency = %ld MHz\n" , gd->cpu_clk); +printf ("DDR frequency = %ld MHz\n" , gd->mem_clk); + +#if defined(CONFIG_CMD_NET ) +print_eth (0 ); +printf ("ip_addr = %s\n" ,getenv ("ipaddr" )); +#endif + +return 0 ; +} +#else #error "a case for this architecture does not exist!"#endif
common/fdt_support.c +34 -32
99 lines not on this page · raw message
common/image.c +3 -2
@@ -81,6 +81,7 @@ static const table_entry_t uimage_arch[] = { { IH_ARCH_NDS32, "nds32", "NDS32", }, { IH_ARCH_OPENRISC, "or1k", "OpenRISC 1000",}, { IH_ARCH_SANDBOX, "sandbox", "Sandbox", }, + { IH_ARCH_ARM64, "arm64", "ARM64", }, { -1, "", "", }, };
@@ -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;
doc/README.arm64 new file +10 -0
@@ -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. + 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. +
examples/standalone/stubs.c +13 -0
@@ -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");#else /*" addi $sp, $sp, -24\n" \ " br $r16\n" \*/
include/configs/vexpress_aemv8a.h new file +200 -0
200 lines not on this page · raw message
include/image.h +1 -0
@@ -156,6 +156,7 @@ struct lmb;#define IH_ARCH_SANDBOX 19/* Sandbox architecture (test only) */ #define IH_ARCH_NDS32 20/* ANDES Technology - NDS32 */ #define IH_ARCH_OPENRISC 21/* OpenRISC 1000 */ +#define IH_ARCH_ARM64 22/* ARM64 */ /* * Image Types
lib/asm-offsets.c +1 -1
@@ -29,7 +29,7 @@ int main(void)DEFINE (GD_BD , offsetof(struct global_data , bd)); -#if defined(CONFIG_ARM ) +#if defined(CONFIG_ARM ) || defined(CONFIG_ARM64 )DEFINE (GD_RELOCADDR , offsetof(struct global_data , relocaddr));
Signature · 1 line
1.7.9.5
PATCH 1/1 part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
Quoted 6 lines · fenghua at phytium.com.cn
From: fenghua <fenghua@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@ligen-virtual-machine.(none)>
It boots! Even it has a lot of compiling warning, but it is really a good start. Thanks for sharing!
York
PATCH 1/1 part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
In reply to fenghua at phytium.com.cnQuoted 6 lines · fenghua at phytium.com.cn
From: fenghua <fenghua@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@ligen-virtual-machine.(none)>
Could you provide a proper signoff (full name and valid e-mail address)?
Quoted 31 lines
--- 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
Quoted 8 lines
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.
arch/arm64/config.mk
Quoted 6 lines
arch/arm64/config.mk new file +0
-0
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).
Quoted 14 lines
arch/arm64/config.mk new file +13
-0@@ -0,0 +1,32 @@ +# +# Copyright (c) 2013 FengHua <[email protected]> +# +# 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
arch/arm64/config.mk line 23
Quoted 10 lines
arch/arm64/config.mk new file +10
-0+# 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?
Quoted 98 lines
common/fdt_support.c +34
-25@@ -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) -{
common/fdt_support.c void do_fixup_by_compat_u32(void *fdt, const char *compat, · line 378
Quoted 10 lines
common/fdt_support.c +0
-7-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?
Quoted 10 lines
common/fdt_support.c +1
-1@@ -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 ;
common/fdt_support.c phys_size_t getenv_bootm_size(void) · line 451
Quoted 8 lines
common/fdt_support.c +1
-1@@ -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?
doc/README.arm64 line 5
Quoted 11 lines
doc/README.arm64 new file +5
-0@@ -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.
doc/README.arm64 line 6
Quoted 1 line
doc/README.arm64 new file +1
-0+ So, GOT is used to relocate u-boot and CONFIG_NEEDS_MANUAL_RELOC is needed.
:-(
Quoted 14 lines
doc/README.arm64 new file +3
-0+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. +examples/standalone/stubs.c +3
-0@@ -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
examples/standalone/stubs.c gd_t *global_data; · line 210
Quoted 10 lines
examples/standalone/stubs.c +10
-0+* 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?
Quoted 38 lines
examples/standalone/stubs.c +0
-0#else /*" addi $sp, $sp, -24\n" \ " br $r16\n" \*/ include/configs/vexpress_aemv8a.h new file +29
-0@@ -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
include/configs/vexpress_aemv8a.h line 39
Quoted 10 lines
include/configs/vexpress_aemv8a.h new file +10
-0+ +#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
PATCH 1/1 part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
Quoted 11 lines
-----????-----
???: "Scott Wood" <[email protected]>
????: 2013?8?14? ???
???: fenghua at phytium.com.cn
??: u-boot at lists.denx.de, trini at ti.com
??: Re: [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.On Mon, 2013-08-12 at 00:05 +0800, fenghua at phytium.com.cn wrote:
Quoted 8 lines
Quoted 6 lines
From: fenghua <fenghua@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@ligen-virtual-machine.(none)>Could you provide a proper signoff (full name and valid e-mail address)?
I will fix it.
Quoted 41 lines
Quoted 32 lines
--- 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.cQuoted 8 lines
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
Quoted 3 lines
It would be nice if the patches were separated into arch support, core support, board support, anything specific to the foundation/fast models, etc.
Actually, I prefered to generate one patch file. but, it's size is out of 100KB.
so, I split it to two part. I will try to generate patch as you recommended.
Quoted 13 lines
arch/arm64/config.mk
Quoted 7 lines
arch/arm64/config.mk new file +0
-0Does 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).
Quoted 7 lines
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).
The porting is performed as a seperate architecture due to a few considerations,
1. The porting will be simple and clear. There's no need to touch any original ARM code and less macro switch is needed.
2. There's no any real chip of armv8 until now. Many aspect of armv8 are not completely confirmed.
Of course, it could be merged with ARM at a proper time in the later. Actually, linux kernel follow this mode.
Quoted 18 lines
Quoted 18 lines
arch/arm64/config.mk new file +17
-0@@ -0,0 +1,32 @@ +# +# Copyright (c) 2013 FengHua <[email protected]> +# +# 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
Quoted 9 lines
arch/arm64/config.mk line 23
Quoted 6 lines
arch/arm64/config.mk new file +6
-0+# 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.
I will fix it.
Quoted 1 line
Plus, what about native builds that don't need a cross compiler?
Currently, there's no real chip of armv8. so,cross compiler is needed.
Quoted 103 lines
Quoted 103 lines
common/fdt_support.c +34
-29@@ -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 ;
Quoted 9 lines
common/fdt_support.c void do_fixup_by_compat_u32(void *fdt, const char *compat, · line 378
Quoted 6 lines
common/fdt_support.c +0
-3- } -} -#ifdef CONFIG_NR_DRAM_BANKS #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else What's going on here?
Whitout this the initrd represented by "linux,initrd-start" could only be placed under 4G address space. This part fix it to 64 bit address space.
Quoted 22 lines
Quoted 10 lines
common/fdt_support.c +1
-1@@ -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 ;common/fdt_support.c phys_size_t getenv_bootm_size(void) · line 451
Quoted 8 lines
common/fdt_support.c +1
-1@@ -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_ARMis not defined here, why is ARM special?
Quoted 15 lines
doc/README.arm64 line 5
Quoted 11 lines
doc/README.arm64 new file +5
-0@@ -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.
I also try to use rela but it not works. maybe something is wrong with the code.
Quoted 22 lines
doc/README.arm64 line 6
Quoted 1 line
doc/README.arm64 new file +1
-0+ So, GOT is used to relocate u-boot and CONFIG_NEEDS_MANUAL_RELOC is needed.:-(
Quoted 18 lines
doc/README.arm64 new file +3
-0+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. +examples/standalone/stubs.c +7
-0@@ -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 ( \
Quoted 8 lines
examples/standalone/stubs.c gd_t *global_data; · line 210
Quoted 6 lines
examples/standalone/stubs.c +6
-0+" .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?
You are right. it's a bug. x19 is defined as a callee-saved register in the ABI.
Quoted 43 lines
Quoted 43 lines
examples/standalone/stubs.c +0
-0#else /*" addi $sp, $sp, -24\n" \ " br $r16\n" \*/ include/configs/vexpress_aemv8a.h new file +33
-0@@ -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
Quoted 9 lines
include/configs/vexpress_aemv8a.h line 39
Quoted 6 lines
include/configs/vexpress_aemv8a.h new file +6
-0+ +/* Cache Definitions */ +//#define CONFIG_SYS_DCACHE_OFF +//#define CONFIG_SYS_ICACHE_OFF + +#define CONFIG_IDENT_STRING " aarch64"Shouldn't
CONFIG_IDENT_STRINGbe the target name (i.e. the board name)?
right, it's better to be defined as vexpress**.
Quoted 4 lines
-Scott
PATCH 1/1 part1 of arm64. This patch provide u-boot with arm64 support. Currently it works on Foundation Model for armv8 or Fast Model for armv8.
Quoted 29 lines · FengHua
Quoted 21 lines
-----????-----
???: "Scott Wood" <[email protected]>
????: 2013?8?14? ???
???: fenghua at phytium.com.cn
??: u-boot at lists.denx.de, trini at ti.com
??: Re: [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.arch/arm64/config.mk
Quoted 5 lines · fenghua at phytium.com.cn
arch/arm64/config.mk new file +0
-0Does 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).Quoted 7 lines
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).
Quoted 2 lines
The porting is performed as a seperate architecture due to a few considerations,
1. The porting will be simple and clear.
No, it's the opposite. It's hard to review what you changed from arm to arm64.
Quoted 1 line
2. There's no any real chip of armv8 until now. Many aspect of armv8 are not completely confirmed.
I'm not sure why that makes a difference.
Quoted 1 line
Of course, it could be merged with ARM at a proper time in the later. Actually, linux kernel follow this mode.
Let's do it the right way from the start.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
arch/arm64/config.mk new file +17
-0@@ -0,0 +1,32 @@ +# +# Copyright (c) 2013 FengHua <[email protected]> +# +# 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 LicenseQuoted 9 lines
arch/arm64/config.mk line 23
Quoted 6 lines
arch/arm64/config.mk new file +6
-0+# 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.
Quoted 4 lines
I will fix it.
Quoted 1 line
Plus, what about native builds that don't need a cross compiler?
Currently, there's no real chip of armv8. so,cross compiler is needed.
Eventually there will be (or someone could be masochistic enough to build inside the emulator). The point remains that default CROSS_COMPILE is a bad idea.
Quoted 112 lines
Quoted 102 lines
Quoted 102 lines
common/fdt_support.c +34
-29@@ -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 ;Quoted 9 lines
common/fdt_support.c void do_fixup_by_compat_u32(void *fdt, const char *compat, · line 378
Quoted 6 lines
common/fdt_support.c +0
-3- } -} -#ifdef CONFIG_NR_DRAM_BANKS #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else What's going on here?
Quoted 2 lines
Whitout this the initrd represented by "linux,initrd-start" could only be placed under 4G address space. This part fix it to 64 bit address space.
Make it a separate patch with a more detailed explanation.
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
doc/README.arm64 new file +0
-0@@ -0,0 +1,10 @@Quoted 9 lines
doc/README.arm64 line 5
Quoted 5 lines
doc/README.arm64 new file +5
-0+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.
Quoted 1 line
I also try to use rela but it not works. maybe something is wrong with the code.
Was it a build error or a runtime problem?
-Scott