Source-Changes-HG archive

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

[src/uebayasi-xip]: src Initial addition of xmd(4), XIP memory disk.



details:   https://anonhg.NetBSD.org/src/rev/15e1a382942d
branches:  uebayasi-xip
changeset: 751778:15e1a382942d
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Thu Aug 19 12:36:58 2010 +0000

description:
Initial addition of xmd(4), XIP memory disk.

diffstat:

 share/man/man4/md.4                    |    3 +-
 share/man/man4/xmd.4                   |   30 +++
 sys/arch/evbppc/conf/OPENBLOCKS266     |    5 +-
 sys/arch/evbppc/conf/majors.evbppc     |    3 +-
 sys/arch/powerpc/conf/files.powerpc    |    4 +-
 sys/arch/powerpc/powerpc/xmd_machdep.c |   69 +++++++
 sys/conf/files                         |    8 +-
 sys/dev/xmd.c                          |  299 +++++++++++++++++++++++++++++++++
 sys/dev/xmdvar.h                       |   36 +++
 9 files changed, 451 insertions(+), 6 deletions(-)

diffs (truncated from 560 to 300 lines):

diff -r dce8cf7c7fd5 -r 15e1a382942d share/man/man4/md.4
--- a/share/man/man4/md.4       Thu Aug 19 01:02:21 2010 +0000
+++ b/share/man/man4/md.4       Thu Aug 19 12:36:58 2010 +0000
@@ -1,4 +1,4 @@
-.\"   $NetBSD: md.4,v 1.5 2007/02/25 04:22:01 uwe Exp $
+.\"   $NetBSD: md.4,v 1.5.26.1 2010/08/19 12:36:59 uebayasi Exp $
 .\"
 .\" This file is in the public domain.
 .\"
@@ -35,5 +35,6 @@
 .El
 .Sh SEE ALSO
 .Xr options 4 ,
+.Xr xmd 4 ,
 .Xr mdconfig 8 ,
 .Xr mdsetimage 8
diff -r dce8cf7c7fd5 -r 15e1a382942d share/man/man4/xmd.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/xmd.4      Thu Aug 19 12:36:58 2010 +0000
@@ -0,0 +1,30 @@
+.\" $NetBSD: xmd.4,v 1.1.2.1 2010/08/19 12:36:59 uebayasi Exp $
+.\"
+.\" This file is in the public domain.
+.\"
+.Dd August 19, 2010
+.Dt XMD 4
+.Os
+.Sh NAME
+.Nm xmd
+.Nd XIP memory disk
+.Sh SYNOPSIS
+.Cd "pseudo-device xmd" Op Ar count
+.Sh DESCRIPTION
+The
+.Nm
+driver enables use of system or user memory as a disk, which can be
+mounted as XIP (eXecute-In-Place), so that filesystem data are read
+without consuming intermediate page cache buffers.
+.Pp
+Memory for the disk is allocated within the kernel and set with
+.Xr mdsetimage 8
+before the
+.Nm
+device may be used as a disk.
+.Nm
+disks should be mounted as read-only to enable XIP.
+.Sh SEE ALSO
+.Xr md 4 ,
+.Xr options 4 ,
+.Xr mdsetimage 8
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/arch/evbppc/conf/OPENBLOCKS266
--- a/sys/arch/evbppc/conf/OPENBLOCKS266        Thu Aug 19 01:02:21 2010 +0000
+++ b/sys/arch/evbppc/conf/OPENBLOCKS266        Thu Aug 19 12:36:58 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: OPENBLOCKS266,v 1.46.2.2 2010/08/11 14:03:58 uebayasi Exp $
+#      $NetBSD: OPENBLOCKS266,v 1.46.2.3 2010/08/19 12:36:58 uebayasi Exp $
 #
 #      GENERIC -- everything that's currently supported
 #
@@ -7,7 +7,7 @@
 
 #options       INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "OPENBLOCKS266-$Revision: 1.46.2.2 $"
+#ident                 "OPENBLOCKS266-$Revision: 1.46.2.3 $"
 
 maxusers       32
 
@@ -197,6 +197,7 @@
 #pseudo-device fss                     # file system snapshot device
 #pseudo-device md              1       # memory disk device
 #pseudo-device vnd                     # disk-like interface to files
+#pseudo-device xmd             1       # XIP memory disk device
 
 # network pseudo-devices
 pseudo-device  loop                    # network loopback
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/arch/evbppc/conf/majors.evbppc
--- a/sys/arch/evbppc/conf/majors.evbppc        Thu Aug 19 01:02:21 2010 +0000
+++ b/sys/arch/evbppc/conf/majors.evbppc        Thu Aug 19 12:36:58 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: majors.evbppc,v 1.28.6.1 2010/08/11 13:56:27 uebayasi Exp $
+#      $NetBSD: majors.evbppc,v 1.28.6.2 2010/08/19 12:36:58 uebayasi Exp $
 #
 # Device majors for evbppc
 # (When possible, make entries the same as macppc)
@@ -81,6 +81,7 @@
 device-major   nsmb            char 98                 nsmb
 device-major   xlcom           char 99                 xlcom
 device-major   flash           char 100  block 15      flash
