summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-22 13:58:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-28 15:02:13 +0200
commit5f5c450aa49ba73dccb52cd8f6e62c6aef1412da (patch)
tree49ebe86ae1a262c1f3ad8f2c0e05b859c0af279b
parentbsp/riscv: Add device tree support (diff)
downloadrtems-5f5c450aa49ba73dccb52cd8f6e62c6aef1412da.tar.bz2
bsp/riscv: Add SMP startup synchronization
Update #3433.
-rw-r--r--bsps/riscv/riscv/start/start.S22
1 files changed, 20 insertions, 2 deletions
diff --git a/bsps/riscv/riscv/start/start.S b/bsps/riscv/riscv/start/start.S
index f40ceeff50..b59e55f2ea 100644
--- a/bsps/riscv/riscv/start/start.S
+++ b/bsps/riscv/riscv/start/start.S
@@ -42,7 +42,7 @@ PUBLIC(bsp_start_vector_table_begin)
PUBLIC(bsp_start_vector_table_end)
PUBLIC(_start)
- .section .bsp_start_text, "ax", @progbits
+ .section .bsp_start_text, "wax", @progbits
.align 2
TYPE_FUNC(_start)
@@ -55,7 +55,7 @@ SYM(_start):
#ifdef RTEMS_SMP
csrr s0, mhartid
- bnez s0, .Lloop_forever
+ bnez s0, .Lwait_for_go
#endif
/* load stack and frame pointers */
@@ -75,6 +75,13 @@ SYM(_start):
la a2, bsp_section_bss_size
call memset
+#ifdef RTEMS_SMP
+ /* Give go to secondary processors */
+ la t0, .Lsecondary_processor_go
+ fence iorw,ow
+ amoswap.w zero, zero, 0(t0)
+#endif
+
/* Init FPU unit if it's there */
li t0, MSTATUS_FS
csrs mstatus, t0
@@ -82,8 +89,19 @@ SYM(_start):
j boot_card
#ifdef RTEMS_SMP
+ /* Wait for go issued by the boot processor (mhartid == 0) */
+.Lwait_for_go:
+ la t0, .Lsecondary_processor_go
+.Lwait_for_go_again:
+ lw t1, 0(t0)
+ fence iorw, iorw
+ sext.w t1, t1
+ bnez t1, .Lwait_for_go_again
.Lloop_forever:
j .Lloop_forever
+
+.Lsecondary_processor_go:
+ .word 0xdeadbeef
#endif
.align 4