Skip to contentSkip to conversation

Add NX25 to support RISC-V

PATCH New Andes 3 participants 30 messages Dec 26, 2017 – Feb 8, 2018

Subsystems (4)
lore
Share & tools
lore

Andes

author
#0 lore raw

v2 cover Add NX25 to support RISC-V

From: Rick Chen <[email protected]>

Changelog v2:
- Patch 5/12 : Changes
- Patch 9/12 : Changes
- Others : No changed

[Patch 5/12] riscv: Add Kconfig to support RISC-V
- Modify the top-level MAINTAINERS for RISC-V

[Patch 9/12] riscv: tools: Prelink u-boot
- Add license information.

Rick Chen (12):
riscv: cpu: Add nx25 to support RISC-V
riscv: nx25: lib: Add relative lib funcs to support RISC-V
riscv: nx25: dts: Add AE250 dts to support RISC-V
riscv: nx25: include: Add header files to support RISC-V
riscv: Add Kconfig to support RISC-V
riscv: board: Add nx25-ae250 to support RISC-V
riscv: configs: Add nx25-ae250.h to support RISC-V
riscv: defconfig: Add nx25-ae250 defconfig to support RISC-V
riscv: tools: Prelink u-boot
riscv: Support standalone
riscv: Modify generic codes to support RISC-V
riscv: doc: Add relative doc to describe RISC-V

 MAINTAINERS                             |   7 +
 Makefile                                |   4 +
 README                                  |  19 +-
 arch/Kconfig                            |   5 +
 arch/riscv/Kconfig                      |  42 +++
 arch/riscv/Makefile                     |  11 +
 arch/riscv/config.mk                    |  33 +++
 arch/riscv/cpu/nx25/Makefile            |  10 +
 arch/riscv/cpu/nx25/cpu.c               |  33 +++
 arch/riscv/cpu/nx25/start.S             | 291 +++++++++++++++++++
 arch/riscv/cpu/nx25/u-boot.lds          |  69 +++++
 arch/riscv/dts/Makefile                 |  14 +
 arch/riscv/dts/ae250.dts                |  96 +++++++
 arch/riscv/include/asm/bitops.h         | 172 +++++++++++
 arch/riscv/include/asm/bootm.h          |  65 +++++
 arch/riscv/include/asm/byteorder.h      |  35 +++
 arch/riscv/include/asm/cache.h          |  22 ++
 arch/riscv/include/asm/config.h         |  13 +
 arch/riscv/include/asm/encoding.h       | 188 ++++++++++++
 arch/riscv/include/asm/global_data.h    |  22 ++
 arch/riscv/include/asm/io.h             | 494 ++++++++++++++++++++++++++++++++
 arch/riscv/include/asm/linkage.h        |  12 +
 arch/riscv/include/asm/mach-types.h     |  30 ++
 arch/riscv/include/asm/posix_types.h    |  89 ++++++
 arch/riscv/include/asm/processor.h      |  26 ++
 arch/riscv/include/asm/ptrace.h         | 106 +++++++
 arch/riscv/include/asm/sections.h       |  11 +
 arch/riscv/include/asm/setup.h          | 191 ++++++++++++
 arch/riscv/include/asm/string.h         |  43 +++
 arch/riscv/include/asm/system.h         |  18 ++
 arch/riscv/include/asm/types.h          |  64 +++++
 arch/riscv/include/asm/u-boot-riscv.h   |  21 ++
 arch/riscv/include/asm/u-boot.h         |  46 +++
 arch/riscv/include/asm/unaligned.h      |   1 +
 arch/riscv/lib/Makefile                 |  14 +
 arch/riscv/lib/boot.c                   |  19 ++
 arch/riscv/lib/bootm.c                  | 248 ++++++++++++++++
 arch/riscv/lib/cache.c                  |  50 ++++
 arch/riscv/lib/interrupts.c             |  76 +++++
 board/AndesTech/nx25-ae250/Kconfig      |  24 ++
 board/AndesTech/nx25-ae250/MAINTAINERS  |   6 +
 board/AndesTech/nx25-ae250/Makefile     |   8 +
 board/AndesTech/nx25-ae250/nx25-ae250.c |  77 +++++
 cmd/bdinfo.c                            |  15 +
 common/board_f.c                        |   2 +-
 common/board_r.c                        |   4 +-
 configs/nx25-ae250_defconfig            |  36 +++
 doc/README.NX25                         |  46 +++
 doc/README.ae250                        | 137 +++++++++
 doc/README.standalone                   |   1 +
 examples/standalone/riscv.lds           |  41 +++
 examples/standalone/stubs.c             |  12 +
 include/configs/nx25-ae250.h            | 126 ++++++++
 include/elf.h                           |   5 +
 include/image.h                         |   1 +
 tools/Makefile                          |   1 +
 tools/prelink-riscv.c                   | 102 +++++++
 tools/prelink-riscv.inc                 | 112 ++++++++
 58 files changed, 3462 insertions(+), 4 deletions(-)
 create mode 100644 arch/riscv/Kconfig
 create mode 100644 arch/riscv/Makefile
 create mode 100644 arch/riscv/config.mk
 create mode 100644 arch/riscv/cpu/nx25/Makefile
 create mode 100644 arch/riscv/cpu/nx25/cpu.c
 create mode 100644 arch/riscv/cpu/nx25/start.S
 create mode 100644 arch/riscv/cpu/nx25/u-boot.lds
 create mode 100644 arch/riscv/dts/Makefile
 create mode 100644 arch/riscv/dts/ae250.dts
 create mode 100644 arch/riscv/include/asm/bitops.h
 create mode 100644 arch/riscv/include/asm/bootm.h
 create mode 100644 arch/riscv/include/asm/byteorder.h
 create mode 100644 arch/riscv/include/asm/cache.h
 create mode 100644 arch/riscv/include/asm/config.h
 create mode 100644 arch/riscv/include/asm/encoding.h
 create mode 100644 arch/riscv/include/asm/global_data.h
 create mode 100644 arch/riscv/include/asm/io.h
 create mode 100644 arch/riscv/include/asm/linkage.h
 create mode 100644 arch/riscv/include/asm/mach-types.h
 create mode 100644 arch/riscv/include/asm/posix_types.h
 create mode 100644 arch/riscv/include/asm/processor.h
 create mode 100644 arch/riscv/include/asm/ptrace.h
 create mode 100644 arch/riscv/include/asm/sections.h
 create mode 100644 arch/riscv/include/asm/setup.h
 create mode 100644 arch/riscv/include/asm/string.h
 create mode 100644 arch/riscv/include/asm/system.h
 create mode 100644 arch/riscv/include/asm/types.h
 create mode 100644 arch/riscv/include/asm/u-boot-riscv.h
 create mode 100644 arch/riscv/include/asm/u-boot.h
 create mode 100644 arch/riscv/include/asm/unaligned.h
 create mode 100644 arch/riscv/lib/Makefile
 create mode 100644 arch/riscv/lib/boot.c
 create mode 100644 arch/riscv/lib/bootm.c
 create mode 100644 arch/riscv/lib/cache.c
 create mode 100644 arch/riscv/lib/interrupts.c
 create mode 100644 board/AndesTech/nx25-ae250/Kconfig
 create mode 100644 board/AndesTech/nx25-ae250/MAINTAINERS
 create mode 100644 board/AndesTech/nx25-ae250/Makefile
 create mode 100644 board/AndesTech/nx25-ae250/nx25-ae250.c
 create mode 100644 configs/nx25-ae250_defconfig
 create mode 100644 doc/README.NX25
 create mode 100644 doc/README.ae250
 create mode 100644 examples/standalone/riscv.lds
 create mode 100644 include/configs/nx25-ae250.h
 create mode 100644 tools/prelink-riscv.c
 create mode 100644 tools/prelink-riscv.inc
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Detail verification message please see doc/README.ae250.

---
 arch/riscv/cpu/nx25/Makefile   |  10 ++
 arch/riscv/cpu/nx25/cpu.c      |  33 +++++
 arch/riscv/cpu/nx25/start.S    | 291 +++++++++++++++++++++++++++++++++++++++++
 arch/riscv/cpu/nx25/u-boot.lds |  69 ++++++++++
 4 files changed, 403 insertions(+)
 create mode 100644 arch/riscv/cpu/nx25/Makefile
 create mode 100644 arch/riscv/cpu/nx25/cpu.c
 create mode 100644 arch/riscv/cpu/nx25/start.S
 create mode 100644 arch/riscv/cpu/nx25/u-boot.lds
