Registering an Interrupt Handler in Rust
Instead of asking a device over and over whether it is done, you register a function the processor jumps to when the device raises its line. In Rust you implement a handler trait on a type that owns whatever state the handler needs, and hand it to a device-managed registration, so the handler is torn down with the device and its state provably outlives it. The handler returns a value saying whether this interrupt was actually yours, which matters on shared lines. It runs in atomic context, so it may not sleep, may not take a mutex, and should do as little as possible before acknowledging the device.
Questions this Concept answers
- Why does the registration in the `kernel` crate take ownership of the data an interrupt handler needs, instead of a raw pointer to it?
This Concept is waiting for its first lesson!
Instead of asking a device over and over whether it is done, you register a function the processor jumps to when the device raises its line. In Rust you implement a handler trait on a type that owns whatever state the handler needs, and hand it to a device-managed registration, so the handler is torn down with the device and its state provably outlives it. The handler returns a value saying whether this interrupt was actually yours, which matters on shared lines. It runs in atomic context, so it may not sleep, may not take a mutex, and should do as little as possible before acknowledging the device.
Are you a teacher? Sign in to start contributing.
Sign In