BUS_SETUP_INTR(9) BSD Kernel Developer's Manual BUS_SETUP_INTR(9)NAME
BUS_SETUP_INTR, bus_setup_intr, BUS_TEARDOWN_INTR, bus_teardown_intr —
create, attach and teardown an interrupt handler
SYNOPSIS
#include <sys/param.h>
#include <sys/bus.h>
int
BUS_SETUP_INTR(device_t dev, device_t child, struct resource *irq,
int flags, driver_intr_t *intr, void *arg, void **cookiep,
lwkt_serialize_t serializer);
int
bus_setup_intr(device_t dev, struct resource *r, int flags,
driver_intr_t handler, void *arg, void **cookiep,
lwkt_serialize_t serializer);
int
BUS_TEARDOWN_INTR(device_t dev, device_t child, struct resource *irq,
void *cookie);
int
bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
DESCRIPTION
The BUS_SETUP_INTR() method will create and attach an interrupt handler
to an interrupt previously allocated by the resource manager's
BUS_ALLOC_RESOURCE(9) method. The defined handler will be called with
the value arg as its only argument.
The cookiep argument is a pointer to a void * that BUS_SETUP_INTR() will
write a cookie for the parent bus' use to if it is successful in estab‐
lishing an interrupt. Driver writers may assume that this cookie will be
non-zero. The nexus driver will write 0 on failure to cookiep.
The flags are found in <sys/bus.h> and tell the interrupt handlers about
certain device driver characteristics and are typically either 0 or
INTR_MPSAFE. If INTR_MPSAFE is specified the kernel is free to call the
interrupt handler without holding the MP lock. INTR_FAST is also some‐
times specified and allows the interrupt handler to be directly called
from the context of the thread being interrupted, but is not recommended
for most drivers. Other interrupt flags exist for special purposes.
If serializer is non-NULL the interrupt handler will be called with the
serializer held. The serializer replaces the obsolete SPL calls that are
no longer relevant on SMP systems. Driver code can obtain the same seri‐
alizer to interlock against the driver interrupt. The serializer also
has enablement and disablement features which mainline driver code can
use to avoid races between interrupt disablement and delayed interrupts
executing from the device's interrupt thread.
The interrupt handler will be detached by BUS_TEARDOWN_INTR(). The
cookie needs to be passed to BUS_TEARDOWN_INTR() in order to tear down
the correct interrupt handler. Once BUS_TEARDOWN_INTR() returns, it is
guaranteed that the interrupt function is not active and will no longer
be called.
The lowercase versions bus_setup_intr() and bus_teardown_intr() are con‐
venience functions to make it easier for drivers to use the resource-man‐
agement functions. All they do is hide indirection through the parent's
method table, making for slightly less wordy code.
RETURN VALUES
Zero is returned on success, otherwise an appropriate error is returned.
SEE ALSOdevice(9), driver(9), serializer(9)AUTHORS
This manual page was written by Jeroen Ruigrok van der Werven
⟨asmodai@FreeBSD.org⟩ based on the manual pages for BUS_CREATE_INTR() and
BUS_CONNECT_INTR() written by Doug Rabson ⟨dfr@FreeBSD.org⟩.
BSD April 7, 2007 BSD