arch/riscv/cpu/nx25/Makefile new file +10 -0
new file mode 100644
index 0000000..5fcf100
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2017 Andes Technology Corporation
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+extra-y	= start.o
+
+obj-y	:= cpu.o
arch/riscv/cpu/nx25/cpu.c new file +33 -0
new file mode 100644
index 0000000..5478f4f
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/* CPU specific code */
+#include <common.h>
+#include <command.h>
+#include <watchdog.h>
+#include <asm/cache.h>
+
+/*
+ * cleanup_before_linux() is called just before we call linux
+ * it prepares the processor for linux
+ *
+ * we disable interrupt and caches.
+ */
+int cleanup_before_linux(void)
+{
+	disable_interrupts();
+
+	/* turn off I/D-cache */
+
+	return 0;
+}
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	disable_interrupts();
+	panic("nx25-ae250 wdt not support yet.\n");
+}
arch/riscv/cpu/nx25/start.S new file +291 -0

291 lines not on this page · raw message

arch/riscv/cpu/nx25/u-boot.lds new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

Hi Tom

How about the Andes NX25 cpu for RISC-V arch patchsets [PATCH v2 x/12] reviewing status ?
Is everything ok ?

Rick

2017-12-26 13:55 GMT+08:00 Andes <[email protected]>:

Quoted 460 lines

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Detail verification message please see doc/README.ae250.

---
 arch/riscv/cpu/nx25/Makefile   |  10 ++
 arch/riscv/cpu/nx25/cpu.c      |  33 +++++
 arch/riscv/cpu/nx25/start.S    | 291 +++++++++++++++++++++++++++++++++++++++++
 arch/riscv/cpu/nx25/u-boot.lds |  69 ++++++++++
 4 files changed, 403 insertions(+)
 create mode 100644 arch/riscv/cpu/nx25/Makefile
 create mode 100644 arch/riscv/cpu/nx25/cpu.c
 create mode 100644 arch/riscv/cpu/nx25/start.S
 create mode 100644 arch/riscv/cpu/nx25/u-boot.lds
arch/riscv/cpu/nx25/Makefile new file +10 -0
new file mode 100644
index 0000000..5fcf100
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2017 Andes Technology Corporation
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+extra-y        = start.o
+
+obj-y  := cpu.o
arch/riscv/cpu/nx25/cpu.c new file +33 -0
new file mode 100644
index 0000000..5478f4f
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/* CPU specific code */
+#include <common.h>
+#include <command.h>
+#include <watchdog.h>
+#include <asm/cache.h>
+
+/*
+ * cleanup_before_linux() is called just before we call linux
+ * it prepares the processor for linux
+ *
+ * we disable interrupt and caches.
+ */
+int cleanup_before_linux(void)
+{
+       disable_interrupts();
+
+       /* turn off I/D-cache */
+
+       return 0;
+}
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       disable_interrupts();
+       panic("nx25-ae250 wdt not support yet.\n");
+}
arch/riscv/cpu/nx25/start.S new file +291 -0
new file mode 100644
index 0000000..6a07663
@@ -0,0 +1,291 @@
+/*
+ * Startup Code for RISC-V Core
+ *
+ * Copyright (c) 2017 Microsemi Corporation.
+ * Copyright (c) 2017 Padmarao Begari <[email protected]>
+ *
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <common.h>
+#include <elf.h>
+#include <asm/encoding.h>
+
+#ifdef CONFIG_32BIT
+#define LREG                   lw
+#define SREG                   sw
+#define REGBYTES               4
+#define RELOC_TYPE             R_RISCV_32
+#define SYM_INDEX              0x8
+#define SYM_SIZE               0x10
+#else
+#define LREG                   ld
+#define SREG                   sd
+#define REGBYTES               8
+#define RELOC_TYPE             R_RISCV_64
+#define SYM_INDEX              0x20
+#define SYM_SIZE               0x18
+#endif
+
+.section      .text
+.globl _start
+_start:
+       j handle_reset
+
+nmi_vector:
+       j nmi_vector
+
+trap_vector:
+       j trap_entry
+
+.global trap_entry
+handle_reset:
+       la t0, trap_entry
+       csrw mtvec, t0
+       csrwi mstatus, 0
+       csrwi mie, 0
+
+/*
+ * Do CPU critical regs init only at reboot,
+ * not when booting from ram
+ */
+#ifdef CONFIG_INIT_CRITICAL
+       jal cpu_init_crit       /* Do CPU critical regs init */
+#endif
+
+/*
+ * Set stackpointer in internal/ex RAM to call board_init_f
+ */
+call_board_init_f:
+       li  t0, -16
+       li  t1, CONFIG_SYS_INIT_SP_ADDR
+       and sp, t1, t0  /* force 16 byte alignment */
+
+#ifdef CONFIG_DEBUG_UART
+       jal     debug_uart_init
+#endif
+
+call_board_init_f_0:
+       mv      a0, sp
+       jal     board_init_f_alloc_reserve
+       mv      sp, a0
+       jal     board_init_f_init_reserve
+
+       mv  a0, zero    /* a0 <-- boot_flags = 0 */
+       la t5, board_init_f
+       jr t5           /* jump to board_init_f() */
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+.globl relocate_code
+relocate_code:
+       mv  s2, a0      /* save addr_sp */
+       mv  s3, a1      /* save addr of gd */
+       mv  s4, a2      /* save addr of destination */
+
+/*
+ *Set up the stack
+ */
+stack_setup:
+       mv sp, s2
+       la t0, _start
+       sub t6, s4, t0  /* t6 <- relocation offset */
+       beq t0, s4, clear_bss   /* skip relocation */
+
+       mv t1, s4       /* t1 <- scratch for copy_loop */
+       la t3, __bss_start
+       sub t3, t3, t0  /* t3 <- __bss_start_ofs */
+       add t2, t0, t3  /* t2 <- source end address */
+
+copy_loop:
+       LREG t5, 0(t0)
+       addi t0, t0, REGBYTES
+       SREG t5, 0(t1)
+       addi t1, t1, REGBYTES
+       blt t0, t2, copy_loop
+
+/*
+ * Update dynamic relocations after board_init_f
+ */
+fix_rela_dyn:
+       la  t1, __rel_dyn_start
+       la  t2, __rel_dyn_end
+       beq t1, t2, clear_bss
+       add t1, t1, t6                  /* t1 <- rela_dyn_start in RAM */
+       add t2, t2, t6                  /* t2 <- rela_dyn_end in RAM */
+
+/*
+ * skip first reserved entry: address, type, addend
+ */
+       bne t1, t2, 7f
+
+6:
+       LREG  t5, -(REGBYTES*2)(t1)     /* t5 <-- relocation info:type */
+       li  t3, R_RISCV_RELATIVE        /* reloc type R_RISCV_RELATIVE */
+       bne t5, t3, 8f                  /* skip non-RISCV_RELOC entries */
+       LREG t3, -(REGBYTES*3)(t1)
+       LREG t5, -(REGBYTES)(t1)        /* t5 <-- addend */
+       add t5, t5, t6                  /* t5 <-- location to fix up in RAM */
+       add t3, t3, t6                  /* t3 <-- location to fix up in RAM */
+       SREG t5, 0(t3)
+7:
+       addi t1, t1, (REGBYTES*3)
+       ble t1, t2, 6b
+
+8:
+       la  t4, __dyn_sym_start
+       add t4, t4, t6
+
+9:
+       LREG  t5, -(REGBYTES*2)(t1)     /* t5 <-- relocation info:type */
+       srli t0, t5, SYM_INDEX          /* t0 <--- sym table index */
+       andi t5, t5, 0xFF               /* t5 <--- relocation type */
+       li  t3, RELOC_TYPE
+       bne t5, t3, 10f                 /* skip non-addned entries */
+
+       LREG t3, -(REGBYTES*3)(t1)
+       li t5, SYM_SIZE
+       mul t0, t0, t5
+       add s1, t4, t0
+       LREG t5, REGBYTES(s1)
+       add t5, t5, t6                  /* t5 <-- location to fix up in RAM */
+       add t3, t3, t6                  /* t3 <-- location to fix up in RAM */
+       SREG t5, 0(t3)
+10:
+       addi t1, t1, (REGBYTES*3)
+       ble t1, t2, 9b
+
+/*
+ * trap update
+*/
+       la t0, trap_entry
+       add t0, t0, t6
+       csrw mtvec, t0
+
+clear_bss:
+       la t0, __bss_start              /* t0 <- rel __bss_start in FLASH */
+       add t0, t0, t6                  /* t0 <- rel __bss_start in RAM */
+       la t1, __bss_end                /* t1 <- rel __bss_end in FLASH */
+       add t1, t1, t6                  /* t1 <- rel __bss_end in RAM */
+       li t2, 0x00000000               /* clear */
+       beq t0, t1, call_board_init_r
+
+clbss_l:
+       SREG t2, 0(t0)                  /* clear loop... */
+       addi t0, t0, REGBYTES
+       bne t0, t1, clbss_l
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+call_board_init_r:
+       la t0, board_init_r
+       mv t4, t0                       /* offset of board_init_r() */
+       add t4, t4, t6                  /* real address of board_init_r() */
+/*
+ * setup parameters for board_init_r
+ */
+       mv a0, s3                       /* gd_t */
+       mv a1, s4                       /* dest_addr */
+
+/*
+ * jump to it ...
+ */
+       jr t4                           /* jump to board_init_r() */
+
+/*
+ * trap entry
+ */
+trap_entry:
+       addi sp, sp, -32*REGBYTES
+       SREG x1, 1*REGBYTES(sp)
+       SREG x2, 2*REGBYTES(sp)
+       SREG x3, 3*REGBYTES(sp)
+       SREG x4, 4*REGBYTES(sp)
+       SREG x5, 5*REGBYTES(sp)
+       SREG x6, 6*REGBYTES(sp)
+       SREG x7, 7*REGBYTES(sp)
+       SREG x8, 8*REGBYTES(sp)
+       SREG x9, 9*REGBYTES(sp)
+       SREG x10, 10*REGBYTES(sp)
+       SREG x11, 11*REGBYTES(sp)
+       SREG x12, 12*REGBYTES(sp)
+       SREG x13, 13*REGBYTES(sp)
+       SREG x14, 14*REGBYTES(sp)
+       SREG x15, 15*REGBYTES(sp)
+       SREG x16, 16*REGBYTES(sp)
+       SREG x17, 17*REGBYTES(sp)
+       SREG x18, 18*REGBYTES(sp)
+       SREG x19, 19*REGBYTES(sp)
+       SREG x20, 20*REGBYTES(sp)
+       SREG x21, 21*REGBYTES(sp)
+       SREG x22, 22*REGBYTES(sp)
+       SREG x23, 23*REGBYTES(sp)
+       SREG x24, 24*REGBYTES(sp)
+       SREG x25, 25*REGBYTES(sp)
+       SREG x26, 26*REGBYTES(sp)
+       SREG x27, 27*REGBYTES(sp)
+       SREG x28, 28*REGBYTES(sp)
+       SREG x29, 29*REGBYTES(sp)
+       SREG x30, 30*REGBYTES(sp)
+       SREG x31, 31*REGBYTES(sp)
+       csrr a0, mcause
+       csrr a1, mepc
+       mv a2, sp
+       jal handle_trap
+       csrw mepc, a0
+
+/*
+ * Remain in M-mode after mret
+ */
+       li t0, MSTATUS_MPP
+       csrs mstatus, t0
+       LREG x1, 1*REGBYTES(sp)
+       LREG x2, 2*REGBYTES(sp)
+       LREG x3, 3*REGBYTES(sp)
+       LREG x4, 4*REGBYTES(sp)
+       LREG x5, 5*REGBYTES(sp)
+       LREG x6, 6*REGBYTES(sp)
+       LREG x7, 7*REGBYTES(sp)
+       LREG x8, 8*REGBYTES(sp)
+       LREG x9, 9*REGBYTES(sp)
+       LREG x10, 10*REGBYTES(sp)
+       LREG x11, 11*REGBYTES(sp)
+       LREG x12, 12*REGBYTES(sp)
+       LREG x13, 13*REGBYTES(sp)
+       LREG x14, 14*REGBYTES(sp)
+       LREG x15, 15*REGBYTES(sp)
+       LREG x16, 16*REGBYTES(sp)
+       LREG x17, 17*REGBYTES(sp)
+       LREG x18, 18*REGBYTES(sp)
+       LREG x19, 19*REGBYTES(sp)
+       LREG x20, 20*REGBYTES(sp)
+       LREG x21, 21*REGBYTES(sp)
+       LREG x22, 22*REGBYTES(sp)
+       LREG x23, 23*REGBYTES(sp)
+       LREG x24, 24*REGBYTES(sp)
+       LREG x25, 25*REGBYTES(sp)
+       LREG x26, 26*REGBYTES(sp)
+       LREG x27, 27*REGBYTES(sp)
+       LREG x28, 28*REGBYTES(sp)
+       LREG x29, 29*REGBYTES(sp)
+       LREG x30, 30*REGBYTES(sp)
+       LREG x31, 31*REGBYTES(sp)
+       addi sp, sp, 32*REGBYTES
+       mret
+
+#ifdef CONFIG_INIT_CRITICAL
+cpu_init_crit:
+    ret
+#endif
arch/riscv/cpu/nx25/u-boot.lds new file +69 -1
new file mode 100644
index 0000000..936fd77
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+OUTPUT_ARCH("riscv")
+ENTRY(_start)
+
+SECTIONS
+{
+       . = ALIGN(4);
+       .text :
+       {
+               arch/riscv/cpu/nx25/start.o     (.text)
+               *(.text)
+       }
+
+       . = ALIGN(4);
+       .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+       . = ALIGN(4);
+       .data : {
+               __global_pointer$ = . + 0x800;
+               *(.data*)
+       }
+       . = ALIGN(4);
+
+       .got : {
+          __got_start = .;
+          *(.got.plt) *(.got)
+          __got_end = .;
+    }
+
+       . = ALIGN(4);
+
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*)));
+       }
+
+    . = ALIGN(4);
+
+    /DISCARD/ : { *(.rela.plt*) }
+    .rela.dyn : {
+        __rel_dyn_start = .;
+        *(.rela*)
+        __rel_dyn_end = .;
+    }
+
+    . = ALIGN(4);
+
+    .dynsym : {
+        __dyn_sym_start = .;
+        *(.dynsym)
+        __dyn_sym_end = .;
+    }
+
+    . = ALIGN(4);
+
+       _end = .;
+
+       .bss : {
+        __bss_start = .;
+        *(.bss)
+               . = ALIGN(4);
+               __bss_end = .;
+       }
+
+}
--

