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
6 changes: 4 additions & 2 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Main function no longer needs to be close to _start. A linker script may copy
all code to RAM and keep .init in flash/ROM.
- `main` function no longer needs to be close to `_start`. A linker script may copy
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.
- `abort` function no longer needs to be close to `_start`.
- In multi-hart targets, the hart ID is now validated earlier in the boot process.

### Fixed

Expand Down
11 changes: 8 additions & 3 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ _abs_start:
"csrw stvec, t0",
#[cfg(not(feature = "s-mode"))]
"csrw mtvec, t0",
// If multi-hart, assert that hart ID is valid
#[cfg(not(feature = "single-hart"))]
"lui t0, %hi(_max_hart_id)
add t0, t0, %lo(_max_hart_id)
bgeu t0, a0, 1f
la t0, abort // If hart_id > _max_hart_id, jump to abort
jr t0
1:", // only valid harts reach this point
);

// ZERO OUT GENERAL-PURPOSE REGISTERS
Expand All @@ -91,9 +99,6 @@ cfg_global_asm!(
#[cfg(not(feature = "single-hart"))]
cfg_global_asm!(
"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)
add t0, t0, %lo(_hart_stack_size)",
#[cfg(riscvm)]
Expand Down