The code that creates/destroys SGMAP DMA maps is the same; put it

in a common place and share it.
This commit is contained in:
thorpej 2001-01-03 19:15:59 +00:00
parent 1d25215235
commit db36913c87
9 changed files with 80 additions and 401 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $ */
/* $NetBSD: sgmap_common.c,v 1.14 2001/01/03 19:15:59 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.14 2001/01/03 19:15:59 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $"
#include <uvm/uvm_extern.h>
#define _ALPHA_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <alpha/common/sgmapvar.h>
@ -225,3 +226,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);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sgmapvar.h,v 1.10 1998/08/14 16:50:02 thorpej Exp $ */
/* $NetBSD: sgmapvar.h,v 1.11 2001/01/03 19:15:59 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -92,4 +92,8 @@ int alpha_sgmap_alloc __P((bus_dmamap_t, bus_size_t,
struct alpha_sgmap *, int));
void alpha_sgmap_free __P((bus_dmamap_t, struct alpha_sgmap *));
int alpha_sgmap_dmamap_create __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void alpha_sgmap_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
#endif /* _ALPHA_COMMON_SGMAPVAR_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: apecs_dma.c,v 1.13 2000/06/29 08:58:45 mrg Exp $ */
/* $NetBSD: apecs_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: apecs_dma.c,v 1.13 2000/06/29 08:58:45 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: apecs_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -59,11 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: apecs_dma.c,v 1.13 2000/06/29 08:58:45 mrg Exp $");
bus_dma_tag_t apecs_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int apecs_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void apecs_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int apecs_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -144,8 +139,8 @@ apecs_dma_init(acp)
t->_boundary = 0;
t->_sgmap = &acp->ac_sgmap;
t->_get_tag = apecs_dma_get_tag;
t->_dmamap_create = apecs_bus_dmamap_create_sgmap;
t->_dmamap_destroy = apecs_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = apecs_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = apecs_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = apecs_bus_dmamap_load_uio_sgmap;
@ -235,55 +230,6 @@ apecs_dma_get_tag(t, bustype)
}
}
/*
* Create an APECS SGMAP-mapped DMA map.
*/
int
apecs_bus_dmamap_create_sgmap(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)
apecs_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy an APECS SGMAP-mapped DMA map.
*/
void
apecs_bus_dmamap_destroy_sgmap(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);
}
/*
* Load an APECS SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: cia_dma.c,v 1.16 2000/06/29 08:58:46 mrg Exp $ */
/* $NetBSD: cia_dma.c,v 1.17 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.16 2000/06/29 08:58:46 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.17 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -62,11 +62,6 @@ bus_dma_tag_t cia_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int cia_bus_dmamap_create_direct __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
int cia_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void cia_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int cia_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -148,8 +143,8 @@ cia_dma_init(ccp)
t->_boundary = 0;
t->_sgmap = &ccp->cc_sgmap;
t->_get_tag = cia_dma_get_tag;
t->_dmamap_create = cia_bus_dmamap_create_sgmap;
t->_dmamap_destroy = cia_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = cia_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = cia_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = cia_bus_dmamap_load_uio_sgmap;
@ -332,55 +327,6 @@ cia_bus_dmamap_create_direct(t, size, nsegments, maxsegsz, boundary,
return (0);
}
/*
* Create a CIA SGMAP-mapped DMA map.
*/
int
cia_bus_dmamap_create_sgmap(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)
cia_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy a CIA SGMAP-mapped DMA map.
*/
void
cia_bus_dmamap_destroy_sgmap(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);
}
/*
* Load a CIA SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: dwlpx_dma.c,v 1.14 2000/06/29 08:58:46 mrg Exp $ */
/* $NetBSD: dwlpx_dma.c,v 1.15 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,v 1.14 2000/06/29 08:58:46 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,v 1.15 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -63,11 +63,6 @@ __KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,v 1.14 2000/06/29 08:58:46 mrg Exp $");
bus_dma_tag_t dwlpx_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int dwlpx_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void dwlpx_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int dwlpx_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -163,8 +158,8 @@ dwlpx_dma_init(ccp)
t->_boundary = 0;
t->_sgmap = &ccp->cc_sgmap;
t->_get_tag = dwlpx_dma_get_tag;
t->_dmamap_create = dwlpx_bus_dmamap_create_sgmap;
t->_dmamap_destroy = dwlpx_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = dwlpx_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = dwlpx_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = dwlpx_bus_dmamap_load_uio_sgmap;
@ -300,55 +295,6 @@ dwlpx_dma_get_tag(t, bustype)
}
}
/*
* Create a DWLPx SGMAP-mapped DMA map.
*/
int
dwlpx_bus_dmamap_create_sgmap(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)
dwlpx_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy a DWLPx SGMAP-mapped DMA map.
*/
void
dwlpx_bus_dmamap_destroy_sgmap(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);
}
/*
* Load a DWLPx SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: lca_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $ */
/* $NetBSD: lca_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: lca_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: lca_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -59,11 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: lca_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $");
bus_dma_tag_t lca_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int lca_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void lca_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int lca_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -143,8 +138,8 @@ lca_dma_init(lcp)
t->_boundary = 0;
t->_sgmap = &lcp->lc_sgmap;
t->_get_tag = lca_dma_get_tag;
t->_dmamap_create = lca_bus_dmamap_create_sgmap;
t->_dmamap_destroy = lca_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = lca_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = lca_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = lca_bus_dmamap_load_uio_sgmap;
@ -238,55 +233,6 @@ lca_dma_get_tag(t, bustype)
}
}
/*
* Create an LCA SGMAP-mapped DMA map.
*/
int
lca_bus_dmamap_create_sgmap(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)
lca_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy an LCA SGMAP-mapped DMA map.
*/
void
lca_bus_dmamap_destroy_sgmap(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);
}
/*
* Load an LCA SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcpcia_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $ */
/* $NetBSD: mcpcia_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mcpcia_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: mcpcia_dma.c,v 1.14 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -60,11 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: mcpcia_dma.c,v 1.13 2000/06/29 08:58:47 mrg Exp $");
bus_dma_tag_t mcpcia_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int mcpcia_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void mcpcia_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int mcpcia_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -147,8 +142,8 @@ mcpcia_dma_init(ccp)
t->_boundary = 0;
t->_sgmap = &ccp->cc_pci_sgmap;
t->_get_tag = mcpcia_dma_get_tag;
t->_dmamap_create = mcpcia_bus_dmamap_create_sgmap;
t->_dmamap_destroy = mcpcia_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = mcpcia_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = mcpcia_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = mcpcia_bus_dmamap_load_uio_sgmap;
@ -173,8 +168,8 @@ mcpcia_dma_init(ccp)
t->_boundary = 0;
t->_sgmap = &ccp->cc_isa_sgmap;
t->_get_tag = mcpcia_dma_get_tag;
t->_dmamap_create = mcpcia_bus_dmamap_create_sgmap;
t->_dmamap_destroy = mcpcia_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = mcpcia_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = mcpcia_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = mcpcia_bus_dmamap_load_uio_sgmap;
@ -293,55 +288,6 @@ mcpcia_dma_get_tag(t, bustype)
}
}
/*
* Create a MCPCIA SGMAP-mapped DMA map.
*/
int
mcpcia_bus_dmamap_create_sgmap(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)
mcpcia_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy a MCPCIA SGMAP-mapped DMA map.
*/
void
mcpcia_bus_dmamap_destroy_sgmap(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);
}
/*
* Load a MCPCIA SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: tsp_dma.c,v 1.2 2000/06/29 08:58:50 mrg Exp $ */
/* $NetBSD: tsp_dma.c,v 1.3 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1999 by Ross Harvey. All rights reserved.
@ -92,11 +92,6 @@
bus_dma_tag_t tsp_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int tsp_bus_dmamap_create_sgmap __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void tsp_bus_dmamap_destroy_sgmap __P((bus_dma_tag_t, bus_dmamap_t));
int tsp_bus_dmamap_load_sgmap __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
@ -182,8 +177,8 @@ tsp_dma_init(pcp)
t->_boundary = 0;
t->_sgmap = &pcp->pc_sgmap;
t->_get_tag = tsp_dma_get_tag;
t->_dmamap_create = tsp_bus_dmamap_create_sgmap;
t->_dmamap_destroy = tsp_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = tsp_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = tsp_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = tsp_bus_dmamap_load_uio_sgmap;
@ -271,55 +266,6 @@ tsp_dma_get_tag(t, bustype)
}
}
/*
* Create a TSP SGMAP-mapped DMA map.
*/
int
tsp_bus_dmamap_create_sgmap(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)
tsp_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy a TSP SGMAP-mapped DMA map.
*/
void
tsp_bus_dmamap_destroy_sgmap(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);
}
/*
* Load a TSP SGMAP-mapped DMA map with a linear buffer.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: ttwoga_dma.c,v 1.1 2000/12/21 20:51:55 thorpej Exp $ */
/* $NetBSD: ttwoga_dma.c,v 1.2 2001/01/03 19:16:00 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ttwoga_dma.c,v 1.1 2000/12/21 20:51:55 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ttwoga_dma.c,v 1.2 2001/01/03 19:16:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -58,11 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: ttwoga_dma.c,v 1.1 2000/12/21 20:51:55 thorpej Exp $
bus_dma_tag_t ttwoga_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
int ttwoga_bus_dmamap_create_sgmap(bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *);
void ttwoga_bus_dmamap_destroy_sgmap(bus_dma_tag_t, bus_dmamap_t);
int ttwoga_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int);
@ -148,8 +143,8 @@ ttwoga_dma_init(struct ttwoga_config *tcp)
t->_boundary = 0;
t->_sgmap = &tcp->tc_sgmap;
t->_get_tag = ttwoga_dma_get_tag;
t->_dmamap_create = ttwoga_bus_dmamap_create_sgmap;
t->_dmamap_destroy = ttwoga_bus_dmamap_destroy_sgmap;
t->_dmamap_create = alpha_sgmap_dmamap_create;
t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
t->_dmamap_load = ttwoga_bus_dmamap_load_sgmap;
t->_dmamap_load_mbuf = ttwoga_bus_dmamap_load_mbuf_sgmap;
t->_dmamap_load_uio = ttwoga_bus_dmamap_load_uio_sgmap;
@ -283,46 +278,6 @@ ttwoga_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
}
}
/*
* Create a T2 SGMAP-mapped DMA map.
*/
int
ttwoga_bus_dmamap_create_sgmap(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)
ttwoga_bus_dmamap_destroy_sgmap(t, map);
}
return (error);
}
/*
* Destroy a T2 SGMAP-mapped DMA map.
*/
void
ttwoga_bus_dmamap_destroy_sgmap(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);
}
/*
* Load a T2 SGMAP-mapped DMA map with a liner buffer.
*/