2.7.4

#3 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

Quoted 5 lines · 陳建志

Hi Tom

How about the Andes NX25 cpu for RISC-V arch patchsets [PATCH v2 x/12] reviewing status ?
Is everything ok ?

Yes, I think everything is OK. Can you please also include an update to .travis.yml that gets the architecture to be built during CI? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180109/c810026f/attachment.sig>
#4 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

In reply to Andes
Quoted 13 lines · Andes

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Quoted 6 lines

Detail verification message please see doc/README.ae250.

Applied to u-boot/master.

But that said, the whole of arch/riscv/ and board/AndesTech/nx25-ae250/ introduces some checkpatch.pl issues, please investigate and fix appropriate ones, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/3bf1f4d8/attachment.sig>
#5 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

Actually I have checked with checkpatch.pl and cleaned most before
sending patchs.
But it seem still left some, I will keep fixing them.

Thanks for Tom and Wolfgang's help.

Rick

2018-01-15 21:52 GMT+08:00 Tom Rini <[email protected]>:

Quoted 30 lines · Andes
Quoted 14 lines

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Quoted 6 lines

Detail verification message please see doc/README.ae250.

Applied to u-boot/master.

But that said, the whole of arch/riscv/ and board/AndesTech/nx25-ae250/ introduces some checkpatch.pl issues, please investigate and fix appropriate ones, thanks!

--
Tom

#6 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

Quoted 4 lines

Actually I have checked with checkpatch.pl and cleaned most before
sending patchs.
But it seem still left some, I will keep fixing them.

Quoted 35 lines

Thanks for Tom and Wolfgang's help.

Rick

2018-01-15 21:52 GMT+08:00 Tom Rini <[email protected]>:

Quoted 30 lines · Andes
Quoted 14 lines

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Quoted 6 lines

Detail verification message please see doc/README.ae250.

Applied to u-boot/master.

But that said, the whole of arch/riscv/ and board/AndesTech/nx25-ae250/ introduces some checkpatch.pl issues, please investigate and fix appropriate ones, thanks!

--
Tom

Hi Tom

I am trying to fix this checkpatch.pl issue.

Though I download mainline by
git clone http://git.denx.de/u-boot.git
It can be seen /arch/riscv folder there.

But when I try to download riscv repository by
git clone http://git.denx.de/u-boot-riscv.git
and it fail.

Below is the error messge:
Cloning into 'u-boot-riscv'...
fatal: http://git.denx.de/u-boot-riscv.git/info/refs not found: did you run git update-server-info on the server?

Download nds32 repo by
git clone http://git.denx.de/u-boot-nds32.git
is ok.

May I ask have this riscv repo been created ?
or
did I do something wrong ?

It seem that after I finish fixing the checkpatch.pl issue, I can not do git push ssh://gu-riscv at git.denx.de/u-boot-riscv.git master without riscv repo for contribution.

Rick

#7 lore raw

