Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/rmind-uvmplock]: src/sys Unify /dev/{mem, kmem, zero, null} implementations...
details: https://anonhg.NetBSD.org/src/rev/5d04a4f6d5e8
branches: rmind-uvmplock
changeset: 753044:5d04a4f6d5e8
user: rmind <rmind%NetBSD.org@localhost>
date: Thu Mar 18 04:36:46 2010 +0000
description:
Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.
Work and depression still in progress.
diffstat:
sys/arch/acorn26/acorn26/machdep.c | 34 ++-
sys/arch/acorn26/acorn26/mem.c | 218 -----------------
sys/arch/acorn26/conf/files.acorn26 | 3 +-
sys/arch/acorn26/include/types.h | 4 +-
sys/arch/alpha/alpha/machdep.c | 46 ++-
sys/arch/alpha/alpha/mem.c | 220 ------------------
sys/arch/alpha/conf/files.alpha | 3 +-
sys/arch/alpha/include/alpha.h | 3 +-
sys/arch/alpha/include/types.h | 4 +-
sys/arch/amd64/amd64/machdep.c | 23 +-
sys/arch/amd64/amd64/mem.c | 264 ---------------------
sys/arch/amd64/conf/files.amd64 | 3 +-
sys/arch/amd64/include/types.h | 3 +-
sys/arch/amiga/amiga/amiga_init.c | 21 +-
sys/arch/amiga/amiga/machdep.c | 12 +-
sys/arch/amiga/amiga/mem.c | 246 --------------------
sys/arch/amiga/conf/files.amiga | 3 +-
sys/arch/amiga/include/types.h | 3 +-
sys/arch/arm/arm32/arm32_machdep.c | 17 +-
sys/arch/arm/arm32/mem.c | 221 ------------------
sys/arch/arm/conf/files.arm | 3 +-
sys/arch/atari/atari/machdep.c | 35 ++-
sys/arch/atari/atari/mem.c | 218 -----------------
sys/arch/atari/conf/files.atari | 3 +-
sys/arch/atari/include/types.h | 4 +-
sys/arch/cesfic/cesfic/machdep.c | 12 +-
sys/arch/cesfic/cesfic/mem.c | 245 --------------------
sys/arch/cesfic/conf/files.cesfic | 3 +-
sys/arch/hp300/conf/files.hp300 | 3 +-
sys/arch/hp300/hp300/machdep.c | 28 ++-
sys/arch/hp300/hp300/mem.c | 245 --------------------
sys/arch/hp300/include/types.h | 3 +-
sys/arch/hp700/dev/mem.c | 125 +---------
sys/arch/hp700/hp700/machdep.c | 15 +-
sys/arch/i386/conf/files.i386 | 3 +-
sys/arch/i386/i386/machdep.c | 41 +++-
sys/arch/i386/i386/mem.c | 270 ----------------------
sys/arch/i386/include/types.h | 3 +-
sys/arch/ia64/conf/files.ia64 | 3 +-
sys/arch/ia64/ia64/machdep.c | 10 +-
sys/arch/ia64/ia64/mem.c | 50 ----
sys/arch/luna68k/conf/files.luna68k | 3 +-
sys/arch/luna68k/luna68k/machdep.c | 18 +-
sys/arch/luna68k/luna68k/mem.c | 236 -------------------
sys/arch/mac68k/conf/files.mac68k | 3 +-
sys/arch/mac68k/mac68k/machdep.c | 13 +-
sys/arch/mac68k/mac68k/mem.c | 234 -------------------
sys/arch/mips/conf/files.mips | 3 +-
sys/arch/mips/include/types.h | 5 +-
sys/arch/mips/mips/mem.c | 209 -----------------
sys/arch/mips/mips/mips_machdep.c | 56 ++++-
sys/arch/mvme68k/conf/files.mvme68k | 3 +-
sys/arch/mvme68k/mvme68k/machdep.c | 14 +-
sys/arch/mvme68k/mvme68k/mem.c | 239 -------------------
sys/arch/news68k/conf/files.news68k | 3 +-
sys/arch/news68k/include/types.h | 3 +-
sys/arch/news68k/news68k/machdep.c | 25 +-
sys/arch/news68k/news68k/mem.c | 240 -------------------
sys/arch/next68k/conf/files.next68k | 3 +-
sys/arch/next68k/next68k/machdep.c | 15 +-
sys/arch/next68k/next68k/mem.c | 244 --------------------
sys/arch/powerpc/conf/files.powerpc | 3 +-
sys/arch/powerpc/powerpc/mem.c | 173 --------------
sys/arch/powerpc/powerpc/powerpc_machdep.c | 17 +-
sys/arch/sh3/conf/files.sh3 | 3 +-
sys/arch/sh3/include/types.h | 5 +-
sys/arch/sh3/sh3/mem.c | 212 -----------------
sys/arch/sh3/sh3/vm_machdep.c | 61 ++++-
sys/arch/sparc/conf/files.sparc | 3 +-
sys/arch/sparc/include/types.h | 3 +-
sys/arch/sparc/sparc/machdep.c | 52 ++++-
sys/arch/sparc/sparc/mem.c | 230 ------------------
sys/arch/sparc64/conf/files.sparc64 | 3 +-
sys/arch/sparc64/sparc64/machdep.c | 37 ++-
sys/arch/sparc64/sparc64/mem.c | 288 -----------------------
sys/arch/sun2/conf/files.sun2 | 4 +-
sys/arch/sun2/include/types.h | 6 +-
sys/arch/sun2/sun2/machdep.c | 44 +++-
sys/arch/sun2/sun2/mem.c | 325 --------------------------
sys/arch/sun2/sun2/mm_md.c | 161 +++++++++++++
sys/arch/sun3/conf/files.sun3 | 6 +-
sys/arch/sun3/include/types.h | 6 +-
sys/arch/sun3/sun3/machdep.c | 50 +++-
sys/arch/sun3/sun3/mem.c | 352 -----------------------------
sys/arch/sun3/sun3/mm_md.c | 145 +++++++++++
sys/arch/sun3/sun3x/machdep.c | 48 +++-
sys/arch/sun3/sun3x/mem.c | 342 ----------------------------
sys/arch/sun3/sun3x/mm_md.c | 145 +++++++++++
sys/arch/usermode/conf/files.usermode | 3 +-
sys/arch/usermode/usermode/mem.c | 52 ----
sys/arch/vax/conf/files.vax | 3 +-
sys/arch/vax/include/types.h | 4 +-
sys/arch/vax/vax/machdep.c | 33 ++-
sys/arch/vax/vax/mem.c | 207 -----------------
sys/arch/x68k/conf/files.x68k | 3 +-
sys/arch/x68k/x68k/machdep.c | 21 +-
sys/arch/x68k/x68k/mem.c | 252 --------------------
sys/arch/x86/x86/x86_machdep.c | 12 +-
sys/arch/xen/conf/files.xen | 4 +-
sys/dev/mm.c | 288 +++++++++++++++++++++--
sys/dev/mm.h | 89 +++++++
sys/kern/init_main.c | 6 +-
sys/sys/conf.h | 4 +-
sys/uvm/uvm_extern.h | 4 +-
sys/uvm/uvm_glue.c | 16 +-
105 files changed, 1625 insertions(+), 6342 deletions(-)
diffs (truncated from 9629 to 300 lines):
diff -r d540665d9a3b -r 5d04a4f6d5e8 sys/arch/acorn26/acorn26/machdep.c
--- a/sys/arch/acorn26/acorn26/machdep.c Wed Mar 17 06:03:16 2010 +0000
+++ b/sys/arch/acorn26/acorn26/machdep.c Thu Mar 18 04:36:46 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.33 2010/02/08 19:02:25 joerg Exp $ */
+/* $NetBSD: machdep.c,v 1.33.2.1 2010/03/18 04:36:46 rmind Exp $ */
/*-
* Copyright (c) 1998 Ben Harris
@@ -32,7 +32,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.33 2010/02/08 19:02:25 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.33.2.1 2010/03/18 04:36:46 rmind Exp $");
#include <sys/buf.h>
#include <sys/kernel.h>
@@ -44,6 +44,8 @@
#include <sys/cpu.h>
#include <sys/device.h>
+#include <dev/mm.h>
+
#include <dev/i2c/i2cvar.h>
#include <dev/i2c/pcf8583var.h>
@@ -202,3 +204,31 @@
return (pcfrtc_bootstrap_write(iociic_bootstrap_cookie(), 0x50,
location, &val, 1));
}
+
+bool
+mm_md_direct_mapped_phys(paddr_t paddr, vaddr_t *vaddr)
+{
+
+ *vaddr = (vaddr_t)MEMC_PHYS_BASE + paddr;
+ return true;
+}
+
+int
+mm_md_physacc(paddr_t pa, vm_prot_t prot)
+{
+
+ return (atop(pa) >= physmem) ? EFAULT : 0;
+}
+
+int
+mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
+{
+
+ if (ptr >= MEMC_PHYS_BASE &&
+ (char *)ptr < (char *)MEMC_PHYS_BASE + ptoa(physmem)) {
+ *handled = true;
+ } else {
+ *handled = false;
+ }
+ return 0;
+}
diff -r d540665d9a3b -r 5d04a4f6d5e8 sys/arch/acorn26/acorn26/mem.c
--- a/sys/arch/acorn26/acorn26/mem.c Wed Mar 17 06:03:16 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/* $NetBSD: mem.c,v 1.14 2009/03/14 15:35:58 dsl Exp $ */
-
-/*
- * Copyright (c) 1982, 1986, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-/*
- * Copyright (c) 1988 University of Utah.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-/*
- * Memory special file
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.14 2009/03/14 15:35:58 dsl Exp $");
-
-#ifdef _KERNEL_OPT
-#include "opt_compat_netbsd.h"
-#endif
-
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sys/systm.h>
-#include <sys/uio.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-
-#include <machine/cpu.h>
-#include <machine/memcreg.h>
-
-#include <uvm/uvm_extern.h>
-
-void *zeropage;
-int physlock;
-
-dev_type_read(mmrw);
-dev_type_ioctl(mmioctl);
-dev_type_mmap(mmmmap);
-
-const struct cdevsw mem_cdevsw = {
- nullopen, nullclose, mmrw, mmrw, mmioctl,
- nostop, notty, nopoll, mmmmap, nokqfilter,
-};
-
-/*ARGSUSED*/
-int
-mmrw(dev_t dev, struct uio *uio, int flags)
-{
- register vm_offset_t v;
- register int c;
- register struct iovec *iov;
- int error = 0;
-
- while (uio->uio_resid > 0 && error == 0) {
- iov = uio->uio_iov;
- if (iov->iov_len == 0) {
- uio->uio_iov++;
- uio->uio_iovcnt--;
- if (uio->uio_iovcnt < 0)
- panic("mmrw");
- continue;
- }
- switch (minor(dev)) {
-
- case DEV_MEM:
- /*
- * On arm26, there's no need to map in the
- * relevant page, as we've got physical memory
- * mapped in at another address and can just
- * use that.
- */
- v = uio->uio_offset;
- c = min(iov->iov_len, MAXPHYS);
- /* XXX Should use pmap_find(). */
- if (v < 0 ||
- (char *)v + c >
- (char*)MEMC_PHYS_BASE + ptoa(physmem))
- return EFAULT;
- error = uiomove((char*)MEMC_PHYS_BASE + uio->uio_offset,
- uio->uio_resid, uio);
- continue;
-
- case DEV_KMEM:
- v = uio->uio_offset;
- c = min(iov->iov_len, MAXPHYS);
- /* Allow reading from physically mapped space. */
- if (((void *)v >= MEMC_PHYS_BASE &&
- (char *)v + c <
- (char*)MEMC_PHYS_BASE + ptoa(physmem)) ||
- uvm_kernacc((void *)v, c,
- uio->uio_rw == UIO_READ ?
- B_READ : B_WRITE))
- error = uiomove((void *)v, c, uio);
- else
- return (EFAULT);
- break;
-
- case DEV_NULL:
- if (uio->uio_rw == UIO_WRITE)
- uio->uio_resid = 0;
- return (0);
-
-#ifdef COMPAT_16
- case _DEV_ZERO_oARM:
-#endif
- case DEV_ZERO:
- if (uio->uio_rw == UIO_WRITE) {
- uio->uio_resid = 0;
- return (0);
- }
- if (zeropage == NULL) {
- zeropage =
- malloc(PAGE_SIZE, M_TEMP, M_WAITOK|M_ZERO);
- }
- c = min(iov->iov_len, PAGE_SIZE);
- error = uiomove(zeropage, c, uio);
- break;
-
- default:
- return (ENXIO);
- }
- }
- if (minor(dev) == DEV_MEM) {
-/*unlock:*/
- if (physlock > 1)
- wakeup((void *)&physlock);
- physlock = 0;
- }
- return (error);
-}
-
-paddr_t
-mmmmap(dev_t dev, off_t off, int prot)
-{
- int ppn;
-
- /*
- * /dev/mem is the only one that makes sense through this
- * interface. For /dev/kmem any physaddr we return here
- * could be transient and hence incorrect or invalid at
- * a later time. /dev/null just doesn't make any sense
- * and /dev/zero is a hack that is handled via the default
- * pager in mmap().
- */
- if (minor(dev) != DEV_MEM)
- return (-1);
-
- /* minor device 0 is physical memory */
-
- /* XXX This may botch our cacheing assumptions. Do we care? */
- ppn = atop(off);
- if (ppn >= 0 && ppn < physmem)
- return ppn;
- return -1;
-}
diff -r d540665d9a3b -r 5d04a4f6d5e8 sys/arch/acorn26/conf/files.acorn26
--- a/sys/arch/acorn26/conf/files.acorn26 Wed Mar 17 06:03:16 2010 +0000
+++ b/sys/arch/acorn26/conf/files.acorn26 Thu Mar 18 04:36:46 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.acorn26,v 1.14 2009/02/14 10:20:55 bjh21 Exp $
+# $NetBSD: files.acorn26,v 1.14.4.1 2010/03/18 04:36:46 rmind Exp $
# Copyright (c) 1997, 1998, 2000 Ben Harris
# All rights reserved.
@@ -188,7 +188,6 @@
file arch/acorn26/acorn26/except.c
file arch/acorn26/acorn26/irq.c
file arch/acorn26/acorn26/machdep.c
-file arch/acorn26/acorn26/mem.c
file arch/acorn26/acorn26/pmap.c
#file arch/acorn26/acorn26/rscons.c
file arch/acorn26/acorn26/stubs.c
diff -r d540665d9a3b -r 5d04a4f6d5e8 sys/arch/acorn26/include/types.h
--- a/sys/arch/acorn26/include/types.h Wed Mar 17 06:03:16 2010 +0000
Home |
Main Index |
Thread Index |
Old Index