diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2005-07-09 22:51:14 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2005-07-09 22:51:14 +0000 |
commit | a3e24ae25c49bd2c55b3271114cc95c11eee1146 (patch) | |
tree | ad7b9bd3ac78eb731a1fc584f4fb6f77243429c5 | |
parent | 19253c52801186cb965c463644848be350c06075 (diff) |
Implement _bus_dmamem_mmap instead of just calling panic();
This is needed by bktr(4).
ok mickey@ miod@
-rw-r--r-- | sys/arch/sparc64/include/param.h | 7 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/machdep.c | 25 |
2 files changed, 28 insertions, 4 deletions
diff --git a/sys/arch/sparc64/include/param.h b/sys/arch/sparc64/include/param.h index f77b3241f2e..22b105e1833 100644 --- a/sys/arch/sparc64/include/param.h +++ b/sys/arch/sparc64/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.14 2004/08/06 22:31:31 mickey Exp $ */ +/* $OpenBSD: param.h,v 1.15 2005/07/09 22:51:13 robert Exp $ */ /* $NetBSD: param.h,v 1.25 2001/05/30 12:28:51 mrg Exp $ */ /* @@ -215,6 +215,11 @@ extern int nbpg, pgofset, pgshift; #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE)) /* + * Mach derived conversion macros + */ +#define sparc64_btop(x) ((unsigned long)(x) >> PGSHIFT) + +/* * dvmamap manages a range of DVMA addresses intended to create double * mappings of physical memory. In a way, `dvmamap' is a submap of the * VM map `phys_map'. The difference is the use of the `resource map' diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index b4b34288760..8b9261bed53 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.75 2005/03/29 19:34:07 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.76 2005/07/09 22:51:13 robert Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1621,10 +1621,29 @@ _bus_dmamem_mmap(t, t0, segs, nsegs, off, prot, flags) off_t off; int prot, flags; { + int i; - panic("_bus_dmamem_mmap: not implemented"); -} + for (i = 0; i < nsegs; i++) { +#ifdef DIAGNOSTIC + if (off & PGOFSET) + panic("_bus_dmamem_mmap: offset unaligned"); + if (segs[i].ds_addr & PGOFSET) + panic("_bus_dmamem_mmap: segment unaligned"); + if (segs[i].ds_len & PGOFSET) + panic("_bus_dmamem_mmap: segment size not multiple" + " of page size"); +#endif + if (off >= segs[i].ds_len) { + off -= segs[i].ds_len; + continue; + } + + return (sparc64_btop((caddr_t)segs[i].ds_addr + off)); + } + /* Page not found. */ + return (-1); +} struct sparc_bus_dma_tag mainbus_dma_tag = { NULL, |