From a3e24ae25c49bd2c55b3271114cc95c11eee1146 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 9 Jul 2005 22:51:14 +0000 Subject: Implement _bus_dmamem_mmap instead of just calling panic(); This is needed by bktr(4). ok mickey@ miod@ --- sys/arch/sparc64/include/param.h | 7 ++++++- 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 $ */ /* @@ -214,6 +214,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 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, -- cgit v1.2.3