diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/dev/bus_dma.c | 8 | ||||
-rw-r--r-- | sys/arch/alpha/include/bus.h | 23 | ||||
-rw-r--r-- | sys/arch/alpha/isa/isa_machdep.h | 6 | ||||
-rw-r--r-- | sys/arch/alpha/isa/isadma_bounce.c | 8 | ||||
-rw-r--r-- | sys/arch/hppa/gsc/gscbus.c | 11 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/mainbus.c | 15 | ||||
-rw-r--r-- | sys/arch/hppa/include/bus.h | 20 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/include/bus.h | 25 | ||||
-rw-r--r-- | sys/arch/i386/isa/isa_machdep.c | 33 | ||||
-rw-r--r-- | sys/arch/macppc/include/bus.h | 23 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/dma.c | 15 | ||||
-rw-r--r-- | sys/arch/mvmeppc/include/bus_mi.h | 25 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/bus_dma.c | 10 |
14 files changed, 127 insertions, 103 deletions
diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c index 2a09c4552a4..81b7171a774 100644 --- a/sys/arch/alpha/dev/bus_dma.c +++ b/sys/arch/alpha/dev/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.4 2001/09/19 20:50:56 mickey Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.5 2001/11/05 17:25:57 art Exp $ */ /* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */ /*- @@ -429,10 +429,12 @@ _bus_dmamap_unload(t, map) * by chipset-specific DMA map synchronization functions. */ void -_bus_dmamap_sync(t, map, op) +_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; { /* diff --git a/sys/arch/alpha/include/bus.h b/sys/arch/alpha/include/bus.h index 2c6070bcfc3..0f7d4a1c183 100644 --- a/sys/arch/alpha/include/bus.h +++ b/sys/arch/alpha/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.14 2001/10/26 01:28:06 nate Exp $ */ +/* $OpenBSD: bus.h,v 1.15 2001/11/05 17:25:57 art Exp $ */ /* $NetBSD: bus.h,v 1.10 1996/12/02 22:19:32 cgd Exp $ */ /* @@ -430,16 +430,12 @@ struct uio; struct alpha_sgmap; /* - * bus_dmasync_op_t - * * 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 /* * alpha_bus_t @@ -537,7 +533,7 @@ struct alpha_bus_dma_tag { bus_dma_segment_t *, int, bus_size_t, int); void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, - bus_dmasync_op_t); + bus_addr_t, bus_size_t, int); /* * DMA memory utility functions. @@ -570,8 +566,8 @@ struct alpha_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, op) \ - (*(t)->_dmamap_sync)((t), (p), (op)) +#define bus_dmamap_sync(t, p, a, s, op) \ + (*(t)->_dmamap_sync)((t), (p), (a), (s), (op)) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) #define bus_dmamem_free(t, sg, n) \ @@ -635,7 +631,8 @@ int _bus_dmamap_load_raw_direct(bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int); void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t); -void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); +void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, + bus_size_t, int); int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size, bus_size_t alignment, bus_size_t boundary, diff --git a/sys/arch/alpha/isa/isa_machdep.h b/sys/arch/alpha/isa/isa_machdep.h index 0fdf551a634..2c9f75f5a07 100644 --- a/sys/arch/alpha/isa/isa_machdep.h +++ b/sys/arch/alpha/isa/isa_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: isa_machdep.h,v 1.9 2001/11/05 02:39:57 art Exp $ */ +/* $OpenBSD: isa_machdep.h,v 1.10 2001/11/05 17:25:57 art Exp $ */ /* $NetBSD: isa_machdep.h,v 1.3 1996/11/19 04:53:07 cgd Exp $ */ /* @@ -77,8 +77,8 @@ int isadma_bounce_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, int isadma_bounce_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int); void isadma_bounce_dmamap_unload(bus_dma_tag_t, bus_dmamap_t); -void isadma_bounce_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, - bus_dmasync_op_t); +void isadma_bounce_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, + bus_size_t, int); int isadma_bounce_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); #endif /* _ALPHA_BUS_DMA_PRIVATE */ diff --git a/sys/arch/alpha/isa/isadma_bounce.c b/sys/arch/alpha/isa/isadma_bounce.c index 7dc9014957d..14b61e65560 100644 --- a/sys/arch/alpha/isa/isadma_bounce.c +++ b/sys/arch/alpha/isa/isadma_bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isadma_bounce.c,v 1.1 2001/11/05 02:39:56 art Exp $ */ +/* $OpenBSD: isadma_bounce.c,v 1.2 2001/11/05 17:25:57 art Exp $ */ /* $NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $ */ /*- @@ -386,12 +386,10 @@ isadma_bounce_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) } void -isadma_bounce_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, - bus_dmasync_op_t ops) +isadma_bounce_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, + bus_size_t len, int ops) { struct isadma_bounce_cookie *cookie = map->_dm_cookie; - bus_addr_t offset = 0; - bus_size_t len = map->dm_mapsize; /* * Mixing PRE and POST operations is not allowed. diff --git a/sys/arch/hppa/gsc/gscbus.c b/sys/arch/hppa/gsc/gscbus.c index c12c94147bb..02ed051d1cf 100644 --- a/sys/arch/hppa/gsc/gscbus.c +++ b/sys/arch/hppa/gsc/gscbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gscbus.c,v 1.14 2001/10/04 22:01:30 mickey Exp $ */ +/* $OpenBSD: gscbus.c,v 1.15 2001/11/05 17:25:57 art Exp $ */ /* * Copyright (c) 1998 Michael Shalayeff @@ -106,7 +106,8 @@ int gsc_dmamap_load_uio __P((void *, bus_dmamap_t, struct uio *, int)); int gsc_dmamap_load_raw __P((void *, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int)); void gsc_dmamap_unload __P((void *, bus_dmamap_t)); -void gsc_dmamap_sync __P((void *, bus_dmamap_t, bus_dmasync_op_t)); +void gsc_dmamap_sync __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, + int)); int gsc_dmamem_alloc __P((void *, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int)); @@ -347,10 +348,12 @@ gsc_dmamap_unload(v, map) } void -gsc_dmamap_sync(v, map, op) +gsc_dmamap_sync(v, map, offset, len, op) void *v; bus_dmamap_t map; - bus_dmasync_op_t op; + bus_addr_t offset; + bus_size_t len; + int op; { } diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c index b31a8ed923b..d1c50ad91c7 100644 --- a/sys/arch/hppa/hppa/mainbus.c +++ b/sys/arch/hppa/hppa/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.13 2001/09/19 20:50:56 mickey Exp $ */ +/* $OpenBSD: mainbus.c,v 1.14 2001/11/05 17:25:57 art Exp $ */ /* * Copyright (c) 1998-2000 Michael Shalayeff @@ -682,7 +682,8 @@ mbus_dmamap_unload(void *v, bus_dmamap_t map) } void -mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_dmasync_op_t ops) +mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t offset, bus_size_t len, + int ops) { int i; switch (ops) { @@ -693,15 +694,17 @@ mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_dmasync_op_t ops) case BUS_DMASYNC_PREREAD: for (i = map->dm_nsegs; i--; ) - pdcache(HPPA_SID_KERNEL, map->dm_segs[i].ds_addr, - map->dm_segs[i].ds_len); + pdcache(HPPA_SID_KERNEL, + map->dm_segs[i].ds_addr + offset, + len); sync_caches(); break; case BUS_DMASYNC_PREWRITE: for (i = map->dm_nsegs; i--; ) - fdcache(HPPA_SID_KERNEL, map->dm_segs[i].ds_addr, - map->dm_segs[i].ds_len); + fdcache(HPPA_SID_KERNEL, + map->dm_segs[i].ds_addr + offset, + len); sync_caches(); break; } diff --git a/sys/arch/hppa/include/bus.h b/sys/arch/hppa/include/bus.h index 1139bb4c994..4465645ca40 100644 --- a/sys/arch/hppa/include/bus.h +++ b/sys/arch/hppa/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.13 2001/07/30 14:15:59 art Exp $ */ +/* $OpenBSD: bus.h,v 1.14 2001/11/05 17:25:57 art Exp $ */ /* * Copyright (c) 1998,1999 Michael Shalayeff @@ -298,12 +298,11 @@ struct mbuf; struct proc; struct uio; -typedef enum { - BUS_DMASYNC_POSTREAD, - BUS_DMASYNC_POSTWRITE, - BUS_DMASYNC_PREREAD, - BUS_DMASYNC_PREWRITE -} bus_dmasync_op_t; +/* Operations performed by bus_dmamap_sync(). */ +#define BUS_DMASYNC_POSTREAD 0x01 +#define BUS_DMASYNC_POSTWRITE 0x02 +#define BUS_DMASYNC_PREREAD 0x04 +#define BUS_DMASYNC_PREWRITE 0x08 typedef const struct hppa_bus_dma_tag *bus_dma_tag_t; typedef struct hppa_bus_dmamap *bus_dmamap_t; @@ -345,7 +344,8 @@ struct hppa_bus_dma_tag { int (*_dmamap_load_raw) __P((void *, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int)); void (*_dmamap_unload) __P((void *, bus_dmamap_t)); - void (*_dmamap_sync) __P((void *, bus_dmamap_t, bus_dmasync_op_t)); + void (*_dmamap_sync) __P((void *, bus_dmamap_t, bus_addr_t, + bus_size_t, int)); /* * DMA memory utility functions. @@ -374,9 +374,9 @@ struct hppa_bus_dma_tag { (*(t)->_dmamap_load_raw)((t)->_cookie, (m), (sg), (n), (s), (f)) #define bus_dmamap_unload(t, p) \ (*(t)->_dmamap_unload)((t)->_cookie, (p)) -#define bus_dmamap_sync(t, p, o) \ +#define bus_dmamap_sync(t, p, a, l, o) \ (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t)->_cookie, (p), (o)) : (void)0) + (*(t)->_dmamap_sync)((t)->_cookie, (p), (a), (l), (o)) : (void)0) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f)) 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 */ diff --git a/sys/arch/macppc/include/bus.h b/sys/arch/macppc/include/bus.h index eb4904a0ad5..91243530911 100644 --- a/sys/arch/macppc/include/bus.h +++ b/sys/arch/macppc/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.1 2001/09/01 15:49:06 drahn Exp $ */ +/* $OpenBSD: bus.h,v 1.2 2001/11/05 17:25:58 art Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom. All rights reserved. @@ -393,12 +393,10 @@ struct mbuf; struct proc; struct uio; -typedef enum { - BUS_DMASYNC_POSTREAD, - BUS_DMASYNC_POSTWRITE, - BUS_DMASYNC_PREREAD, - BUS_DMASYNC_PREWRITE -} bus_dmasync_op_t; +#define BUS_DMASYNC_POSTREAD 0x01 +#define BUS_DMASYNC_POSTWRITE 0x02 +#define BUS_DMASYNC_PREREAD 0x04 +#define BUS_DMASYNC_PREWRITE 0x08 typedef struct powerpc_bus_dma_tag *bus_dma_tag_t; typedef struct powerpc_bus_dmamap *bus_dmamap_t; @@ -440,7 +438,8 @@ struct powerpc_bus_dma_tag { int (*_dmamap_load_raw) __P((bus_dma_tag_t , bus_dmamap_t, 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)); + void (*_dmamap_sync) __P((bus_dma_tag_t , bus_dmamap_t, + bus_addr_t, bus_size_t, int)); /* * DMA memory utility functions. @@ -469,9 +468,9 @@ struct powerpc_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, a, l, o) \ (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0) + (*(t)->_dmamap_sync)((t), (p), (a), (l), (o)) : (void)0) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f)) @@ -494,7 +493,8 @@ int _dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t, struct uio *, int)); int _dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t, 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)); +void _dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t, + int)); int _dmamem_alloc __P((bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int)); @@ -524,6 +524,7 @@ struct powerpc_bus_dmamap { /* * PUBLIC MEMBERS: these are used by machine-independent code. */ + bus_size_t dm_mapsize; /* size of the mapping */ int dm_nsegs; /* # valid segments in mapping */ bus_dma_segment_t dm_segs[1]; /* segments; variable length */ }; diff --git a/sys/arch/macppc/macppc/dma.c b/sys/arch/macppc/macppc/dma.c index 0258f412bbf..c7b1b7198f6 100644 --- a/sys/arch/macppc/macppc/dma.c +++ b/sys/arch/macppc/macppc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.3 2001/09/19 20:50:57 mickey Exp $ */ +/* $OpenBSD: dma.c,v 1.4 2001/11/05 17:25:58 art Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -104,6 +104,7 @@ _dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp) map->_dm_boundary = boundary; map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT); map->dm_nsegs = 0; /* no valid mappings */ + map->dm_mapsize = 0; *dmamp = map; return (0); @@ -140,11 +141,13 @@ _dmamap_load(t, map, buf, buflen, p, flags) caddr_t vaddr = buf; int first, seg; pmap_t pmap; + bus_size_t saved_buflen; /* * Make sure that on error condition we return "no valid mappings". */ map->dm_nsegs = 0; + map->dm_mapsize = 0; if (buflen > map->_dm_size) return (EINVAL); @@ -157,6 +160,7 @@ _dmamap_load(t, map, buf, buflen, p, flags) lastaddr = ~0; /* XXX gcc */ bmask = ~(map->_dm_boundary - 1); + saved_buflen = buflen; for (first = 1, seg = 0; buflen > 0; ) { /* * Get the physical address for this segment. @@ -215,6 +219,7 @@ _dmamap_load(t, map, buf, buflen, p, flags) return (EFBIG); /* XXX better return value here? */ map->dm_nsegs = seg + 1; + map->dm_mapsize = saved_buflen; return (0); } @@ -280,6 +285,7 @@ _dmamap_load_raw(t, map, segs, nsegs, size, flags) bcopy(segs, map->dm_segs, nsegs * sizeof(*segs)); map->dm_nsegs = nsegs; + map->dm_mapsize = size; return (0); } @@ -298,6 +304,7 @@ _dmamap_unload(t, map) * invalid. */ map->dm_nsegs = 0; + map->dm_mapsize = 0; } /* @@ -305,10 +312,12 @@ _dmamap_unload(t, map) * by bus-specific DMA map synchronization functions. */ void -_dmamap_sync(t, map, op) +_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; { /* Nothing to do here. */ diff --git a/sys/arch/mvmeppc/include/bus_mi.h b/sys/arch/mvmeppc/include/bus_mi.h index 9ce8209835b..a2cc5b80ba3 100644 --- a/sys/arch/mvmeppc/include/bus_mi.h +++ b/sys/arch/mvmeppc/include/bus_mi.h @@ -1,5 +1,5 @@ /* $NetBSD: bus.h,v 1.1 2001/06/06 17:37:37 matt Exp $ */ -/* $OpenBSD: bus_mi.h,v 1.2 2001/09/23 01:42:38 miod Exp $ */ +/* $OpenBSD: bus_mi.h,v 1.3 2001/11/05 17:25:58 art Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -977,15 +977,10 @@ bus_space_copy_region_4(t, h1, o1, h2, o2, c) struct mbuf; struct uio; -/* - * Operations performed by bus_dmamap_sync(). - */ -typedef enum { - BUS_DMASYNC_PREREAD = 0x01, /* pre-read synchronization */ - BUS_DMASYNC_POSTREAD = 0x02, /* post-read synchronization */ - BUS_DMASYNC_PREWRITE = 0x04, /* pre-write synchronization */ - BUS_DMASYNC_POSTWRITE = 0x08 /* post-write synchronization */ -} 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 powerpc_bus_dma_tag *bus_dma_tag_t; typedef struct powerpc_bus_dmamap *bus_dmamap_t; @@ -1035,7 +1030,8 @@ struct powerpc_bus_dma_tag { int (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t, 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)); + void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t, + bus_addr_t, bus_size_t, int)); /* * DMA memory utility functions. @@ -1065,9 +1061,9 @@ struct powerpc_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, a, l, o) \ (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0) + (*(t)->_dmamap_sync)((t), (p), (a), (l), (o)) : (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)) @@ -1119,7 +1115,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/mvmeppc/mvmeppc/bus_dma.c b/sys/arch/mvmeppc/mvmeppc/bus_dma.c index c00ab320083..eef88567b78 100644 --- a/sys/arch/mvmeppc/mvmeppc/bus_dma.c +++ b/sys/arch/mvmeppc/mvmeppc/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.5 2001/09/19 20:50:57 mickey Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.6 2001/11/05 17:25:58 art Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -405,10 +405,12 @@ _bus_dmamap_unload(t, map) */ void -_bus_dmamap_sync(t, map, op) +_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; { int i; switch (op) { @@ -418,7 +420,7 @@ _bus_dmamap_sync(t, map, op) case BUS_DMASYNC_PREREAD: for (i = map->dm_nsegs; i--; ) invdcache(map->dm_segs[i].ds_addr, - map->dm_segs[i].ds_len); + len); break; } } |