|DDI_INTR_ADD_HANDLER(9F)||Kernel Functions for Drivers||DDI_INTR_ADD_HANDLER(9F)|
#include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> #include <sys/sunddi.h> int ddi_intr_add_handler(ddi_intr_handle_t *h, ddi_intr_handler_t inthandler, void *arg1, void *arg2);
int ddi_intr_remove_handler(ddi_intr_handle_t h);
The routine inthandler with the arguments arg1 and arg2 is called upon receipt of the appropriate interrupt. The interrupt handler should return DDI_INTR_CLAIMED if the interrupt is claimed and DDI_INTR_UNCLAIMED otherwise.
The ddi_intr_add_handler() function must be called after ddi_intr_alloc(), but before ddi_intr_enable() is called. The interrupt must be enabled through ddi_intr_enable() or ddi_intr_block_enable() before it can be used.
The ddi_intr_remove_handler() function removes the handler association, added previously with ddi_intr_add_handler(), for the interrupt identified by the interrupt handle h argument. Unloadable drivers should call this routine during their detach(9E) routine to remove the interrupt handler from the system.
The ddi_intr_remove_handler() function is used to disassociate the handler after the interrupt is disabled to remove dup-ed interrupt handles. See ddi_intr_dup_handler(9F) for dup-ed interrupt handles. If a handler is duplicated with the ddi_intr_dup_handler() function, all added and duplicated instances of the handler must be removed with ddi_intr_remove_handler() in order for the handler to be completely removed.
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
Writing Device Drivers
If a device driver that uses MSI and MSI-X interrupts resets the device, the device might reset its configuration space modifications. Such a reset could cause a device driver to lose any MSI and MSI-X interrupt usage settings that have been applied.
The second argument, arg2, is optional. Device drivers are free to use the two arguments however they see fit. There is no officially recommended model or restrictions. For example, an interrupt handler may wish to use the first argument as the pointer to its softstate and the second argument as the value of the MSI vector.
|April 22, 2005||OmniOS|