summaryrefslogtreecommitdiff
path: root/sys/arch/mvmeppc
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-05-08 20:12:24 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-05-08 20:12:24 +0000
commitd39f5688dbcd9ee3d5547b7cbd6da0ba431ee37c (patch)
treeb853b68f11a39f6c68ebcc8a66f71f34c5fa9203 /sys/arch/mvmeppc
parenta9f14e51617a32cddd6a506b7d932871f34654d4 (diff)
Better bus_dmamap_load() implementation which does not use vtophys(),
from macppc. Also properly handle BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE in bus_dmamap_sync().
Diffstat (limited to 'sys/arch/mvmeppc')
-rw-r--r--sys/arch/mvmeppc/mvmeppc/bus_dma.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sys/arch/mvmeppc/mvmeppc/bus_dma.c b/sys/arch/mvmeppc/mvmeppc/bus_dma.c
index 5f4d75355df..01418675113 100644
--- a/sys/arch/mvmeppc/mvmeppc/bus_dma.c
+++ b/sys/arch/mvmeppc/mvmeppc/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.13 2004/01/29 20:26:48 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.14 2004/05/08 20:12:23 miod Exp $ */
/* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */
/*-
@@ -147,6 +147,12 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
bus_addr_t curaddr, lastaddr, baddr, bmask;
vaddr_t vaddr = (vaddr_t)buf;
int seg;
+ pmap_t pmap;
+
+ if (p != NULL)
+ pmap = p->p_vmspace->vm_map.pmap;
+ else
+ pmap = pmap_kernel();
lastaddr = *lastaddrp;
bmask = ~(map->_dm_boundary - 1);
@@ -155,11 +161,10 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first)
/*
* Get the physical address for this segment.
*/
- if (p != NULL)
- (void) pmap_extract(p->p_vmspace->vm_map.pmap,
- vaddr, (paddr_t *)&curaddr);
- else
- curaddr = vtophys(vaddr);
+ if (pmap_extract(pmap, vaddr, (paddr_t *)&curaddr) == FALSE) {
+ panic("dmamap_load_buffer pmap %p vaddr %lx "
+ "pmap_extract failed", pmap, vaddr);
+ }
/*
* If we're beyond the bounce threshold, notify
@@ -415,16 +420,14 @@ _bus_dmamap_sync(t, map, offset, len, op)
int op;
{
int i;
- switch (op) {
- case BUS_DMASYNC_POSTREAD:
- case BUS_DMASYNC_POSTWRITE:
- case BUS_DMASYNC_PREWRITE:
- case BUS_DMASYNC_PREREAD:
- for (i = map->dm_nsegs; i--; )
- invdcache((void *)PCI_MEM_TO_PHYS(map->dm_segs[i].ds_addr),
- len);
- break;
- }
+
+ /* XXX and if it's not a PCI device??? */
+ if ((op & (BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE)) == 0)
+ return;
+
+ for (i = map->dm_nsegs; i--; )
+ invdcache((void *)PCI_MEM_TO_PHYS(map->dm_segs[i].ds_addr),
+ len);
}
/*