summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-07-18 20:03:52 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-07-18 20:03:52 +0000
commitb007e14e7536bea466ad35993456b451c6bff196 (patch)
tree718761e2b703db9c27a727711e3e4ffe8fa82212 /sys
parent412985aa577b78a0e750c2e3dfbad1eb58a2410b (diff)
bus_dmamem_map() maps with a single segment in directly-translated XKPHYS
space, either cache coherent for regular mappings and uncached for BUS_DMA_COHERENT mappings, as done on all other platforms with direct mappings.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mips64/include/cpu.h13
-rw-r--r--sys/arch/sgi/sgi/bus_dma.c41
2 files changed, 36 insertions, 18 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index 4b4b42c046a..7fbcc814a9f 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.19 2007/06/18 20:25:53 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.20 2007/07/18 20:03:50 miod Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -80,6 +80,7 @@
#define XKPHYS_TO_PHYS(x) ((paddr_t)(x) & 0x0000000fffffffffUL)
#define PHYS_TO_XKPHYS(x,c) ((paddr_t)(x) | XKPHYS_BASE | (c) << 59)
#define IS_XKPHYS(va) (((va) >> 62) == 2)
+#define XKPHYS_TO_CCA(x) (((x) >> 59) & 0x07)
#endif
#ifdef _KERNEL
@@ -519,14 +520,14 @@ extern u_int32_t cpu_counter_last; /* Last compare value loaded */
* Low level access routines to CPU registers
*/
-void setsoftintr0(void);
-void clearsoftintr0(void);
-void setsoftintr1(void);
-void clearsoftintr1(void);
+void setsoftintr0(void);
+void clearsoftintr0(void);
+void setsoftintr1(void);
+void clearsoftintr1(void);
u_int32_t enableintr(void);
u_int32_t disableintr(void);
u_int32_t updateimask(intrmask_t);
-void setsr(u_int32_t);
+void setsr(u_int32_t);
u_int32_t getsr(void);
#endif /* _KERNEL */
diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c
index 0a0fd0faca6..243713314d5 100644
--- a/sys/arch/sgi/sgi/bus_dma.c
+++ b/sys/arch/sgi/sgi/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.1 2007/06/21 20:17:10 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.2 2007/07/18 20:03:51 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -371,7 +371,7 @@ _dmamap_sync(t, map, addr, size, op)
ssize = map->dm_segs[curseg].ds_len;
vaddr = map->dm_segs[curseg].ds_vaddr;
- if (addr > 0) {
+ if (addr != 0) {
if (addr >= ssize) {
addr -= ssize;
ssize = 0;
@@ -381,11 +381,15 @@ _dmamap_sync(t, map, addr, size, op)
addr = 0;
}
}
- if (ssize > size) {
+ if (ssize > size)
ssize = size;
+
+ if (IS_XKPHYS(vaddr) && XKPHYS_TO_CCA(vaddr) == CCA_NC) {
+ size -= ssize;
+ ssize = 0;
}
- if (ssize) {
+ if (ssize != 0) {
#ifdef DEBUG_BUSDMASYNC_FRAG
printf(" syncing %p:%p ", vaddr, ssize);
if (op & BUS_DMASYNC_PREWRITE) printf("PRW ");
@@ -483,9 +487,20 @@ _dmamem_map(t, segs, nsegs, size, kvap, flags)
int flags;
{
vaddr_t va;
+ paddr_t pa;
bus_addr_t addr;
int curseg;
+ if (nsegs == 1) {
+ if (flags & BUS_DMA_COHERENT)
+ *kvap = (caddr_t)PHYS_TO_XKPHYS(segs[0].ds_addr,
+ CCA_NC);
+ else
+ *kvap = (caddr_t)PHYS_TO_XKPHYS(segs[0].ds_addr,
+ CCA_NONCOHERENT);
+ return (0);
+ }
+
size = round_page(size);
va = uvm_km_valloc(kernel_map, size);
if (va == 0)
@@ -499,15 +514,18 @@ _dmamem_map(t, segs, nsegs, size, kvap, flags)
addr += NBPG, va += NBPG, size -= NBPG) {
if (size == 0)
panic("_dmamem_map: size botch");
- pmap_enter(pmap_kernel(), va, (*t->_device_to_pa)(addr),
+ pa = (*t->_device_to_pa)(addr);
+ pmap_enter(pmap_kernel(), va, pa,
VM_PROT_READ | VM_PROT_WRITE,
VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
segs[curseg].ds_vaddr = va;
if (flags & BUS_DMA_COHERENT &&
sys_config.system_type == SGI_O2)
- pmap_page_cache(PHYS_TO_VM_PAGE((*t->_device_to_pa)(addr)), PV_UNCACHED);
+ pmap_page_cache(PHYS_TO_VM_PAGE(pa),
+ PV_UNCACHED);
}
+ pmap_update(pmap_kernel());
}
return (0);
@@ -523,18 +541,17 @@ _dmamem_unmap(t, kva, size)
caddr_t kva;
size_t size;
{
-
-#ifdef DIAGNOSTIC
- if ((u_long)kva & PGOFSET)
- panic("_dmamem_unmap");
-#endif
+ if (IS_XKPHYS((vaddr_t)kva))
+ return;
size = round_page(size);
+ pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size);
+ pmap_update(pmap_kernel());
uvm_km_free(kernel_map, (vaddr_t)kva, size);
}
/*
- * Common functin for mmap(2)'ing DMA-safe memory. May be called by
+ * Common function for mmap(2)'ing DMA-safe memory. May be called by
* bus-specific DMA mmap(2)'ing functions.
*/
paddr_t