summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-05 17:25:59 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-05 17:25:59 +0000
commit85530efaf7a6a42f72dd88dd2812fc34f33a931e (patch)
treefe27ed806015eba36ede599b284de31066d02abb /sys/arch/i386
parent6278fb02068a0fc75a8a6ecb4ed0a3292aad76ab (diff)
Switch everything to the new bus_dmamap_sync API.
Most work by Wilbern Cobb <vedge@csoft.org> with some fixes from me, mickey@ and drahn@.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/machdep.c8
-rw-r--r--sys/arch/i386/include/bus.h25
-rw-r--r--sys/arch/i386/isa/isa_machdep.c33
3 files changed, 39 insertions, 27 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 72d05721a4c..db953029c67 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.178 2001/10/04 21:25:03 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.179 2001/11/05 17:25:57 art Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3012,10 +3012,12 @@ _bus_dmamap_unload(t, map)
* by bus-specific DMA map synchronization functions.
*/
void
-_bus_dmamap_sync(t, map, op)
+_bus_dmamap_sync(t, map, addr, size, op)
bus_dma_tag_t t;
bus_dmamap_t map;
- bus_dmasync_op_t op;
+ bus_addr_t addr;
+ bus_size_t size;
+ int op;
{
/* Nothing to do here. */
diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h
index c04d967e0cd..7f65068456f 100644
--- a/sys/arch/i386/include/bus.h
+++ b/sys/arch/i386/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.30 2001/07/30 14:15:59 art Exp $ */
+/* $OpenBSD: bus.h,v 1.31 2001/11/05 17:25:57 art Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -747,16 +747,12 @@ struct proc;
struct uio;
/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
+ * Operations performed by bus_dmamap_sync().
*/
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE,
-} bus_dmasync_op_t;
+#define BUS_DMASYNC_PREREAD 0x01
+#define BUS_DMASYNC_POSTREAD 0x02
+#define BUS_DMASYNC_PREWRITE 0x04
+#define BUS_DMASYNC_POSTWRITE 0x08
typedef struct i386_bus_dma_tag *bus_dma_tag_t;
typedef struct i386_bus_dmamap *bus_dmamap_t;
@@ -799,7 +795,7 @@ struct i386_bus_dma_tag {
bus_dma_segment_t *, int, bus_size_t, int));
void (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
- bus_dmasync_op_t));
+ bus_addr_t, bus_size_t, int));
/*
* DMA memory utility functions.
@@ -829,9 +825,9 @@ struct i386_bus_dma_tag {
(*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
#define bus_dmamap_unload(t, p) \
(*(t)->_dmamap_unload)((t), (p))
-#define bus_dmamap_sync(t, p, o) \
+#define bus_dmamap_sync(t, p, o, l, ops) \
(void)((t)->_dmamap_sync ? \
- (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0)
+ (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
(*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
@@ -882,7 +878,8 @@ int _bus_dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t,
int _bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
bus_dma_segment_t *, int, bus_size_t, int));
void _bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
-void _bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t));
+void _bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+ bus_size_t, int));
int _bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
bus_size_t alignment, bus_size_t boundary,
diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c
index 345633fc772..13cdd3ff3cb 100644
--- a/sys/arch/i386/isa/isa_machdep.c
+++ b/sys/arch/i386/isa/isa_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isa_machdep.c,v 1.38 2001/07/30 14:15:59 art Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.39 2001/11/05 17:25:57 art Exp $ */
/* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */
#define ISA_DMA_STATS
@@ -169,7 +169,7 @@ int _isa_bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
bus_dma_segment_t *, int, bus_size_t, int));
void _isa_bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
void _isa_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t,
- bus_dmasync_op_t));
+ bus_addr_t, bus_size_t, int));
int _isa_bus_dmamem_alloc __P((bus_dma_tag_t, bus_size_t, bus_size_t,
bus_size_t, bus_dma_segment_t *, int, int *, int));
@@ -885,13 +885,24 @@ _isa_bus_dmamap_unload(t, map)
* Synchronize an ISA DMA map.
*/
void
-_isa_bus_dmamap_sync(t, map, op)
+_isa_bus_dmamap_sync(t, map, offset, len, op)
bus_dma_tag_t t;
bus_dmamap_t map;
- bus_dmasync_op_t op;
+ bus_addr_t offset;
+ bus_size_t len;
+ int op;
{
struct i386_isa_dma_cookie *cookie = map->_dm_cookie;
+#ifdef DEBUG
+ if ((op & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTREAD)) != 0) {
+ if (offset >= map->dm_mapsize)
+ panic("_isa_bus_dmamap_sync: bad offset");
+ if (len == 0 || (offset + len) > map->dm_mapsize)
+ panic("_isa_bus_dmamap_sync: bad length");
+ }
+#endif
+
switch (op) {
case BUS_DMASYNC_PREREAD:
/*
@@ -905,8 +916,9 @@ _isa_bus_dmamap_sync(t, map, op)
* caller's buffer to the bounce buffer.
*/
if (cookie->id_flags & ID_IS_BOUNCING)
- bcopy(cookie->id_origbuf, cookie->id_bouncebuf,
- cookie->id_origbuflen);
+ bcopy(cookie->id_origbuf + offset,
+ cookie->id_bouncebuf + offset,
+ len);
break;
case BUS_DMASYNC_POSTREAD:
@@ -915,8 +927,9 @@ _isa_bus_dmamap_sync(t, map, op)
* bounce buffer to the caller's buffer.
*/
if (cookie->id_flags & ID_IS_BOUNCING)
- bcopy(cookie->id_bouncebuf, cookie->id_origbuf,
- cookie->id_origbuflen);
+ bcopy(cookie->id_bouncebuf + offset,
+ cookie->id_origbuf + offset,
+ len);
break;
case BUS_DMASYNC_POSTWRITE:
@@ -1214,7 +1227,7 @@ isadma_copyfrombuf(addr, nbytes, nphys, phys)
bus_dma_tag_t dmat = ((struct isa_softc *)isa_dev)->sc_dmat;
bus_dmamap_t dmam = phys[0].dmam;
- bus_dmamap_sync(dmat, dmam, BUS_DMASYNC_POSTREAD);
+ bus_dmamap_sync(dmat, dmam, 0, dmam->dm_mapsize, BUS_DMASYNC_POSTREAD);
}
/*
@@ -1230,7 +1243,7 @@ isadma_copytobuf(addr, nbytes, nphys, phys)
bus_dma_tag_t dmat = ((struct isa_softc *)isa_dev)->sc_dmat;
bus_dmamap_t dmam = phys[0].dmam;
- bus_dmamap_sync(dmat, dmam, BUS_DMASYNC_PREWRITE);
+ bus_dmamap_sync(dmat, dmam, 0, dmam->dm_mapsize, BUS_DMASYNC_PREWRITE);
}
#endif /* __ISADMA_COMPAT */
#endif /* NISADMA > 0 */