summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2008-09-07 04:44:24 +0000
committernyan <nyan@FreeBSD.org>2008-09-07 04:44:24 +0000
commit909db6af61bee69faa1bf964ad229c0d93aa4444 (patch)
treeca8f13ff36b07b21a2f88f12309b1ca8abfd8f8c /sys
parent598da5ab172a68da03b4ef0ea269980d585972ef (diff)
downloadFreeBSD-src-909db6af61bee69faa1bf964ad229c0d93aa4444.zip
FreeBSD-src-909db6af61bee69faa1bf964ad229c0d93aa4444.tar.gz
- Add the i386_memio_map_load() function to load I/O address table.
- Add the bus_space_compare macro for bus_space consistency. - Switch using the bus_space_map_load() in isa_load_resourcev().
Diffstat (limited to 'sys')
-rw-r--r--sys/i386/isa/isa.c23
-rw-r--r--sys/pc98/include/bus.h22
-rw-r--r--sys/pc98/pc98/busiosubr.c25
3 files changed, 49 insertions, 21 deletions
diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c
index a62c658..786de1a 100644
--- a/sys/i386/isa/isa.c
+++ b/sys/i386/isa/isa.c
@@ -203,28 +203,9 @@ isa_alloc_resourcev(device_t child, int type, int *rid,
int
isa_load_resourcev(struct resource *re, bus_addr_t *res, bus_size_t count)
{
- bus_addr_t start;
- bus_space_handle_t bh;
- int i;
-
- bh = rman_get_bushandle(re);
- if (count > bh->bsh_maxiatsz) {
- printf("isa_load_resourcev: map size too large\n");
- return EINVAL;
- }
-
- start = rman_get_start(re);
- for (i = 0; i < bh->bsh_maxiatsz; i++) {
- if (i < count)
- bh->bsh_iat[i] = start + res[i];
- else
- bh->bsh_iat[i] = start;
- }
-
- bh->bsh_iatsz = count;
- bh->bsh_bam = rman_get_bustag(re)->bs_ra; /* relocate access */
- return 0;
+ return bus_space_map_load(rman_get_bustag(re), rman_get_bushandle(re),
+ count, res, 0);
}
#endif /* PC98 */
diff --git a/sys/pc98/include/bus.h b/sys/pc98/include/bus.h
index 39111f5..07b7ea3 100644
--- a/sys/pc98/include/bus.h
+++ b/sys/pc98/include/bus.h
@@ -92,7 +92,13 @@
#define BUS_SPACE_UNRESTRICTED (~0)
+/*
+ * address relocation table
+ */
#define BUS_SPACE_IAT_MAXSIZE 33
+typedef bus_addr_t *bus_space_iat_t;
+
+#define BUS_SPACE_IAT_SZ(IOTARRAY) (sizeof(IOTARRAY)/sizeof(bus_addr_t))
/*
* Access methods for bus resources and address space.
@@ -224,6 +230,19 @@ void i386_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
i386_memio_unmap((t), (h), (s))
/*
+ * int bus_space_map_load (bus_space_tag_t t, bus_space_handle_t bsh,
+ * bus_size_t size, bus_space_iat_t iat, u_int flags);
+ *
+ * Load I/O address table of bus space.
+ */
+
+int i386_memio_map_load(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t size, bus_space_iat_t iat, u_int flags);
+
+#define bus_space_map_load(t, h, s, iat, f) \
+ i386_memio_map_load((t), (h), (s), (iat), (f))
+
+/*
* int bus_space_subregion (bus_space_tag_t t,
* bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
* bus_space_handle_t *nbshp);
@@ -260,6 +279,9 @@ void i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh,
int i386_memio_compare(bus_space_tag_t t1, bus_space_handle_t bsh1,
bus_space_tag_t t2, bus_space_handle_t bsh2);
+#define bus_space_compare(t1, h1, t2, h2) \
+ i386_memio_compare((t1), (h1), (t2), (h2))
+
/*
* Access methods for bus resources and address space.
*/
diff --git a/sys/pc98/pc98/busiosubr.c b/sys/pc98/pc98/busiosubr.c
index 79b06ce..dffe5ff 100644
--- a/sys/pc98/pc98/busiosubr.c
+++ b/sys/pc98/pc98/busiosubr.c
@@ -221,6 +221,31 @@ i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
}
int
+i386_memio_map_load(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t size, bus_space_iat_t iat, u_int flags __unused)
+{
+ int i;
+
+ if (size > bsh->bsh_maxiatsz) {
+ printf("i386_memio_map_load: map size too large\n");
+ return EINVAL;
+ }
+
+ for (i = 0; i < bsh->bsh_maxiatsz; i++) {
+ if (i < size)
+ bsh->bsh_iat[i] = iat[i];
+ else
+ bsh->bsh_iat[i] = 0;
+ bsh->bsh_iat[i] += bsh->bsh_base;
+ }
+
+ bsh->bsh_iatsz = size;
+ bsh->bsh_bam = t->bs_ra; /* relocate access */
+
+ return 0;
+}
+
+int
i386_memio_subregion(bus_space_tag_t t, bus_space_handle_t pbsh,
bus_size_t offset, bus_size_t size,
bus_space_handle_t *tbshp)
OpenPOWER on IntegriCloud