PATCH v2 1/12 riscv: cpu: Add nx25 to support RISC-V

2018-02-02 16:20 GMT+08:00 陳建志 <[email protected]>:

Quoted 65 lines
Quoted 4 lines

Actually I have checked with checkpatch.pl and cleaned most before
sending patchs.
But it seem still left some, I will keep fixing them.

Quoted 35 lines

Thanks for Tom and Wolfgang's help.

Rick

2018-01-15 21:52 GMT+08:00 Tom Rini <[email protected]>:

Quoted 30 lines · Andes
Quoted 14 lines

From: Rick Chen <[email protected]>

Add Andes nx25 cpu core (called AndesStar V5) to support RISC-V arch

Verifications:
1. startup and relocation ok.
2. boot from rom or ram both ok.
2. timer driver ok.
3. uart driver ok
4. mmc driver ok
5. spi driver ok.
6. 32/64 bit both ok.

Quoted 6 lines

Detail verification message please see doc/README.ae250.

Applied to u-boot/master.

But that said, the whole of arch/riscv/ and board/AndesTech/nx25-ae250/ introduces some checkpatch.pl issues, please investigate and fix appropriate ones, thanks!

--
Tom

Hi Tom

I am trying to fix this checkpatch.pl issue.

Though I download mainline by
git clone http://git.denx.de/u-boot.git
It can be seen /arch/riscv folder there.

But when I try to download riscv repository by
git clone http://git.denx.de/u-boot-riscv.git
and it fail.

Below is the error messge:
Cloning into 'u-boot-riscv'...
fatal: http://git.denx.de/u-boot-riscv.git/info/refs not found: did you run git update-server-info on the server?

Download nds32 repo by
git clone http://git.denx.de/u-boot-nds32.git
is ok.

May I ask have this riscv repo been created ?
or
did I do something wrong ?

Quoted 5 lines

It seem that after I finish fixing the checkpatch.pl issue, I can not do git push ssh://gu-riscv at git.denx.de/u-boot-riscv.git master without riscv repo for contribution.

Rick

Hi Tom

It can be downloaded now.

Please ignore it.

Rick

author
#8 lore raw

PATCH v2 2/12 riscv: nx25: lib: Add relative lib funcs to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add makefile, interrupts.c and boot.c,... functions to support RISC-V arch.

---
 arch/riscv/lib/Makefile     |  14 +++
 arch/riscv/lib/boot.c       |  19 ++++
 arch/riscv/lib/bootm.c      | 248 ++++++++++++++++++++++++++++++++++++++++++++
 arch/riscv/lib/cache.c      |  50 +++++++++
 arch/riscv/lib/interrupts.c |  76 ++++++++++++++
 5 files changed, 407 insertions(+)
 create mode 100644 arch/riscv/lib/Makefile
 create mode 100644 arch/riscv/lib/boot.c
 create mode 100644 arch/riscv/lib/bootm.c
 create mode 100644 arch/riscv/lib/cache.c
 create mode 100644 arch/riscv/lib/interrupts.c
arch/riscv/lib/Makefile new file +14 -0
new file mode 100644
index 0000000..323cf3e
@@ -0,0 +1,14 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2017 Andes Technology Corporation
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_GO) += boot.o
+obj-y	+= cache.o
+obj-y	+= interrupts.o
arch/riscv/lib/boot.c new file +19 -0
new file mode 100644
index 0000000..39ba9b4
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+unsigned long do_go_exec(ulong (*entry)(int, char * const []),
+			 int argc, char * const argv[])
+{
+	cleanup_before_linux();
+
+	return entry(argc, argv);
+}
arch/riscv/lib/bootm.c new file +248 -0

248 lines not on this page · raw message

arch/riscv/lib/cache.c new file +50 -0

50 lines not on this page · raw message

arch/riscv/lib/interrupts.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 2/12 riscv: nx25: lib: Add relative lib funcs to support RISC-V

Quoted 9 lines · Andes

From: Rick Chen <[email protected]>

Add makefile, interrupts.c and boot.c,... functions to support RISC-V arch.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/e3243189/attachment.sig>
author
#10 lore raw

PATCH v2 3/12 riscv: nx25: dts: Add AE250 dts to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

AE250 is the Soc using NX25 cpu core base on RISC-V arch. Details please see the doc/README.ae250.

---
 arch/riscv/dts/Makefile  | 14 +++++++
 arch/riscv/dts/ae250.dts | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)
 create mode 100644 arch/riscv/dts/Makefile
 create mode 100644 arch/riscv/dts/ae250.dts
arch/riscv/dts/Makefile new file +14 -0
new file mode 100644
index 0000000..718b99f
@@ -0,0 +1,14 @@
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+dtb-$(CONFIG_TARGET_NX25_AE250) += ae250.dtb
+targets += $(dtb-y)
+
+DTC_FLAGS += -R 4 -p 0x1000
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
arch/riscv/dts/ae250.dts new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 3/12 riscv: nx25: dts: Add AE250 dts to support RISC-V

Quoted 8 lines · Andes

From: Rick Chen <[email protected]>

AE250 is the Soc using NX25 cpu core base on RISC-V arch. Details please see the doc/README.ae250.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/cb2806a4/attachment.sig>
author
#12 lore raw

PATCH v2 4/12 riscv: nx25: include: Add header files to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add header files for RISC-V.
Cache, ptregs, data type and other definitions are included.

---
 arch/riscv/include/asm/bitops.h       | 172 ++++++++++++
 arch/riscv/include/asm/bootm.h        |  65 +++++
 arch/riscv/include/asm/byteorder.h    |  35 +++
 arch/riscv/include/asm/cache.h        |  22 ++
 arch/riscv/include/asm/config.h       |  13 +
 arch/riscv/include/asm/encoding.h     | 188 +++++++++++++
 arch/riscv/include/asm/global_data.h  |  22 ++
 arch/riscv/include/asm/io.h           | 494 ++++++++++++++++++++++++++++++++++
 arch/riscv/include/asm/linkage.h      |  12 +
 arch/riscv/include/asm/mach-types.h   |  30 +++
 arch/riscv/include/asm/posix_types.h  |  89 ++++++
 arch/riscv/include/asm/processor.h    |  26 ++
 arch/riscv/include/asm/ptrace.h       | 106 ++++++++
 arch/riscv/include/asm/sections.h     |  11 +
 arch/riscv/include/asm/setup.h        | 191 +++++++++++++
 arch/riscv/include/asm/string.h       |  43 +++
 arch/riscv/include/asm/system.h       |  18 ++
 arch/riscv/include/asm/types.h        |  64 +++++
 arch/riscv/include/asm/u-boot-riscv.h |  21 ++
 arch/riscv/include/asm/u-boot.h       |  46 ++++
 arch/riscv/include/asm/unaligned.h    |   1 +
 21 files changed, 1669 insertions(+)
 create mode 100644 arch/riscv/include/asm/bitops.h
 create mode 100644 arch/riscv/include/asm/bootm.h
 create mode 100644 arch/riscv/include/asm/byteorder.h
 create mode 100644 arch/riscv/include/asm/cache.h
 create mode 100644 arch/riscv/include/asm/config.h
 create mode 100644 arch/riscv/include/asm/encoding.h
 create mode 100644 arch/riscv/include/asm/global_data.h
 create mode 100644 arch/riscv/include/asm/io.h
 create mode 100644 arch/riscv/include/asm/linkage.h
 create mode 100644 arch/riscv/include/asm/mach-types.h
 create mode 100644 arch/riscv/include/asm/posix_types.h
 create mode 100644 arch/riscv/include/asm/processor.h
 create mode 100644 arch/riscv/include/asm/ptrace.h
 create mode 100644 arch/riscv/include/asm/sections.h
 create mode 100644 arch/riscv/include/asm/setup.h
 create mode 100644 arch/riscv/include/asm/string.h
 create mode 100644 arch/riscv/include/asm/system.h
 create mode 100644 arch/riscv/include/asm/types.h
 create mode 100644 arch/riscv/include/asm/u-boot-riscv.h
 create mode 100644 arch/riscv/include/asm/u-boot.h
 create mode 100644 arch/riscv/include/asm/unaligned.h
