Source-Changes-HG archive

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

[src/trunk]: src/sys add block device driver



details:   https://anonhg.NetBSD.org/src/rev/650b8a55c4d4
branches:  trunk
changeset: 565667:650b8a55c4d4
user:      cl <cl%NetBSD.org@localhost>
date:      Sat Apr 17 12:56:26 2004 +0000

description:
add block device driver

diffstat:

 sys/arch/xen/conf/GENERIC                   |   19 +-
 sys/arch/xen/conf/XEN                       |   10 +-
 sys/arch/xen/conf/files.xen                 |   11 +-
 sys/arch/xen/conf/majors.xen                |    3 +-
 sys/arch/xen/i386/autoconf.c                |   11 +-
 sys/arch/xen/i386/mainbus.c                 |   20 +-
 sys/arch/xen/include/hypervisor-ifs/block.h |   17 +-
 sys/arch/xen/include/xbdvar.h               |   53 +
 sys/arch/xen/xen/xbd.c                      |  861 ++++++++++++++++++++++++++++
 sys/conf/files                              |    4 +-
 10 files changed, 980 insertions(+), 29 deletions(-)

diffs (truncated from 1210 to 300 lines):

diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/conf/GENERIC
--- a/sys/arch/xen/conf/GENERIC Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/conf/GENERIC Sat Apr 17 12:56:26 2004 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: GENERIC,v 1.1 2004/03/11 21:44:08 cl Exp $
-# NetBSD: GENERIC,v 1.594 2004/02/25 18:56:26 perry Exp 
+# $NetBSD: GENERIC,v 1.2 2004/04/17 12:56:27 cl Exp $
+# NetBSD: GENERIC,v 1.596 2004/04/07 13:13:59 augustss Exp 
 #
 # GENERIC machine description file
 #
@@ -23,7 +23,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.1 $"
+#ident                 "GENERIC-$Revision: 1.2 $"
 
 maxusers       32              # estimated number of users
 
@@ -130,13 +130,13 @@
 
 # File systems
 file-system    FFS             # UFS
-#file-system   EXT2FS          # second extended file system (linux)
-#file-system   LFS             # log-structured file system
+file-system    EXT2FS          # second extended file system (linux)
+file-system    LFS             # log-structured file system
 file-system    MFS             # memory file system
 file-system    NFS             # Network File System client
-#file-system   NTFS            # Windows/NT file system (experimental)
-#file-system   CD9660          # ISO 9660 + Rock Ridge file system
-#file-system   MSDOSFS         # MS-DOS file system
+file-system    NTFS            # Windows/NT file system (experimental)
+file-system    CD9660          # ISO 9660 + Rock Ridge file system
+file-system    MSDOSFS         # MS-DOS file system
 file-system    FDESC           # /dev/fd
 file-system    KERNFS          # /kern
 file-system    NULLFS          # loopback file system
@@ -187,7 +187,7 @@
 
 # Kernel root file system and dump configuration.
 config         netbsd  root on ? type ?
-#config                netbsd  root on xennet0 type nfs
+#config                netbsd  root on xbd0a type ffs
 #config                netbsd  root on ? type nfs
 
 #
@@ -202,6 +202,7 @@
 
 xenc*  at mainbus?             # Xen virtual console
 xennet*        at mainbus?             # Xen virtual network interface
+xbd*   at mainbus?             # Xen virtual block device
 
 
 # Pull in optional local configuration
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/conf/XEN
--- a/sys/arch/xen/conf/XEN     Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/conf/XEN     Sat Apr 17 12:56:26 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: XEN,v 1.1 2004/03/11 21:44:08 cl Exp $
+# $NetBSD: XEN,v 1.2 2004/04/17 12:56:27 cl Exp $
 
 include        "arch/xen/conf/std.xen"
 
@@ -70,8 +70,8 @@
 #options       EXEC_MACHO      # exec MACH-O binaries
 #options       COMPAT_PECOFF   # kernel support to run Win32 apps
 
