First cut of Flash memory disk. Needs more work though...
authorpefo <pefo@openbsd.org>
Sun, 23 Feb 1997 21:59:24 +0000 (21:59 +0000)
committerpefo <pefo@openbsd.org>
Sun, 23 Feb 1997 21:59:24 +0000 (21:59 +0000)
sys/arch/wgrisc/conf/GENERIC
sys/arch/wgrisc/conf/Makefile.wgrisc
sys/arch/wgrisc/conf/files.wgrisc
sys/arch/wgrisc/dev/flash.c [new file with mode: 0644]
sys/arch/wgrisc/dev/flashreg.h [new file with mode: 0644]
sys/arch/wgrisc/include/param.h
sys/arch/wgrisc/riscbus/riscbus.c
sys/arch/wgrisc/wgrisc/autoconf.c
sys/arch/wgrisc/wgrisc/conf.c

index 16d585c..d6cf121 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: GENERIC,v 1.2 1997/02/20 11:50:45 pefo Exp $
+#      $OpenBSD: GENERIC,v 1.3 1997/02/23 21:59:24 pefo Exp $
 #
 #      Generic configuration file for Willowglen RISC-PC 9100
 #
@@ -85,6 +85,8 @@ com3          at riscbus?
 asc0           at riscbus?
 scsibus*       at asc?
 
+flash0         at riscbus?
+
 #
 #      ISA Bus.
 #
index 341b1ca..a1be843 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile.wgrisc,v 1.1.1.1 1997/02/06 16:02:45 pefo Exp $
+#      $OpenBSD: Makefile.wgrisc,v 1.2 1997/02/23 21:59:25 pefo Exp $
 
 #      @(#)Makefile.wgrisc     8.2 (Berkeley) 2/16/94
 #
@@ -99,7 +99,6 @@ SYSTEM_LD=    -@if [ X${DEBUG} = X-g ]; \
                        ${SYSTEM_OBJ} vers.o
 #
 SYSTEM_LD_TAIL=        chmod 755 $@; \
-               elf2ecoff $@ $@.ecoff; \
                size $@
 
 %LOAD
index 98d094b..2900988 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: files.wgrisc,v 1.1.1.1 1997/02/06 16:02:45 pefo Exp $
+#      $OpenBSD: files.wgrisc,v 1.2 1997/02/23 21:59:26 pefo Exp $
 #
 # maxpartitions must be first item in files.${ARCH}
 #
@@ -71,6 +71,11 @@ device       asc: scsi
 attach asc at riscbus
 file   arch/wgrisc/dev/asc.c           asc     needs-count
 
+#      FLASH Memory device driver
+device flash
+attach flash at riscbus
+file   arch/wgrisc/dev/flash.c         flash   needs-count
+
 #
 #      ISA
 #