arch/riscv/include/asm/bitops.h new file +172 -0
new file mode 100644
index 0000000..55d420f
@@ -0,0 +1,172 @@
+/*
+ * Copyright 1995, Russell King.
+ * Various bits and pieces copyrights include:
+ * Linus Torvalds (test_bit).
+ *
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
+ *
+ * Please note that the code in this file should never be included
+ * from user space.  Many of these are not implemented in assembler
+ * since they would be too costly.  Also, they require priviledged
+ * instructions (which are not available from user mode) to ensure
+ * that they are atomic.
+ */
+
+#ifndef __ASM_RISCV_BITOPS_H
+#define __ASM_RISCV_BITOPS_H
+
+#ifdef __KERNEL__
+
+#include <asm/system.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
+#define smp_mb__before_clear_bit()	do { } while (0)
+#define smp_mb__after_clear_bit()	do { } while (0)
+
+/*
+ * Function prototypes to keep gcc -Wall happy.
+ */
+static inline void __set_bit(int nr, void *addr)
+{
+	int *a = (int *)addr;
+	int mask;
+
+	a += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	*a |= mask;
+}
+
+static inline void __clear_bit(int nr, void *addr)
+{
+	int *a = (int *)addr;
+	int mask;
+
+	a += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	*a &= ~mask;
+}
+
+static inline void __change_bit(int nr, void *addr)
+{
+	int mask;
+	unsigned long *ADDR = (unsigned long *)addr;
+
+	ADDR += nr >> 5;
+	mask = 1 << (nr & 31);
+	*ADDR ^= mask;
+}
+
+static inline int __test_and_set_bit(int nr, void *addr)
+{
+	int mask, retval;
+	unsigned int *a = (unsigned int *)addr;
+
+	a += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	retval = (mask & *a) != 0;
+	*a |= mask;
+	return retval;
+}
+
+static inline int __test_and_clear_bit(int nr, void *addr)
+{
+	int mask, retval;
+	unsigned int *a = (unsigned int *)addr;
+
+	a += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	retval = (mask & *a) != 0;
+	*a &= ~mask;
+	return retval;
+}
+
+static inline int __test_and_change_bit(int nr, void *addr)
+{
+	int mask, retval;
+	unsigned int *a = (unsigned int *)addr;
+
+	a += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	retval = (mask & *a) != 0;
+	*a ^= mask;
+	return retval;
+}
+
+/*
+ * This routine doesn't need to be atomic.
+ */
+static inline int test_bit(int nr, const void *addr)
+{
+	return ((unsigned char *)addr)[nr >> 3] & (1U << (nr & 7));
+}
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+static inline unsigned long ffz(unsigned long word)
+{
+	int k;
+
+	word = ~word;
+	k = 31;
+	if (word & 0x0000ffff) {
+		k -= 16; word <<= 16;
+	}
+	if (word & 0x00ff0000) {
+		k -= 8;  word <<= 8;
+	}
+	if (word & 0x0f000000) {
+		k -= 4;  word <<= 4;
+	}
+	if (word & 0x30000000) {
+		k -= 2;  word <<= 2;
+	}
+	if (word & 0x40000000)
+		k -= 1;
+
+	return k;
+}
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+/*
+ * redefined in include/linux/bitops.h
+ * #define ffs(x) generic_ffs(x)
+ */
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
+
+#define ext2_set_bit			test_and_set_bit
+#define ext2_clear_bit			test_and_clear_bit
+#define ext2_test_bit			test_bit
+#define ext2_find_first_zero_bit	find_first_zero_bit
+#define ext2_find_next_zero_bit		find_next_zero_bit
+
+/* Bitmap functions for the minix filesystem. */
+#define minix_test_and_set_bit(nr, addr)	test_and_set_bit(nr, addr)
+#define minix_set_bit(nr, addr)			set_bit(nr, addr)
+#define minix_test_and_clear_bit(nr, addr)	test_and_clear_bit(nr, addr)
+#define minix_test_bit(nr, addr)		test_bit(nr, addr)
+#define minix_find_first_zero_bit(addr, size)	find_first_zero_bit(addr, size)
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_RISCV_BITOPS_H */
arch/riscv/include/asm/bootm.h new file +65 -0

65 lines not on this page · raw message

arch/riscv/include/asm/byteorder.h new file +35 -0
new file mode 100644
index 0000000..d26ac56
@@ -0,0 +1,35 @@
+/*
+ *  linux/include/asm-arm/byteorder.h
+ *
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * ARM Endian-ness.  In little endian mode, the data bus is connected such
+ * that byte accesses appear as:
+ *  0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
+ * and word accesses (data or instruction) appear as:
+ *  d0...d31
+ *
+ * When in big endian mode, byte accesses appear as:
+ *  0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
+ * and word accesses (data or instruction) appear as:
+ *  d0...d31
+ */
+
+#ifndef __ASM_RISCV_BYTEORDER_H
+#define __ASM_RISCV_BYTEORDER_H
+
+#include <asm/types.h>
+
+#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
+#  define __BYTEORDER_HAS_U64__
+#  define __SWAB_64_THRU_32__
+#endif
+
+#ifdef __RISCVEB__
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
+#endif
arch/riscv/include/asm/cache.h new file +22 -0
new file mode 100644
index 0000000..facf072
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _ASM_RISCV_CACHE_H
+#define _ASM_RISCV_CACHE_H
+
+/*
+ * The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
+ * We use that value for aligning DMA buffers unless the board config has
+ * specified an alternate cache line size.
+ */
+#ifdef CONFIG_SYS_CACHELINE_SIZE
+#define ARCH_DMA_MINALIGN	CONFIG_SYS_CACHELINE_SIZE
+#else
+#define ARCH_DMA_MINALIGN	32
+#endif
+
+#endif /* _ASM_RISCV_CACHE_H */
arch/riscv/include/asm/config.h new file +13 -0
new file mode 100644
index 0000000..5f94eb0
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _ASM_CONFIG_H_
+#define _ASM_CONFIG_H_
+
+#define CONFIG_LMB
+
+#endif
arch/riscv/include/asm/encoding.h new file +188 -0

188 lines not on this page · raw message

arch/riscv/include/asm/global_data.h new file +22 -0
new file mode 100644
index 0000000..0cce98a
@@ -0,0 +1,22 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * Copyright (c) 2017 Microsemi Corporation.
+ * Padmarao Begari, Microsemi Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef	__ASM_GBL_DATA_H
+#define __ASM_GBL_DATA_H
+
+/* Architecture-specific global data */
+struct arch_global_data {
+};
+
+#include <asm-generic/global_data.h>
+
+#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("gp")
+
+#endif /* __ASM_GBL_DATA_H */
arch/riscv/include/asm/io.h new file +494 -0

494 lines not on this page · raw message

arch/riscv/include/asm/linkage.h new file +12 -0
new file mode 100644
index 0000000..60d5317
@@ -0,0 +1,12 @@
+/*
+ * U-Boot - linkage.h
+ *
+ * Copyright (c) 2005-2007 Analog Devices Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#endif
arch/riscv/include/asm/mach-types.h new file +30 -0
new file mode 100644
index 0000000..f70b407
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_RISCV_MACH_TYPE_H
+#define __ASM_RISCV_MACH_TYPE_H
+
+#ifndef __ASSEMBLY__
+/* The type of machine we're running on */
+extern unsigned int __machine_arch_type;
+#endif
+
+#define MACH_TYPE_AE250		1
+
+#ifdef CONFIG_ARCH_AE250
+# ifdef machine_arch_type
+#  undef machine_arch_type
+#  define machine_arch_type __machine_arch_type
+# else
+#  define machine_arch_type MACH_TYPE_AE250
+# endif
+# define machine_is_ae250() (machine_arch_type == MACH_TYPE_AE250)
+#else
+# define machine_is_ae250() (1)
+#endif
+
+#endif /* __ASM_RISCV_MACH_TYPE_H */
arch/riscv/include/asm/posix_types.h new file +89 -0

89 lines not on this page · raw message

arch/riscv/include/asm/processor.h new file +26 -0
new file mode 100644
index 0000000..fe35752
@@ -0,0 +1,26 @@
+/*
+ * linux/include/asm-arm/processor.h
+ *
+ * Copyright (C) 1995-2002 Russell King
+ *
+ * Copyright (C) 2011 Andes Technology Corporation
+ * Copyright (C) 2010 Shawn Lin (nobuhiro at andestech.com)
+ * Copyright (C) 2011 Macpaul Lin (macpaul at andestech.com)
+ * Copyright (C) 2017 Rick Chen (rick at andestech.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_RISCV_PROCESSOR_H
+#define __ASM_RISCV_PROCESSOR_H
+
+/**************************************************************
+ * CAUTION:
+ *   - do not implement for RISCV Arch yet.
+ *   - so far some files include /asm/processor.h, but
+ *     no one uses the macros defined in this head file.
+ **************************************************************/
+
+#endif /* __ASM_RISCV_PROCESSOR_H */
arch/riscv/include/asm/ptrace.h new file +106 -0

106 lines not on this page · raw message

arch/riscv/include/asm/sections.h new file +11 -0
new file mode 100644
index 0000000..9faa099
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_RISCV_SECTIONS_H
+#define __ASM_RISCV_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/riscv/include/asm/setup.h new file +191 -0

191 lines not on this page · raw message

arch/riscv/include/asm/string.h new file +43 -0

43 lines not on this page · raw message

arch/riscv/include/asm/system.h new file +18 -0
new file mode 100644
index 0000000..443a300
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_RISCV_SYSTEM_H
+#define __ASM_RISCV_SYSTEM_H
+
+/*
+ * Interrupt configuring macros.
+ *
+ * TODO
+ *
+ */
+
+#endif	/* __ASM_RISCV_SYSTEM_H */
arch/riscv/include/asm/types.h new file +64 -0

64 lines not on this page · raw message

arch/riscv/include/asm/u-boot-riscv.h new file +21 -0
new file mode 100644
index 0000000..18099cd
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <[email protected]>
+ *
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _U_BOOT_RISCV_H_
+#define _U_BOOT_RISCV_H_	1
+
+/* cpu/.../cpu.c */
+int cleanup_before_linux(void);
+
+/* board/.../... */
+int board_init(void);
+
+#endif	/* _U_BOOT_RISCV_H_ */
arch/riscv/include/asm/u-boot.h new file +46 -0

46 lines not on this page · raw message

arch/riscv/include/asm/unaligned.h new file +1 -0
new file mode 100644
index 0000000..6cecbbb
@@ -0,0 +1 @@
+#include <asm-generic/unaligned.h>
Signature · 1 line
2.7.4
#13 lore raw

PATCH v2 4/12 riscv: nx25: include: Add header files to support RISC-V

Quoted 8 lines · Andes

From: Rick Chen <[email protected]>

Add header files for RISC-V.
Cache, ptregs, data type and other definitions are included.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/b31bf2a1/attachment.sig>
author
#14 lore raw

PATCH v2 5/12 riscv: Add Kconfig to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add Kconfig and makefile for RISC-V
Also modify MAINTAINERS for it.

---
 MAINTAINERS          |  7 +++++++
 arch/riscv/Kconfig   | 42 ++++++++++++++++++++++++++++++++++++++++++
 arch/riscv/Makefile  | 11 +++++++++++
 arch/riscv/config.mk | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 93 insertions(+)
 create mode 100644 arch/riscv/Kconfig
 create mode 100644 arch/riscv/Makefile
 create mode 100644 arch/riscv/config.mk
MAINTAINERS +7 -0
index e950267..3cbe758 100644
@@ -423,6 +423,13 @@ S:	Orphaned (Since 2017-01)
 T:	git git://git.denx.de/u-boot-onenand.git
 F:	drivers/mtd/onenand/
 
+RISC-V
+M:	Rick Chen <[email protected]>
+S:	Maintained
+T:	git git://git.denx.de/u-boot-riscv.git
+F:	arch/riscv/
+F:	tools/prelink-riscv.c
+
 SANDBOX
 M:	Simon Glass <[email protected]>
 S:	Maintained
arch/riscv/Kconfig new file +42 -0

42 lines not on this page · raw message

arch/riscv/Makefile new file +11 -0
new file mode 100644
index 0000000..09d24db
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2017 Andes Technology Corporation.
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+head-y := arch/riscv/cpu/$(CPU)/start.o
+
+libs-y += arch/riscv/cpu/$(CPU)/
+libs-y += arch/riscv/lib/
arch/riscv/config.mk new file +33 -0
new file mode 100644
index 0000000..6b681c4
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2000-2002
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (c) 2017 Microsemi Corporation.
+# Padmarao Begari, Microsemi Corporation <[email protected]>
+#
+# Copyright (C) 2017 Andes Technology Corporation
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
+ifeq ($(CROSS_COMPILE),)
+CROSS_COMPILE := riscv32-unknown-linux-gnu-
+endif
+
+32bit-emul		:= elf32lriscv
+64bit-emul		:= elf64lriscv
+
+ifdef CONFIG_32BIT
+PLATFORM_LDFLAGS	+= -m $(32bit-emul)
+endif
+
+ifdef CONFIG_64BIT
+PLATFORM_LDFLAGS	+= -m $(64bit-emul)
+endif
+
+CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
+			      -T $(srctree)/examples/standalone/riscv.lds
+
+PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
+PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
+LDFLAGS_u-boot += --gc-sections -static -pie
Signature · 1 line
2.7.4
#15 lore raw

PATCH v2 5/12 riscv: Add Kconfig to support RISC-V

Quoted 9 lines · Andes

From: Rick Chen <[email protected]>

Add Kconfig and makefile for RISC-V
Also modify MAINTAINERS for it.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/a0e9e8aa/attachment.sig>
author
#16 lore raw

PATCH v2 6/12 riscv: board: Add nx25-ae250 to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 board to do platform initializations.

---
 board/AndesTech/nx25-ae250/Kconfig      | 24 ++++++++++
 board/AndesTech/nx25-ae250/MAINTAINERS  |  6 +++
 board/AndesTech/nx25-ae250/Makefile     |  8 ++++
 board/AndesTech/nx25-ae250/nx25-ae250.c | 77 +++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+)
 create mode 100644 board/AndesTech/nx25-ae250/Kconfig
 create mode 100644 board/AndesTech/nx25-ae250/MAINTAINERS
 create mode 100644 board/AndesTech/nx25-ae250/Makefile
 create mode 100644 board/AndesTech/nx25-ae250/nx25-ae250.c
board/AndesTech/nx25-ae250/Kconfig new file +24 -0
new file mode 100644
index 0000000..2fb3234
@@ -0,0 +1,24 @@
+if TARGET_NX25_AE250
+
+config SYS_CPU
+	default "nx25"
+
+config SYS_BOARD
+	default "nx25-ae250"
+
+config SYS_VENDOR
+	default "AndesTech"
+
+config SYS_SOC
+	default "ae250"
+
+config SYS_CONFIG_NAME
+	default "nx25-ae250"
+
+config ENV_SIZE
+	default 0x2000 if ENV_IS_IN_SPI_FLASH
+
+config ENV_OFFSET
+	default 0x140000 if ENV_IS_IN_SPI_FLASH
+
+endif
board/AndesTech/nx25-ae250/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..1bff127
@@ -0,0 +1,6 @@
+NX25-AE250 BOARD
+M:	Rick Chen <[email protected]>
+S:	Maintained
+F:	board/AndesTech/nx25-ae250/
+F:	include/configs/nx25-ae250.h
+F:	configs/nx25-ae250_defconfig
board/AndesTech/nx25-ae250/Makefile new file +8 -0
new file mode 100644
index 0000000..66b6814
@@ -0,0 +1,8 @@
+#
+# Copyright (C) 2017 Andes Technology Corporation.
+# Rick Chen, Andes Technology Corporation <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= nx25-ae250.o
board/AndesTech/nx25-ae250/nx25-ae250.c new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 6/12 riscv: board: Add nx25-ae250 to support RISC-V

Quoted 7 lines · Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 board to do platform initializations.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/5c5e51e0/attachment.sig>
author
#18 lore raw

PATCH v2 7/12 riscv: configs: Add nx25-ae250.h to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 board configuartion options for RISC-V

---
 include/configs/nx25-ae250.h | 126 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 include/configs/nx25-ae250.h