-#file-system   FFS             # UFS
-#file-system   EXT2FS          # second extended file system (linux)
+file-system    FFS             # UFS
+file-system    EXT2FS          # second extended file system (linux)
 #file-system   LFS             # log-structured file system
 #file-system   MFS             # memory file system
 file-system    NFS             # Network File System client
@@ -109,6 +109,7 @@
 #options       NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""
 
 config         netbsd  root on ? type ?
+#config                netbsd  root on xbd0a type ffs
 #config                netbsd  root on xennet0 type nfs
 
 mainbus0 at root
@@ -119,12 +120,13 @@
 
 xenc*  at mainbus?             # Xen virtual console
 xennet*        at mainbus?             # Xen virtual network interface
+xbd*   at mainbus?             # Xen virtual block device
 
 
 include        "arch/xen/conf/GENERIC.local"
 
 
-#pseudo-device ccd             4       # concatenated/striped disk devices
+pseudo-device  ccd             4       # concatenated/striped disk devices
 #pseudo-device cgd             4       # cryptographic disk devices
 #pseudo-device md              1       # memory disk device (ramdisk)
 #pseudo-device vnd             4       # disk-like interface to files
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/conf/files.xen       Sat Apr 17 12:56:26 2004 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: files.xen,v 1.3 2004/03/25 15:26:35 wiz Exp $
+#      $NetBSD: files.xen,v 1.4 2004/04/17 12:56:27 cl Exp $
 #      NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
-#      NetBSD: files.i386,v 1.249 2004/02/16 17:11:27 wiz Exp 
+#      NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
 maxpartitions 8
 
@@ -191,9 +191,8 @@
 attach xennet at mainbus
 file   arch/xen/xen/if_xennet.c        xennet needs-flag
 
-#device        xd: XXXXdisk
-#attach        xd at mainbus
-#file  arch/xen/xen/disk.c             xd needs-flag
-
+device xbd: disk
+attach xbd at mainbus
+file   arch/xen/xen/xbd.c              xbd needs-flag
 
 include "arch/xen/conf/majors.i386"
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/conf/majors.xen
--- a/sys/arch/xen/conf/majors.xen      Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/conf/majors.xen      Sat Apr 17 12:56:26 2004 +0000
@@ -1,8 +1,9 @@
-#      $NetBSD: majors.xen,v 1.1 2004/03/11 21:44:08 cl Exp $
+#      $NetBSD: majors.xen,v 1.2 2004/04/17 12:56:27 cl Exp $
 #
 # Device majors for Xen
 #
 
+device-major   xbd             char 142 block 142      xbd
 device-major   xenc            char 143                xenc
 
 # Majors up to 143 are reserved for machine-dependant drivers.
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/i386/autoconf.c
--- a/sys/arch/xen/i386/autoconf.c      Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/i386/autoconf.c      Sat Apr 17 12:56:26 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.1 2004/03/11 21:44:08 cl Exp $  */
+/*     $NetBSD: autoconf.c,v 1.2 2004/04/17 12:56:27 cl Exp $  */
 /*     NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp    */
 
 /*-
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.1 2004/03/11 21:44:08 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2 2004/04/17 12:56:27 cl Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_multiprocessor.h"
@@ -530,6 +530,13 @@
                        goto found;
                }
        }
+       if (dev->dv_class == DV_DISK) {
+               char bootdev[16]; /* sizeof(dv_xname) */
+
+               xen_parse_cmdline(bootdev, NULL);
+               if (strncmp(bootdev, dev->dv_xname, 16) == 0)
+                       goto found;
+       }
 #endif
        if (dev->dv_class == DV_IFNET) {
                struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF);
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/i386/mainbus.c
--- a/sys/arch/xen/i386/mainbus.c       Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/i386/mainbus.c       Sat Apr 17 12:56:26 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.1 2004/03/11 21:44:08 cl Exp $   */
+/*     $NetBSD: mainbus.c,v 1.2 2004/04/17 12:56:27 cl Exp $   */
 /*     NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp       */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2004/03/11 21:44:08 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.2 2004/04/17 12:56:27 cl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -57,6 +57,7 @@
 #include "vesabios.h"
 #include "xenc.h"
 #include "xennet.h"