diff --git a/sys/arch/wgrisc/dev/flash.c b/sys/arch/wgrisc/dev/flash.c
new file mode 100644 (file)
index 0000000..89bbf9c
--- /dev/null
@@ -0,0 +1,363 @@
+/*     $OpenBSD: flash.c,v 1.1 1997/02/23 21:59:27 pefo Exp $ */
+
+/*
+ * Copyright (c) 1997 Per Fogelstrom
+ * 
+ * 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 under OpenBSD by
+ *     Per Fogelstrom for Willowglen Singapore.
+ * 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 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/param.h>
+#include <sys/conf.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/uio.h>
+#include <sys/buf.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/fcntl.h>
+#include <sys/device.h>
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+#include <machine/pio.h>
+
+#include <wgrisc/riscbus/riscbus.h>
+#include <wgrisc/dev/flashreg.h>
+#include <wgrisc/wgrisc/wgrisctype.h>
+
+extern int cputype;
+
+void flashattach __P((struct device *, struct device *, void *));
+int  flashmatch __P((struct device *, void *, void *));
+
+struct flashtype {
+       char    *fl_name;
+       int     fl_size;
+       int     fl_blksz;
+       u_char  fl_manf;
+       u_char  fl_type;
+};
+struct flashtype flashlist[] = {
+       { "Samsung KM29N16000", 2097152, 4096, 0xec, 0x64 },
+       { NULL },
+};
+
+struct flashsoftc {
+       struct device   sc_dev;
+       int             sc_prot;
+       size_t          sc_size;
+       int             sc_present;
+       struct flashtype *sc_ftype;
+};
+
+struct cfattach flash_ca = {
+       sizeof(struct flashsoftc), flashmatch, flashattach
+};
+struct cfdriver flash_cd = {
+       NULL, "flash", DV_DISK, 0       /* Yes! We want is as root device */
+};
+
+int
+flashmatch(parent, cf, args)
+       struct device *parent;
+       void *cf;
+       void *args;
+{
+       struct confargs *ca = args;
+
+       if(!BUS_MATCHNAME(ca, "flash"))
+               return(0);
+       return(1);
+}
+
+void
+flashattach(parent, self, args)
+       struct device *parent, *self;
+       void *args;
+{
+       struct confargs *ca = args;
+       struct flashsoftc *sc = (struct flashsoftc *)self;
+       struct flashtype *flist;
+       int i, manf, type;
+
+       switch(cputype) {
+       case WGRISC9100:        /* WGRISC9100 can have 4 chips */
+               sc->sc_present = 0;
+               sc->sc_ftype = NULL;
+               OUT_FL_CTRL(0, 0);      /* All CS lines high */
+               for(i = 0; i < 4; i++) {
+                       OUT_FL_CLE(FL_READID, (1 << i));
+                       OUT_FL_ALE1(0, (1 << i));
+                       manf = IN_FL_DATA;
+                       type = IN_FL_DATA;
+                       flist = flashlist;
+                       while(flist->fl_name != 0) {
+                               if(flist->fl_manf == manf &&
+                                  flist->fl_type == type) {
+                                       sc->sc_present |= 1 << i;
+                                       sc->sc_size += flist->fl_size;
+                                       if(sc->sc_ftype == NULL) {
+                                               sc->sc_ftype = flist;
+                                       }
+                                       else if(sc->sc_ftype == flist) {
+                                       }
+/* XXX Protection test type dependent ? */
+                                       OUT_FL_CLE(FL_READSTAT, (1 << i));
+                                       if(!(IN_FL_DATA & FLST_UNPROT)) {
+                                               sc->sc_prot = 1;
+                                       }
+                                       break;
+                               }
+                               flist++;
+                       }
+               }
+               break;
+
+       default:
+               printf("flash: Unknown cputype '%d'", cputype);
+       }
+       if(sc->sc_ftype != NULL) {
+               printf(" %s, %d*%d bytes%s.", sc->sc_ftype->fl_name,
+                               sc->sc_size / sc->sc_ftype->fl_size,
+                               sc->sc_ftype->fl_size,
+                               sc->sc_prot ? " Write protected" : "");
+       }
+       else {
+               printf("WARNING! Flash type not identified!");
+       }
+       printf("\n");
+}
+
+static int
+flashgetblk(sc, blk, offs, cnt)
+       struct flashsoftc *sc;
+       char *blk;
+       size_t offs;
+       size_t cnt;
+{
+       int chip;
+       int blkadr;
+
+       chip = 1 << (offs / sc->sc_ftype->fl_size);
+       blkadr = offs % sc->sc_ftype->fl_size;
+
+       OUT_FL_CLE(FL_READ1, chip);
+       OUT_FL_ALE3(blkadr, chip);
+       WAIT_FL_RDY;
+       while(cnt--) {
+               *blk++ = IN_FL_DATA;
+       }
+       return(0);
+}
+
+static int
+flashputblk(sc, blk, offs, cnt)
+       struct flashsoftc *sc;
+       char *blk;
+       size_t offs;
+       size_t cnt;
+{
+       int chip;
+       int blkadr;
+
+       chip = 1 << (offs / sc->sc_ftype->fl_size);
+       blkadr = offs % sc->sc_ftype->fl_size;
+
+       OUT_FL_CLE(FL_SEQDI, chip);
+       OUT_FL_ALE3(blkadr, chip);
+       while(cnt--) {
+               OUT_FL_DATA(*blk);
+               blk++;
+       }
+       OUT_FL_CLE(FL_PGPROG, chip);
+       WAIT_FL_RDY;
+       OUT_FL_CLE(FL_READSTAT, chip);
+       if(IN_FL_DATA & FLST_ERROR) {
+               return(-1);
+       }
+       return(0);
+}
+
+static int
+flasheraseblk(sc, offs)
+       struct flashsoftc *sc;
+       size_t offs;
+{
+       int chip;
+       int blkadr;
+
+       chip = 1 << (offs / sc->sc_ftype->fl_size);
+       blkadr = offs % sc->sc_ftype->fl_size;
+
+       OUT_FL_CLE(FL_BLERASE, chip);
+       OUT_FL_ALE2(blkadr, chip);
+       OUT_FL_CLE(FL_REERASE, chip);
+       WAIT_FL_RDY;
+       OUT_FL_CLE(FL_READSTAT, chip);
+       if(IN_FL_DATA & FLST_ERROR) {
+               return(-1);
+       }
+       return(0);
+}
+
+/*ARGSUSED*/
+int
+flashopen(dev, flag, mode, p)
+       dev_t dev;
+       int flag, mode;
+       struct proc *p;
+{
+       if (minor(dev) >= flash_cd.cd_ndevs || flash_cd.cd_devs[minor(dev)] == NULL)
+               return (ENODEV);
+       return(0);
+}
+
+/*ARGSUSED*/
+int
+flashclose(dev, flag, mode, p)
+       dev_t dev;
+       int flag, mode;
+       struct proc *p;
+{
+       return(0);
+}
+
+/*ARGSUSED*/
+int
+flashioctl(dev, cmd, data, flag, p)
+       dev_t   dev;
+       u_char *data;
+       int     cmd, flag;
+       struct proc *p;
+{
+       int unit = minor(dev);
+       struct flashsoftc *sc = (struct flashsoftc *) flash_cd.cd_devs[unit];
+       int error = 0;
+
+       switch (cmd) {
+       default:
+               error = ENOTTY;
+               break;
+       }
+       return(error);
+}
+
+void
+flashstrategy(bp)
+       struct buf *bp;
+{
+       int unit = minor(bp->b_dev);
+       struct flashsoftc *sc = (struct flashsoftc *) flash_cd.cd_devs[unit];
+       int error = 0;
+       size_t offs, xfer, cnt;
+       caddr_t buf;
+
+       offs = bp->b_blkno << DEV_BSHIFT;       /* Start address */
+       buf = bp->b_data;
+       bp->b_resid = bp->b_bcount;
+       if(offs < sc->sc_size) {
+               xfer = bp->b_resid;
+               if(offs + xfer > sc->sc_size) {
+                       xfer = sc->sc_size - offs;
+               }
+               if(bp->b_flags & B_READ) {
+                       bp->b_resid -= xfer;
+                       while(xfer > 0) {
+                               cnt = (xfer > 256) ? 256 : xfer;
+                               flashgetblk(sc, buf, offs, cnt);
+                               xfer -= cnt;
+                               offs += cnt;
+                               buf += cnt;
+                       }
+               }
+               else {
+                       while(xfer > 0) {
+                               if((offs & (sc->sc_ftype->fl_blksz - 1)) == 0 &&
+                                  (xfer >= sc->sc_ftype->fl_blksz)) {
+                                       if(flasheraseblk(sc, offs))
+                                               error = EIO;
+                               }
+                               cnt = (xfer > 256) ? 256 : xfer;
+                               if(flashputblk(sc, buf, offs, cnt))
+                                       error = EIO;
+                               xfer -= cnt;
+                               buf += cnt;
+                               offs += cnt;
+                               bp->b_resid -= cnt;
+                       }
+               }
+       }
+       else if(!(bp->b_flags & B_READ)) {      /* No space for write */
+               error = EIO;
+       }
+       if(error) {
+               bp->b_error = error;
+               bp->b_flags |= B_ERROR;
+       }
+
+       biodone(bp);
+}
+
+/*ARGSUSED*/
+int
+flashread(dev, uio, ioflag)
+        dev_t dev;
+        struct uio *uio;
+       int ioflag;
+{
+       return (physio(flashstrategy, NULL, dev, B_READ, minphys, uio));
+}
+
+/*ARGSUSED*/
+int
+flashwrite(dev, uio, ioflag)
+        dev_t dev;
+        struct uio *uio;
+        int ioflag;
+{
+       return (physio(flashstrategy, NULL, dev, B_WRITE, minphys, uio));
+}
+
+int
+flashdump(dev, blkno, va, size)
+       dev_t dev;
+       daddr_t blkno;
+       caddr_t va;
+       size_t size;
+{
+       return(ENODEV);
+}
+
+int
+flashsize(dev)
+       dev_t dev;
+{
+       return(0);
+}
diff --git a/sys/arch/wgrisc/dev/flashreg.h b/sys/arch/wgrisc/dev/flashreg.h
new file mode 100644 (file)
index 0000000..d06eb76
--- /dev/null
@@ -0,0 +1,112 @@
+/*     $OpenBSD: flashreg.h,v 1.1 1997/02/23 21:59:28 pefo Exp $ */
+
+/*
+ * Copyright (c) 1997 Per Fogelstrom
+ * 
+ * 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 under OpenBSD by
+ *     Per Fogelstrom for Willowglen Singapore.
+ * 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 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.
+ *
+ */
+
+/*
+ *     Definitions for the Samsung KM29N16000 2M/8 NAND Flash Memory.
+ */
+
+/* Commands */
+
+#define        FL_SEQDI        0x80    /* Sequential data input        */
+#define        FL_READ1        0x00    /* Read 1 (normal read          */
+#define        FL_READ2        0x50    /* Read 2 (extended read        */
+#define        FL_READID       0x90    /* Read chip id                 */
+#define        FL_RESET        0xff    /* Chip control reset           */
+#define        FL_PGPROG       0x10    /* Page program                 */
+#define        FL_BLERASE      0x60    /* Block erase                  */
+#define        FL_SUERASE      0xb0    /* Suspend erase                */
+#define        FL_REERASE      0xd0    /* Resume erase                 */
+#define        FL_READSTAT     0x70    /* Read status                  */
+#define        FL_READREG      0xe0    /* Read register                */
+
+/* Status */
+#define        FLST_ERROR      0x01    /* Error in Program/Erase       */
+#define        FLST_ESUSP      0x20    /* Erase suspended              */
+#define        FLST_RDY        0x40    /* Ready                        */
+#define        FLST_UNPROT     0x80    /* Memory not wr protected      */
+
+/* Handy macros */
+#define        FLC_ALE         0x80    /* Control reg ALE bit          */
+#define        FLC_CLE         0x40    /* Control reg CLE bit          */
+#define        FLC_NCS         0x3f    /* CS bits                      */
+
+#define WAIT_FL_RDY                                            \
+       while((inb(RISC_STATUS) & 0x10) == 0)
+
+#define OUT_FL_CTRL(x, cs)                                     \
+       do {                                                    \
+           outb(RISC_FLASH_CTRL, (x) | (FLC_NCS ^ (cs)));      \
+           wbflush();                                          \
+       } while(0)
+
+#define OUT_FL_DATA(x)                                         \
+       outb(RISC_FLASH_WRITE, (x))
+
+#define IN_FL_DATA                                             \
+       inb(RISC_FLASH_READ)
+
+#define        OUT_FL_CLE(cmd, cs)                                     \
+       do {                                                    \
+           OUT_FL_CTRL(FLC_CLE, (cs));                         \
+           OUT_FL_DATA(cmd);                                   \
+           OUT_FL_CTRL(0, cs);                                 \
+       } while(0);
+
+#define OUT_FL_ALE1(addr, cs)                                  \
+       do {                                                    \
+           register int _a = addr;                             \
+           OUT_FL_CTRL(FLC_ALE, (cs));                         \
+           OUT_FL_DATA(_a);                                    \
+           OUT_FL_CTRL(0, cs);                                 \
+       } while(0);
+
+#define OUT_FL_ALE2(addr, cs)                                  \
+       do {                                                    \
+           register int _a = addr;                             \
+           OUT_FL_CTRL(FLC_ALE, (cs));                         \
+           OUT_FL_DATA(_a >> 8);                               \
+           OUT_FL_DATA(_a >> 16);                              \
+           OUT_FL_CTRL(0, cs);                                 \
+       } while(0);
+
+#define OUT_FL_ALE3(addr, cs)                                  \
+       do {                                                    \
+           register int _a = addr;                             \
+           OUT_FL_CTRL(FLC_ALE, (cs));                         \
+           OUT_FL_DATA(_a);                                    \
+           OUT_FL_DATA(_a >> 8);                               \
+           OUT_FL_DATA(_a >> 16);                              \
+           OUT_FL_CTRL(0, cs);                                 \
+       } while(0);
+
index 2978cf3..89821d1 100644 (file)
@@ -1,4 +1,4 @@
-/*      $OpenBSD: param.h,v 1.1.1.1 1997/02/06 16:02:43 pefo Exp $ */
+/*      $OpenBSD: param.h,v 1.2 1997/02/23 21:59:29 pefo Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -95,8 +95,8 @@
  * of the hardware page size.
  */
 #define        MSIZE           128             /* size of an mbuf */
