pub struct DeviceInterruptManager<T: InterruptManager> { /* private fields */ }
Expand description

A struct to manage interrupts and interrupt modes for a device.

The interrupt manager may support multiple working mode. For example, an interrupt manager for a PCI device may work in legacy mode, PCI MSI mode or PCI MSIx mode. Under certain conditions, the interrupt manager may switch between interrupt working modes. To simplify implementation, switching working mode is only supported at configuration stage and will be disabled at runtime stage. The DeviceInterruptManager::enable() switches the interrupt manager from configuration stage into runtime stage. And DeviceInterruptManager::reset() switches from runtime stage back to initial configuration stage.

Implementations

Create an interrupt manager for a device.

Arguments
  • intr_mgr: underline interrupt manager to allocate/free interrupt groups.
  • resources: resources assigned to the device, including assigned interrupt resources.

Set device_id for MSI routing

Check whether the interrupt manager has been activated.

Switch the interrupt manager from configuration stage into runtime stage.

The working mode could only be changed at configuration stage, and all requests to change working mode at runtime stage will be rejected.

If the interrupt manager is still in DISABLED mode when DeviceInterruptManager::enable() is called, it will be put into LEGACY mode if LEGACY mode is supported.

Switch the interrupt manager from runtime stage back into initial configuration stage.

Currently we doesn’t track the usage of interrupt group object given out by get_group(), so the the caller needs to take the responsibility to release all interrupt group object reference before calling DeviceInterruptManager::reset().

Get the current interrupt working mode.

Switch interrupt working mode.

Currently switching working mode is only supported during device configuration stage and will always return failure if called during device runtime stage. The device switches from configuration stage to runtime stage by invoking DeviceInterruptManager::enable(). With this constraint, the device drivers may call DeviceInterruptManager::get_group() to get the underline active interrupt group object, and directly calls the interrupt group object’s methods to trigger/acknowledge interrupts.

This is a key design decision for optimizing performance. Though the DeviceInterruptManager object itself is not multi-thread safe and must be protected from concurrent access by the caller, the interrupt source group object is multi-thread safe and could be called concurrently to trigger/acknowledge interrupts. This design may help to improve performance for MSI interrupts.

Arguments
  • mode: target working mode.

Get the underline interrupt source group object, so the device driver could concurrently trigger/acknowledge interrupts by using the returned group object.

Get the underline interrupt source group object, ignore the mode

Reconfigure a specific interrupt in current working mode at configuration or runtime stage.

It’s mainly used to reconfigure Generic MSI/PCI MSI/PCI MSIx interrupts. Actually legacy interrupts don’t support reconfiguration yet.

Set the high address for a MSI message.

Set the low address for a MSI message.

Set the data for a MSI message.

Set msi irq MASK bit

Get msi irq MASK state

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.