+#include "xbd.h"
 #include "npx.h"
 
 #include "opt_mpacpi.h"
@@ -102,6 +103,13 @@
 #include <machine/if_xennetvar.h>
 #endif
 
+#if NXBD > 0
+#include <sys/buf.h>
+#include <sys/disk.h>
+#include <dev/dkvar.h>
+#include <machine/xbdvar.h>
+#endif
+
 int    mainbus_match(struct device *, struct cfdata *, void *);
 void   mainbus_attach(struct device *, struct device *, void *);
 
@@ -138,8 +146,8 @@
 #if NXENNET > 0
        struct xennet_attach_args mba_xennet;
 #endif
-#if NXENDISK > 0
-       struct xendisk_attach_args mba_xendisk;
+#if NXBD > 0
+       struct xbd_attach_args mba_xbd;
 #endif
 #if NNPX > 0
        struct xen_npx_attach_args mba_xennpx;
@@ -388,6 +396,10 @@
        mba.mba_xennet.xa_busname = "xennet";
        xennet_scan(self, &mba.mba_xennet, mainbus_print);
 #endif
+#if NXBD > 0
+       mba.mba_xbd.xa_busname = "xbd";
+       xbd_scan(self, &mba.mba_xbd, mainbus_print);
+#endif
 #if NNPX > 0
        mba.mba_xennpx.xa_busname = "npx";
        config_found(self, &mba.mba_xennpx, mainbus_print);
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/include/hypervisor-ifs/block.h
--- a/sys/arch/xen/include/hypervisor-ifs/block.h       Sat Apr 17 12:53:27 2004 +0000
+++ b/sys/arch/xen/include/hypervisor-ifs/block.h       Sat Apr 17 12:56:26 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: block.h,v 1.1 2004/03/11 21:44:08 cl Exp $     */
+/*     $NetBSD: block.h,v 1.2 2004/04/17 12:56:27 cl Exp $     */
 
 /*
  *
@@ -34,6 +34,8 @@
 #ifndef __BLOCK_H__
 #define __BLOCK_H__
 
+typedef u64 xen_sector_t;
+
 /*
  *
  * These are the ring data structures for buffering messages between 
@@ -76,6 +78,19 @@
     unsigned long   status;               /* cuurently boolean good/bad   */
 } blk_ring_resp_entry_t;
 
+/*
+ * We use a special capitalised type name because it is _essential_ that all 
+ * arithmetic on indexes is done on an integer type of the correct size.
+ */
+typedef unsigned int BLK_RING_IDX;
+
+/*
+ * Ring indexes are 'free running'. That is, they are not stored modulo the
+ * size of the ring buffer. The following macro converts a free-running counter
+ * into a value that can directly index a ring-buffer array.
+ */
+#define MASK_BLK_IDX(_i) ((_i)&(BLK_RING_SIZE-1))
+
 typedef struct blk_ring_st 
 {
     unsigned int req_prod;  /* Request producer. Updated by guest OS. */
diff -r 5952d9d0e3e0 -r 650b8a55c4d4 sys/arch/xen/include/xbdvar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/xen/include/xbdvar.h     Sat Apr 17 12:56:26 2004 +0000
@@ -0,0 +1,53 @@
+/* $NetBSD: xbdvar.h,v 1.1 2004/04/17 12:56:27 cl Exp $ */
+
+/*
+ *
+ * Copyright (c) 2004 Christian Limpach.
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Christian Limpach.
+ * 4. 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



Home | Main Index | Thread Index | Old Index