-#define        MCLBYTES        2048            /* enough for whole Ethernet packet */
-#define        MCLSHIFT        10
+#define        MCLSHIFT        11              /* log2(MCLBYTES) */
+#define        MCLBYTES        (1 << MCLSHIFT) /* enough for whole Ethernet packet */
 #define        MCLOFSET        (MCLBYTES - 1)
 #ifndef NMBCLUSTERS
 #ifdef GATEWAY
index 97743a9..a6684b2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: riscbus.c,v 1.1.1.1 1997/02/06 16:02:44 pefo Exp $ */
+/*     $OpenBSD: riscbus.c,v 1.2 1997/02/23 21:59:31 pefo Exp $ */
 
 /*
  * Copyright (c) 1996 Per Fogelstrom
@@ -113,6 +113,8 @@ struct riscbus_dev wgrisc9100_cpu[] = {
           INT_MASK_5,  riscbus_intrnull, (void *)RISC_COM2, },
        {{ "com",       6, 0, },
           INT_MASK_5,  riscbus_intrnull, (void *)RISC_COM3, },
+       {{ "flash",     7, 0, },
+          0, NULL, (void *)NULL, },
        {{ NULL,       -1, NULL, },
           0, NULL, (void *)NULL, },
 };
index 856f976..2cbc766 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: autoconf.c,v 1.1.1.1 1997/02/06 16:02:46 pefo Exp $   */
+/*     $OpenBSD: autoconf.c,v 1.2 1997/02/23 21:59:32 pefo Exp $       */
 /*
  * Copyright (c) 1996 Per Fogelstrom
  * Copyright (c) 1995 Theo de Raadt
@@ -41,7 +41,7 @@
  * from: Utah Hdr: autoconf.c 1.31 91/01/21
  *
  *     from: @(#)autoconf.c    8.1 (Berkeley) 6/10/93
- *      $Id: autoconf.c,v 1.1.1.1 1997/02/06 16:02:46 pefo Exp $
+ *      $Id: autoconf.c,v 1.2 1997/02/23 21:59:32 pefo Exp $
  */
 
 /*
@@ -123,6 +123,7 @@ static      struct nam2blk {
 } nam2blk[] = {
        { "sd", 0 },    /* 0 = sd */
        { "fd", 7 },    /* 7 = floppy  (ick!)*/
