Go to main content

Writing Device Drivers for Oracle® Solaris 11.3

Exit Print View

Updated: March 2019

DDI Interrupt Functions

The Oracle Solaris OS provides a framework for registering and unregistering interrupts and provides support for Message Signaled Interrupts (MSIs). Interrupt management interfaces enable you to manipulate priorities, capabilities, and interrupt masking, and to obtain pending information.

Interrupt Capability Functions

Use the following functions to obtain interrupt information:


Returns the number of interrupts available for a specified hardware device and interrupt type.


Returns the number of interrupts that the device supports for the specified interrupt type.


Returns the hardware interrupt types that are supported by both the device and the host.


Returns interrupt capability flags for the specified interrupt.

Interrupt Initialization and Destruction Functions

Use the following functions to create and remove interrupts:


Allocates system resources and interrupt vectors for the specified type of interrupt.


Releases the system resources and interrupt vectors for a specified interrupt handle.


Sets the capability of the specified interrupt through the use of the DDI_INTR_FLAG_LEVEL and DDI_INTR_FLAG_EDGE flags.


Adds an interrupt handler.


Use with MSI-X only. Copies an address and data pair for an allocated interrupt vector to an unused interrupt vector on the same device.


Removes the specified interrupt handler.


Enables the specified interrupt.


Disables the specified interrupt.


Use with MSI only. Enables the specified range of interrupts.


Use with MSI only. Disables the specified range of interrupts.


Sets an interrupt mask if the specified interrupt is enabled.


Clears an interrupt mask if the specified interrupt is enabled.


Reads the interrupt pending bit if such a bit is supported by either the host bridge or the device.

Priority Management Functions

Use the following functions to obtain and set priority information:


Returns the current software priority setting for the specified interrupt.


Sets the interrupt priority level for the specified interrupt.


Returns the minimum priority level for a high-level interrupt.

Soft Interrupt Functions

Use the following functions to manipulate soft interrupts and soft interrupt handlers:


Adds a soft interrupt handler.


Triggers the specified soft interrupt.


Removes the specified soft interrupt handler.


Returns the soft interrupt priority for the specified interrupt.


Changes the relative soft interrupt priority for the specified soft interrupt.

Interrupt Function Examples

    This section provides examples for performing the following tasks:

  • Changing soft interrupt priority

  • Checking for pending interrupts

  • Setting interrupt masks

  • Clearing interrupt masks

Example 17  Changing Soft Interrupt Priority

Use the ddi_intr_set_softint_pri(9F) function to change the soft interrupt priority to 9.

if (ddi_intr_set_softint_pri(mydev->mydev_softint_hdl, 9) != DDI_SUCCESS)
    cmn_err (CE_WARN, "ddi_intr_set_softint_pri failed");
Example 18  Checking for Pending Interrupts

Use the ddi_intr_get_pending(9F) function to check whether an interrupt is pending.

if (ddi_intr_get_pending(mydevp->htable[0], &pending) != DDI_SUCCESS)
    cmn_err(CE_WARN, "ddi_intr_get_pending() failed");
else if (pending)
    cmn_err(CE_NOTE, "ddi_intr_get_pending(): Interrupt pending");
Example 19  Setting Interrupt Masks

Use the ddi_intr_set_mask(9F) function to set interrupt masking to prevent the device from receiving interrupts.

if ((ddi_intr_set_mask(mydevp->htable[0]) != DDI_SUCCESS))
    cmn_err(CE_WARN, "ddi_intr_set_mask() failed");
Example 20  Clearing Interrupt Masks

Use the ddi_intr_clr_mask(9F) function to clear interrupt masking. The ddi_intr_clr_mask(9F) function fails if the specified interrupt is not enabled. If the ddi_intr_clr_mask(9F) function succeeds, the device starts generating interrupts.

if (ddi_intr_clr_mask(mydevp->htable[0]) != DDI_SUCCESS)
    cmn_err(CE_WARN, "ddi_intr_clr_mask() failed");