-
Notifications
You must be signed in to change notification settings - Fork 164
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
riscv-rt
: Implement support for hardware interrupt dispatching
#158
Comments
I see two cons for using hardware interrupt dispatching:
Nevertheless, it's easy to implement "fake" vectored interrupt dispatching with a single trap entry point and two arrays of handler pointers. |
i've opened an issue over at Also, i think the vectored IRQ would break the current trap implementation since pc would jump to BASE+4*cause. I think currently the trap reads the cause and then jumps to the correct handler in the vector table. the vectored IRQ would use non-vectortable addresses. |
527: add device.x for riscv targets, and provides __EXTERNAL_INTERRUPTS r=therealprof a=allexoll This PR is a proposal to address #526 . `__EXTERNAL_INTERRUPTS` is the symbol used since `__INTERRUPTS` is used by [riscv-rt](https://github.com/rust-embedded/riscv-rt/blob/47ece5f5163a2e38ce5e4685b5d3145713d7954a/src/lib.rs#L505) I think it fits because the peripheral interrupts are supposed to be pending through the external interrupt. This provides hals with information to manage interrupt request. either through a PLIC or trough the vectored interrupt when that is implemented (in [riscv-rt](https://github.com/rust-embedded/riscv-rt/issues/1) i suppose). Remarks welcome Co-authored-by: Alexis Marquet <[email protected]>
We stumbled into this in our project. We're using a version of lowRISC Ibex which doesn't support direct mode interrupts at all. I patched an implementation of riscv-rt that defaults to vectored interrupts and that one seems to be working out for us. @Disasm Do you think it would be useful work for me to see if some of it can be upstreamed? If it happens that the implementation causes code bloat, it could be gated with a feature-flag such as Related: any advice for how to pass user-picked Rust feature-flags as preproc. defines for the assembly compilation unit? I guess the SMODE-feature/define uses something like that? |
I propose a modification to this crate to ease vector-like handling of the external interrupts.
Having this, we could do a default implementation that looks like this: #[no_mangle]
fn DefaultMachineExternalHandler() {
let interrupt_n = _get_external_interrupt_n();
if interrupt_n < __EXTERNAL_INTERRUPTS.len() {
__EXTERNAL_INTERRUPTS[interrupt_n]();
_clear_external_interrupt(interrupt_n);
} else {
DefaultInterruptHandler();
}
} What do you think? |
It turns out that my proposed approach wasn't that easy to implement. I developed a macro for doing the same. You can check it in rust-embedded/riscv-rt#113 |
riscv-rt
: Implement support for hardware interrupt dispatching
Currently there is a single interrupt entry point. RISCV CPU's also have a hardware dispatching mode.
The text was updated successfully, but these errors were encountered: