Skip to content

Commit f68a0e4

Browse files
Merge pull request #289 from rust-embedded/default-mp-hook
`riscv-rt`: Remove weak symbol for _mp_hook
2 parents 6b1c22c + 3a57add commit f68a0e4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3939
they must enable the `pre-init` feature.
4040
- Deprecate `riscv_rt::pre_init` attribute macro. It is not sound to run Rust code before initializing the RAM.
4141
Instead, we recommend defining the `__pre_init` function with `core::arch::global_asm!`.
42+
- Replace weak definition of `_mp_hook` with `PROVIDE(_mp_hook = _default_mp_hook)`.
4243

4344
### Fixed
4445

riscv-rt/link.x.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ PROVIDE(abort = _default_abort);
3131
_pre_init_trap defaults to _default_abort. Note that _pre_init_trap must be 4-byte aligned */
3232
PROVIDE(_pre_init_trap = _default_abort);
3333

34+
/* Multi-processor hook function (for multi-core targets only). If no _mp_hook symbol
35+
is provided, then _mp_hook maps to _default_mp_hook, which leaves HART 0 running while
36+
the other HARTS stuck in a busy loop. Note that _default_mp_hook cannot be overwritten.
37+
We use PROVIDE to avoid compilation errors in single hart targets, not to allow users
38+
to overwrite the symbol. */
39+
PROVIDE(_default_mp_hook = abort);
40+
PROVIDE(_mp_hook = _default_mp_hook);
41+
3442
/* Default trap entry point. If not _start_trap symbol is provided, then _start_trap maps to
3543
_default_start_trap, which saves caller saved registers, calls _start_trap_rust, restores
3644
caller saved registers and then returns. Note that _start_trap must be 4-byte aligned */

riscv-rt/src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ cfg_global_asm!(
226226
// Default implementation of `_mp_hook` wakes hart 0 and busy-loops all the other harts.
227227
// Users can override this function by defining their own `_mp_hook`.
228228
// This function is only used when the `single-hart` feature is not enabled.
229-
".weak _mp_hook
230-
_mp_hook:
229+
".global _default_mp_hook
230+
_default_mp_hook:
231231
beqz a0, 2f // if hartid is 0, return true
232232
1: wfi // Otherwise, wait for interrupt in a loop
233233
j 1b

0 commit comments

Comments
 (0)