summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhibbits <jhibbits@FreeBSD.org>2016-01-27 02:23:54 +0000
committerjhibbits <jhibbits@FreeBSD.org>2016-01-27 02:23:54 +0000
commit31bb8ee5bdf9a6332a86e4774ebdccba877ce42e (patch)
tree5ac500b634909ff3fe2556201aef7e16d85316d2 /sys/kern
parentd2ca0a07825355904475b1fe585efdd49eeae0b3 (diff)
downloadFreeBSD-src-31bb8ee5bdf9a6332a86e4774ebdccba877ce42e.zip
FreeBSD-src-31bb8ee5bdf9a6332a86e4774ebdccba877ce42e.tar.gz
Convert rman to use rman_res_t instead of u_long
Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/bus_if.m22
-rw-r--r--sys/kern/subr_bus.c42
-rw-r--r--sys/kern/subr_rman.c32
3 files changed, 49 insertions, 47 deletions
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
index bafa448..e55b1ce 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -44,8 +44,8 @@ INTERFACE bus;
CODE {
static struct resource *
null_alloc_resource(device_t dev, device_t child,
- int type, int *rid, u_long start, u_long end,
- u_long count, u_int flags)
+ int type, int *rid, rman_res_t start, rman_res_t end,
+ rman_res_t count, u_int flags)
{
return (0);
}
@@ -264,9 +264,9 @@ METHOD struct resource * alloc_resource {
device_t _child;
int _type;
int *_rid;
- u_long _start;
- u_long _end;
- u_long _count;
+ rman_res_t _start;
+ rman_res_t _end;
+ rman_res_t _count;
u_int _flags;
} DEFAULT null_alloc_resource;
@@ -332,8 +332,8 @@ METHOD int adjust_resource {
device_t _child;
int _type;
struct resource *_res;
- u_long _start;
- u_long _end;
+ rman_res_t _start;
+ rman_res_t _end;
};
/**
@@ -433,8 +433,8 @@ METHOD int set_resource {
device_t _child;
int _type;
int _rid;
- u_long _start;
- u_long _count;
+ rman_res_t _start;
+ rman_res_t _count;
};
/**
@@ -457,8 +457,8 @@ METHOD int get_resource {
device_t _child;
int _type;
int _rid;
- u_long *_startp;
- u_long *_countp;
+ rman_res_t *_startp;
+ rman_res_t *_countp;
};
/**
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index b1159b6..6aca991 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -3063,8 +3063,8 @@ resource_list_free(struct resource_list *rl)
* @param count XXX end-start+1
*/
int
-resource_list_add_next(struct resource_list *rl, int type, u_long start,
- u_long end, u_long count)
+resource_list_add_next(struct resource_list *rl, int type, rman_res_t start,
+ rman_res_t end, rman_res_t count)
{
int rid;
@@ -3092,7 +3092,7 @@ resource_list_add_next(struct resource_list *rl, int type, u_long start,
*/
struct resource_list_entry *
resource_list_add(struct resource_list *rl, int type, int rid,
- u_long start, u_long end, u_long count)
+ rman_res_t start, rman_res_t end, rman_res_t count)
{
struct resource_list_entry *rle;
@@ -3250,7 +3250,7 @@ resource_list_delete(struct resource_list *rl, int type, int rid)
*/
struct resource *
resource_list_reserve(struct resource_list *rl, device_t bus, device_t child,
- int type, int *rid, u_long start, u_long end, u_long count, u_int flags)
+ int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct resource_list_entry *rle = NULL;
int passthrough = (device_get_parent(child) != bus);
@@ -3307,7 +3307,7 @@ resource_list_reserve(struct resource_list *rl, device_t bus, device_t child,
*/
struct resource *
resource_list_alloc(struct resource_list *rl, device_t bus, device_t child,
- int type, int *rid, u_long start, u_long end, u_long count, u_int flags)
+ int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct resource_list_entry *rle = NULL;
int passthrough = (device_get_parent(child) != bus);
@@ -3949,7 +3949,7 @@ bus_generic_teardown_intr(device_t dev, device_t child, struct resource *irq,
*/
int
bus_generic_adjust_resource(device_t dev, device_t child, int type,
- struct resource *r, u_long start, u_long end)
+ struct resource *r, rman_res_t start, rman_res_t end)
{
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
@@ -3966,7 +3966,7 @@ bus_generic_adjust_resource(device_t dev, device_t child, int type,
*/
struct resource *
bus_generic_alloc_resource(device_t dev, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
+ rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
@@ -4104,7 +4104,7 @@ bus_generic_get_dma_tag(device_t dev, device_t child)
*/
int
bus_generic_rl_get_resource(device_t dev, device_t child, int type, int rid,
- u_long *startp, u_long *countp)
+ rman_res_t *startp, rman_res_t *countp)
{
struct resource_list * rl = NULL;
struct resource_list_entry * rle = NULL;
@@ -4135,7 +4135,7 @@ bus_generic_rl_get_resource(device_t dev, device_t child, int type, int rid,
*/
int
bus_generic_rl_set_resource(device_t dev, device_t child, int type, int rid,
- u_long start, u_long count)
+ rman_res_t start, rman_res_t count)
{
struct resource_list * rl = NULL;
@@ -4203,7 +4203,7 @@ bus_generic_rl_release_resource(device_t dev, device_t child, int type,
*/
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)
+ int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct resource_list * rl = NULL;
@@ -4289,8 +4289,8 @@ bus_release_resources(device_t dev, const struct resource_spec *rs,
* parent of @p dev.
*/
struct resource *
-bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end,
- u_long count, u_int flags)
+bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, rman_res_t end,
+ rman_res_t count, u_int flags)
{
if (dev->parent == NULL)
return (NULL);
@@ -4305,8 +4305,8 @@ bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end,
* parent of @p dev.
*/
int
-bus_adjust_resource(device_t dev, int type, struct resource *r, u_long start,
- u_long end)
+bus_adjust_resource(device_t dev, int type, struct resource *r, rman_res_t start,
+ rman_res_t end)
{
if (dev->parent == NULL)
return (EINVAL);
@@ -4436,7 +4436,7 @@ bus_describe_intr(device_t dev, struct resource *irq, void *cookie,
*/
int
bus_set_resource(device_t dev, int type, int rid,
- u_long start, u_long count)
+ rman_res_t start, rman_res_t count)
{
return (BUS_SET_RESOURCE(device_get_parent(dev), dev, type, rid,
start, count));
@@ -4450,7 +4450,7 @@ bus_set_resource(device_t dev, int type, int rid,
*/
int
bus_get_resource(device_t dev, int type, int rid,
- u_long *startp, u_long *countp)
+ rman_res_t *startp, rman_res_t *countp)
{
return (BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
startp, countp));
@@ -4462,10 +4462,11 @@ bus_get_resource(device_t dev, int type, int rid,
* This function simply calls the BUS_GET_RESOURCE() method of the
* parent of @p dev and returns the start value.
*/
-u_long
+rman_res_t
bus_get_resource_start(device_t dev, int type, int rid)
{
- u_long start, count;
+ rman_res_t start;
+ rman_res_t count;
int error;
error = BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
@@ -4481,10 +4482,11 @@ bus_get_resource_start(device_t dev, int type, int rid)
* This function simply calls the BUS_GET_RESOURCE() method of the
* parent of @p dev and returns the count value.
*/
-u_long
+rman_res_t
bus_get_resource_count(device_t dev, int type, int rid)
{
- u_long start, count;
+ rman_res_t start;
+ rman_res_t count;
int error;
error = BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index 310bd5e..3050e44 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -90,8 +90,8 @@ struct resource_i {
TAILQ_ENTRY(resource_i) r_link;
LIST_ENTRY(resource_i) r_sharelink;
LIST_HEAD(, resource_i) *r_sharehead;
- u_long r_start; /* index of the first entry in this resource */
- u_long r_end; /* index of the last entry (inclusive) */
+ rman_res_t r_start; /* index of the first entry in this resource */
+ rman_res_t r_end; /* index of the last entry (inclusive) */
u_int r_flags;
void *r_virtual; /* virtual address of this resource */
struct device *r_dev; /* device which has allocated this resource */
@@ -154,7 +154,7 @@ rman_init(struct rman *rm)
}
int
-rman_manage_region(struct rman *rm, u_long start, u_long end)
+rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end)
{
struct resource_i *r, *s, *t;
int rv = 0;
@@ -274,7 +274,7 @@ rman_fini(struct rman *rm)
}
int
-rman_first_free_region(struct rman *rm, u_long *start, u_long *end)
+rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
{
struct resource_i *r;
@@ -292,7 +292,7 @@ rman_first_free_region(struct rman *rm, u_long *start, u_long *end)
}
int
-rman_last_free_region(struct rman *rm, u_long *start, u_long *end)
+rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
{
struct resource_i *r;
@@ -311,7 +311,7 @@ rman_last_free_region(struct rman *rm, u_long *start, u_long *end)
/* Shrink or extend one or both ends of an allocated resource. */
int
-rman_adjust_resource(struct resource *rr, u_long start, u_long end)
+rman_adjust_resource(struct resource *rr, rman_res_t start, rman_res_t end)
{
struct resource_i *r, *s, *t, *new;
struct rman *rm;
@@ -434,13 +434,13 @@ rman_adjust_resource(struct resource *rr, u_long start, u_long end)
#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_PREFETCHABLE))
struct resource *
-rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
- u_long count, u_long bound, u_int flags,
+rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end,
+ rman_res_t count, rman_res_t bound, u_int flags,
struct device *dev)
{
u_int new_rflags;
struct resource_i *r, *s, *rv;
- u_long rstart, rend, amask, bmask;
+ rman_res_t rstart, rend, amask, bmask;
rv = NULL;
@@ -641,8 +641,8 @@ out:
}
struct resource *
-rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
- u_int flags, struct device *dev)
+rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end,
+ rman_res_t count, u_int flags, struct device *dev)
{
return (rman_reserve_resource_bound(rm, start, end, count, 0, flags,
@@ -803,13 +803,13 @@ rman_make_alignment_flags(uint32_t size)
}
void
-rman_set_start(struct resource *r, u_long start)
+rman_set_start(struct resource *r, rman_res_t start)
{
r->__r_i->r_start = start;
}
-u_long
+rman_res_t
rman_get_start(struct resource *r)
{
@@ -817,20 +817,20 @@ rman_get_start(struct resource *r)
}
void
-rman_set_end(struct resource *r, u_long end)
+rman_set_end(struct resource *r, rman_res_t end)
{
r->__r_i->r_end = end;
}
-u_long
+rman_res_t
rman_get_end(struct resource *r)
{
return (r->__r_i->r_end);
}
-u_long
+rman_res_t
rman_get_size(struct resource *r)
{
OpenPOWER on IntegriCloud