include/configs/nx25-ae250.h new file +126 -0
new file mode 100644
index 0000000..b523797
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * CPU and Board Configuration Options
+ */
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_SERVERIP
+
+#ifdef CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SYS_TEXT_BASE	0x00000000
+#ifdef CONFIG_OF_CONTROL
+#undef CONFIG_OF_SEPARATE
+#define CONFIG_OF_EMBED
+#endif
+#else
+#define CONFIG_SYS_TEXT_BASE	0x80000000
+#endif
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_SYS_CBSIZE	1024	/* Console I/O Buffer Size */
+
+/*
+ * Print Buffer Size
+ */
+#define CONFIG_SYS_PBSIZE	\
+	(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+
+/*
+ * max number of command args
+ */
+#define CONFIG_SYS_MAXARGS	16
+
+/*
+ * Boot Argument Buffer Size
+ */
+#define CONFIG_SYS_BARGSIZE	CONFIG_SYS_CBSIZE
+
+/*
+ * Size of malloc() pool
+ * 512kB is suggested, (CONFIG_ENV_SIZE + 128 * 1024) was not enough
+ */
+#define CONFIG_SYS_MALLOC_LEN   (512 << 10)
+
+/*
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS	2
+#define PHYS_SDRAM_0	0x00000000		/* SDRAM Bank #1 */
+#define PHYS_SDRAM_1	\
+	(PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE)	/* SDRAM Bank #2 */
+#define PHYS_SDRAM_0_SIZE	0x20000000	/* 512 MB */
+#define PHYS_SDRAM_1_SIZE	0x20000000	/* 512 MB */
+#define CONFIG_SYS_SDRAM_BASE	PHYS_SDRAM_0
+
+/*
+ * Serial console configuration
+ */
+#define CONFIG_CONS_INDEX		1
+#define CONFIG_SYS_NS16550_SERIAL
+#ifndef CONFIG_DM_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	-4
+#endif
+#define CONFIG_SYS_NS16550_CLK		19660800
+
+/*
+ * SD (MMC) controller
+ */
+#define CONFIG_FTSDC010_NUMBER		1
+#define CONFIG_FTSDC010_SDIO
+
+/* Init Stack Pointer */
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x1000000 - \
+					GENERATED_GBL_DATA_SIZE)
+
+/*
+ * Load address and memory test area should agree with
+ * arch/riscv/config.mk. Be careful not to overwrite U-Boot itself.
+ */
+#define CONFIG_SYS_LOAD_ADDR		0x100000	/* SDRAM */
+
+/*
+ * memtest works on 512 MB in DRAM
+ */
+#define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_0
+#define CONFIG_SYS_MEMTEST_END		(PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE)
+
+/* environments */
+#define CONFIG_ENV_SPI_BUS		0
+#define CONFIG_ENV_SPI_CS		0
+#define CONFIG_ENV_SPI_MAX_HZ		50000000
+#define CONFIG_ENV_SPI_MODE		0
+#define CONFIG_ENV_SECT_SIZE		0x1000
+#define CONFIG_ENV_OVERWRITE
+
+/* SPI FLASH */
+#define CONFIG_SF_DEFAULT_BUS		0
+#define CONFIG_SF_DEFAULT_CS		0
+#define CONFIG_SF_DEFAULT_SPEED		1000000
+#define CONFIG_SF_DEFAULT_MODE		0
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 16 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+
+/* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ	(64 << 20)
+/* Increase max gunzip size */
+#define CONFIG_SYS_BOOTM_LEN	(64 << 20)
+
+#endif /* __CONFIG_H */
Signature · 1 line
2.7.4
#19 lore raw

PATCH v2 7/12 riscv: configs: Add nx25-ae250.h to support RISC-V

Quoted 7 lines · Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 board configuartion options for RISC-V

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/70c1e8be/attachment.sig>
author
#20 lore raw

PATCH v2 8/12 riscv: defconfig: Add nx25-ae250 defconfig to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 default configuration for RISC-V

---
 configs/nx25-ae250_defconfig | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 configs/nx25-ae250_defconfig
configs/nx25-ae250_defconfig new file +36 -0
new file mode 100644
index 0000000..1f68b66
@@ -0,0 +1,36 @@
+CONFIG_RISCV=y
+CONFIG_TARGET_NX25_AE250=y
+CONFIG_DEFAULT_DEVICE_TREE="ae250"
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_SYS_PROMPT="RISC-V # "
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SF_TEST=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_MMC=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_NDS32=y
+CONFIG_FTSDC010=y
+CONFIG_DM_ETH=y
+CONFIG_FTMAC100=y
+CONFIG_BAUDRATE=38400
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
+CONFIG_DM_SPI=y
+CONFIG_ATCSPI200_SPI=y
+CONFIG_TIMER=y
+CONFIG_ATCPIT100_TIMER=y
Signature · 1 line
2.7.4
#21 lore raw

PATCH v2 8/12 riscv: defconfig: Add nx25-ae250 defconfig to support RISC-V

Quoted 7 lines · Andes

From: Rick Chen <[email protected]>

Add nx25-ae250 default configuration for RISC-V

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/6d01194c/attachment.sig>
author
#22 lore raw

PATCH v2 9/12 riscv: tools: Prelink u-boot

In reply to Andes

From: Rick Chen <[email protected]>

Add prelink-riscv to arrange .rela.dyn and .rela.got in compile time. So that u-boot can be directly executed without fixup.

---
 Makefile                |   4 ++
 tools/Makefile          |   1 +
 tools/prelink-riscv.c   | 102 +++++++++++++++++++++++++++++++++++++++++++
 tools/prelink-riscv.inc | 112 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 219 insertions(+)
 create mode 100644 tools/prelink-riscv.c
 create mode 100644 tools/prelink-riscv.inc
Makefile +4 -0
index c573ddb..bb6416f 100644
@@ -1264,6 +1264,10 @@ ifeq ($(CONFIG_KALLSYMS),y)
 	$(call cmd,u-boot__) common/system_map.o
 endif
 
+ifeq ($(CONFIG_RISCV),y)
+	@tools/prelink-riscv $@ 0
+endif
+
 quiet_cmd_sym ?= SYM     $@
       cmd_sym ?= $(OBJDUMP) -t $< > $@
 u-boot.sym: u-boot FORCE
tools/Makefile +1 -0
index 4d32fe5..571f571 100644
@@ -185,6 +185,7 @@ hostprogs-$(CONFIG_KIRKWOOD) += kwboot
 hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
 hostprogs-y += proftool
 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
+hostprogs-$(CONFIG_RISCV) += prelink-riscv
 
 hostprogs-y += fdtgrep
 fdtgrep-objs += $(LIBFDT_OBJS) fdtgrep.o
tools/prelink-riscv.c new file +102 -0

102 lines not on this page · raw message

tools/prelink-riscv.inc new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.7.4
#23 lore raw

PATCH v2 9/12 riscv: tools: Prelink u-boot

Quoted 10 lines · Andes

From: Rick Chen <[email protected]>

Add prelink-riscv to arrange .rela.dyn and .rela.got in compile time. So that u-boot can be directly executed without fixup.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/dcd5d368/attachment.sig>
author
#24 lore raw

PATCH v2 10/12 riscv: Support standalone

In reply to Andes

From: Rick Chen <[email protected]>

Run hello_world successfully.

U-Boot 2018.01-rc2-00033-gb265b91-dirty (Dec 22 2017 - 13:54:21 +0800)

DRAM:  1 GiB
MMC:   mmc at f0e00000: 0
SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB
In:    serial at f0300000
Out:   serial at f0300000
Err:   serial at f0300000

Net:
Warning: mac at e0100000 (eth0) using random MAC address - 0a:47:9b:f8:b4:f2
eth0: mac at e0100000
RISC-V # mmc rescan
RISC-V # fatls mmc 0:1
318907 u-boot-ae250-64.bin
1252 hello_world_ae250_32.bin
328787 u-boot-ae250-32.bin

3 file(s), 0 dir(s)

RISC-V # fatload mmc 0:1 0x600000 hello_world_ae250_32.bin reading hello_world_ae250_32.bin
1252 bytes read in 23 ms (52.7 KiB/s)
RISC-V # go 0x600000
Example expects ABI version 9
Actual U-Boot ABI version 9
Hello World
argc = 1
argv[0] = "0x600000"
argv[1] = "$B@"
Hit any key to exit ...

RISC-V #

---
 examples/standalone/riscv.lds | 41 +++++++++++++++++++++++++++++++++++++++++
 examples/standalone/stubs.c   | 12 ++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 examples/standalone/riscv.lds
examples/standalone/riscv.lds new file +41 -0
new file mode 100644
index 0000000..7d8c482
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+OUTPUT_ARCH(riscv)
+ENTRY(_start)
+SECTIONS
+{
+    . = ALIGN(4);
+    .text :
+    {
+        *(.text)
+    }
+
+    . = ALIGN(4);
+    .data : {
+			__global_pointer$ = . + 0x800;
+			*(.data)
+		}
+
+    . = ALIGN(4);
+
+    .got : {
+        __got_start = .;
+        *(.got)
+        __got_end = .;
+    }
+
+     . = ALIGN(4);
+    __bss_start = .;
+    .bss : { *(.bss) }
+    __bss_end = .;
+
+    . = ALIGN(4);
+    .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
+
+    _end = .;
+}
examples/standalone/stubs.c +12 -0
index 9c7a8c0..fadde66 100644
@@ -172,6 +172,18 @@ gd_t *global_data;
 "	lwi	$r16, [$r16 + (%1)]\n"	\
 "	jr	$r16\n"			\
 	: : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