+       { "flash", 10 } /* 10 = Flash memory disk */
 };
 
 static int
index 796489d..521defa 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: conf.c,v 1.1.1.1 1997/02/06 16:02:45 pefo Exp $ */
+/*     $OpenBSD: conf.c,v 1.2 1997/02/23 21:59:33 pefo Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)conf.c        8.2 (Berkeley) 11/14/93
- *      $Id: conf.c,v 1.1.1.1 1997/02/06 16:02:45 pefo Exp $
+ *      $Id: conf.c,v 1.2 1997/02/23 21:59:33 pefo Exp $
  */
 
 #include <sys/param.h>
@@ -69,6 +69,8 @@ bdev_decl(fd);
 bdev_decl(wd);
 #include "acd.h"
 bdev_decl(acd);
+#include "flash.h"
+bdev_decl(flash);
 
 struct bdevsw  bdevsw[] =
 {
@@ -82,7 +84,7 @@ struct bdevsw bdevsw[] =
        bdev_notdef(),                  /* 7: Floppy disk driver */
        bdev_notdef(),                  /* 8:  */
        bdev_notdef(),                  /* 9:  */
-       bdev_notdef(),                  /* 10:  */
+       bdev_disk_init(NFLASH,flash),   /* 10: Flash ram disk driver */
        bdev_notdef(),                  /* 11:  */
        bdev_notdef(),                  /* 12:  */
        bdev_notdef(),                  /* 13:  */
@@ -96,23 +98,6 @@ int  nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
  *     Character devices.
  */
 
-/* open, close, read, write, ioctl, tty, mmap */
-#define cdev_pc_init(c,n) { \
-       dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
-       dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
-       dev_init(c,n,tty), ttselect, dev_init(c,n,mmap), D_TTY }
-
-/* open, close, write, ioctl */
-#define        cdev_lpt_init(c,n) { \
-       dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
-       dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
-       0, seltrue, (dev_type_mmap((*))) enodev }
-
-/* open, close, write, ioctl */
-#define        cdev_spkr_init(c,n) { \
-       dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
-       dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
-       0, seltrue, (dev_type_mmap((*))) enodev }
 
 cdev_decl(cn);
 cdev_decl(sw);
