rust-embedded / riscv

Low level access to RISC-V processors
841 stars 162 forks source link

RFC: Platform-specific exception codes #146

Closed SoulSharer closed 1 week ago

SoulSharer commented 1 year ago

image

Are there any plans to provide support for platform specific extensions in riscv crate? Reading through RISC-V Privileged Architectures specification I see that there are cases where, for example, a 3.1.15 Machine Cause Register has exception codes allocated for platform and custom use.

Was wondering if it would be possible to extend enums Interrupt and Exception from outside of the riscv crate itself. The best I could came up thus far is adding "PlatformSpecific1-32" fields to Interrupt and creating a user-defined enum PlatformInterrupt with conversion between (TryFrom<Interrupt> for PlaftormInterrupt) where applicable. (same goes for Exception)

romancardenas commented 1 year ago

Hi! I don't think we have plans to add this functionality right now. If you think this feature is useful, feel free to open a PR/RFC and we can discuss it further :)

In my opinion, we should look at how cortex-m deals with platform-specific interrupts and follow their approach.

romancardenas commented 5 months ago

While working on #200, I've been thinking on how to provide this functionality. I propose the following approach: