diff options
author | Martin Reindl <martin@cvs.openbsd.org> | 2006-03-20 01:00:59 +0000 |
---|---|---|
committer | Martin Reindl <martin@cvs.openbsd.org> | 2006-03-20 01:00:59 +0000 |
commit | 10c3543afc957b694b05960e2373daf5f4ee710c (patch) | |
tree | f6f71c1b85806ec21dda3923487d9ddf62712db4 /sys/arch/alpha/dev | |
parent | 47d1b7910df488e3f366bcf35740d01d2e08323c (diff) |
factorize SGMAP-mapped DMA map creation and destroy code
ok miod@, additional testing jsg@
from NetBSD
Diffstat (limited to 'sys/arch/alpha/dev')
-rw-r--r-- | sys/arch/alpha/dev/sgmap_common.c | 47 | ||||
-rw-r--r-- | sys/arch/alpha/dev/sgmapvar.h | 6 |
2 files changed, 51 insertions, 2 deletions
diff --git a/sys/arch/alpha/dev/sgmap_common.c b/sys/arch/alpha/dev/sgmap_common.c index 53cc0a4881f..f650f889795 100644 --- a/sys/arch/alpha/dev/sgmap_common.c +++ b/sys/arch/alpha/dev/sgmap_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmap_common.c,v 1.6 2003/10/18 20:14:41 jmc Exp $ */ +/* $OpenBSD: sgmap_common.c,v 1.7 2006/03/20 01:00:58 martin Exp $ */ /* $NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $ */ /*- @@ -38,6 +38,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#define _ALPHA_BUS_DMA_PRIVATE + #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -228,3 +230,46 @@ alpha_sgmap_free(map, sgmap) map->_dm_flags &= ~DMAMAP_HAS_SGMAP; } + +int +alpha_sgmap_dmamap_create(t, size, nsegments, maxsegsz, boundary, + flags, dmamp) + bus_dma_tag_t t; + bus_size_t size; + int nsegments; + bus_size_t maxsegsz; + bus_size_t boundary; + int flags; + bus_dmamap_t *dmamp; +{ + bus_dmamap_t map; + int error; + + error = _bus_dmamap_create(t, size, nsegments, maxsegsz, + boundary, flags, dmamp); + if (error) + return (error); + + map = *dmamp; + + if (flags & BUS_DMA_ALLOCNOW) { + error = alpha_sgmap_alloc(map, round_page(size), + t->_sgmap, flags); + if (error) + alpha_sgmap_dmamap_destroy(t, map); +} + + return (error); +} + +void +alpha_sgmap_dmamap_destroy(t, map) + bus_dma_tag_t t; + bus_dmamap_t map; +{ + + if (map->_dm_flags & DMAMAP_HAS_SGMAP) + alpha_sgmap_free(map, t->_sgmap); + + _bus_dmamap_destroy(t, map); +} diff --git a/sys/arch/alpha/dev/sgmapvar.h b/sys/arch/alpha/dev/sgmapvar.h index c8c150fd5ac..402aaaacb34 100644 --- a/sys/arch/alpha/dev/sgmapvar.h +++ b/sys/arch/alpha/dev/sgmapvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmapvar.h,v 1.2 2002/03/14 01:26:26 millert Exp $ */ +/* $OpenBSD: sgmapvar.h,v 1.3 2006/03/20 01:00:58 martin Exp $ */ /* $NetBSD: sgmapvar.h,v 1.10 1998/08/14 16:50:02 thorpej Exp $ */ /*- @@ -93,4 +93,8 @@ int alpha_sgmap_alloc(bus_dmamap_t, bus_size_t, struct alpha_sgmap *, int); void alpha_sgmap_free(bus_dmamap_t, struct alpha_sgmap *); +int alpha_sgmap_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, + bus_size_t, int, bus_dmamap_t *); +void alpha_sgmap_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); + #endif /* _ALPHA_COMMON_SGMAPVAR_H */ |