From mboxrd@z Thu Jan 1 00:00:00 1970 From: fenghua at phytium.com.cn Date: Thu, 15 Aug 2013 21:47:10 +0800 Subject: [U-Boot] [PATCH v3 1/5] core support of arm64 In-Reply-To: <1376574434-48664-1-git-send-email-fenghua@phytium.com.cn> References: <1376574434-48664-1-git-send-email-fenghua@phytium.com.cn> Message-ID: <1376574434-48664-2-git-send-email-fenghua@phytium.com.cn> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: David Feng This patch provide u-boot with arm64 support. Currently, it works on Foundation Model for armv8 or Fast Model for armv8. Signed-off-by: David Feng --- Changes for v3: - rewrite cache.S and exception.S that partly originated from linux kernel, so the license should be ok. common/cmd_bdinfo.c | 32 ++++++++++++++++++++++++++++++++ common/image.c | 5 +++-- doc/README.arm64 | 10 ++++++++++ examples/standalone/stubs.c | 13 +++++++++++++ include/image.h | 1 + lib/asm-offsets.c | 4 ---- 6 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 doc/README.arm64 diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index af884b8..4a7b61b 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -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 diff --git a/common/image.c b/common/image.c index 56a5a62..7a24550 100644 --- a/common/image.c +++ b/common/image.c @@ -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; 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. + 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..578985a 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, x9 is a call-clobbered + * register + */ +#define EXPORT_FUNC(x) \ + asm volatile ( \ +" .globl " #x "\n" \ +#x ":\n" \ +" ldr x9, [x18, %0]\n" \ +" ldr x9, [x9, %1]\n" \ +" br x9\n" \ + : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "x19"); #else /*" addi $sp, $sp, -24\n" \ " br $r16\n" \*/ diff --git a/include/image.h b/include/image.h index f93a393..491e547 100644 --- a/include/image.h +++ b/include/image.h @@ -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 diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 6ea7b03..450514d 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -29,15 +29,11 @@ int main(void) DEFINE(GD_BD, offsetof(struct global_data, bd)); -#if defined(CONFIG_ARM) - DEFINE(GD_RELOCADDR, offsetof(struct global_data, relocaddr)); DEFINE(GD_RELOC_OFF, offsetof(struct global_data, reloc_off)); DEFINE(GD_START_ADDR_SP, offsetof(struct global_data, start_addr_sp)); -#endif - return 0; } -- 1.7.9.5