@@ -133,28 +118,19 @@ cdev_decl(log);
 cdev_decl(fd);
 #include "st.h"
 cdev_decl(st);
-#ifdef notyet
-#include "fdc.h"
-bdev_decl(fd);
-#endif
 cdev_decl(vnd);
 #include "bpfilter.h"
 cdev_decl(bpf);
 #include "com.h"
 cdev_decl(com);
-#include "lpt.h"
-cdev_decl(lpt);
 cdev_decl(sd);
-#ifdef notyet
-#include "pc.h"
-cdev_decl(pc);
-cdev_decl(pms);
-#endif
 cdev_decl(cd);
 #include "uk.h"
 cdev_decl(uk);
 cdev_decl(wd);
 cdev_decl(acd);
+cdev_decl(flash);
+
 
 /* open, close, read, ioctl */
 cdev_decl(ipl);
@@ -182,13 +158,13 @@ struct cdevsw     cdevsw[] =
        cdev_notdef(),                  /* 13: Floppy disk */
        cdev_notdef(),                  /* 14: builtin pc style console dev */
        cdev_notdef(),                  /* 15: builtin PS2 style mouse */
-       cdev_lpt_init(NLPT,lpt),        /* 16: lpt paralell printer interface */
+       cdev_notdef(),                  /* 16: lpt paralell printer interface */
        cdev_tty_init(NCOM,com),        /* 17: com 16C450 serial interface */
        cdev_disk_init(NWDC,wd),        /* 18: ST506/ESDI/IDE disk */
        cdev_disk_init(NACD,acd),       /* 19: ATAPI CD-ROM */
        cdev_tty_init(NPTY,pts),        /* 20: pseudo-tty slave */
        cdev_ptc_init(NPTY,ptc),        /* 21: pseudo-tty master */
-       cdev_notdef(),                  /* 22: */
+       cdev_disk_init(NFLASH,flash),   /* 22: Flash memory driver */
        cdev_notdef(),                  /* 23: */
        cdev_notdef(),                  /* 24: */
        cdev_notdef(),                  /* 25: */