aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/bhnd/siba
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2016-05-24 01:12:19 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2016-05-24 01:12:19 +0000
commitf4a3eb02973afb7e2c2d1a116dbcb331f91ae022 (patch)
tree05f381a195ef4b0641261ad2cc856d9440c7bca8 /sys/dev/bhnd/siba
parent95320acebcdbd8ba6faba99bb31ba8a0c405c60c (diff)
Notes
Diffstat (limited to 'sys/dev/bhnd/siba')
-rw-r--r--sys/dev/bhnd/siba/siba.c2
-rw-r--r--sys/dev/bhnd/siba/siba_subr.c12
-rw-r--r--sys/dev/bhnd/siba/sibavar.h2
3 files changed, 12 insertions, 4 deletions
diff --git a/sys/dev/bhnd/siba/siba.c b/sys/dev/bhnd/siba/siba.c
index c34fc4fca7d2..a508d3b39ae9 100644
--- a/sys/dev/bhnd/siba/siba.c
+++ b/sys/dev/bhnd/siba/siba.c
@@ -409,7 +409,7 @@ siba_get_region_addr(device_t dev, device_t child, bhnd_port_type port_type,
continue;
*addr = addrspace->sa_base;
- *size = addrspace->sa_size;
+ *size = addrspace->sa_size - addrspace->sa_bus_reserved;
return (0);
}
diff --git a/sys/dev/bhnd/siba/siba_subr.c b/sys/dev/bhnd/siba/siba_subr.c
index e688006c2c66..5d9fc72b1dcd 100644
--- a/sys/dev/bhnd/siba/siba_subr.c
+++ b/sys/dev/bhnd/siba/siba_subr.c
@@ -243,11 +243,16 @@ siba_append_dinfo_region(struct siba_devinfo *dinfo, bhnd_port_type port_type,
{
struct siba_addrspace *sa;
struct siba_port *port;
+ rman_res_t r_size;
/* Verify that base + size will not overflow */
if (UINT32_MAX - size < base)
return (ERANGE);
+ /* Verify that size - bus_reserved will not underflow */
+ if (size < bus_reserved)
+ return (ERANGE);
+
/* Must not be 0-length */
if (size == 0)
return (EINVAL);
@@ -266,11 +271,12 @@ siba_append_dinfo_region(struct siba_devinfo *dinfo, bhnd_port_type port_type,
sa->sa_size = size;
sa->sa_sid = sid;
sa->sa_region_num = region_num;
-
+ sa->sa_bus_reserved = bus_reserved;
+
/* Populate the resource list */
- size -= bus_reserved;
+ r_size = size - bus_reserved;
sa->sa_rid = resource_list_add_next(&dinfo->resources, SYS_RES_MEMORY,
- base, base + size - 1, size);
+ base, base + r_size - 1, r_size);
/* Append to target port */
STAILQ_INSERT_TAIL(&port->sp_addrs, sa, sa_link);
diff --git a/sys/dev/bhnd/siba/sibavar.h b/sys/dev/bhnd/siba/sibavar.h
index 784803c6cee4..2c9f14c50e78 100644
--- a/sys/dev/bhnd/siba/sibavar.h
+++ b/sys/dev/bhnd/siba/sibavar.h
@@ -97,6 +97,8 @@ struct siba_addrspace {
u_int sa_region_num; /**< bhnd region id */
uint8_t sa_sid; /**< siba-assigned address space ID */
int sa_rid; /**< bus resource id */
+ uint32_t sa_bus_reserved;/**< number of bytes at high end of
+ * address space reserved for the bus */
STAILQ_ENTRY(siba_addrspace) sa_link;
};