Skip to content

riscv-rt: Remove weak symbol for _mp_hook #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
they must enable the `pre-init` feature.
- Deprecate `riscv_rt::pre_init` attribute macro. It is not sound to run Rust code before initializing the RAM.
Instead, we recommend defining the `__pre_init` function with `core::arch::global_asm!`.
- Replace weak definition of `_mp_hook` with `PROVIDE(_mp_hook = _default_mp_hook)`.

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions riscv-rt/link.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ PROVIDE(abort = _default_abort);
_pre_init_trap defaults to _default_abort. Note that _pre_init_trap must be 4-byte aligned */
PROVIDE(_pre_init_trap = _default_abort);

/* Multi-processor hook function (for multi-core targets only). If no _mp_hook symbol
is provided, then _mp_hook maps to _default_mp_hook, which leaves HART 0 running while
the other HARTS stuck in a busy loop. Note that _default_mp_hook cannot be overwritten.
We use PROVIDE to avoid compilation errors in single hart targets, not to allow users
to overwrite the symbol. */
PROVIDE(_default_mp_hook = abort);
PROVIDE(_mp_hook = _default_mp_hook);

/* Default trap entry point. If not _start_trap symbol is provided, then _start_trap maps to
_default_start_trap, which saves caller saved registers, calls _start_trap_rust, restores
caller saved registers and then returns. Note that _start_trap must be 4-byte aligned */
Expand Down
4 changes: 2 additions & 2 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ cfg_global_asm!(
// Default implementation of `_mp_hook` wakes hart 0 and busy-loops all the other harts.
// Users can override this function by defining their own `_mp_hook`.
// This function is only used when the `single-hart` feature is not enabled.
".weak _mp_hook
_mp_hook:
".global _default_mp_hook
_default_mp_hook:
beqz a0, 2f // if hartid is 0, return true
1: wfi // Otherwise, wait for interrupt in a loop
j 1b
Expand Down