Skip Navigation Links | |
Exit Print View | |
Writing Device Drivers Oracle Solaris 11.1 Information Library |
Part I Designing Device Drivers for the Oracle Solaris Platform
1. Overview of Oracle Solaris Device Drivers
2. Oracle Solaris Kernel and Device Tree
5. Managing Events and Queueing Tasks
7. Device Access: Programmed I/O
Standard and Extended Message-Signaled Interrupts
The Interrupt Resource Management Feature
Register a Callback Handler Function
Unregister a Callback Handler Function
Modify Number of Interrupt Vectors Requested
Interrupt Usage and Flexibility
Example Implementation of Interrupt Resource Management
Interrupt Handler Functionality
Handling High-Level Interrupts
High-Level Interrupt Handling Example
10. Mapping Device and Kernel Memory
13. Hardening Oracle Solaris Drivers
14. Layered Driver Interface (LDI)
Part II Designing Specific Kinds of Device Drivers
15. Drivers for Character Devices
18. SCSI Host Bus Adapter Drivers
19. Drivers for Network Devices
Part III Building a Device Driver
22. Compiling, Loading, Packaging, and Testing Drivers
23. Debugging, Testing, and Tuning Device Drivers
24. Recommended Coding Practices
B. Summary of Oracle Solaris DDI/DKI Services
C. Making a Device Driver 64-Bit Ready
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.
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.
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.
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.
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.
This section provides examples for performing the following tasks:
Changing soft interrupt priority
Checking for pending interrupts
Setting interrupt masks
Clearing interrupt masks
Example 8-1 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 8-2 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 8-3 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 8-4 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");