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/sgmap_common.c | |
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/sgmap_common.c')
-rw-r--r-- | sys/arch/alpha/dev/sgmap_common.c | 47 |
1 files changed, 46 insertions, 1 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); +} |