Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arc/dev Moved from /cvsroot/syssrc/sys/arch/pica/de...



details:   https://anonhg.NetBSD.org/src/rev/37c60cc135b1
branches:  trunk
changeset: 480964:37c60cc135b1
user:      soda <soda%NetBSD.org@localhost>
date:      Sun Jan 23 20:08:09 2000 +0000

description:
Moved from /cvsroot/syssrc/sys/arch/pica/dev/fd.c,v

diffstat:

 sys/arch/arc/dev/fd.c |  1183 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1183 insertions(+), 0 deletions(-)

diffs (truncated from 1187 to 300 lines):

diff -r b19ff3582b97 -r 37c60cc135b1 sys/arch/arc/dev/fd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/dev/fd.c     Sun Jan 23 20:08:09 2000 +0000
@@ -0,0 +1,1183 @@
+/*     $NetBSD: fd.c,v 1.14 2000/01/23 20:08:10 soda Exp $     */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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 NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 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.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Don Ahn.
+ *
+ * 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.
+ *
+ *     @(#)fd.c        7.4 (Berkeley) 5/25/91
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/disklabel.h>
+#include <sys/dkstat.h>
+#include <sys/disk.h>
+#include <sys/buf.h>
+#include <sys/uio.h>
+#include <sys/syslog.h>
+#include <sys/queue.h>
+
+#include <machine/cpu.h>
+#include <machine/pio.h>
+#include <machine/autoconf.h>
+
+#include <mips/locore.h>
+#include <pica/dev/fdreg.h>
+#include <pica/dev/dma.h>
+
+#include "locators.h"
+
+
+#define FDUNIT(dev)    (minor(dev) / 8)
+#define FDTYPE(dev)    (minor(dev) % 8)
+
+enum fdc_state {
+       DEVIDLE = 0,
+       MOTORWAIT,
+       DOSEEK,
+       SEEKWAIT,
+       SEEKTIMEDOUT,
+       SEEKCOMPLETE,
+       DOIO,
+       IOCOMPLETE,
+       IOTIMEDOUT,
+       DORESET,
+       RESETCOMPLETE,
+       RESETTIMEDOUT,
+       DORECAL,
+       RECALWAIT,
+       RECALTIMEDOUT,
+       RECALCOMPLETE,
+};
+
+/* software state, per controller */
+struct fdc_softc {
+       struct device sc_dev;           /* boilerplate */
+
+       struct dma_softc __dma;
+       struct dma_softc *dma;
+
+       int sc_iobase;
+
+       struct fd_softc *sc_fd[4];      /* pointers to children */
+       TAILQ_HEAD(drivehead, fd_softc) sc_drives;
+       enum fdc_state sc_state;
+       int sc_errors;                  /* number of retries so far */
+       u_char sc_status[7];            /* copy of registers */
+};
+
+/* controller driver configuration */
+int fdcprobe __P((struct device *, void *, void *));
+void fdcattach __P((struct device *, struct device *, void *));
+
+struct cfattach fdc_ca = {
+       sizeof(struct fdc_softc), fdcprobe, fdcattach
+};
+
+/*
+ * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
+ * we tell them apart.
+ */
+struct fd_type {
+       int     sectrac;        /* sectors per track */
+       int     heads;          /* number of heads */
+       int     seccyl;         /* sectors per cylinder */
+       int     secsize;        /* size code for sectors */
+       int     datalen;        /* data len when secsize = 0 */
+       int     steprate;       /* step rate and head unload time */
+       int     gap1;           /* gap len between sectors */
+       int     gap2;           /* formatting gap */
+       int     tracks;         /* total num of tracks */
+       int     size;           /* size of disk in sectors */
+       int     step;           /* steps per cylinder */
+       int     rate;           /* transfer speed code */
+       char    *name;
+};
+
+/* The order of entries in the following table is important -- BEWARE! */
+struct fd_type fd_types[] = {
+        { 18,2,36,2,0xff,0xcf,0x1b,0x6c,80,2880,1,FDC_500KBPS,"1.44MB"    }, /* 1.44MB diskette */
+        { 15,2,30,2,0xff,0xdf,0x1b,0x54,80,2400,1,FDC_500KBPS, "1.2MB"    }, /* 1.2 MB AT-diskettes */
+        {  9,2,18,2,0xff,0xdf,0x23,0x50,40, 720,2,FDC_300KBPS, "360KB/AT" }, /* 360kB in 1.2MB drive */
+        {  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,1,FDC_250KBPS, "360KB/PC" }, /* 360kB PC diskettes */
+        {  9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS, "720KB"    }, /* 3.5" 720kB diskette */
+        {  9,2,18,2,0xff,0xdf,0x23,0x50,80,1440,1,FDC_300KBPS, "720KB/x"  }, /* 720kB in 1.2MB drive */
+        {  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS, "360KB/x"  }, /* 360kB in 720kB drive */
+};
+
+/* software state, per disk (with up to 4 disks per ctlr) */
+struct fd_softc {
+       struct device sc_dev;
+       struct disk sc_dk;
+
+       struct fd_type *sc_deftype;     /* default type descriptor */
+       struct fd_type *sc_type;        /* current type descriptor */
+
+       daddr_t sc_blkno;       /* starting block number */
+       int sc_bcount;          /* byte count left */
+       int sc_skip;            /* bytes already transferred */
+       int sc_nblks;           /* number of blocks currently tranferring */
+       int sc_nbytes;          /* number of bytes currently tranferring */
+
+       int sc_drive;           /* physical unit number */
+       int sc_flags;
+#define        FD_OPEN         0x01            /* it's open */
+#define        FD_MOTOR        0x02            /* motor should be on */
+#define        FD_MOTOR_WAIT   0x04            /* motor coming up */
+       int sc_cylin;           /* where we think the head is */
+
+       void *sc_sdhook;        /* saved shutdown hook for drive. */
+
+       TAILQ_ENTRY(fd_softc) sc_drivechain;
+       int sc_ops;             /* I/O ops since last switch */
+       struct buf_queue sc_q;  /* pending I/O requests */
+       int sc_active;          /* number of active I/O operations */
+};
+
+/* floppy driver configuration */
+int fdprobe __P((struct device *, void *, void *));
+void fdattach __P((struct device *, struct device *, void *));
+
+struct cfattach fd_ca = {
+       sizeof(struct fd_softc), fdprobe, fdattach
+};
+
+extern struct cfdriver fd_cd;
+
+void fdgetdisklabel __P((struct fd_softc *));
+int fd_get_parms __P((struct fd_softc *));
+void fdstrategy __P((struct buf *));
+void fdstart __P((struct fd_softc *));
+
+struct dkdriver fddkdriver = { fdstrategy };
+
+struct fd_type *fd_nvtotype __P((char *, int, int));
+void fd_set_motor __P((struct fdc_softc *fdc, int reset));
+void fd_motor_off __P((void *arg));
+void fd_motor_on __P((void *arg));
+int fdcresult __P((struct fdc_softc *fdc));
+int out_fdc __P((int iobase, u_char x));
+void fdcstart __P((struct fdc_softc *fdc));
+void fdcstatus __P((struct device *dv, int n, char *s));
+void fdctimeout __P((void *arg));
+void fdcpseudointr __P((void *arg));
+int fdcintr __P((void *));
+void fdcretry __P((struct fdc_softc *fdc));
+void fdfinish __P((struct fd_softc *fd, struct buf *bp));
+
+int
+fdcprobe(parent, match, aux)
+       struct device *parent;
+       void *match, *aux;
+{
+       register struct confargs *ca = aux;
+       int iobase = (long)BUS_CVTADDR(ca);
+
+       if (!BUS_MATCHNAME(ca, "fdc"))
+               return (0);
+
+       /* reset */
+       outb(iobase + fdout, 0);
+       delay(100);
+       outb(iobase + fdout, FDO_FRST);
+
+       /* see if it can handle a command */
+       if (out_fdc(iobase, NE7CMD_SPECIFY) < 0)
+               return 0;
+       out_fdc(iobase, 0xdf);
+       out_fdc(iobase, 2);
+
+       return 1;
+}
+
+/*
+ * Arguments passed between fdcattach and fdprobe.
+ */
+struct fdc_attach_args {
+       int fa_drive;
+       struct fd_type *fa_deftype;
+};
+
+/*
+ * Print the location of a disk drive (called just before attaching the
+ * the drive).  If `fdc' is not NULL, the drive was found but was not
+ * in the system config file; print the drive name as well.
+ * Return QUIET (config_find ignores this if the device was configured) to
+ * avoid printing `fdN not configured' messages.
+ */
+int
+fdprint(aux, fdc)
+       void *aux;
+       const char *fdc;
+{
+       register struct fdc_attach_args *fa = aux;
+
+       if (!fdc)
+               printf(" drive %d", fa->fa_drive);
+       return QUIET;
+}
+
+void
+fdcattach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{



Home | Main Index | Thread Index | Old Index