Skip to content

Commit 34e07c6

Browse files
Merge pull request #128 from ivq/fix_single_hart_stack
Fix setting incorrect sp if single-hart
2 parents 448eec9 + 408acae commit 34e07c6

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- New GitHub workflow for checking invalid labels in PRs
1313
- New GitHub workflow for checking modifications on CHANGELOG.md
1414
- New GitHub workflow for checking clippy lints in PRs
15+
- Optional cargo feature `single-hart` for single CPU targets
1516

1617
### Changed
1718

riscv-rt/src/asm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,16 @@ _abs_start:
8585
.option push
8686
.option norelax
8787
la gp, __global_pointer$
88-
.option pop",
88+
.option pop
89+
// Allocate stacks",
8990
#[cfg(all(not(feature = "single-hart"), feature = "s-mode"))]
9091
"mv t2, a0 // the hartid is passed as parameter by SMODE",
9192
#[cfg(all(not(feature = "single-hart"), not(feature = "s-mode")))]
9293
"csrr t2, mhartid",
9394
#[cfg(not(feature = "single-hart"))]
9495
"lui t0, %hi(_max_hart_id)
9596
add t0, t0, %lo(_max_hart_id)
96-
bgtu t2, t0, abort",
97-
"// Allocate stacks
98-
la sp, _stack_start
97+
bgtu t2, t0, abort
9998
lui t0, %hi(_hart_stack_size)
10099
add t0, t0, %lo(_hart_stack_size)",
101100
#[cfg(all(not(feature = "single-hart"), riscvm))]
@@ -109,9 +108,10 @@ _abs_start:
109108
addi t1, t1, -1
110109
bnez t1, 1b
111110
2: ",
112-
"sub sp, sp, t0
113-
114-
// Set frame pointer
111+
"la sp, _stack_start",
112+
#[cfg(not(feature = "single-hart"))]
113+
"sub sp, sp, t0",
114+
"// Set frame pointer
115115
add s0, sp, zero
116116
117117
jal zero, _start_rust

riscv-rt/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
//!
328328
//! ## `single-hart`
329329
//!
330-
//! This feature saves a little code size by removing unnecessary stack space calculation if there is only one hart on the target.
330+
//! This feature saves a little code size if there is only one hart on the target.
331331
//!
332332
//! ## `s-mode`
333333
//!

0 commit comments

Comments
 (0)