diff options
author | mdodd <mdodd@FreeBSD.org> | 2000-10-18 05:15:40 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2000-10-18 05:15:40 +0000 |
commit | 2754d6b4a3ae34fa1afd240a26a5d38df1f95b5c (patch) | |
tree | 785b00126626038b902c6425491be5586a61fcb4 /sys/kern/subr_bus.c | |
parent | 8d4d849c73c6d050f96586a4d263f569cff7ae45 (diff) | |
download | FreeBSD-src-2754d6b4a3ae34fa1afd240a26a5d38df1f95b5c.zip FreeBSD-src-2754d6b4a3ae34fa1afd240a26a5d38df1f95b5c.tar.gz |
Add new bus method 'GET_RESOURCE_LIST' and appropriate generic
implementation.
Add bus_generic_rl_{get,set,delete,release,alloc}_resource() functions
which provide generic operations for devices using resource list style
resource management.
This should simplify a number of bus drivers. Further commits to follow.
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 9bd6688..b315a2a 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1964,6 +1964,13 @@ bus_generic_write_ivar(device_t dev, device_t child, int index, return ENOENT; } +int +bus_generic_get_resource_list (device_t dev, device_t child, + struct resource_list *rl) +{ + return ENOENT; +} + void bus_generic_driver_added(device_t dev, driver_t *driver) { @@ -2048,6 +2055,91 @@ bus_generic_deactivate_resource(device_t dev, device_t child, int type, return (EINVAL); } +int +bus_generic_rl_get_resource (device_t dev, device_t child, int type, int rid, + u_long *startp, u_long *countp) +{ + struct resource_list * rl = NULL; + struct resource_list_entry * rle = NULL; + int retval = 0; + + retval = BUS_GET_RESOURCE_LIST(dev, child, rl); + if (retval) + return (retval); + + rle = resource_list_find(rl, type, rid); + if (!rle) + return ENOENT; + + if (startp) + *startp = rle->start; + if (countp) + *countp = rle->count; + + return (0); +} + +int +bus_generic_rl_set_resource (device_t dev, device_t child, int type, int rid, + u_long start, u_long count) +{ + struct resource_list * rl = NULL; + int retval = 0; + + retval = BUS_GET_RESOURCE_LIST(dev, child, rl); + if (retval) + return (retval); + + resource_list_add(rl, type, rid, start, (start + count - 1), count); + + return (0); +} + +void +bus_generic_rl_delete_resource (device_t dev, device_t child, int type, int rid) +{ + struct resource_list * rl = NULL; + int retval = 0; + + retval = BUS_GET_RESOURCE_LIST(dev, child, rl); + if (retval) + return; + + resource_list_delete(rl, type, rid); + + return; +} + +int +bus_generic_rl_release_resource (device_t dev, device_t child, int type, + int rid, struct resource *r) +{ + struct resource_list * rl = NULL; + int retval = 0; + + retval = BUS_GET_RESOURCE_LIST(dev, child, rl); + if (retval) + return (retval); + + return (resource_list_release(rl, dev, child, type, rid, r)); +} + +struct resource * +bus_generic_rl_alloc_resource (device_t dev, device_t child, int type, + int *rid, u_long start, u_long end, + u_long count, u_int flags) +{ + struct resource_list * rl = NULL; + int retval = 0; + + retval = BUS_GET_RESOURCE_LIST(dev, child, rl); + if (retval) + return (0); + + return resource_list_alloc(rl, dev, child, type, rid, + start, end, count, flags); +} + /* * Some convenience functions to make it easier for drivers to use the * resource-management functions. All these really do is hide the |