+device-major   xmd             char 101  block 16      xmd
 
 # Majors up to 143 are reserved for machine-dependant drivers.
 # New machine-independent driver majors are assigned in 
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/arch/powerpc/conf/files.powerpc
--- a/sys/arch/powerpc/conf/files.powerpc       Thu Aug 19 01:02:21 2010 +0000
+++ b/sys/arch/powerpc/conf/files.powerpc       Thu Aug 19 12:36:58 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.powerpc,v 1.71.4.2 2010/08/11 13:20:07 uebayasi Exp $
+#      $NetBSD: files.powerpc,v 1.71.4.3 2010/08/19 12:36:58 uebayasi Exp $
 
 defflag        opt_altivec.h   ALTIVEC K_ALTIVEC
 defflag        opt_openpic.h   OPENPIC OPENPIC_SERIAL_MODE
@@ -94,3 +94,5 @@
 file arch/powerpc/powerpc/linux_sigcode.S              compat_linux
 file arch/powerpc/powerpc/linux_trap.c                 compat_linux
 file arch/powerpc/powerpc/linux_syscall.c              compat_linux
+
+file arch/powerpc/powerpc/xmd_machdep.c                        xmd
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/arch/powerpc/powerpc/xmd_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/powerpc/xmd_machdep.c    Thu Aug 19 12:36:58 2010 +0000
@@ -0,0 +1,69 @@
+/*     $NetBSD: xmd_machdep.c,v 1.1.2.1 2010/08/19 12:36:58 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 "opt_xip.h"
+
+#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)
+{
+
+       /* addr is in PA == VA RAM area. */
+       KASSERT(addr >= 0x00000000);
+       KASSERT(addr < 0x80000000);
+
+       return addr;
+}
+
+void *
+xmd_machdep_physload(vaddr_t addr, size_t size)
+{
+       paddr_t s, e, as, ae;
+
+       /* addr is in PA == VA RAM area. */
+       KASSERT(addr >= 0x00000000);
+       KASSERT(addr < 0x80000000);
+
+       s = as = (addr) >> PAGE_SHIFT;
+       e = ae = (addr + size) >> PAGE_SHIFT;
+
+       return uvm_page_physload_device(s, e, as, ae, PROT_READ, 0);
+}
+
+void
+xmd_machdep_physunload(void *phys)
+{
+
+       uvm_page_physunload_device(phys);
+}
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/conf/files
--- a/sys/conf/files    Thu Aug 19 01:02:21 2010 +0000
+++ b/sys/conf/files    Thu Aug 19 12:36:58 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.974.2.7 2010/08/17 06:45:56 uebayasi Exp $
+#      $NetBSD: files,v 1.974.2.8 2010/08/19 12:36:58 uebayasi Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -271,6 +271,10 @@
 defparam opt_md.h              MEMORY_DISK_SERVER=1 MEMORY_DISK_ROOT_SIZE
                                MEMORY_DISK_RBFLAGS
 
+# XIP memory (ram) disk options
+#
+defflag        opt_xmd.h               XMD_ROOT_SIZE
+
 defflag opt_tftproot.h         TFTPROOT TFTPROOT_DEBUG
 
 # Support for hardware performance monitoring counters
@@ -1256,6 +1260,7 @@
 defpseudodev cgd:      disk, des, blowfish, cast128, rijndael
 defpseudodev md:       disk
 defpseudodev fss:      disk
+defpseudodev xmd:      disk
 
 defpseudo pty:         tty
 defpseudo rnd
@@ -1415,6 +1420,7 @@
 file   dev/sequencer.c                 sequencer               needs-flag
 file   dev/video.c                     video                   needs-flag
 file   dev/vnd.c                       vnd                     needs-flag
+file   dev/xmd.c                       xmd                     needs-count
 file   kern/bufq_disksort.c            bufq_disksort
 file   kern/bufq_fcfs.c                bufq_fcfs
 file   kern/bufq_priocscan.c           bufq_priocscan
diff -r dce8cf7c7fd5 -r 15e1a382942d sys/dev/xmd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/xmd.c     Thu Aug 19 12:36:58 2010 +0000
@@ -0,0 +1,299 @@
+/*     $NetBSD: xmd.c,v 1.1.2.1 2010/08/19 12:36:58 uebayasi Exp $     */
+
+/*-
+ * Copyright (c) 2010 Tsubai Masanari.  All rights reserved.
+ * Copyright (c) 2010 Masao Uebayashi.  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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 "opt_xip.h"
+#include "opt_xmd.h"
+
+#ifndef XIP
+#error xmd(4) needs options XIP
+#endif
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/ioctl.h>
+#include <sys/kmem.h>
+#include <sys/buf.h>
+#include <sys/bufq.h>
+#include <sys/device.h>
+#include <sys/disk.h>
+#include <sys/disklabel.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/kmem.h>
+
+#include <machine/vmparam.h>
+
+#include <dev/xmdvar.h>
+
+struct xmd_softc {
+       vaddr_t sc_addr;
+       size_t sc_size;
+
+       void *sc_phys;
+
+       struct disk sc_dkdev;
+       struct bufq_state *sc_buflist;
+};
+
+void xmdattach(int);
+static void xmd_attach(device_t, device_t, void *);
+static int xmd_detach(device_t, int);
+static dev_type_open(xmd_open);
+static dev_type_close(xmd_close);
+static dev_type_ioctl(xmd_ioctl);
+static dev_type_mmap(xmd_mmap);
+static dev_type_strategy(xmd_strategy);
+static dev_type_size(xmd_size);
+
+struct bdevsw xmd_bdevsw = {
+       xmd_open, xmd_close, xmd_strategy, xmd_ioctl,
+       nodump, xmd_size, D_DISK | D_MPSAFE
+};
+



Home | Main Index | Thread Index | Old Index