Skip to main content

setup_interrupts

Attribute Macro setup_interrupts 

Source
#[setup_interrupts]
Expand description

Attribute to mark which function will set interrupts before jumping to the entry point.

The riscv-rt crates provides a default implementation that works for most cases. If you want to provide your own implementation, you must enable the custom-setup-interrupts feature in the riscv-rt crate and use this macro on your function. The riscv-rt crate re-exports this macro if the custom-setup-interrupts feature is enabled, so you can use it as riscv_rt::setup_interrupts without depending on riscv-macros directly.

The function must have the signature of [unsafe] fn([usize]), where the argument corresponds to the hart ID of the current hart. This is useful for multi-hart systems to perform hart-specific interrupt setup.

§IMPORTANT

This attribute can appear at most once in the dependency graph.

§Examples

#[riscv_macros::setup_interrupts]
unsafe fn setup_interrupts(hart_id: usize) {
    // do something here
}