Skip to content

Commit

Permalink
Remove weak symbols, use abort for defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
rslawson committed Jan 8, 2025
1 parent fe6da17 commit db13f72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
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"
);

0 comments on commit db13f72

Please sign in to comment.