Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/uebayasi-xip]: src Implement pmap_physload_device(9) to replace xmd(4) M...



details:   https://anonhg.NetBSD.org/src/rev/0e26d9f53cc1
branches:  uebayasi-xip
changeset: 751824:0e26d9f53cc1
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat Oct 30 08:41:05 2010 +0000

description:
Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).

diffstat:

 share/man/man9/pmap.9                  |  39 ++++++++++++++++-
 sys/arch/acorn26/acorn26/mem.c         |  12 +++--
 sys/arch/acorn26/acorn26/pmap.c        |  11 ++++-
 sys/arch/alpha/alpha/mem.c             |   7 +-
 sys/arch/alpha/alpha/pmap.c            |  17 ++++++-
 sys/arch/amd64/amd64/mem.c             |   6 +-
 sys/arch/arm/arm/xmd_machdep.c         |  68 ------------------------------
 sys/arch/arm/arm32/mem.c               |   7 +-
 sys/arch/arm/arm32/pmap.c              |  11 ++++-
 sys/arch/arm/conf/files.arm            |   4 +-
 sys/arch/cesfic/cesfic/mem.c           |   7 +-
 sys/arch/hp300/hp300/mem.c             |   7 +-
 sys/arch/hp700/dev/mem.c               |   6 +-
 sys/arch/hppa/hppa/pmap.c              |  16 ++++++-
 sys/arch/i386/i386/mem.c               |   6 +-
 sys/arch/luna68k/luna68k/mem.c         |   7 +-
 sys/arch/m68k/m68k/pmap_motorola.c     |  17 ++++++-
 sys/arch/mac68k/mac68k/mem.c           |   6 +-
 sys/arch/mips/conf/files.mips          |   4 +-
 sys/arch/mips/mips/pmap.c              |  17 ++++++-
 sys/arch/mips/mips/xmd_machdep.c       |  68 ------------------------------
 sys/arch/mvme68k/mvme68k/mem.c         |   7 +-
 sys/arch/news68k/news68k/mem.c         |   7 +-
 sys/arch/next68k/next68k/mem.c         |   7 +-
 sys/arch/powerpc/ibm4xx/pmap.c         |  15 +++++-
 sys/arch/powerpc/oea/pmap.c            |  16 ++++++-
 sys/arch/powerpc/powerpc/mem.c         |   7 +-
 sys/arch/powerpc/powerpc/xmd_machdep.c |  76 ----------------------------------
 sys/arch/sh3/sh3/mem.c                 |   7 +-
 sys/arch/sh3/sh3/pmap.c                |  11 ++++-
 sys/arch/sparc64/sparc64/pmap.c        |  11 ++++-
 sys/arch/sun2/sun2/mem.c               |   8 +-
 sys/arch/sun2/sun2/pmap.c              |  11 ++++-
 sys/arch/sun3/sun3/mem.c               |   6 +-
 sys/arch/sun3/sun3/pmap.c              |  17 ++++++-
 sys/arch/sun3/sun3x/mem.c              |   6 +-
 sys/arch/sun3/sun3x/pmap.c             |  16 ++++++-
 sys/arch/usermode/usermode/pmap.c      |  11 ++++-
 sys/arch/vax/vax/mem.c                 |   7 +-
 sys/arch/vax/vax/pmap.c                |  11 ++++-
 sys/arch/x68k/x68k/mem.c               |   7 +-
 sys/arch/x86/x86/pmap.c                |  11 ++++-
 sys/arch/x86/x86/xmd_machdep.c         |  68 ------------------------------
 sys/arch/xen/conf/files.xen            |   4 +-
 sys/common/pmap/pmap_common.c          |  53 +++++++++++++++++++++++
 sys/uvm/files.uvm                      |   4 +-
 sys/uvm/uvm_pmap.h                     |   5 +-
 47 files changed, 364 insertions(+), 388 deletions(-)

diffs (truncated from 1591 to 300 lines):

diff -r 80f6fb654ded -r 0e26d9f53cc1 share/man/man9/pmap.9
--- a/share/man/man9/pmap.9     Sat Oct 30 07:29:08 2010 +0000
+++ b/share/man/man9/pmap.9     Sat Oct 30 08:41:05 2010 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: pmap.9,v 1.42.2.2 2010/08/17 06:40:05 uebayasi Exp $
+.\"    $NetBSD: pmap.9,v 1.42.2.3 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
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/acorn26/acorn26/mem.c
--- a/sys/arch/acorn26/acorn26/mem.c    Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/acorn26/acorn26/mem.c    Sat Oct 30 08:41:05 2010 +0000
@@ -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);
 }
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/acorn26/acorn26/pmap.c
--- a/sys/arch/acorn26/acorn26/pmap.c   Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/acorn26/acorn26/pmap.c   Sat Oct 30 08:41:05 2010 +0000
@@ -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)
 {
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/alpha/alpha/mem.c
--- a/sys/arch/alpha/alpha/mem.c        Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/alpha/alpha/mem.c        Sat Oct 30 08:41:05 2010 +0000
@@ -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);
 }
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Sat Oct 30 08:41:05 2010 +0000
@@ -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
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/amd64/amd64/mem.c
--- a/sys/arch/amd64/amd64/mem.c        Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/amd64/amd64/mem.c        Sat Oct 30 08:41:05 2010 +0000
@@ -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);
 }
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/arm/arm/xmd_machdep.c
--- a/sys/arch/arm/arm/xmd_machdep.c    Sat Oct 30 07:29:08 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*     $NetBSD: xmd_machdep.c,v 1.1.2.1 2010/08/28 16:24:33 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: xmd_machdep.c,v 1.1.2.1 2010/08/28 16:24:33 uebayasi Exp $");
-
-#include "opt_xip.h"
-
-#ifndef XIP
-#error xmd(4) needs options XIP
-#endif
-
-#include <sys/param.h>
-#include <sys/mman.h>
-
-#include <uvm/uvm_page.h>
-
-#include <dev/xmdvar.h>
-
-paddr_t
-xmd_machdep_mmap(vaddr_t addr, off_t off, int prot)
-{
-
-       return arm_btop(vtophys(addr + off));
-}
-
-void *
-xmd_machdep_physload(vaddr_t addr, size_t size)
-{
-       paddr_t start, end;
-
-       start = arm_btop(vtophys(addr));
-       end = arm_btop(vtophys(addr + size));
-
-       return uvm_page_physload_device(start, end, start, end, PROT_READ, 0);
-}
-
-void
-xmd_machdep_physunload(void *phys)
-{
-
-       uvm_page_physunload_device(phys);
-}
diff -r 80f6fb654ded -r 0e26d9f53cc1 sys/arch/arm/arm32/mem.c
--- a/sys/arch/arm/arm32/mem.c  Sat Oct 30 07:29:08 2010 +0000
+++ b/sys/arch/arm/arm32/mem.c  Sat Oct 30 08:41:05 2010 +0000
@@ -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



Home | Main Index | Thread Index | Old Index