-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Labels
Description
https://github.com/rust-embedded/riscv/blob/master/riscv-rt/src/asm.rs#L100
If M-extension is not present, looks like stack address provided for hart_id +1, a.e. for hart_id ==0:
lui t0, %hi(_hart_stack_size)
add t0, t0, %lo(_hart_stack_size),
mul t0, t2, t0,
beqz t2, 2f // skip if hart ID is 0
... //some code
2:
la t1, _stack_start,
sub t1, t1, t0, <- here stack pointer init value is _stack_start - _hart_stack_size
Also, for hart_id == 1:
lui t0, %hi(_hart_stack_size)
add t0, t0, %lo(_hart_stack_size),
beqz t2, 2f
mv t1, t0
1:
add t0, t0, t1 <- t0 = t1+t1 = 2*_hart_stack_size
addi t2, t2, -1
bnez t2, 1b
2:
la t1, _stack_start,
"sub t1, t1, t0, <- here stack pointer init value is _stack_start - 2*_hart_stack_size
etc. for other harts.