summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-06-07 02:30:35 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-06-07 02:30:35 +0000
commitaf1d7788f946103f1f71ffcbc3b4887428e05017 (patch)
tree8a050ff66ccb3c77f42288c9e4933844e7281982 /sys
parente84e71fddd573dcb11f739875f38e8d36d9582cb (diff)
on amd64, store a pointer to the loaded data and the type. This will
eventually be needed by bouncebuffers, and I need it for some of my evil graphics shitz. ok kettenis@ with some tweaks
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/bus_dma.c16
-rw-r--r--sys/arch/amd64/amd64/sg_dma.c30
-rw-r--r--sys/arch/amd64/include/bus.h14
3 files changed, 51 insertions, 9 deletions
diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c
index d1e427547f2..5a5c4de055b 100644
--- a/sys/arch/amd64/amd64/bus_dma.c
+++ b/sys/arch/amd64/amd64/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.27 2009/04/21 17:05:29 oga Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.28 2009/06/07 02:30:34 oga Exp $ */
/* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
@@ -155,8 +155,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
map->_dm_maxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
- map->dm_mapsize = 0; /* no valid mappings */
- map->dm_nsegs = 0;
*dmamp = map;
return (0);
@@ -199,6 +197,9 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
if (error == 0) {
map->dm_mapsize = buflen;
map->dm_nsegs = seg + 1;
+ map->_dm_origbuf = buf;
+ map->_dm_buftype = BUS_BUFTYPE_LINEAR;
+ map->_dm_proc = p;
}
return (error);
}
@@ -241,6 +242,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
if (error == 0) {
map->dm_mapsize = m0->m_pkthdr.len;
map->dm_nsegs = seg + 1;
+ map->_dm_origbuf = m0;
+ map->_dm_buftype = BUS_BUFTYPE_MBUF;
}
return (error);
}
@@ -296,6 +299,8 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
if (error == 0) {
map->dm_mapsize = uio->uio_resid;
map->dm_nsegs = seg + 1;
+ map->_dm_origbuf = uio;
+ map->_dm_buftype = BUS_BUFTYPE_UIO;
}
return (error);
}
@@ -380,6 +385,8 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
map->dm_mapsize = mapsize;
map->dm_nsegs = seg + 1;
+ map->_dm_origbuf = segs;
+ map->_dm_buftype = BUS_BUFTYPE_RAW;
return (0);
}
@@ -397,6 +404,9 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
+ map->_dm_buftype = BUS_BUFTYPE_INVALID;
+ map->_dm_origbuf = NULL;
+ map->_dm_proc = NULL;
}
/*
diff --git a/sys/arch/amd64/amd64/sg_dma.c b/sys/arch/amd64/amd64/sg_dma.c
index a32a32cea64..c726660bd0a 100644
--- a/sys/arch/amd64/amd64/sg_dma.c
+++ b/sys/arch/amd64/amd64/sg_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sg_dma.c,v 1.3 2009/06/06 05:26:28 oga Exp $ */
+/* $OpenBSD: sg_dma.c,v 1.4 2009/06/07 02:30:34 oga Exp $ */
/*
* Copyright (c) 2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -338,6 +338,10 @@ sg_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
spm->spm_start = 0;
spm->spm_size = 0;
mtx_leave(&is->sg_mtx);
+ } else {
+ map->_dm_origbuf = buf;
+ map->_dm_buftype = BUS_BUFTYPE_LINEAR;
+ map->_dm_proc = p;
}
return (err);
@@ -357,7 +361,7 @@ sg_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *mb,
*/
bus_dma_segment_t segs[MAX_DMA_SEGS];
size_t len;
- int i;
+ int i, err;
/*
* Make sure that on error condition we return "no valid mappings".
@@ -407,7 +411,13 @@ sg_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *mb,
}
}
- return (sg_dmamap_load_raw(t, map, segs, i, (bus_size_t)len, flags));
+ err = sg_dmamap_load_raw(t, map, segs, i, (bus_size_t)len, flags);
+
+ if (err == 0) {
+ map->_dm_origbuf = mb;
+ map->_dm_buftype = BUS_BUFTYPE_MBUF;
+ }
+ return (err);
}
/*
@@ -424,7 +434,7 @@ sg_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
*/
bus_dma_segment_t segs[MAX_DMA_SEGS];
size_t len;
- int i, j;
+ int i, j, err;
/*
* Make sure that on errror we return "no valid mappings".
@@ -475,7 +485,13 @@ sg_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
}
- return (sg_dmamap_load_raw(t, map, segs, i, (bus_size_t)len, flags));
+ err = sg_dmamap_load_raw(t, map, segs, i, (bus_size_t)len, flags);
+
+ if (err == 0) {
+ map->_dm_origbuf = uio;
+ map->_dm_buftype = BUS_BUFTYPE_UIO;
+ }
+ return (err);
}
/*
@@ -587,6 +603,10 @@ sg_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
spm->spm_start = 0;
spm->spm_size = 0;
mtx_leave(&is->sg_mtx);
+ } else {
+ /* This will be overwritten if mbuf or uio called us */
+ map->_dm_origbuf = segs;
+ map->_dm_buftype = BUS_BUFTYPE_RAW;
}
return (err);
diff --git a/sys/arch/amd64/include/bus.h b/sys/arch/amd64/include/bus.h
index d043ffd717e..382e722378a 100644
--- a/sys/arch/amd64/include/bus.h
+++ b/sys/arch/amd64/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.18 2009/05/10 15:04:48 oga Exp $ */
+/* $OpenBSD: bus.h,v 1.19 2009/06/07 02:30:34 oga Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -451,6 +451,13 @@ void bus_space_barrier(bus_space_tag_t, bus_space_handle_t,
#define BUS_DMA_ZERO 0x1000 /* zero memory in dmamem_alloc */
#define BUS_DMA_SG 0x2000 /* Internal. memory is for SG map */
+/* types for _dm_buftype */
+#define BUS_BUFTYPE_INVALID 0
+#define BUS_BUFTYPE_LINEAR 1
+#define BUS_BUFTYPE_MBUF 2
+#define BUS_BUFTYPE_UIO 3
+#define BUS_BUFTYPE_RAW 4
+
/* Forwards needed by prototypes below. */
struct mbuf;
struct proc;
@@ -572,6 +579,11 @@ struct bus_dmamap {
bus_size_t _dm_boundary; /* don't cross this */
int _dm_flags; /* misc. flags */
+ void *_dm_origbuf; /* pointer to original data */
+ int _dm_buftype; /* type of data */
+ /* XXX do we REALLY need the proc stuff */
+ struct proc *_dm_proc; /* proc that owns the mapping */
+
void *_dm_cookie; /* cookie for bus-specific functions */
/*