-
Notifications
You must be signed in to change notification settings - Fork 187
Closed
Description
At the moment, the trap handler is initialized rather late in the boot procedure (it is more or less the last thing to happen before jumping to main). However, traps may happen before this, and they will not be handled appropriately (as far as I can tell, my CPU lands in a reset loop).
The most prominent situation in which this may happen is when I accidentally run the software compiled with multiplication instructions on a machine without them, because of these lines: https://github.com/rust-embedded/riscv-rt/blob/master/asm.S#L99-L110
I see multiple different approaches to improve the current situation:
- Simply hardcode the non-mul branch in the
asm.S. Since the factor against we are multiplying is rather low (it's the number of harts of the machine), the run time overhead shouldn't hit that hard. - Going one step further, I suggest compiling
asm.Sfor therv32iandrv64itargets only. Most of these extensions aren't needed anyways during initialization. - Alternatively, define a pre-Rust trap handler which is initialized first in
_start. Once the Rust runtime is ready,default_setup_interruptswill override it to the actual implementation.
Metadata
Metadata
Assignees
Labels
No labels