+#elif defined(CONFIG_RISCV)
+/*
+ * t7 holds the pointer to the global_data. gp is call clobbered.
+ */
+#define EXPORT_FUNC(f, a, x, ...)	\
+	asm volatile (			\
+"	.globl " #x "\n"		\
+#x ":\n"				\
+"	lw	x19, %0(gp)\n"		\
+"	lw	x19, %1(x19)\n"		\
+"	jr	x19\n"			\
+	: : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "x19");
 #elif defined(CONFIG_ARC)
 /*
  * r25 holds the pointer to the global_data. r10 is call clobbered.
Signature · 1 line
2.7.4
#25 lore raw

PATCH v2 10/12 riscv: Support standalone

Quoted 35 lines · Andes

From: Rick Chen <[email protected]>

Run hello_world successfully.

U-Boot 2018.01-rc2-00033-gb265b91-dirty (Dec 22 2017 - 13:54:21 +0800)

DRAM:  1 GiB
MMC:   mmc at f0e00000: 0
SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB
In:    serial at f0300000
Out:   serial at f0300000
Err:   serial at f0300000

Net:
Warning: mac at e0100000 (eth0) using random MAC address - 0a:47:9b:f8:b4:f2
eth0: mac at e0100000
RISC-V # mmc rescan
RISC-V # fatls mmc 0:1
318907 u-boot-ae250-64.bin
1252 hello_world_ae250_32.bin
328787 u-boot-ae250-32.bin

3 file(s), 0 dir(s)

RISC-V # fatload mmc 0:1 0x600000 hello_world_ae250_32.bin reading hello_world_ae250_32.bin
1252 bytes read in 23 ms (52.7 KiB/s)
RISC-V # go 0x600000
Example expects ABI version 9
Actual U-Boot ABI version 9
Hello World
argc = 1
argv[0] = "0x600000"
argv[1] = "$B@"
Hit any key to exit ...

Quoted 5 lines

RISC-V #

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/01c31c85/attachment.sig>
author
#26 lore raw

PATCH v2 11/12 riscv: Modify generic codes to support RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Support common commands bdinfo and image format, also modify common generic flow for RISC-V.

---
 arch/Kconfig     |  5 +++++
 cmd/bdinfo.c     | 15 +++++++++++++++
 common/board_f.c |  2 +-
 common/board_r.c |  4 ++--
 include/elf.h    |  5 +++++
 include/image.h  |  1 +
 6 files changed, 29 insertions(+), 3 deletions(-)
arch/Kconfig +5 -0
index 0b12ed9..762230c 100644
@@ -54,6 +54,10 @@ config PPC
 	select HAVE_PRIVATE_LIBGCC
 	select SUPPORT_OF_CONTROL
 
+config RISCV
+	bool "riscv architecture"
+	select SUPPORT_OF_CONTROL
+
 config SANDBOX
 	bool "Sandbox"
 	select BOARD_LATE_INIT
@@ -194,3 +198,4 @@ source "arch/sandbox/Kconfig"
 source "arch/sh/Kconfig"
 source "arch/x86/Kconfig"
 source "arch/xtensa/Kconfig"
+source "arch/riscv/Kconfig"
cmd/bdinfo.c +15 -0
index 27ffcd5..c7ebad1 100644
@@ -417,6 +417,21 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+#elif defined(CONFIG_RISCV)
+
+int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	bd_t *bd = gd->bd;
+
+	print_num("arch_number", bd->bi_arch_number);
+	print_bi_boot_params(bd);
+	print_bi_dram(bd);
+	print_eth_ip_addr();
+	print_baudrate();
+
+	return 0;
+}
+
 #elif defined(CONFIG_ARC)
 
 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
common/board_f.c +1 -1
index e46eced..0bdce64 100644
@@ -218,7 +218,7 @@ static int setup_mon_len(void)
 	gd->mon_len = (ulong)&_end - (ulong)_init;
 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
 	gd->mon_len = CONFIG_SYS_MONITOR_LEN;
-#elif defined(CONFIG_NDS32) || defined(CONFIG_SH)
+#elif defined(CONFIG_NDS32) || defined(CONFIG_SH) || defined(CONFIG_RISCV)
 	gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
 #elif defined(CONFIG_SYS_MONITOR_BASE)
 	/* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
common/board_r.c +2 -2
index 09167c1..2a9df6b 100644
@@ -126,7 +126,7 @@ static int initr_reloc_global_data(void)
 {
 #ifdef __ARM__
 	monitor_flash_len = _end - __image_copy_start;
-#elif defined(CONFIG_NDS32)
+#elif defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
 	monitor_flash_len = (ulong)&_end - (ulong)&_start;
 #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
 	monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
@@ -704,7 +704,7 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_DM
 	initr_dm,
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_NDS32)
+#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
 	board_init,	/* Setup chipselects */
 #endif
 	/*
include/elf.h +5 -0
index aaecac7..fe2128f 100644
@@ -613,6 +613,11 @@ unsigned long elf_hash(const unsigned char *name);
 #define R_AARCH64_NONE		0	/* No relocation.  */
 #define R_AARCH64_RELATIVE	1027	/* Adjust by program base.  */
 
+/* RISC-V relocations */
+#define R_RISCV_32		1
+#define R_RISCV_64		2
+#define R_RISCV_RELATIVE	3
+
 #ifndef __ASSEMBLER__
 int valid_elf_image(unsigned long addr);
 #endif
include/image.h +1 -0
index a128a62..a41a836 100644
@@ -190,6 +190,7 @@ enum {
 	IH_ARCH_ARC,			/* Synopsys DesignWare ARC */
 	IH_ARCH_X86_64,			/* AMD x86_64, Intel and Via */
 	IH_ARCH_XTENSA,			/* Xtensa	*/
+	IH_ARCH_RISCV,			/* RISC-V */
 
 	IH_ARCH_COUNT,
 };
Signature · 1 line
2.7.4
#27 lore raw

PATCH v2 11/12 riscv: Modify generic codes to support RISC-V

Quoted 9 lines · Andes

From: Rick Chen <[email protected]>

Support common commands bdinfo and image format, also modify common generic flow for RISC-V.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/d1d56a2a/attachment.sig>
author
#28 lore raw

PATCH v2 12/12 riscv: doc: Add relative doc to describe RISC-V

In reply to Andes

From: Rick Chen <[email protected]>

Add documents to describe NX25 and AE250. Also update other documents for RISC-V.

---
 README                |  19 ++++++-
 doc/README.NX25       |  46 +++++++++++++++++
 doc/README.ae250      | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/README.standalone |   1 +
 4 files changed, 202 insertions(+), 1 deletion(-)
 create mode 100644 doc/README.NX25
 create mode 100644 doc/README.ae250
README +18 -1
index 93c7ea9..33bff88 100644
@@ -143,6 +143,7 @@ Directory Hierarchy:
   /nios2		Files generic to Altera NIOS2 architecture
   /openrisc		Files generic to OpenRISC architecture
   /powerpc		Files generic to PowerPC architecture
+  /riscv		Files generic to RISC-V architecture
   /sandbox		Files generic to HW-independent "sandbox"
   /sh			Files generic to SH architecture
   /x86			Files generic to x86 architecture
@@ -3511,7 +3512,7 @@ Low Level (hardware related) configuration options:
 		globally (CONFIG_CMD_MEMORY).
 
 - CONFIG_SKIP_LOWLEVEL_INIT
-		[ARM, NDS32, MIPS only] If this variable is defined, then certain
+		[ARM, NDS32, MIPS, RISC-V only] If this variable is defined, then certain
 		low level initializations (like setting up the memory
 		controller) are omitted and/or U-Boot does not
 		relocate itself into RAM.
@@ -4965,6 +4966,22 @@ On NDS32, the following registers are used:
 NOTE: DECLARE_GLOBAL_DATA_PTR must be used with file-global scope,
 or current versions of GCC may "optimize" the code too much.
 
+On RISC-V, the following registers are used:
+
+	x0: hard-wired zero (zero)
+	x1: return address (ra)
+	x2:	stack pointer (sp)
+	x3:	global pointer (gp)
+	x4:	thread pointer (tp)
+	x5:	link register (t0)
+	x8:	frame pointer (fp)
+	x10-x11:	arguments/return values (a0-1)
+	x12-x17:	arguments (a2-7)
+	x28-31:	 temporaries (t3-6)
+	pc:	program counter (pc)
+
+    ==> U-Boot will use gp to hold a pointer to the global data
+
 Memory Management:
 ------------------
 
doc/README.NX25 new file +46 -0

46 lines not on this page · raw message

doc/README.ae250 new file +137 -0

137 lines not on this page · raw message

doc/README.standalone +1 -0
index 659a12f..28ebde1 100644
@@ -58,6 +58,7 @@ Design Notes on Exporting U-Boot Functions to Standalone Applications:
 	Blackfin	0x00001000	0x00001000
 	NDS32		0x00300000	0x00300000
 	Nios II		0x02000000	0x02000000
+	RISC-V		0x00600000	0x00600000
 
    For example, the "hello world" application may be loaded and
    executed on a PowerPC board with the following commands:
Signature · 1 line
2.7.4
#29 lore raw

PATCH v2 12/12 riscv: doc: Add relative doc to describe RISC-V

Quoted 8 lines · Andes

From: Rick Chen <[email protected]>

Add documents to describe NX25 and AE250. Also update other documents for RISC-V.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180115/3619de21/attachment.sig>