diff options
author | jhb <jhb@FreeBSD.org> | 2008-03-20 21:24:32 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-03-20 21:24:32 +0000 |
commit | 6cf6d7b22b5d548a6ec6807400ca3ae0731e1ef6 (patch) | |
tree | 885a4249c364d8b7ce6b6edbc94f378c0e100668 /sys/kern/subr_bus.c | |
parent | f997b9d36a153a47597611c46f5f3fd6569faa58 (diff) | |
download | FreeBSD-src-6cf6d7b22b5d548a6ec6807400ca3ae0731e1ef6.zip FreeBSD-src-6cf6d7b22b5d548a6ec6807400ca3ae0731e1ef6.tar.gz |
Implement a BUS_BIND_INTR() method in the bus interface to bind an IRQ
resource to a CPU. The default method is to pass the request up to the
parent similar to BUS_CONFIG_INTR() so that all busses don't have to
explicitly implement bus_bind_intr. A bus_bind_intr(9) wrapper routine
similar to bus_setup/teardown_intr() is added for device drivers to use.
Unbinding an interrupt is done by binding it to NOCPU. The IRQ resource
must be allocated, but it can happen in any order with respect to
bus_setup_intr(). Currently it is only supported on amd64 and i386 via
nexus(4) methods that simply call the intr_bind() routine.
Tested by: gallatin
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 27a9f96..84eeb6a 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3222,6 +3222,23 @@ bus_generic_deactivate_resource(device_t dev, device_t child, int type, } /** + * @brief Helper function for implementing BUS_BIND_INTR(). + * + * This simple implementation of BUS_BIND_INTR() simply calls the + * BUS_BIND_INTR() method of the parent of @p dev. + */ +int +bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq, + int cpu) +{ + + /* Propagate up the bus hierarchy until someone handles it. */ + if (dev->parent) + return (BUS_BIND_INTR(dev->parent, child, irq, cpu)); + return (EINVAL); +} + +/** * @brief Helper function for implementing BUS_CONFIG_INTR(). * * This simple implementation of BUS_CONFIG_INTR() simply calls the @@ -3529,6 +3546,20 @@ bus_teardown_intr(device_t dev, struct resource *r, void *cookie) } /** + * @brief Wrapper function for BUS_BIND_INTR(). + * + * This function simply calls the BUS_BIND_INTR() method of the + * parent of @p dev. + */ +int +bus_bind_intr(device_t dev, struct resource *r, int cpu) +{ + if (dev->parent == NULL) + return (EINVAL); + return (BUS_BIND_INTR(dev->parent, dev, r, cpu)); +} + +/** * @brief Wrapper function for BUS_SET_RESOURCE(). * * This function simply calls the BUS_SET_RESOURCE() method of the |