Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API

to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create).  dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
This commit is contained in:
matt 2005-03-09 19:04:43 +00:00
parent 0b156a5946
commit a6db24a485
55 changed files with 317 additions and 169 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.11 2005/03/09 04:23:33 simonb Exp $ */
/* $NetBSD: bus_dma.c,v 1.12 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.11 2005/03/09 04:23:33 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.12 2005/03/09 19:04:43 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -92,10 +92,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct algor_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -164,8 +165,8 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map,
sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
if (buflen < sgsize)
sgsize = buflen;
if (map->_dm_maxsegsz < sgsize)
sgsize = map->_dm_maxsegsz;
if (map->dm_maxsegsz < sgsize)
sgsize = map->dm_maxsegsz;
/*
* Make sure we don't cross any boundaries.
@ -188,7 +189,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -242,6 +243,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -283,6 +285,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -329,6 +332,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -390,6 +394,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~ALGOR_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.8 2003/06/15 23:08:54 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.9 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -627,7 +627,7 @@ struct algor_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -640,6 +640,7 @@ struct algor_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.56 2005/03/09 04:23:33 simonb Exp $ */
/* $NetBSD: bus_dma.c,v 1.57 2005/03/09 19:04:43 matt 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: bus_dma.c,v 1.56 2005/03/09 04:23:33 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.57 2005/03/09 19:04:43 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -95,12 +95,13 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct alpha_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
if (t->_boundary != 0 && t->_boundary < boundary)
map->_dm_boundary = t->_boundary;
else
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
map->_dm_window = NULL;
@ -164,8 +165,8 @@ _bus_dmamap_load_buffer_direct(bus_dma_tag_t t, bus_dmamap_t map,
sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
if (buflen < sgsize)
sgsize = buflen;
if (map->_dm_maxsegsz < sgsize)
sgsize = map->_dm_maxsegsz;
if (map->dm_maxsegsz < sgsize)
sgsize = map->dm_maxsegsz;
/*
* Make sure we don't cross any boundaries.
@ -188,7 +189,7 @@ _bus_dmamap_load_buffer_direct(bus_dma_tag_t t, bus_dmamap_t map,
if ((map->_dm_flags & DMAMAP_NO_COALESCE) == 0 &&
curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -241,6 +242,7 @@ _bus_dmamap_load_direct(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -278,6 +280,7 @@ _bus_dmamap_load_mbuf_direct(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -367,6 +370,7 @@ _bus_dmamap_load_uio_direct(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -433,6 +437,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_window = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.49 2003/06/15 23:08:54 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.50 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -699,7 +699,7 @@ struct alpha_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -716,6 +716,7 @@ struct alpha_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.22 2005/01/22 11:08:18 tsutsui Exp $ */
/* $NetBSD: bus_dma.c,v 1.23 2005/03/09 19:04:43 matt Exp $ */
/* NetBSD: bus_dma.c,v 1.20 2000/01/10 03:24:36 simonb Exp */
/*-
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.22 2005/01/22 11:08:18 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.23 2005/03/09 19:04:43 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -116,10 +116,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct arc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -197,7 +198,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg]._ds_paddr & bmask) ==
(curaddr & bmask)))
@ -246,6 +247,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return EINVAL;
@ -287,6 +289,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -333,6 +336,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -393,6 +397,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~ARC_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.17 2005/01/22 07:35:34 tsutsui Exp $ */
/* $NetBSD: bus.h,v 1.18 2005/03/09 19:04:43 matt Exp $ */
/* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */
/* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
@ -810,7 +810,7 @@ struct arc_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -823,6 +823,7 @@ struct arc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma_jazz.c,v 1.10 2005/01/22 07:35:34 tsutsui Exp $ */
/* $NetBSD: bus_dma_jazz.c,v 1.11 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (C) 2003 Izumi Tsutsui.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma_jazz.c,v 1.10 2005/01/22 07:35:34 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma_jazz.c,v 1.11 2005/03/09 19:04:43 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -186,7 +186,7 @@ jazz_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
int npte;
tlbmap = (jazz_tlbmap_t)map->_dm_cookie;
npte = jazz_dma_page_round(map->_dm_maxsegsz) /
npte = jazz_dma_page_round(map->dm_maxsegsz) /
JAZZ_DMA_PAGE_SIZE + 1;
jazz_dmatlb_free(tlbmap->vaddr, npte);
free(tlbmap, M_DMAMAP);

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.42 2005/01/02 22:47:26 chris Exp $ */
/* $NetBSD: bus_dma.c,v 1.43 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.42 2005/01/02 22:47:26 chris Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.43 2005/03/09 19:04:43 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -138,7 +138,7 @@ _bus_dmamap_load_paddr(bus_dma_tag_t t, bus_dmamap_t map,
* previous segment if possible.
*/
if (nseg > 0 && curaddr == lastaddr &&
segs[nseg-1].ds_len + sgsize <= map->_dm_maxsegsz &&
segs[nseg-1].ds_len + sgsize <= map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(segs[nseg-1].ds_addr & bmask) == (curaddr & bmask))) {
/* coalesce */
@ -202,12 +202,13 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct arm32_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_origbuf = NULL;
map->_dm_buftype = ARM32_BUFTYPE_INVALID;
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -233,6 +234,7 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
/*
* Explicit unload.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_origbuf = NULL;
@ -262,6 +264,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -302,6 +305,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -413,6 +417,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.13 2003/11/09 05:29:59 tsutsui Exp $ */
/* $NetBSD: bus.h,v 1.14 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -913,7 +913,7 @@ struct arm32_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -926,6 +926,7 @@ struct arm32_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.31 2003/11/10 08:51:51 wiz Exp $ */
/* $NetBSD: bus.h,v 1.32 2005/03/09 19:04:43 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -661,7 +661,7 @@ struct atari_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */
int _dm_flags; /* misc. flags */
@ -671,6 +671,7 @@ struct atari_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.c,v 1.19 2004/11/28 17:34:45 thorpej Exp $ */
/* $NetBSD: bus.c,v 1.20 2005/03/09 19:04:44 matt Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.19 2004/11/28 17:34:45 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.20 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -178,10 +178,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct cobalt_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -267,7 +268,7 @@ _bus_dmamap_load_buffer(map, buf, buflen, p, flags,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -319,6 +320,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return EINVAL;
@ -363,6 +365,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -412,6 +415,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -479,6 +483,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~COBALT_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.10 2003/06/15 23:08:58 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.11 2005/03/09 19:04:44 matt Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -599,7 +599,7 @@ struct cobalt_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns this mapping */
@ -607,6 +607,7 @@ struct cobalt_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: gapspci_dma.c,v 1.9 2005/02/19 15:37:35 tsutsui Exp $ */
/* $NetBSD: gapspci_dma.c,v 1.10 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: gapspci_dma.c,v 1.9 2005/02/19 15:37:35 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: gapspci_dma.c,v 1.10 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -170,9 +170,10 @@ gaps_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map->_dm_size = size;
map->_dm_segcnt = 1;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
if (flags & BUS_DMA_ALLOCNOW) {
u_long res;
@ -230,6 +231,7 @@ gaps_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *addr,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
}
/* XXX Don't support DMA to process space right now. */
@ -273,6 +275,7 @@ gaps_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
}
#ifdef DIAGNOSTIC
@ -335,6 +338,7 @@ gaps_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
map->dm_segs[0].ds_addr,
map->dm_mapsize, EX_NOWAIT);
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.9 2005/02/19 15:43:13 tsutsui Exp $ */
/* $NetBSD: bus.h,v 1.10 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -577,7 +577,7 @@ struct dreamcast_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -589,6 +589,7 @@ struct dreamcast_bus_dmamap {
int dm_nsegs; /* # valid segments in mapping */
bus_dma_segment_t dm_segs[1]; /* segments; variable length */
bus_size_t dm_mapsize; /* size of the mapping */
bus_size_t dm_maxsegsz; /* largest possible segment */
};
#endif /* _DREAMCAST_BUS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.6 2004/11/28 17:34:45 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.7 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.6 2004/11/28 17:34:45 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.7 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -92,10 +92,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct ibm4xx_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_bounce_thresh = t->_bounce_thresh;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -178,7 +179,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -224,6 +225,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -254,6 +256,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -299,6 +302,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -358,6 +362,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.6 2004/07/27 22:16:40 jkunz Exp $ */
/* $NetBSD: bus.h,v 1.7 2005/03/09 19:04:44 matt Exp $ */
/* $OpenBSD: bus.h,v 1.13 2001/07/30 14:15:59 art Exp $ */
@ -435,7 +435,7 @@ struct hppa_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -444,6 +444,7 @@ struct hppa_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.22 2004/11/28 17:34:45 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.23 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.22 2004/11/28 17:34:45 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.23 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -113,9 +113,10 @@ _hpcmips_bd_map_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct bus_dmamap_hpcmips *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->bdm.dm_maxsegsz = maxsegsz;
map->bdm.dm_mapsize = 0; /* no valid mappings */
map->bdm.dm_nsegs = 0;
map->bdm.dm_segs = (bus_dma_segment_t *)((char *)mapstore +
@ -194,7 +195,7 @@ _hpcmips_bd_map_load_buffer(bus_dmamap_t mapx, void *buf, bus_size_t buflen,
} else {
if (curaddr == lastaddr &&
(map->bdm.dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->bdm.dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->bdm.dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -242,6 +243,7 @@ _hpcmips_bd_map_load(bus_dma_tag_t t, bus_dmamap_t mapx, void *buf,
*/
map->bdm.dm_mapsize = 0;
map->bdm.dm_nsegs = 0;
KASSERT(map->bdm.dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -283,6 +285,7 @@ _hpcmips_bd_map_load_mbuf(bus_dma_tag_t t, bus_dmamap_t mapx, struct mbuf *m0,
*/
map->bdm.dm_mapsize = 0;
map->bdm.dm_nsegs = 0;
KASSERT(map->bdm.dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -329,6 +332,7 @@ _hpcmips_bd_map_load_uio(bus_dma_tag_t t, bus_dmamap_t mapx, struct uio *uio,
*/
map->bdm.dm_mapsize = 0;
map->bdm.dm_nsegs = 0;
KASSERT(map->bdm.dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -389,6 +393,7 @@ _hpcmips_bd_map_unload(bus_dma_tag_t t, bus_dmamap_t mapx)
* No resources to free; just mark the mappings as
* invalid.
*/
map->bdm.dm_maxsegsz = map->_dm_maxmaxsegsz;
map->bdm.dm_mapsize = 0;
map->bdm.dm_nsegs = 0;
map->_dm_flags &= ~HPCMIPS_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.17 2003/06/15 23:08:59 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.18 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -1087,6 +1087,7 @@ struct bus_dma_segment {
* Describes a DMA mapping.
*/
struct bus_dmamap {
bus_size_t dm_maxsegsz; /* largest possible segment */
bus_size_t dm_mapsize; /* size of the mapping */
int dm_nsegs; /* # valid segments in mapping */
bus_dma_segment_t *dm_segs; /* segments; variable length */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma_hpcmips.h,v 1.2 2002/01/06 12:39:55 takemura Exp $ */
/* $NetBSD: bus_dma_hpcmips.h,v 1.3 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 2001 TAKEMRUA Shin. All rights reserved.
@ -64,7 +64,7 @@ struct bus_dmamap_hpcmips {
struct bus_dmamap bdm;
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz;/* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct bus_dma_segment_hpcmips _dm_segs[1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.9 2003/06/15 23:09:00 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.10 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@ -727,7 +727,7 @@ struct hpcsh_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -740,6 +740,7 @@ struct hpcsh_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.h,v 1.4 2004/08/28 21:31:07 thorpej Exp $ */
/* $NetBSD: bus_dma.h,v 1.5 2005/03/09 19:04:44 matt Exp $ */
/*
* This file was extracted from from alpha/include/bus.h
@ -210,7 +210,7 @@ struct m68k_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -220,6 +220,7 @@ struct m68k_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.12 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:44 matt Exp $ */
/*
* This file was taken from from alpha/common/bus_dma.c
@ -46,7 +46,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.12 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -108,12 +108,13 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct m68k_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
if (t->_boundary != 0 && t->_boundary < boundary)
map->_dm_boundary = t->_boundary;
else
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -200,7 +201,7 @@ _bus_dmamap_load_buffer_direct_common(t, map, buf, buflen, p, flags,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -258,6 +259,7 @@ _bus_dmamap_load_direct(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -291,6 +293,7 @@ _bus_dmamap_load_mbuf_direct(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -339,6 +342,7 @@ _bus_dmamap_load_uio_direct(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -404,7 +408,7 @@ _bus_dmamap_load_raw_direct(t, map, segs, nsegs, size, flags)
int i;
for (i=0;i<nsegs;i++) {
#ifdef DIAGNOSTIC
if (map->_dm_maxsegsz < map->dm_segs[i].ds_len) {
if (map->dm_maxsegsz < map->dm_segs[i].ds_len) {
panic("_bus_dmamap_load_raw_direct: segment too large for map");
}
#endif
@ -432,6 +436,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.16 2003/06/15 23:09:01 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.17 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -883,7 +883,7 @@ struct macppc_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */
int _dm_flags; /* misc. flags */
@ -893,6 +893,7 @@ struct macppc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.29 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.30 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.29 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.30 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -97,10 +97,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct macppc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_bounce_thresh = t->_bounce_thresh;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -192,7 +193,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -243,6 +244,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -276,6 +278,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -324,6 +327,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -390,6 +394,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.h,v 1.3 2003/01/28 01:08:02 kent Exp $ */
/* $NetBSD: bus_dma.h,v 1.4 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -207,7 +207,7 @@ struct mips_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -220,6 +220,7 @@ struct mips_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.12 2005/03/09 04:23:33 simonb Exp $ */
/* $NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.12 2005/03/09 04:23:33 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -92,10 +92,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -165,8 +166,8 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map,
sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
if (buflen < sgsize)
sgsize = buflen;
if (map->_dm_maxsegsz < sgsize)
sgsize = map->_dm_maxsegsz;
if (map->dm_maxsegsz < sgsize)
sgsize = map->dm_maxsegsz;
/*
* Make sure we don't cross any boundaries.
@ -189,7 +190,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -243,6 +244,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -284,6 +286,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -330,6 +333,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -390,6 +394,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~MIPS_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.11 2003/06/15 23:09:02 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.12 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -905,7 +905,7 @@ struct mipsco_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -917,6 +917,7 @@ struct mipsco_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.14 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.15 2005/03/09 19:04:44 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.14 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.15 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -122,9 +122,10 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct mipsco_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -211,7 +212,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg]._ds_paddr & bmask) ==
(curaddr & bmask)))
@ -265,6 +266,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -308,6 +310,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -356,6 +359,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -421,6 +425,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~MIPSCO_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.h,v 1.11 2003/01/28 01:08:03 kent Exp $ */
/* $NetBSD: bus_dma.h,v 1.12 2005/03/09 19:04:44 matt Exp $ */
/*
* This file was extracted from from next68k/include/bus.h
@ -209,7 +209,7 @@ struct mvme68k_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
void *_dm_cookie; /* Bus-specific cookie */
@ -217,6 +217,7 @@ struct mvme68k_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.26 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.27 2005/03/09 19:04:44 matt Exp $ */
/*
* This file was taken from from next68k/dev/bus_dma.c, which was originally
@ -46,7 +46,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.26 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.27 2005/03/09 19:04:44 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -111,9 +111,10 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct mvme68k_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -210,7 +211,7 @@ _bus_dmamap_load_buffer_direct_common(t, map, buf, buflen, p, flags,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -273,6 +274,7 @@ _bus_dmamap_load_direct(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -306,6 +308,7 @@ _bus_dmamap_load_mbuf_direct(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -354,6 +357,7 @@ _bus_dmamap_load_uio_direct(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -419,7 +423,7 @@ _bus_dmamap_load_raw_direct(t, map, segs, nsegs, size, flags)
int i;
for (i=0;i<nsegs;i++) {
#ifdef DIAGNOSTIC
if (map->_dm_maxsegsz < map->dm_segs[i].ds_len) {
if (map->dm_maxsegsz < map->dm_segs[i].ds_len) {
panic("_bus_dmamap_load_raw_direct: segment too large for map");
}
#endif
@ -447,6 +451,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~BUS_DMA_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.10 2005/02/06 02:36:01 tsutsui Exp $ */
/* $NetBSD: bus.h,v 1.11 2005/03/09 19:04:44 matt Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -609,7 +609,7 @@ struct newsmips_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
int _dm_maptbl; /* DMA mapping table index */
@ -619,6 +619,7 @@ struct newsmips_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.c,v 1.18 2005/02/06 02:18:02 tsutsui Exp $ */
/* $NetBSD: bus.c,v 1.19 2005/03/09 19:04:45 matt Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.18 2005/02/06 02:18:02 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.19 2005/03/09 19:04:45 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -170,10 +170,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct newsmips_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -250,7 +251,7 @@ _bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -297,6 +298,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return EINVAL;
@ -338,6 +340,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -384,6 +387,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -443,6 +447,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~NEWSMIPS_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.6 2003/10/24 05:01:09 matt Exp $ */
/* $NetBSD: bus.h,v 1.7 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -627,7 +627,7 @@ struct powerpc_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
bus_addr_t _dm_bounce_thresh;/*bounce threshold; see tag */
int _dm_flags; /* misc. flags */
@ -640,6 +640,7 @@ struct powerpc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.5 2003/06/15 23:09:03 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.6 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@ -854,13 +854,14 @@ struct playstation2_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.9 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.10 2005/03/09 19:04:45 matt Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.9 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.10 2005/03/09 19:04:45 matt Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -108,9 +108,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct playstation2_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -186,7 +187,7 @@ _bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -233,6 +234,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return EINVAL;
@ -273,6 +275,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -318,6 +321,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -377,6 +381,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~PLAYSTATION2_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.19 2003/06/15 23:09:04 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.20 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -612,7 +612,7 @@ struct pmax_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -620,6 +620,7 @@ struct pmax_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.40 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.41 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.40 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.41 2005/03/09 19:04:45 matt Exp $");
#include "opt_cputype.h"
@ -132,10 +132,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct pmax_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->_dm_proc = NULL;
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -220,7 +221,7 @@ _bus_dmamap_load_buffer(map, buf, buflen, p, flags,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -272,6 +273,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -316,6 +318,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -365,6 +368,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -432,6 +436,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~PMAX_DMAMAP_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.13 2003/09/03 13:30:05 simonb Exp $ */
/* $NetBSD: bus.h,v 1.14 2005/03/09 19:04:45 matt Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
/*-
@ -773,7 +773,7 @@ struct powerpc_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */
int _dm_flags; /* misc. flags */
@ -783,6 +783,7 @@ struct powerpc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.6 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.7 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.6 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.7 2005/03/09 19:04:45 matt Exp $");
#define DEBUG 1
@ -175,10 +175,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct powerpc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_bounce_thresh = t->_bounce_thresh;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -274,7 +275,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
(vaddr == map->dm_segs[seg].ds_vaddr +
(curaddr - map->dm_segs[seg].ds_addr)) &&
((map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz) &&
map->dm_maxsegsz) &&
((map->_dm_boundary == 0) ||
((map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))) {
@ -332,6 +333,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -365,6 +367,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -413,6 +416,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -478,6 +482,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.20 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.21 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.20 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.21 2005/03/09 19:04:45 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -121,10 +121,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct powerpc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_bounce_thresh = t->_bounce_thresh;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -195,7 +196,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
if (buflen < sgsize)
sgsize = buflen;
sgsize = min(sgsize, map->_dm_maxsegsz);
sgsize = min(sgsize, map->dm_maxsegsz);
/*
* Make sure we don't cross any boundaries.
@ -217,7 +218,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -269,6 +270,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -302,6 +304,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -378,6 +381,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -445,6 +449,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.13 2004/01/13 12:57:24 sekiya Exp $ */
/* $NetBSD: bus.h,v 1.14 2005/03/09 19:04:45 matt Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -606,7 +606,7 @@ struct sgimips_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
struct proc *_dm_proc; /* proc that owns the mapping */
@ -614,6 +614,7 @@ struct sgimips_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.6 2003/06/15 23:09:05 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.7 2005/03/09 19:04:45 matt Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -1009,7 +1009,7 @@ struct sh5_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
void *_dm_cookie; /* Bus-specific cookie */
@ -1017,6 +1017,7 @@ struct sh5_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.12 2004/09/16 03:57:11 rumble Exp $ */
/* $NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:45 matt 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: bus_dma.c,v 1.12 2004/09/16 03:57:11 rumble Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.13 2005/03/09 19:04:45 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -138,9 +138,10 @@ _bus_dmamap_create(void *cookie, bus_size_t size, int nsegments,
map = (struct sh5_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -230,7 +231,7 @@ _bus_dmamap_load_buffer_direct_common(void *cookie, bus_dmamap_t map,
if (curaddr == lastaddr &&
map->dm_segs[seg]._ds_flags == cacheable &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))
@ -295,6 +296,7 @@ _bus_dmamap_load_direct(void *cookie, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -330,6 +332,7 @@ _bus_dmamap_load_mbuf_direct(void *cookie, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -377,6 +380,7 @@ _bus_dmamap_load_uio_direct(void *cookie, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -442,7 +446,7 @@ _bus_dmamap_load_raw_direct(void *cookie, bus_dmamap_t map,
if (segs[i].ds_len == 0)
continue;
#ifdef DIAGNOSTIC
if (map->_dm_maxsegsz < map->dm_segs[i].ds_len)
if (map->dm_maxsegsz < map->dm_segs[i].ds_len)
panic("_bus_dmamap_load_raw_direct: segment too large for map");
#endif
map->dm_segs[j++] = segs[i];
@ -467,6 +471,7 @@ _bus_dmamap_unload(void *cookie, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
map->_dm_flags &= ~BUS_DMA_COHERENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.44 2004/11/15 10:18:58 martin Exp $ */
/* $NetBSD: bus.h,v 1.45 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -1691,7 +1691,7 @@ struct sparc_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -1707,6 +1707,7 @@ struct sparc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.252 2005/01/30 16:56:26 chs Exp $ */
/* $NetBSD: machdep.c,v 1.253 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252 2005/01/30 16:56:26 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.253 2005/03/09 19:04:45 matt Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_sunos.h"
@ -1544,10 +1544,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct sparc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_align = PAGE_SIZE;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -2019,6 +2020,8 @@ sun4_dmamap_unload(t, map)
bus_size_t len;
int i, s, error;
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
if ((flags & _BUS_DMA_DIRECTMAP) != 0) {
/* Nothing to release */
map->dm_mapsize = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.48 2004/06/30 21:16:39 pk Exp $ */
/* $NetBSD: bus.h,v 1.49 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -1669,7 +1669,7 @@ struct sparc_bus_dmamap {
bus_size_t _dm_dvmasize; /* DVMA segment for this map. */
bus_size_t _dm_size; /* largest DMA transfer mappable */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_segcnt; /* number of segs this map can map */
int _dm_flags; /* misc. flags */
@ -1685,6 +1685,7 @@ struct sparc_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.178 2005/03/04 22:04:51 scw Exp $ */
/* $NetBSD: machdep.c,v 1.179 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.178 2005/03/04 22:04:51 scw Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.179 2005/03/09 19:04:45 matt Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -985,10 +985,11 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct sparc_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT|BUS_DMA_COHERENT|
BUS_DMA_NOWRITE|BUS_DMA_NOCACHE);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -1038,6 +1039,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
* Make sure that on error condition we return "no valid mappings".
*/
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
{
@ -1073,7 +1075,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
if (map->dm_segs[i].ds_len == 0)
map->dm_segs[i].ds_addr = pa;
if (pa == (map->dm_segs[i].ds_addr + map->dm_segs[i].ds_len)
&& ((map->dm_segs[i].ds_len + incr) <= map->_dm_maxsegsz)) {
&& ((map->dm_segs[i].ds_len + incr) <= map->dm_maxsegsz)) {
/* Hey, waddyaknow, they're contiguous */
map->dm_segs[i].ds_len += incr;
incr = PAGE_SIZE;
@ -1103,6 +1105,8 @@ _bus_dmamap_load_mbuf(t, map, m, flags)
int i;
size_t len;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
/* Record mbuf for *_unload */
map->_dm_type = _DM_TYPE_MBUF;
map->_dm_source = (void *)m;
@ -1137,7 +1141,7 @@ _bus_dmamap_load_mbuf(t, map, m, flags)
if (i > 0 &&
pa == (segs[i-1].ds_addr + segs[i-1].ds_len) &&
((segs[i-1].ds_len + incr) <=
map->_dm_maxsegsz)) {
map->dm_maxsegsz)) {
/* Hey, waddyaknow, they're contiguous */
segs[i-1].ds_len += incr;
continue;
@ -1217,6 +1221,8 @@ _bus_dmamap_load_uio(t, map, uio, flags)
struct proc *p = uio->uio_procp;
struct pmap *pm;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (uio->uio_segflg == UIO_USERSPACE) {
pm = p->p_vmspace->vm_map.pmap;
} else
@ -1254,7 +1260,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
if (i > 0 && pa == (segs[i-1].ds_addr + segs[i-1].ds_len)
&& ((segs[i-1].ds_len + incr) <= map->_dm_maxsegsz)) {
&& ((segs[i-1].ds_len + incr) <= map->dm_maxsegsz)) {
/* Hey, waddyaknow, they're contiguous */
segs[i-1].ds_len += incr;
continue;
@ -1333,6 +1339,7 @@ _bus_dmamap_unload(t, map)
}
/* Mark the mappings as invalid. */
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.7 2005/01/22 15:36:11 chs Exp $ */
/* $NetBSD: bus.h,v 1.8 2005/03/09 19:04:45 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -931,7 +931,7 @@ struct sun68k_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -947,6 +947,7 @@ struct sun68k_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.c,v 1.12 2005/01/22 15:36:12 chs Exp $ */
/* $NetBSD: bus.c,v 1.13 2005/03/09 19:04:46 matt Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -160,7 +160,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.12 2005/01/22 15:36:12 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.13 2005/03/09 19:04:46 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -214,10 +214,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct sun68k_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_align = PAGE_SIZE;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.22 2003/06/15 23:09:07 fvdl Exp $ */
/* $NetBSD: bus.h,v 1.23 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -1040,7 +1040,7 @@ struct vax_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
@ -1056,6 +1056,7 @@ struct vax_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.21 2004/11/28 17:34:46 thorpej Exp $ */
/* $NetBSD: bus_dma.c,v 1.22 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.21 2004/11/28 17:34:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.22 2005/03/09 19:04:46 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -118,9 +118,10 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map = (struct vax_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -177,6 +178,7 @@ _bus_dmamap_load(t, map, buf, buflen, p, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return (EINVAL);
@ -218,6 +220,7 @@ _bus_dmamap_load_mbuf(t, map, m0, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -269,6 +272,7 @@ _bus_dmamap_load_uio(t, map, uio, flags)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -340,6 +344,7 @@ _bus_dmamap_unload(t, map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}
@ -626,7 +631,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.12 2005/01/18 07:12:16 chs Exp $ */
/* $NetBSD: bus.h,v 1.13 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -824,7 +824,7 @@ struct x68k_bus_dmamap {
*/
bus_size_t x68k_dm_size; /* largest DMA transfer mappable */
int x68k_dm_segcnt; /* number of segs this map can map */
bus_size_t x68k_dm_maxsegsz; /* largest possible segment */
bus_size_t x68k_dm_maxmaxsegsz; /* fixed largest possible segment*/
bus_size_t x68k_dm_boundary; /* don't cross this */
bus_addr_t x68k_dm_bounce_thresh; /* bounce threshold */
int x68k_dm_flags; /* misc. flags */
@ -834,6 +834,7 @@ struct x68k_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.c,v 1.25 2005/01/18 07:12:16 chs Exp $ */
/* $NetBSD: bus.c,v 1.26 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.25 2005/01/18 07:12:16 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.26 2005/03/09 19:04:46 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -114,10 +114,11 @@ x68k_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct x68k_bus_dmamap *)mapstore;
map->x68k_dm_size = size;
map->x68k_dm_segcnt = nsegments;
map->x68k_dm_maxsegsz = maxsegsz;
map->x68k_dm_maxmaxsegsz = maxsegsz;
map->x68k_dm_boundary = boundary;
map->x68k_dm_bounce_thresh = t->_bounce_thresh;
map->x68k_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -152,6 +153,7 @@ x68k_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->x68k_dm_maxmaxsegsz);
if (buflen > map->x68k_dm_size)
return (EINVAL);
@ -182,6 +184,7 @@ x68k_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->x68k_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -228,6 +231,7 @@ x68k_bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->x68k_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -291,6 +295,7 @@ x68k_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
* No resources to free; just mark the mappings as
* invalid.
*/
map->dm_maxsegsz = map->x68k_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}
@ -595,7 +600,7 @@ x68k_bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
} else {
if (curaddr == lastaddr &&
(map->dm_segs[seg].ds_len + sgsize) <=
map->x68k_dm_maxsegsz &&
map->dm_maxsegsz &&
(map->x68k_dm_boundary == 0 ||
(map->dm_segs[seg].ds_addr & bmask) ==
(curaddr & bmask)))

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.7 2004/06/20 18:04:08 thorpej Exp $ */
/* $NetBSD: bus.h,v 1.8 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@ -1159,7 +1159,7 @@ struct x86_bus_dmamap {
*/
bus_size_t _dm_size; /* largest DMA transfer mappable */
int _dm_segcnt; /* number of segs this map can map */
bus_size_t _dm_maxsegsz; /* largest possible segment */
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
bus_size_t _dm_boundary; /* don't cross this */
bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */
int _dm_flags; /* misc. flags */
@ -1169,6 +1169,7 @@ struct x86_bus_dmamap {
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/
bus_size_t dm_maxsegsz; /* largest possible segment */
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma.c,v 1.18 2005/02/19 21:40:21 jdolecek Exp $ */
/* $NetBSD: bus_dma.c,v 1.19 2005/03/09 19:04:46 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.18 2005/02/19 21:40:21 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.19 2005/03/09 19:04:46 matt Exp $");
/*
* The following is included because _bus_dma_uiomove is derived from
@ -176,10 +176,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map = (struct x86_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_maxmaxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_bounce_thresh = t->_bounce_thresh;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_maxsegsz = maxsegsz;
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;
@ -262,6 +263,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
if (buflen > map->_dm_size)
return EINVAL;
@ -342,7 +344,7 @@ again:
* previous segment if possible.
*/
if (nseg > 0 && paddr == lastaddr &&
segs[nseg-1].ds_len + sgsize <= map->_dm_maxsegsz &&
segs[nseg-1].ds_len + sgsize <= map->dm_maxsegsz &&
(map->_dm_boundary == 0 ||
(segs[nseg-1].ds_addr & bmask) == (paddr & bmask))) {
/* coalesce */
@ -385,6 +387,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
#ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@ -523,6 +526,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
resid = uio->uio_resid;
iov = uio->uio_iov;
@ -617,6 +621,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
cookie->id_flags &= ~X86_DMA_IS_BOUNCING;
cookie->id_buftype = X86_DMA_BUFTYPE_INVALID;
}
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
map->dm_mapsize = 0;
map->dm_nsegs = 0;
}