From 0cba91022e4304684ed37e16d8b3e08912ae4415 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 30 Dec 2020 11:56:11 +0100 Subject: [PATCH] cpu/vexriscv_smp: move smp_slave to crt0. Fixes bare metal demo compilation with VexRiscv-SMP. --- litex/soc/cores/cpu/vexriscv_smp/boot-helper.S | 14 -------------- litex/soc/cores/cpu/vexriscv_smp/crt0.S | 16 +++++++++++++--- litex/soc/software/demo/Makefile | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/litex/soc/cores/cpu/vexriscv_smp/boot-helper.S b/litex/soc/cores/cpu/vexriscv_smp/boot-helper.S index daaa82cdb..3a530dd1f 100644 --- a/litex/soc/cores/cpu/vexriscv_smp/boot-helper.S +++ b/litex/soc/cores/cpu/vexriscv_smp/boot-helper.S @@ -3,7 +3,6 @@ .global smp_lottery_target .global smp_lottery_lock .global smp_lottery_args -.global smp_slave boot_helper: sw x10, smp_lottery_args , x14 @@ -14,16 +13,3 @@ boot_helper: li x15, 1 sw x15, smp_lottery_lock, x14 jr x13 - -smp_slave: - lw a0, smp_lottery_lock - beqz a0, smp_slave - fence r, r - - .word(0x100F) //i$ flush - lw x10, smp_lottery_args - lw x11, smp_lottery_args+4 - lw x12, smp_lottery_args+8 - lw x13, smp_lottery_target - jr x13 - diff --git a/litex/soc/cores/cpu/vexriscv_smp/crt0.S b/litex/soc/cores/cpu/vexriscv_smp/crt0.S index fdc12de07..3e466fdd0 100644 --- a/litex/soc/cores/cpu/vexriscv_smp/crt0.S +++ b/litex/soc/cores/cpu/vexriscv_smp/crt0.S @@ -56,13 +56,13 @@ trap_entry: addi sp,sp,16*4 mret .text - + crt_init: la sp, _fstack + 4 la a0, trap_entry csrw mtvec, a0 sw x0, smp_lottery_lock, a1 - + data_init: la a0, _fdata la a1, _edata @@ -75,13 +75,23 @@ data_loop: add a2,a2,4 j data_loop data_done: - + smp_tyranny: csrr a0, mhartid beqz a0, bss_init call smp_slave +smp_slave: + lw a0, smp_lottery_lock + beqz a0, smp_slave + fence r, r + .word(0x100F) //i$ flush + lw x10, smp_lottery_args + lw x11, smp_lottery_args+4 + lw x12, smp_lottery_args+8 + lw x13, smp_lottery_target + jr x13 bss_init: la a0, _fbss diff --git a/litex/soc/software/demo/Makefile b/litex/soc/software/demo/Makefile index fa236d2fe..5a2a47c3e 100644 --- a/litex/soc/software/demo/Makefile +++ b/litex/soc/software/demo/Makefile @@ -18,7 +18,7 @@ demo.elf: $(OBJECTS) $(LD) $(LDFLAGS) \ -T linker.ld \ -N -o $@ \ - $(BUILD_DIR)/software/libbase/crt0.o \ + $(BUILD_DIR)/software/libbase/crt0.o \ $(OBJECTS) \ -L$(BUILD_DIR)/software/libbase \ -L$(BUILD_DIR)/software/libcompiler_rt \