diff options
author | Palmer Dabbelt <palmer@dabbelt.com> | 2017-06-14 08:59:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 08:59:41 -0700 |
commit | 61d6152830d752cd81c34368ecc24a5a2a107061 (patch) | |
tree | 58c5b8c05ae24b8c6b035545634200eb3742c064 /bsp/env/start.S | |
parent | 809711e87af06ca5c151a2fac568382330f2feb6 (diff) | |
parent | 99a8e6a697a340a5f44db82e68ab8ab9be604131 (diff) |
Merge pull request #64 from sifive/multicore-scratchpad
Add support for multicore systems and scratchpad-only systems
Diffstat (limited to 'bsp/env/start.S')
-rw-r--r-- | bsp/env/start.S | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/bsp/env/start.S b/bsp/env/start.S index e86105b..4e9f665 100644 --- a/bsp/env/start.S +++ b/bsp/env/start.S @@ -1,18 +1,27 @@ // See LICENSE for license details. +#include <sifive/smp.h> -// See LICENSE for license details. +/* This is defined in sifive/platform.h, but that can't be included from + * assembly. */ +#define CLINT_CTRL_ADDR 0x02000000 .section .init .globl _start .type _start,@function _start: + .cfi_startproc + .cfi_undefined ra .option push .option norelax la gp, __global_pointer$ .option pop la sp, _sp +#if defined(ENABLE_SMP) + smp_pause(t0, t1) +#endif + /* Load data section */ la a0, _data_lma la a1, _data @@ -52,11 +61,51 @@ _start: 1: #endif +#if defined(ENABLE_SMP) + smp_resume(t0, t1) + + csrr a0, mhartid + bnez a0, 2f +#endif + + auipc ra, 0 + addi sp, sp, -16 +#if __riscv_xlen == 32 + sw ra, 8(sp) +#else + sd ra, 8(sp) +#endif + /* argc = argv = 0 */ li a0, 0 li a1, 0 call main tail exit +1: + j 1b + +#if defined(ENABLE_SMP) +2: + la t0, trap_entry + csrw mtvec, t0 + + csrr a0, mhartid + la t1, _sp + slli t0, a0, 10 + sub sp, t1, t0 + + auipc ra, 0 + addi sp, sp, -16 +#if __riscv_xlen == 32 + sw ra, 8(sp) +#else + sd ra, 8(sp) +#endif + + call secondary_main + tail exit 1: j 1b +#endif + .cfi_endproc |