Skip to content
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

Remove weak symbols, use abort for defaults. #254

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
2 changes: 2 additions & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
allow users get the initial address of the heap when initializing an allocator.
- Update documentation.
- Removed `.init.rust` section, as it is no longer required.
- Add global `_abort` symbol, `PROVIDE(abort = _abort)`, and replace `DefaultHandler` and
`ExceptionHandler` with `PROVIDE(... = abort)`.

## [v0.13.0] - 2024-10-19

Expand Down
11 changes: 6 additions & 5 deletions riscv-rt/link.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ PROVIDE(_heap_size = 0);

/** TRAP ENTRY POINTS **/

/* Default abort entry point. If no abort symbol is provided, then abort maps to _abort. */
EXTERN(_abort);
PROVIDE(abort = _abort);

/* Default trap entry point. The riscv-rt crate provides a weak alias of this function,
which saves caller saved registers, calls _start_trap_rust, restores caller saved registers
and then returns. Users can override this alias by defining the symbol themselves */
Expand All @@ -54,7 +58,7 @@ PROVIDE(_start_MachineExternal_trap = _start_DefaultHandler_trap);

/* Default exception handler. The riscv-rt crate provides a weak alias of this function,
which is a busy loop. Users can override this alias by defining the symbol themselves */
EXTERN(ExceptionHandler);
PROVIDE(ExceptionHandler = abort);

/* It is possible to define a special handler for each exception type.
By default, all exceptions are handled by ExceptionHandler. However, users can
Expand All @@ -76,13 +80,10 @@ PROVIDE(StorePageFault = ExceptionHandler);

/** INTERRUPT HANDLERS **/

/* Default interrupt handler. The riscv-rt crate provides a weak alias of this function,
which is a busy loop. Users can override this alias by defining the symbol themselves */
EXTERN(DefaultHandler);

/* It is possible to define a special handler for each interrupt type.
By default, all interrupts are handled by DefaultHandler. However, users can
override these alias by defining the symbol themselves */
PROVIDE(DefaultHandler = abort);
PROVIDE(SupervisorSoft = DefaultHandler);
PROVIDE(MachineSoft = DefaultHandler);
PROVIDE(SupervisorTimer = DefaultHandler);
Expand Down
16 changes: 3 additions & 13 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,6 @@ _setup_interrupts:",
#[cfg(not(feature = "s-mode"))]
"csrw mtvec, t0",
"ret",
// Default implementation of `ExceptionHandler` is an infinite loop.
// Users can override this function by defining their own `ExceptionHandler`
".weak ExceptionHandler
ExceptionHandler:
j ExceptionHandler",
// Default implementation of `DefaultHandler` is an infinite loop.
// Users can override this function by defining their own `DefaultHandler`
".weak DefaultHandler
DefaultHandler:
j DefaultHandler",
// Default implementation of `_pre_init_trap` is an infinite loop.
// Users can override this function by defining their own `_pre_init_trap`
// If the execution reaches this point, it means that there is a bug in the boot code.
Expand All @@ -278,7 +268,7 @@ riscv_rt_macros::vectored_interrupt_trap!();
#[rustfmt::skip]
global_asm!(
".section .text.abort
.weak abort
abort: // make sure there is an abort symbol when linking
j abort"
.global _abort
_abort: // make sure there is an abort symbol when linking
j _abort"
);
Loading