diff options
author | jhb <jhb@FreeBSD.org> | 2011-04-29 21:36:45 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-04-29 21:36:45 +0000 |
commit | deafe4e5935414f3eecacab7035e974aed41f689 (patch) | |
tree | a10e3ccb13df7df7d9773ae454c4eab95b57171c /sys/kern | |
parent | f99737eb7bcd6c02fdf8bafc61179eb2711a4ed7 (diff) | |
download | FreeBSD-src-deafe4e5935414f3eecacab7035e974aed41f689.zip FreeBSD-src-deafe4e5935414f3eecacab7035e974aed41f689.tar.gz |
Add a new bus method, BUS_ADJUST_RESOURCE() that is intended to be a
wrapper around rman_adjust_resource(). Include a generic implementation,
bus_generic_adjust_resource() which passes the request up to the parent
bus. There is currently no default implementation. A
bus_adjust_resource() wrapper is provided for use in drivers.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/bus_if.m | 24 | ||||
-rw-r--r-- | sys/kern/subr_bus.c | 32 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index de808de..96fbda8 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -297,6 +297,30 @@ METHOD int deactivate_resource { }; /** + * @brief Adjust a resource + * + * Adjust the start and/or end of a resource allocated by + * BUS_ALLOC_RESOURCE. At least part of the new address range must overlap + * with the existing address range. If the successful, the resource's range + * will be adjusted to [start, end] on return. + * + * @param _dev the parent device of @p _child + * @param _child the device which allocated the resource + * @param _type the type of resource + * @param _res the resource to adjust + * @param _start the new starting address of the resource range + * @param _end the new ending address of the resource range + */ +METHOD int adjust_resource { + device_t _dev; + device_t _child; + int _type; + struct resource *_res; + u_long _start; + u_long _end; +}; + +/** * @brief Release a resource * * Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index a865586..c947735 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3646,6 +3646,23 @@ bus_generic_teardown_intr(device_t dev, device_t child, struct resource *irq, } /** + * @brief Helper function for implementing BUS_ADJUST_RESOURCE(). + * + * This simple implementation of BUS_ADJUST_RESOURCE() simply calls the + * BUS_ADJUST_RESOURCE() method of the parent of @p dev. + */ +int +bus_generic_adjust_resource(device_t dev, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + /* Propagate up the bus hierarchy until someone handles it. */ + if (dev->parent) + return (BUS_ADJUST_RESOURCE(dev->parent, child, type, r, start, + end)); + return (EINVAL); +} + +/** * @brief Helper function for implementing BUS_ALLOC_RESOURCE(). * * This simple implementation of BUS_ALLOC_RESOURCE() simply calls the @@ -3976,6 +3993,21 @@ bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end, } /** + * @brief Wrapper function for BUS_ADJUST_RESOURCE(). + * + * This function simply calls the BUS_ADJUST_RESOURCE() method of the + * parent of @p dev. + */ +int +bus_adjust_resource(device_t dev, int type, struct resource *r, u_long start, + u_long end) +{ + if (dev->parent == NULL) + return (EINVAL); + return (BUS_ADJUST_RESOURCE(dev->parent, dev, type, r, start, end)); +} + +/** * @brief Wrapper function for BUS_ACTIVATE_RESOURCE(). * * This function simply calls the BUS_ACTIVATE_RESOURCE() method of the |