Module Name: src Committed By: uebayasi Date: Sat Oct 30 08:41:14 UTC 2010
Modified Files: src/share/man/man9 [uebayasi-xip]: pmap.9 src/sys/arch/acorn26/acorn26 [uebayasi-xip]: mem.c pmap.c src/sys/arch/alpha/alpha [uebayasi-xip]: mem.c pmap.c src/sys/arch/amd64/amd64 [uebayasi-xip]: mem.c src/sys/arch/arm/arm32 [uebayasi-xip]: mem.c pmap.c src/sys/arch/arm/conf [uebayasi-xip]: files.arm src/sys/arch/cesfic/cesfic [uebayasi-xip]: mem.c src/sys/arch/hp300/hp300 [uebayasi-xip]: mem.c src/sys/arch/hp700/dev [uebayasi-xip]: mem.c src/sys/arch/hppa/hppa [uebayasi-xip]: pmap.c src/sys/arch/i386/i386 [uebayasi-xip]: mem.c src/sys/arch/luna68k/luna68k [uebayasi-xip]: mem.c src/sys/arch/m68k/m68k [uebayasi-xip]: pmap_motorola.c src/sys/arch/mac68k/mac68k [uebayasi-xip]: mem.c src/sys/arch/mips/conf [uebayasi-xip]: files.mips src/sys/arch/mips/mips [uebayasi-xip]: pmap.c src/sys/arch/mvme68k/mvme68k [uebayasi-xip]: mem.c src/sys/arch/news68k/news68k [uebayasi-xip]: mem.c src/sys/arch/next68k/next68k [uebayasi-xip]: mem.c src/sys/arch/powerpc/ibm4xx [uebayasi-xip]: pmap.c src/sys/arch/powerpc/oea [uebayasi-xip]: pmap.c src/sys/arch/powerpc/powerpc [uebayasi-xip]: mem.c src/sys/arch/sh3/sh3 [uebayasi-xip]: mem.c pmap.c src/sys/arch/sparc64/sparc64 [uebayasi-xip]: pmap.c src/sys/arch/sun2/sun2 [uebayasi-xip]: mem.c pmap.c src/sys/arch/sun3/sun3 [uebayasi-xip]: mem.c pmap.c src/sys/arch/sun3/sun3x [uebayasi-xip]: mem.c pmap.c src/sys/arch/usermode/usermode [uebayasi-xip]: pmap.c src/sys/arch/vax/vax [uebayasi-xip]: mem.c pmap.c src/sys/arch/x68k/x68k [uebayasi-xip]: mem.c src/sys/arch/x86/x86 [uebayasi-xip]: pmap.c src/sys/arch/xen/conf [uebayasi-xip]: files.xen src/sys/uvm [uebayasi-xip]: files.uvm uvm_pmap.h Added Files: src/sys/common/pmap [uebayasi-xip]: pmap_common.c Removed Files: src/sys/arch/arm/arm [uebayasi-xip]: xmd_machdep.c src/sys/arch/mips/mips [uebayasi-xip]: xmd_machdep.c src/sys/arch/powerpc/powerpc [uebayasi-xip]: xmd_machdep.c src/sys/arch/x86/x86 [uebayasi-xip]: xmd_machdep.c Log Message: Implement pmap_physload_device(9) to replace xmd(4) MD backend. Implement pmap_mmap(9) and use it from mem(4) and xmd(4). To generate a diff of this commit: cvs rdiff -u -r1.42.2.1 -r1.42.2.2 src/share/man/man9/pmap.9 cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/arch/acorn26/acorn26/mem.c cvs rdiff -u -r1.30.2.4 -r1.30.2.5 src/sys/arch/acorn26/acorn26/pmap.c cvs rdiff -u -r1.40 -r1.40.2.1 src/sys/arch/alpha/alpha/mem.c cvs rdiff -u -r1.252.2.4 -r1.252.2.5 src/sys/arch/alpha/alpha/pmap.c cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/arch/amd64/amd64/mem.c cvs rdiff -u -r1.1.2.1 -r0 src/sys/arch/arm/arm/xmd_machdep.c cvs rdiff -u -r1.26.6.5 -r1.26.6.6 src/sys/arch/arm/arm32/mem.c cvs rdiff -u -r1.211.2.15 -r1.211.2.16 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.97.2.4 -r1.97.2.5 src/sys/arch/arm/conf/files.arm cvs rdiff -u -r1.13 -r1.13.2.1 src/sys/arch/cesfic/cesfic/mem.c cvs rdiff -u -r1.48 -r1.48.40.1 src/sys/arch/hp300/hp300/mem.c cvs rdiff -u -r1.21.2.2 -r1.21.2.3 src/sys/arch/hp700/dev/mem.c cvs rdiff -u -r1.63.2.7 -r1.63.2.8 src/sys/arch/hppa/hppa/pmap.c cvs rdiff -u -r1.72 -r1.72.2.1 src/sys/arch/i386/i386/mem.c cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/arch/luna68k/luna68k/mem.c cvs rdiff -u -r1.55.2.3 -r1.55.2.4 src/sys/arch/m68k/m68k/pmap_motorola.c cvs rdiff -u -r1.40 -r1.40.4.1 src/sys/arch/mac68k/mac68k/mem.c cvs rdiff -u -r1.64.2.1 -r1.64.2.2 src/sys/arch/mips/conf/files.mips cvs rdiff -u -r1.188.2.4 -r1.188.2.5 src/sys/arch/mips/mips/pmap.c cvs rdiff -u -r1.1.2.1 -r0 src/sys/arch/mips/mips/xmd_machdep.c cvs rdiff -u -r1.27 -r1.27.30.1 src/sys/arch/mvme68k/mvme68k/mem.c cvs rdiff -u -r1.19 -r1.19.64.1 src/sys/arch/news68k/news68k/mem.c cvs rdiff -u -r1.25 -r1.25.64.1 src/sys/arch/next68k/next68k/mem.c cvs rdiff -u -r1.60.2.5 -r1.60.2.6 src/sys/arch/powerpc/ibm4xx/pmap.c cvs rdiff -u -r1.69.2.3 -r1.69.2.4 src/sys/arch/powerpc/oea/pmap.c cvs rdiff -u -r1.29 -r1.29.64.1 src/sys/arch/powerpc/powerpc/mem.c cvs rdiff -u -r1.1.2.2 -r0 src/sys/arch/powerpc/powerpc/xmd_machdep.c cvs rdiff -u -r1.26.64.2 -r1.26.64.3 src/sys/arch/sh3/sh3/mem.c cvs rdiff -u -r1.74.2.3 -r1.74.2.4 src/sys/arch/sh3/sh3/pmap.c cvs rdiff -u -r1.250.2.4 -r1.250.2.5 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.16 -r1.16.62.1 src/sys/arch/sun2/sun2/mem.c cvs rdiff -u -r1.43 -r1.43.2.1 src/sys/arch/sun2/sun2/pmap.c cvs rdiff -u -r1.51.64.1 -r1.51.64.2 src/sys/arch/sun3/sun3/mem.c cvs rdiff -u -r1.164.2.1 -r1.164.2.2 src/sys/arch/sun3/sun3/pmap.c cvs rdiff -u -r1.33.64.1 -r1.33.64.2 src/sys/arch/sun3/sun3x/mem.c cvs rdiff -u -r1.110.2.1 -r1.110.2.2 src/sys/arch/sun3/sun3x/pmap.c cvs rdiff -u -r1.5 -r1.5.2.1 src/sys/arch/usermode/usermode/pmap.c cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/arch/vax/vax/mem.c cvs rdiff -u -r1.175.2.3 -r1.175.2.4 src/sys/arch/vax/vax/pmap.c cvs rdiff -u -r1.36.64.1 -r1.36.64.2 src/sys/arch/x68k/x68k/mem.c cvs rdiff -u -r1.100.2.4 -r1.100.2.5 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.1.2.2 -r0 src/sys/arch/x86/x86/xmd_machdep.c cvs rdiff -u -r1.106.2.2 -r1.106.2.3 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r0 -r1.1.2.1 src/sys/common/pmap/pmap_common.c cvs rdiff -u -r1.16.2.1 -r1.16.2.2 src/sys/uvm/files.uvm cvs rdiff -u -r1.32.2.4 -r1.32.2.5 src/sys/uvm/uvm_pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man9/pmap.9 diff -u src/share/man/man9/pmap.9:1.42.2.1 src/share/man/man9/pmap.9:1.42.2.2 --- src/share/man/man9/pmap.9:1.42.2.1 Tue Aug 17 06:40:05 2010 +++ src/share/man/man9/pmap.9 Sat Oct 30 08:41:14 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: pmap.9,v 1.42.2.1 2010/08/17 06:40:05 uebayasi Exp $ +.\" $NetBSD: pmap.9,v 1.42.2.2 2010/10/30 08:41:14 uebayasi Exp $ .\" .\" Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd November 4, 2009 +.Dd October 30, 2010 .Dt PMAP 9 .Os .Sh NAME @@ -69,6 +69,12 @@ .Fn "pmap_protect" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" "vm_prot_t prot" .Ft void .Fn "pmap_unwire" "pmap_t pmap" "vaddr_t va" +.Ft void * +.Fn "pmap_physload_device" "vaddr_t addr" "off_t off" "int prot" "int flags" +.Ft void +.Fn "pmap_unphysload_device" "void *phys" +.Ft paddr_t +.Fn "pmap_mmap" "vaddr_t addr" "off_t off" .Ft bool .Fn "pmap_extract" "pmap_t pmap" "vaddr_t va" "paddr_t *pap" .Ft void @@ -594,6 +600,35 @@ .Dq wired attribute on the mapping for virtual address .Fa va . +.It void * Fn "pmap_physload_device" "vaddr_t addr" "off_t off" \ + "int prot" "int flags" +This function registers a kernel virtual address region of system +memory described by +.Fa addr +and +.Fa off +as a physical device memory segment like a NOR FlashROM, +and return a cookie pointer to the registered segment. +The registered region will be mapped into user address space. +.It void Fn "pmap_physunload_device" "void *phys" +Free a physical segment previously allocated by +.Fn pmap_physload_device 9 . +.It paddr_t Fn "pmap_mmap" "vaddr_t addr" "off_t off" +This function converts a given kernel virtual address described by +.Fa addr +and +.Fa off +to a physical mmap cookie. +This interface is only used by machine-dependent memory devices, +.Xr mem 4 +and +.Xr xmd 4 , +to map part of kernel memory to user address spaces. +.Pp +Note that the +.Fn pmap_mmap +cares only addresses. +Callers are respensible to check protection. .It bool Fn "pmap_extract" "pmap_t pmap" "vaddr_t va" "paddr_t *pap" This function extracts a mapping from the specified physical map. It serves two purposes: to determine if a mapping exists for the specified Index: src/sys/arch/acorn26/acorn26/mem.c diff -u src/sys/arch/acorn26/acorn26/mem.c:1.14 src/sys/arch/acorn26/acorn26/mem.c:1.14.2.1 --- src/sys/arch/acorn26/acorn26/mem.c:1.14 Sat Mar 14 15:35:58 2009 +++ src/sys/arch/acorn26/acorn26/mem.c Sat Oct 30 08:41:05 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.14 2009/03/14 15:35:58 dsl Exp $ */ +/* $NetBSD: mem.c,v 1.14.2.1 2010/10/30 08:41:05 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.14 2009/03/14 15:35:58 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.14.2.1 2010/10/30 08:41:05 uebayasi Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -212,7 +212,9 @@ /* XXX This may botch our cacheing assumptions. Do we care? */ ppn = atop(off); - if (ppn >= 0 && ppn < physmem) - return ppn; - return -1; + KASSERT(ppn >= 0); + if (ppn >= physmem) + return -1; + + return pmap_mmap(0, off); } Index: src/sys/arch/acorn26/acorn26/pmap.c diff -u src/sys/arch/acorn26/acorn26/pmap.c:1.30.2.4 src/sys/arch/acorn26/acorn26/pmap.c:1.30.2.5 --- src/sys/arch/acorn26/acorn26/pmap.c:1.30.2.4 Fri May 28 15:42:17 2010 +++ src/sys/arch/acorn26/acorn26/pmap.c Sat Oct 30 08:41:05 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.30.2.4 2010/05/28 15:42:17 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.30.2.5 2010/10/30 08:41:05 uebayasi Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 Ben Harris * All rights reserved. @@ -102,7 +102,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.30.2.4 2010/05/28 15:42:17 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.30.2.5 2010/10/30 08:41:05 uebayasi Exp $"); #include <sys/kernel.h> /* for cold */ #include <sys/malloc.h> @@ -723,6 +723,13 @@ splx(s); } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return atop(addr + off); +} + bool pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *ppa) { Index: src/sys/arch/alpha/alpha/mem.c diff -u src/sys/arch/alpha/alpha/mem.c:1.40 src/sys/arch/alpha/alpha/mem.c:1.40.2.1 --- src/sys/arch/alpha/alpha/mem.c:1.40 Sat Mar 14 15:35:59 2009 +++ src/sys/arch/alpha/alpha/mem.c Sat Oct 30 08:41:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.40 2009/03/14 15:35:59 dsl Exp $ */ +/* $NetBSD: mem.c,v 1.40.2.1 2010/10/30 08:41:06 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -78,7 +78,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.40 2009/03/14 15:35:59 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.40.2.1 2010/10/30 08:41:06 uebayasi Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -216,5 +216,6 @@ */ if ((prot & alpha_pa_access(off)) != prot) return (-1); - return (alpha_btop(off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/alpha/alpha/pmap.c diff -u src/sys/arch/alpha/alpha/pmap.c:1.252.2.4 src/sys/arch/alpha/alpha/pmap.c:1.252.2.5 --- src/sys/arch/alpha/alpha/pmap.c:1.252.2.4 Wed Jul 7 16:35:24 2010 +++ src/sys/arch/alpha/alpha/pmap.c Sat Oct 30 08:41:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.252.2.4 2010/07/07 16:35:24 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.252.2.5 2010/10/30 08:41:06 uebayasi Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008 The NetBSD Foundation, Inc. @@ -141,7 +141,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.252.2.4 2010/07/07 16:35:24 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.252.2.5 2010/10/30 08:41:06 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -2033,6 +2033,19 @@ } /* + * pmap_mmap [ INTERFACE ] + * + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return alpha_btop(addr + off); +} + +/* * pmap_extract: [ INTERFACE ] * * Extract the physical address associated with the given Index: src/sys/arch/amd64/amd64/mem.c diff -u src/sys/arch/amd64/amd64/mem.c:1.19 src/sys/arch/amd64/amd64/mem.c:1.19.2.1 --- src/sys/arch/amd64/amd64/mem.c:1.19 Sun Mar 29 01:10:28 2009 +++ src/sys/arch/amd64/amd64/mem.c Sat Oct 30 08:41:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.19 2009/03/29 01:10:28 rmind Exp $ */ +/* $NetBSD: mem.c,v 1.19.2.1 2010/10/30 08:41:06 uebayasi Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -106,7 +106,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.19 2009/03/29 01:10:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.19.2.1 2010/10/30 08:41:06 uebayasi Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -260,5 +260,5 @@ if (check_pa_acc(off, prot) != 0) return -1; - return x86_btop(off); + return pmap_mmap(0, off); } Index: src/sys/arch/arm/arm32/mem.c diff -u src/sys/arch/arm/arm32/mem.c:1.26.6.5 src/sys/arch/arm/arm32/mem.c:1.26.6.6 --- src/sys/arch/arm/arm32/mem.c:1.26.6.5 Wed Jul 7 16:35:25 2010 +++ src/sys/arch/arm/arm32/mem.c Sat Oct 30 08:41:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.26.6.5 2010/07/07 16:35:25 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.26.6.6 2010/10/30 08:41:06 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ #include "opt_xip.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26.6.5 2010/07/07 16:35:25 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26.6.6 2010/10/30 08:41:06 uebayasi Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -218,5 +218,6 @@ if (off >= ctob(physmem) && kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL) != 0) return -1; - return arm_btop(off); + + return pmap_mmap(0, off); } Index: src/sys/arch/arm/arm32/pmap.c diff -u src/sys/arch/arm/arm32/pmap.c:1.211.2.15 src/sys/arch/arm/arm32/pmap.c:1.211.2.16 --- src/sys/arch/arm/arm32/pmap.c:1.211.2.15 Tue Aug 17 06:44:02 2010 +++ src/sys/arch/arm/arm32/pmap.c Sat Oct 30 08:41:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.211.2.15 2010/08/17 06:44:02 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.211.2.16 2010/10/30 08:41:06 uebayasi Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. @@ -212,7 +212,7 @@ #include <machine/param.h> #include <arm/arm32/katelib.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.15 2010/08/17 06:44:02 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.16 2010/10/30 08:41:06 uebayasi Exp $"); #ifdef PMAP_DEBUG @@ -3515,6 +3515,13 @@ cpu_cpwait(); } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return arm_btop(vtophys(addr + off)); +} + bool pmap_extract(pmap_t pm, vaddr_t va, paddr_t *pap) { Index: src/sys/arch/arm/conf/files.arm diff -u src/sys/arch/arm/conf/files.arm:1.97.2.4 src/sys/arch/arm/conf/files.arm:1.97.2.5 --- src/sys/arch/arm/conf/files.arm:1.97.2.4 Fri Oct 22 07:21:01 2010 +++ src/sys/arch/arm/conf/files.arm Sat Oct 30 08:41:07 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.arm,v 1.97.2.4 2010/10/22 07:21:01 uebayasi Exp $ +# $NetBSD: files.arm,v 1.97.2.5 2010/10/30 08:41:07 uebayasi Exp $ # temporary define to allow easy moving to ../arch/arm/arm32 defflag ARM32 @@ -188,5 +188,3 @@ file arch/arm/arm/linux_sigcode.S compat_linux file arch/arm/arm/linux_syscall.c compat_linux file arch/arm/arm/linux_trap.c compat_linux - -file arch/arm/arm/xmd_machdep.c xmd Index: src/sys/arch/cesfic/cesfic/mem.c diff -u src/sys/arch/cesfic/cesfic/mem.c:1.13 src/sys/arch/cesfic/cesfic/mem.c:1.13.2.1 --- src/sys/arch/cesfic/cesfic/mem.c:1.13 Sat Mar 14 15:36:04 2009 +++ src/sys/arch/cesfic/cesfic/mem.c Sat Oct 30 08:41:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.13 2009/03/14 15:36:04 dsl Exp $ */ +/* $NetBSD: mem.c,v 1.13.2.1 2010/10/30 08:41:07 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.13 2009/03/14 15:36:04 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.13.2.1 2010/10/30 08:41:07 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -241,5 +241,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return (-1); - return (m68k_btop(off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/hp300/hp300/mem.c diff -u src/sys/arch/hp300/hp300/mem.c:1.48 src/sys/arch/hp300/hp300/mem.c:1.48.40.1 --- src/sys/arch/hp300/hp300/mem.c:1.48 Wed Oct 17 19:54:24 2007 +++ src/sys/arch/hp300/hp300/mem.c Sat Oct 30 08:41:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.48 2007/10/17 19:54:24 garbled Exp $ */ +/* $NetBSD: mem.c,v 1.48.40.1 2010/10/30 08:41:07 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.48 2007/10/17 19:54:24 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.48.40.1 2010/10/30 08:41:07 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -241,5 +241,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return -1; - return m68k_btop((u_int)off); + + return pmap_mmap(0, off); } Index: src/sys/arch/hp700/dev/mem.c diff -u src/sys/arch/hp700/dev/mem.c:1.21.2.2 src/sys/arch/hp700/dev/mem.c:1.21.2.3 --- src/sys/arch/hp700/dev/mem.c:1.21.2.2 Tue Aug 17 06:44:24 2010 +++ src/sys/arch/hp700/dev/mem.c Sat Oct 30 08:41:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.21.2.2 2010/08/17 06:44:24 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.21.2.3 2010/10/30 08:41:07 uebayasi Exp $ */ /* $OpenBSD: mem.c,v 1.30 2007/09/22 16:21:32 krw Exp $ */ /* @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.21.2.2 2010/08/17 06:44:24 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.21.2.3 2010/10/30 08:41:07 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -418,5 +418,5 @@ if (off > ptoa(physmem)) return -1; - return btop(off); + return pmap_mmap(0, off); } Index: src/sys/arch/hppa/hppa/pmap.c diff -u src/sys/arch/hppa/hppa/pmap.c:1.63.2.7 src/sys/arch/hppa/hppa/pmap.c:1.63.2.8 --- src/sys/arch/hppa/hppa/pmap.c:1.63.2.7 Tue Aug 17 06:44:32 2010 +++ src/sys/arch/hppa/hppa/pmap.c Sat Oct 30 08:41:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.63.2.7 2010/08/17 06:44:32 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.63.2.8 2010/10/30 08:41:07 uebayasi Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.63.2.7 2010/08/17 06:44:32 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.63.2.8 2010/10/30 08:41:07 uebayasi Exp $"); #include "opt_xip.h" @@ -1566,6 +1566,18 @@ } /* + * pmap_mmap(addr, off) + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return btop(addr + off); +} + +/* * pmap_extract(pmap, va, pap) * fills in the physical address corresponding to the * virtual address specified by pmap and va into the Index: src/sys/arch/i386/i386/mem.c diff -u src/sys/arch/i386/i386/mem.c:1.72 src/sys/arch/i386/i386/mem.c:1.72.2.1 --- src/sys/arch/i386/i386/mem.c:1.72 Sun Mar 29 01:10:28 2009 +++ src/sys/arch/i386/i386/mem.c Sat Oct 30 08:41:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.72 2009/03/29 01:10:28 rmind Exp $ */ +/* $NetBSD: mem.c,v 1.72.2.1 2010/10/30 08:41:08 uebayasi Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -106,7 +106,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.72 2009/03/29 01:10:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.72.2.1 2010/10/30 08:41:08 uebayasi Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -266,5 +266,5 @@ if (check_pa_acc(off, prot) != 0) return -1; - return x86_btop(off); + return pmap_mmap(0, off); } Index: src/sys/arch/luna68k/luna68k/mem.c diff -u src/sys/arch/luna68k/luna68k/mem.c:1.15 src/sys/arch/luna68k/luna68k/mem.c:1.15.2.1 --- src/sys/arch/luna68k/luna68k/mem.c:1.15 Sat Mar 14 15:36:08 2009 +++ src/sys/arch/luna68k/luna68k/mem.c Sat Oct 30 08:41:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.15 2009/03/14 15:36:08 dsl Exp $ */ +/* $NetBSD: mem.c,v 1.15.2.1 2010/10/30 08:41:08 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -74,7 +74,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.15 2009/03/14 15:36:08 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.15.2.1 2010/10/30 08:41:08 uebayasi Exp $"); /* * Memory special file @@ -232,5 +232,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return (-1); - return (m68k_btop((u_int)off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/m68k/m68k/pmap_motorola.c diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.55.2.3 src/sys/arch/m68k/m68k/pmap_motorola.c:1.55.2.4 --- src/sys/arch/m68k/m68k/pmap_motorola.c:1.55.2.3 Tue Aug 17 06:44:48 2010 +++ src/sys/arch/m68k/m68k/pmap_motorola.c Sat Oct 30 08:41:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_motorola.c,v 1.55.2.3 2010/08/17 06:44:48 uebayasi Exp $ */ +/* $NetBSD: pmap_motorola.c,v 1.55.2.4 2010/10/30 08:41:08 uebayasi Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -119,7 +119,7 @@ #include "opt_m68k_arch.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.55.2.3 2010/08/17 06:44:48 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.55.2.4 2010/10/30 08:41:08 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1658,6 +1658,19 @@ } /* + * pmap_mmap: [ INTERFACE ] + * + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return m68k_btop(addr + (u_int)off); +} + +/* * pmap_extract: [ INTERFACE ] * * Extract the physical address associated with the given Index: src/sys/arch/mac68k/mac68k/mem.c diff -u src/sys/arch/mac68k/mac68k/mem.c:1.40 src/sys/arch/mac68k/mac68k/mem.c:1.40.4.1 --- src/sys/arch/mac68k/mac68k/mem.c:1.40 Fri Dec 19 18:49:38 2008 +++ src/sys/arch/mac68k/mac68k/mem.c Sat Oct 30 08:41:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.40 2008/12/19 18:49:38 cegger Exp $ */ +/* $NetBSD: mem.c,v 1.40.4.1 2010/10/30 08:41:08 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.40 2008/12/19 18:49:38 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.40.4.1 2010/10/30 08:41:08 uebayasi Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -230,5 +230,5 @@ if ((u_int)off >= maxaddr) return (-1); - return (m68k_btop((u_int)off)); + return pmap_mmap(0, off); } Index: src/sys/arch/mips/conf/files.mips diff -u src/sys/arch/mips/conf/files.mips:1.64.2.1 src/sys/arch/mips/conf/files.mips:1.64.2.2 --- src/sys/arch/mips/conf/files.mips:1.64.2.1 Sat Aug 28 18:24:07 2010 +++ src/sys/arch/mips/conf/files.mips Sat Oct 30 08:41:09 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.mips,v 1.64.2.1 2010/08/28 18:24:07 uebayasi Exp $ +# $NetBSD: files.mips,v 1.64.2.2 2010/10/30 08:41:09 uebayasi Exp $ # defflag opt_cputype.h NOFPU @@ -67,8 +67,6 @@ file arch/mips/mips/procfs_machdep.c procfs -file arch/mips/mips/xmd_machdep.c xmd - # Binary compatibility with 32bit NetBSD (COMPAT_NETBSD32) file arch/mips/mips/netbsd32_machdep.c compat_netbsd32 include "compat/netbsd32/files.netbsd32" Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.188.2.4 src/sys/arch/mips/mips/pmap.c:1.188.2.5 --- src/sys/arch/mips/mips/pmap.c:1.188.2.4 Tue Aug 17 06:44:52 2010 +++ src/sys/arch/mips/mips/pmap.c Sat Oct 30 08:41:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.188.2.4 2010/08/17 06:44:52 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.188.2.5 2010/10/30 08:41:09 uebayasi Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.188.2.4 2010/08/17 06:44:52 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.188.2.5 2010/10/30 08:41:09 uebayasi Exp $"); /* * Manages physical address maps. @@ -1544,6 +1544,19 @@ } /* + * Routine: pmap_mmap + * Function: + * Convert the given kernel virtual address to the + * page frame number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return mips_btop(vtophys(addr + off)); +} + +/* * Routine: pmap_extract * Function: * Extract the physical page address associated Index: src/sys/arch/mvme68k/mvme68k/mem.c diff -u src/sys/arch/mvme68k/mvme68k/mem.c:1.27 src/sys/arch/mvme68k/mvme68k/mem.c:1.27.30.1 --- src/sys/arch/mvme68k/mvme68k/mem.c:1.27 Sat Jan 12 09:54:29 2008 +++ src/sys/arch/mvme68k/mvme68k/mem.c Sat Oct 30 08:41:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.27 2008/01/12 09:54:29 tsutsui Exp $ */ +/* $NetBSD: mem.c,v 1.27.30.1 2010/10/30 08:41:09 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.27 2008/01/12 09:54:29 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.27.30.1 2010/10/30 08:41:09 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -235,5 +235,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return (-1); - return m68k_btop((u_int)off); + + return pmap_mmap(0, off); } Index: src/sys/arch/news68k/news68k/mem.c diff -u src/sys/arch/news68k/news68k/mem.c:1.19 src/sys/arch/news68k/news68k/mem.c:1.19.64.1 --- src/sys/arch/news68k/news68k/mem.c:1.19 Sun Mar 4 11:00:01 2007 +++ src/sys/arch/news68k/news68k/mem.c Sat Oct 30 08:41:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.19 2007/03/04 11:00:01 tsutsui Exp $ */ +/* $NetBSD: mem.c,v 1.19.64.1 2010/10/30 08:41:09 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.19 2007/03/04 11:00:01 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.19.64.1 2010/10/30 08:41:09 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -236,5 +236,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return -1; - return m68k_btop((u_int)off); + + return pmap_mmap(0, off); } Index: src/sys/arch/next68k/next68k/mem.c diff -u src/sys/arch/next68k/next68k/mem.c:1.25 src/sys/arch/next68k/next68k/mem.c:1.25.64.1 --- src/sys/arch/next68k/next68k/mem.c:1.25 Mon Mar 5 12:30:38 2007 +++ src/sys/arch/next68k/next68k/mem.c Sat Oct 30 08:41:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.25 2007/03/05 12:30:38 tsutsui Exp $ */ +/* $NetBSD: mem.c,v 1.25.64.1 2010/10/30 08:41:10 uebayasi Exp $ */ /* * This file was taken from mvme68k/mvme68k/mem.c @@ -84,7 +84,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.25 2007/03/05 12:30:38 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.25.64.1 2010/10/30 08:41:10 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -240,5 +240,6 @@ */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return (-1); - return (m68k_btop((u_int)off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/powerpc/ibm4xx/pmap.c diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.60.2.5 src/sys/arch/powerpc/ibm4xx/pmap.c:1.60.2.6 --- src/sys/arch/powerpc/ibm4xx/pmap.c:1.60.2.5 Sat Aug 14 02:09:57 2010 +++ src/sys/arch/powerpc/ibm4xx/pmap.c Sat Oct 30 08:41:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.60.2.5 2010/08/14 02:09:57 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.60.2.6 2010/10/30 08:41:10 uebayasi Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60.2.5 2010/08/14 02:09:57 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60.2.6 2010/10/30 08:41:10 uebayasi Exp $"); #include "opt_xip.h" @@ -1044,6 +1044,17 @@ } /* + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return trunc_page((paddr_t)addr + off); +} + +/* * Get the physical page address for the given pmap/virtual address. */ bool Index: src/sys/arch/powerpc/oea/pmap.c diff -u src/sys/arch/powerpc/oea/pmap.c:1.69.2.3 src/sys/arch/powerpc/oea/pmap.c:1.69.2.4 --- src/sys/arch/powerpc/oea/pmap.c:1.69.2.3 Fri Apr 30 14:39:44 2010 +++ src/sys/arch/powerpc/oea/pmap.c Sat Oct 30 08:41:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.69.2.3 2010/04/30 14:39:44 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.69.2.4 2010/10/30 08:41:10 uebayasi Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. @@ -63,7 +63,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.69.2.3 2010/04/30 14:39:44 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.69.2.4 2010/10/30 08:41:10 uebayasi Exp $"); #define PMAP_NOOPNAMES @@ -2098,6 +2098,18 @@ } /* + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + struct lwp *l = curlwp; + + return trunc_page((paddr_t)addr + off); +} + +/* * Get the physical page address for the given pmap/virtual address. */ bool Index: src/sys/arch/powerpc/powerpc/mem.c diff -u src/sys/arch/powerpc/powerpc/mem.c:1.29 src/sys/arch/powerpc/powerpc/mem.c:1.29.64.1 --- src/sys/arch/powerpc/powerpc/mem.c:1.29 Sun Mar 4 06:00:38 2007 +++ src/sys/arch/powerpc/powerpc/mem.c Sat Oct 30 08:41:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.29 2007/03/04 06:00:38 christos Exp $ */ +/* $NetBSD: mem.c,v 1.29.64.1 2010/10/30 08:41:10 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.29 2007/03/04 06:00:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.29.64.1 2010/10/30 08:41:10 uebayasi Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -169,5 +169,6 @@ if (atop(off) >= physmem && kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL) != 0) return (-1); - return (trunc_page((paddr_t)off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/sh3/sh3/mem.c diff -u src/sys/arch/sh3/sh3/mem.c:1.26.64.2 src/sys/arch/sh3/sh3/mem.c:1.26.64.3 --- src/sys/arch/sh3/sh3/mem.c:1.26.64.2 Thu May 27 14:47:29 2010 +++ src/sys/arch/sh3/sh3/mem.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.26.64.2 2010/05/27 14:47:29 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.26.64.3 2010/10/30 08:41:11 uebayasi Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26.64.2 2010/05/27 14:47:29 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26.64.3 2010/10/30 08:41:11 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -196,7 +196,8 @@ if (!__mm_mem_addr(off) && kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL) != 0) return (-1); - return (sh3_btop((paddr_t)off)); + + return pmap_mmap(0, off); } /* Index: src/sys/arch/sh3/sh3/pmap.c diff -u src/sys/arch/sh3/sh3/pmap.c:1.74.2.3 src/sys/arch/sh3/sh3/pmap.c:1.74.2.4 --- src/sys/arch/sh3/sh3/pmap.c:1.74.2.3 Wed Apr 28 08:31:07 2010 +++ src/sys/arch/sh3/sh3/pmap.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.74.2.3 2010/04/28 08:31:07 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.74.2.4 2010/10/30 08:41:11 uebayasi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74.2.3 2010/04/28 08:31:07 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74.2.4 2010/10/30 08:41:11 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -626,6 +626,13 @@ } } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return sh3_btop((paddr_t)addr + off); +} + bool pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) { Index: src/sys/arch/sparc64/sparc64/pmap.c diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.250.2.4 src/sys/arch/sparc64/sparc64/pmap.c:1.250.2.5 --- src/sys/arch/sparc64/sparc64/pmap.c:1.250.2.4 Tue Aug 17 06:45:20 2010 +++ src/sys/arch/sparc64/sparc64/pmap.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.250.2.4 2010/08/17 06:45:20 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.250.2.5 2010/10/30 08:41:11 uebayasi Exp $ */ /* * * Copyright (C) 1996-1999 Eduardo Horvath. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.250.2.4 2010/08/17 06:45:20 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.250.2.5 2010/10/30 08:41:11 uebayasi Exp $"); #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ #define HWREF @@ -2172,6 +2172,13 @@ mutex_exit(&pmap_lock); } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return -1; +} + /* * Extract the physical page address associated * with the given map/virtual_address pair. Index: src/sys/arch/sun2/sun2/mem.c diff -u src/sys/arch/sun2/sun2/mem.c:1.16 src/sys/arch/sun2/sun2/mem.c:1.16.62.1 --- src/sys/arch/sun2/sun2/mem.c:1.16 Sat Mar 10 22:29:24 2007 +++ src/sys/arch/sun2/sun2/mem.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.16 2007/03/10 22:29:24 thorpej Exp $ */ +/* $NetBSD: mem.c,v 1.16.62.1 2010/10/30 08:41:11 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.16 2007/03/10 22:29:24 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.16.62.1 2010/10/30 08:41:11 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -281,8 +281,8 @@ case DEV_MEM: /* Allow access only in "managed" RAM. */ if (off < avail_start || off >= avail_end) - break; - return (off); + return -1; + return pmap_mmap(0, off); case DEV_VME16D16: if (off & 0xffff0000) Index: src/sys/arch/sun2/sun2/pmap.c diff -u src/sys/arch/sun2/sun2/pmap.c:1.43 src/sys/arch/sun2/sun2/pmap.c:1.43.2.1 --- src/sys/arch/sun2/sun2/pmap.c:1.43 Fri Dec 11 13:56:16 2009 +++ src/sys/arch/sun2/sun2/pmap.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.43 2009/12/11 13:56:16 tsutsui Exp $ */ +/* $NetBSD: pmap.c,v 1.43.2.1 2010/10/30 08:41:11 uebayasi Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.43 2009/12/11 13:56:16 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.43.2.1 2010/10/30 08:41:11 uebayasi Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -2852,6 +2852,13 @@ { } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return addr + off; +} + /* * This extracts the PMEG associated with the given map/virtual * address pair. Returns SEGINV if VA not valid. Index: src/sys/arch/sun3/sun3/mem.c diff -u src/sys/arch/sun3/sun3/mem.c:1.51.64.1 src/sys/arch/sun3/sun3/mem.c:1.51.64.2 --- src/sys/arch/sun3/sun3/mem.c:1.51.64.1 Fri Oct 22 07:21:37 2010 +++ src/sys/arch/sun3/sun3/mem.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.51.64.1 2010/10/22 07:21:37 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.51.64.2 2010/10/30 08:41:11 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.51.64.1 2010/10/22 07:21:37 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.51.64.2 2010/10/30 08:41:11 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -289,7 +289,7 @@ /* Allow access only in "managed" RAM. */ if (off < avail_start || off >= avail_end) break; - return (off); + return pmap_mmap(0, off); case DEV_VME16D16: if (off & 0xffff0000) Index: src/sys/arch/sun3/sun3/pmap.c diff -u src/sys/arch/sun3/sun3/pmap.c:1.164.2.1 src/sys/arch/sun3/sun3/pmap.c:1.164.2.2 --- src/sys/arch/sun3/sun3/pmap.c:1.164.2.1 Fri Oct 22 07:21:37 2010 +++ src/sys/arch/sun3/sun3/pmap.c Sat Oct 30 08:41:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.164.2.1 2010/10/22 07:21:37 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.164.2.2 2010/10/30 08:41:11 uebayasi Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.1 2010/10/22 07:21:37 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.2 2010/10/30 08:41:11 uebayasi Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -2860,6 +2860,19 @@ } /* + * Routine: pmap_mmap + * Function: + * Convert the given kernel virtual address to the page frame + * number (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return addr + off; +} + +/* * Routine: pmap_extract * Function: * Extract the physical page address associated Index: src/sys/arch/sun3/sun3x/mem.c diff -u src/sys/arch/sun3/sun3x/mem.c:1.33.64.1 src/sys/arch/sun3/sun3x/mem.c:1.33.64.2 --- src/sys/arch/sun3/sun3x/mem.c:1.33.64.1 Fri Oct 22 07:21:38 2010 +++ src/sys/arch/sun3/sun3x/mem.c Sat Oct 30 08:41:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.33.64.1 2010/10/22 07:21:38 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.33.64.2 2010/10/30 08:41:12 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.33.64.1 2010/10/22 07:21:38 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.33.64.2 2010/10/30 08:41:12 uebayasi Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -276,7 +276,7 @@ /* Allow access only in valid memory. */ if (!pmap_pa_exists(off)) break; - return (off); + return pmap_mmap(0, off); #if 0 /* XXX - NOTYET */ /* XXX - Move this to bus_subr.c? */ Index: src/sys/arch/sun3/sun3x/pmap.c diff -u src/sys/arch/sun3/sun3x/pmap.c:1.110.2.1 src/sys/arch/sun3/sun3x/pmap.c:1.110.2.2 --- src/sys/arch/sun3/sun3x/pmap.c:1.110.2.1 Fri Oct 22 07:21:38 2010 +++ src/sys/arch/sun3/sun3x/pmap.c Sat Oct 30 08:41:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.110.2.1 2010/10/22 07:21:38 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.110.2.2 2010/10/30 08:41:12 uebayasi Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.110.2.1 2010/10/22 07:21:38 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.110.2.2 2010/10/30 08:41:12 uebayasi Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -2912,6 +2912,18 @@ } } +/* pmap_mmap INTERFACE + ** + * Convert the given kernel virtual address to the page frame number + * (mmap cookie). + */ +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return addr + off; +} + /* pmap_extract_kernel INTERNAL ** * Extract a translation from the kernel address space. Index: src/sys/arch/usermode/usermode/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.5 src/sys/arch/usermode/usermode/pmap.c:1.5.2.1 --- src/sys/arch/usermode/usermode/pmap.c:1.5 Sat Nov 7 07:27:48 2009 +++ src/sys/arch/usermode/usermode/pmap.c Sat Oct 30 08:41:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.5 2009/11/07 07:27:48 cegger Exp $ */ +/* $NetBSD: pmap.c,v 1.5.2.1 2010/10/30 08:41:12 uebayasi Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.5 2009/11/07 07:27:48 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.5.2.1 2010/10/30 08:41:12 uebayasi Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -169,6 +169,13 @@ { } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return -1; +} + bool pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) { Index: src/sys/arch/vax/vax/mem.c diff -u src/sys/arch/vax/vax/mem.c:1.38 src/sys/arch/vax/vax/mem.c:1.38.4.1 --- src/sys/arch/vax/vax/mem.c:1.38 Fri Dec 19 18:49:38 2008 +++ src/sys/arch/vax/vax/mem.c Sat Oct 30 08:41:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.38 2008/12/19 18:49:38 cegger Exp $ */ +/* $NetBSD: mem.c,v 1.38.4.1 2010/10/30 08:41:12 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.38 2008/12/19 18:49:38 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.38.4.1 2010/10/30 08:41:12 uebayasi Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -202,6 +202,7 @@ if ((u_int)off > ctob(physmem) && kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL) != 0) return (-1); - return (btop((u_int)off)); + + return pmap_mmap(0, off); } Index: src/sys/arch/vax/vax/pmap.c diff -u src/sys/arch/vax/vax/pmap.c:1.175.2.3 src/sys/arch/vax/vax/pmap.c:1.175.2.4 --- src/sys/arch/vax/vax/pmap.c:1.175.2.3 Tue Aug 17 06:45:26 2010 +++ src/sys/arch/vax/vax/pmap.c Sat Oct 30 08:41:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.175.2.3 2010/08/17 06:45:26 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.175.2.4 2010/10/30 08:41:12 uebayasi Exp $ */ /* * Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.175.2.3 2010/08/17 06:45:26 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.175.2.4 2010/10/30 08:41:12 uebayasi Exp $"); #include "opt_ddb.h" #include "opt_cputype.h" @@ -1233,6 +1233,13 @@ return virtual + (count - pstart) + KERNBASE; } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return btop(addr + (u_int)off); +} + #if 0 bool pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) Index: src/sys/arch/x68k/x68k/mem.c diff -u src/sys/arch/x68k/x68k/mem.c:1.36.64.1 src/sys/arch/x68k/x68k/mem.c:1.36.64.2 --- src/sys/arch/x68k/x68k/mem.c:1.36.64.1 Wed Apr 28 08:31:07 2010 +++ src/sys/arch/x68k/x68k/mem.c Sat Oct 30 08:41:13 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.36.64.1 2010/04/28 08:31:07 uebayasi Exp $ */ +/* $NetBSD: mem.c,v 1.36.64.2 2010/10/30 08:41:13 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.36.64.1 2010/04/28 08:31:07 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.36.64.2 2010/10/30 08:41:13 uebayasi Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -235,7 +235,8 @@ */ if (!isinram ((paddr_t) off)) return (-1); - return (m68k_btop((u_int)off)); + + return pmap_mmap(0, off); } static int Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.100.2.4 src/sys/arch/x86/x86/pmap.c:1.100.2.5 --- src/sys/arch/x86/x86/pmap.c:1.100.2.4 Tue Aug 17 06:45:34 2010 +++ src/sys/arch/x86/x86/pmap.c Sat Oct 30 08:41:13 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.100.2.4 2010/08/17 06:45:34 uebayasi Exp $ */ +/* $NetBSD: pmap.c,v 1.100.2.5 2010/10/30 08:41:13 uebayasi Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -149,7 +149,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.100.2.4 2010/08/17 06:45:34 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.100.2.5 2010/10/30 08:41:13 uebayasi Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -2896,6 +2896,13 @@ return 0; } +paddr_t +pmap_mmap(vaddr_t addr, off_t off) +{ + + return x86_btop(vtophys(addr + off)); +} + /* * pmap_extract: extract a PA for the given VA */ Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.106.2.2 src/sys/arch/xen/conf/files.xen:1.106.2.3 --- src/sys/arch/xen/conf/files.xen:1.106.2.2 Fri Aug 27 09:41:16 2010 +++ src/sys/arch/xen/conf/files.xen Sat Oct 30 08:41:13 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.106.2.2 2010/08/27 09:41:16 uebayasi Exp $ +# $NetBSD: files.xen,v 1.106.2.3 2010/10/30 08:41:13 uebayasi Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp @@ -286,8 +286,6 @@ attach ipmi at ipmibus file arch/x86/x86/ipmi.c ipmi needs-flag -file arch/x86/x86/xmd_machdep.c xmd - # CPUS device cpu Index: src/sys/uvm/files.uvm diff -u src/sys/uvm/files.uvm:1.16.2.1 src/sys/uvm/files.uvm:1.16.2.2 --- src/sys/uvm/files.uvm:1.16.2.1 Fri Apr 30 14:44:37 2010 +++ src/sys/uvm/files.uvm Sat Oct 30 08:41:14 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.uvm,v 1.16.2.1 2010/04/30 14:44:37 uebayasi Exp $ +# $NetBSD: files.uvm,v 1.16.2.2 2010/10/30 08:41:14 uebayasi Exp $ # # UVM options @@ -44,3 +44,5 @@ file uvm/uvm_unix.c file uvm/uvm_user.c file uvm/uvm_vnode.c + +file common/pmap/pmap_common.c Index: src/sys/uvm/uvm_pmap.h diff -u src/sys/uvm/uvm_pmap.h:1.32.2.4 src/sys/uvm/uvm_pmap.h:1.32.2.5 --- src/sys/uvm/uvm_pmap.h:1.32.2.4 Tue Aug 17 06:48:16 2010 +++ src/sys/uvm/uvm_pmap.h Sat Oct 30 08:41:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pmap.h,v 1.32.2.4 2010/08/17 06:48:16 uebayasi Exp $ */ +/* $NetBSD: uvm_pmap.h,v 1.32.2.5 2010/10/30 08:41:14 uebayasi Exp $ */ /* * Copyright (c) 1991, 1993 @@ -156,6 +156,9 @@ struct pmap *pmap_create(void); void pmap_destroy(pmap_t); int pmap_enter(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +paddr_t pmap_mmap(vaddr_t, off_t); +void *pmap_physload_device(vaddr_t, size_t, int, int); +void pmap_physunload_device(void *); bool pmap_extract(pmap_t, vaddr_t, paddr_t *); #if defined(PMAP_GROWKERNEL) vaddr_t pmap_growkernel(vaddr_t); Added files: Index: src/sys/common/pmap/pmap_common.c diff -u /dev/null src/sys/common/pmap/pmap_common.c:1.1.2.1 --- /dev/null Sat Oct 30 08:41:15 2010 +++ src/sys/common/pmap/pmap_common.c Sat Oct 30 08:41:14 2010 @@ -0,0 +1,53 @@ +/* $NetBSD: pmap_common.c,v 1.1.2.1 2010/10/30 08:41:14 uebayasi Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: pmap_common.c,v 1.1.2.1 2010/10/30 08:41:14 uebayasi Exp $"); + +#include <sys/param.h> +#include <sys/types.h> + +#include <uvm/uvm.h> + +void * +pmap_physload_device(vaddr_t addr, size_t size, int prot, int flags) +{ + paddr_t start, end; + + start = pmap_mmap(addr, 0); + end = pmap_mmap(addr, size); + + return uvm_page_physload_device(start, end, start, end, prot, flags); +} + +void +pmap_physunload_device(void *phys) +{ + + uvm_page_physunload_device(phys); +}