Skip to content

Commit

Permalink
feat(multi-cores): allocate seperate stack for each hart
Browse files Browse the repository at this point in the history
  • Loading branch information
Siudya committed Dec 8, 2024
1 parent c030f21 commit 9ff1bd0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions am/src/nemu/isa/riscv/boot/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
_start:
init_regs

mv s0, zero
la sp, _stack_pointer
li a0, MSTATUS_FS & (MSTATUS_FS >> 1)
csrs mstatus, a0
csrwi fcsr, 0

init_fregs # init fregs after fp enable

la t0, _stack_top
la t1, _stack_pointer
sub t3, t1, t0
csrr t4, mhartid
mul t5, t3, t4
add sp, t5, t1

jal _trm_init
8 changes: 7 additions & 1 deletion am/src/nemu/isa/riscv/boot/start_flash.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

_start:
mv s0, zero
la sp, _stack_pointer
li a0, MSTATUS_FS & (MSTATUS_FS >> 1)
csrs mstatus, a0
csrwi fcsr, 0
Expand All @@ -25,4 +24,11 @@ _start:
# or a0, a0, a1
# csrw pmpcfg0, a0

la t0, _stack_top
la t1, _stack_pointer
sub t3, t1, t0
csrr t4, mhartid
mul t5, t3, t4
add sp, t5, t1

jal _trm_init
1 change: 1 addition & 0 deletions am/src/nemu/ldscript/section.ld
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SECTIONS {
_stack_top = ALIGN(0x1000);
. = _stack_top + 0x8000;
_stack_pointer = .;
. = _stack_top + 0x320000;
end = .;
_end = .;
_heap_start = ALIGN(0x1000);
Expand Down

0 comments on commit 9ff1bd0

Please sign in to comment.