Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
all code to RAM and keep .init in flash/ROM.
- By default, the stack is now split into equal parts based on the number of
harts.
- In M-mode, the hart ID is moved to `a0` at the beginning of the runtime.

### Fixed

Expand Down
22 changes: 7 additions & 15 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ _abs_start:
csrw sip, 0",
#[cfg(not(feature = "s-mode"))]
"csrw mie, 0
csrw mip, 0",
csrw mip, 0
csrr a0, mhartid", // Make sure that the hart ID is in a0 in M-mode
// Set pre-init trap vector
"la t0, _pre_init_trap",
#[cfg(feature = "s-mode")]
Expand All @@ -89,11 +90,8 @@ cfg_global_asm!(
);
#[cfg(not(feature = "single-hart"))]
cfg_global_asm!(
#[cfg(feature = "s-mode")]
"mv t2, a0 // the hartid is passed as parameter by SMODE",
#[cfg(not(feature = "s-mode"))]
"csrr t2, mhartid",
"lui t0, %hi(_max_hart_id)
"mv t2, a0
lui t0, %hi(_max_hart_id)
add t0, t0, %lo(_max_hart_id)
bgtu t2, t0, abort
lui t0, %hi(_hart_stack_size)
Expand Down Expand Up @@ -131,18 +129,12 @@ cfg_global_asm!(
sd a2, 8 * 2(sp)",
);

// SKIP RAM INITIALIZATION IF CURRENT HART IS NOT THE BOOT HART
#[cfg(not(feature = "single-hart"))]
// CALL __pre_init (IF ENABLED) AND INITIALIZE RAM
cfg_global_asm!(
#[cfg(not(feature = "s-mode"))]
"csrr a0, mhartid",
#[cfg(not(feature = "single-hart"))]
// Skip RAM initialization if current hart is not the boot hart
"call _mp_hook
mv t0, a0

beqz a0, 4f",
);
// IF CURRENT HART IS THE BOOT HART CALL __pre_init (IF ENABLED) AND INITIALIZE RAM
cfg_global_asm!(
#[cfg(feature = "pre-init")]
"call __pre_init",
"// Copy .data from flash to RAM
Expand Down