adds some hooks for SMT startup
This commit is contained in:
32
env/start.S
vendored
32
env/start.S
vendored
@@ -9,18 +9,35 @@ _start:
|
||||
.option push
|
||||
.option norelax
|
||||
.option norvc
|
||||
//#ifdef WITH_SIGNATURE
|
||||
#ifdef WITH_SIGNATURE
|
||||
j 1f
|
||||
.2byte 0x4e4d
|
||||
.2byte 0x5352
|
||||
.4byte 0x669
|
||||
1:
|
||||
//#endif
|
||||
#endif
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la sp, _sp
|
||||
csrr t0, mhartid // Get hart ID
|
||||
la t1, __stack_size // stack size
|
||||
la sp, _sp // Base stack address
|
||||
/* this loop is to avoid multiplication which is not available on all ISAs */
|
||||
1:
|
||||
beqz t0, 2f
|
||||
sub sp, sp, t1 // Subtract __stack_size to get per-hart stack base
|
||||
addi t0, t0, -1
|
||||
j 1b
|
||||
2:
|
||||
la t0, trap_entry
|
||||
csrw mtvec, t0
|
||||
#ifdef HARTX_WAIT4WFI
|
||||
/* block other cores until hart 0 has finished initialization */
|
||||
csrr t0, mhartid
|
||||
beqz t0, hart0_init
|
||||
wfi
|
||||
j hartx_start
|
||||
hart0_init:
|
||||
#endif
|
||||
/* Load data section */
|
||||
la a0, _data_lma
|
||||
la a1, _data
|
||||
@@ -50,6 +67,10 @@ _start:
|
||||
call atexit
|
||||
call __libc_init_array
|
||||
#endif
|
||||
la a0, mtx
|
||||
li t0, 1
|
||||
sw t0, 0(a0)
|
||||
hartx_start:
|
||||
#ifndef __riscv_float_abi_soft
|
||||
/* Enable FPU */
|
||||
li t0, MSTATUS_FS
|
||||
@@ -66,3 +87,8 @@ _start:
|
||||
li a1, 0
|
||||
call main
|
||||
tail _exit
|
||||
|
||||
|
||||
.data
|
||||
mtx:
|
||||
.word 0 # 32-bit value
|
||||
|
||||
Reference in New Issue
Block a user