Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #128 from ivq/fix_single_hart_stack
Browse files Browse the repository at this point in the history
Fix setting incorrect sp if single-hart
  • Loading branch information
romancardenas authored Nov 10, 2023
2 parents 6624491 + 97f9b6a commit 7fe4dc3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- New GitHub workflow for checking invalid labels in PRs
- New GitHub workflow for checking modifications on CHANGELOG.md
- New GitHub workflow for checking clippy lints in PRs
- Optional cargo feature `single-hart` for single CPU targets

### Changed

Expand Down
14 changes: 7 additions & 7 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,16 @@ _abs_start:
.option push
.option norelax
la gp, __global_pointer$
.option pop",
.option pop
// Allocate stacks",
#[cfg(all(not(feature = "single-hart"), feature = "s-mode"))]
"mv t2, a0 // the hartid is passed as parameter by SMODE",
#[cfg(all(not(feature = "single-hart"), not(feature = "s-mode")))]
"csrr t2, mhartid",
#[cfg(not(feature = "single-hart"))]
"lui t0, %hi(_max_hart_id)
add t0, t0, %lo(_max_hart_id)
bgtu t2, t0, abort",
"// Allocate stacks
la sp, _stack_start
bgtu t2, t0, abort
lui t0, %hi(_hart_stack_size)
add t0, t0, %lo(_hart_stack_size)",
#[cfg(all(not(feature = "single-hart"), riscvm))]
Expand All @@ -109,9 +108,10 @@ _abs_start:
addi t1, t1, -1
bnez t1, 1b
2: ",
"sub sp, sp, t0
// Set frame pointer
"la sp, _stack_start",
#[cfg(not(feature = "single-hart"))]
"sub sp, sp, t0",
"// Set frame pointer
add s0, sp, zero
jal zero, _start_rust
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
//!
//! ## `single-hart`
//!
//! This feature saves a little code size by removing unnecessary stack space calculation if there is only one hart on the target.
//! This feature saves a little code size if there is only one hart on the target.
//!
//! ## `s-mode`
//!
Expand Down

0 comments on commit 7fe4dc3

Please sign in to comment.