Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/sys/arch/sparc/dev Apply patch (requested by pk):
details: https://anonhg.NetBSD.org/src/rev/49622d9133f0
branches: netbsd-1-4
changeset: 470303:49622d9133f0
user: he <he%NetBSD.org@localhost>
date: Mon Feb 07 19:44:34 2000 +0000
description:
Apply patch (requested by pk):
Fix several problems:
o Floppy driver dislikes being accessed with no floppy inserted
(PR#5740)
o Floppy drive being detected even though there is none (PR#5760)
o Panic when fdformat is used (PR#9251)
diffstat:
sys/arch/sparc/dev/fd.c | 940 +++++++++++++++++++++++++++-----------------
sys/arch/sparc/dev/fdreg.h | 45 +-
sys/arch/sparc/dev/fdvar.h | 31 +-
3 files changed, 604 insertions(+), 412 deletions(-)
diffs (truncated from 1681 to 300 lines):
diff -r 23f1014a8a42 -r 49622d9133f0 sys/arch/sparc/dev/fd.c
--- a/sys/arch/sparc/dev/fd.c Mon Feb 07 19:35:10 2000 +0000
+++ b/sys/arch/sparc/dev/fd.c Mon Feb 07 19:44:34 2000 +0000
@@ -1,4 +1,40 @@
-/* $NetBSD: fd.c,v 1.67 1999/03/24 05:51:10 mrg Exp $ */
+/* $NetBSD: fd.c,v 1.67.2.1 2000/02/07 19:44:34 he Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg.
+ *
+ * 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) 1993, 1994, 1995 Charles M. Hannum.
@@ -81,7 +117,6 @@
/* XXX misuse a flag to identify format operation */
#define B_FORMAT B_XXX
-#define b_cylin b_resid
#define FD_DEBUG
#ifdef FD_DEBUG
@@ -90,28 +125,30 @@
enum fdc_state {
DEVIDLE = 0,
- MOTORWAIT,
- DOSEEK,
- SEEKWAIT,
- SEEKTIMEDOUT,
- SEEKCOMPLETE,
- DOIO,
- IOCOMPLETE,
- IOTIMEDOUT,
- DORESET,
- RESETCOMPLETE,
- RESETTIMEDOUT,
- DORECAL,
- RECALWAIT,
- RECALTIMEDOUT,
- RECALCOMPLETE,
+ MOTORWAIT, /* 1 */
+ DOSEEK, /* 2 */
+ SEEKWAIT, /* 3 */
+ SEEKTIMEDOUT, /* 4 */
+ SEEKCOMPLETE, /* 5 */
+ DOIO, /* 6 */
+ IOCOMPLETE, /* 7 */
+ IOTIMEDOUT, /* 8 */
+ IOCLEANUPWAIT, /* 9 */
+ IOCLEANUPTIMEDOUT,/*10 */
+ DORESET, /* 11 */
+ RESETCOMPLETE, /* 12 */
+ RESETTIMEDOUT, /* 13 */
+ DORECAL, /* 14 */
+ RECALWAIT, /* 15 */
+ RECALTIMEDOUT, /* 16 */
+ RECALCOMPLETE, /* 17 */
};
/* software state, per controller */
struct fdc_softc {
struct device sc_dev; /* boilerplate */
bus_space_tag_t sc_bustag;
- caddr_t sc_reg;
+
struct fd_softc *sc_fd[4]; /* pointers to children */
TAILQ_HEAD(drivehead, fd_softc) sc_drives;
enum fdc_state sc_state;
@@ -119,15 +156,18 @@
#define FDC_82077 0x01
#define FDC_NEEDHEADSETTLE 0x02
#define FDC_EIS 0x04
+#define FDC_NEEDMOTORWAIT 0x08
int sc_errors; /* number of retries so far */
int sc_overruns; /* number of DMA overruns */
int sc_cfg; /* current configuration */
struct fdcio sc_io;
+#define sc_handle sc_io.fdcio_handle
#define sc_reg_msr sc_io.fdcio_reg_msr
#define sc_reg_fifo sc_io.fdcio_reg_fifo
#define sc_reg_dor sc_io.fdcio_reg_dor
#define sc_reg_drs sc_io.fdcio_reg_msr
-#define sc_istate sc_io.fdcio_istate
+#define sc_itask sc_io.fdcio_itask
+#define sc_istatus sc_io.fdcio_istatus
#define sc_data sc_io.fdcio_data
#define sc_tc sc_io.fdcio_tc
#define sc_nstat sc_io.fdcio_nstat
@@ -135,6 +175,7 @@
#define sc_intrcnt sc_io.fdcio_intrcnt
};
+#undef FDC_C_HANDLER
#ifndef FDC_C_HANDLER
extern struct fdcio *fdciop;
#endif
@@ -145,7 +186,7 @@
void fdcattach_mainbus __P((struct device *, struct device *, void *));
void fdcattach_obio __P((struct device *, struct device *, void *));
-void fdcattach __P((struct fdc_softc *, int, struct bootpath *));
+void fdcattach __P((struct fdc_softc *, int));
struct cfattach fdc_mainbus_ca = {
sizeof(struct fdc_softc), fdcmatch_mainbus, fdcattach_mainbus
@@ -180,7 +221,7 @@
/* 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,0xf6,1, "1.44MB" }, /* 1.44MB diskette */
+ { 18,2,36,2,0xff,0xcf,0x1b,0x54,80,2880,1,FDC_500KBPS,0xf6,1, "1.44MB" }, /* 1.44MB diskette */
{ 9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS,0xf6,1, "720KB" }, /* 3.5" 720kB diskette */
{ 9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS,0xf6,1, "360KB/x" }, /* 360kB in 720kB drive */
{ 8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS,0xf6,1, "1.2MB/NEC" } /* 1.2 MB japanese format */
@@ -212,7 +253,7 @@
TAILQ_ENTRY(fd_softc) sc_drivechain;
int sc_ops; /* I/O ops since last switch */
- struct buf sc_q; /* head of buf chain */
+ struct buf sc_q; /* pending I/O requests */
};
/* floppy driver configuration */
@@ -238,14 +279,14 @@
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((struct fdc_softc *fdc, u_char x));
+int fdc_wrfifo __P((struct fdc_softc *fdc, u_char x));
void fdcstart __P((struct fdc_softc *fdc));
-void fdcstatus __P((struct device *dv, int n, char *s));
+void fdcstatus __P((struct fdc_softc *fdc, char *s));
void fdc_reset __P((struct fdc_softc *fdc));
void fdctimeout __P((void *arg));
void fdcpseudointr __P((void *arg));
#ifdef FDC_C_HANDLER
-int fdchwintr __P((void *));
+int fdc_c_hwintr __P((void *));
#else
void fdchwintr __P((void));
#endif
@@ -256,7 +297,15 @@
int fdformat __P((dev_t, struct ne7_fd_formb *, struct proc *));
void fd_do_eject __P((struct fd_softc *));
void fd_mountroot_hook __P((struct device *));
-static void fdconf __P((struct fdc_softc *));
+static int fdconf __P((struct fdc_softc *));
+static void establish_chip_type __P((
+ struct fdc_softc *,
+ bus_space_tag_t,
+ bus_type_t,
+ bus_addr_t,
+ bus_size_t,
+ bus_space_handle_t));
+
#if PIL_FDSOFT == 4
#define IE_FDSOFT IE_L4
@@ -273,7 +322,7 @@
ienab_bis(IE_L4); \
} while(0)
#else
-#define AUDIO_SET_SWINTR ienab_bis(IE_FDSOFT)
+#define FD_SET_SWINTR ienab_bis(IE_FDSOFT)
#endif /* defined(SUN4M) */
#endif /* FDC_C_HANDLER */
@@ -334,12 +383,64 @@
NULL, NULL));
}
+static void
+establish_chip_type(fdc, tag, type, addr, size, handle)
+ struct fdc_softc *fdc;
+ bus_space_tag_t tag;
+ bus_type_t type;
+ bus_addr_t addr;
+ bus_size_t size;
+ bus_space_handle_t handle;
+{
+ u_int8_t v;
+
+ /*
+ * This hack from Chris Torek: apparently DOR really
+ * addresses MSR/DRS on a 82072.
+ * We used to rely on the VERSION command to tell the
+ * difference (which did not work).
+ */
+
+ /* First, check the size of the register bank */
+ if (size < 8)
+ /* It isn't a 82077 */
+ return;
+
+ /* Then probe the DOR register offset */
+ if (bus_space_probe(tag, type, addr,
+ 1, /* probe size */
+ FDREG77_DOR, /* offset */
+ 0, /* flags */
+ NULL, NULL) == 0) {
+
+ /* It isn't a 82077 */
+ return;
+ }
+
+ v = bus_space_read_1(tag, handle, FDREG77_DOR);
+ if (v == NE7_RQM) {
+ /*
+ * Value in DOR looks like it's really MSR
+ */
+ bus_space_write_1(tag, handle, FDREG77_DOR, FDC_250KBPS);
+ v = bus_space_read_1(tag, handle, FDREG77_DOR);
+ if (v == NE7_RQM) {
+ /*
+ * The value in the DOR didn't stick;
+ * it isn't a 82077
+ */
+ return;
+ }
+ }
+
+ fdc->sc_flags |= FDC_82077;
+}
+
/*
* Arguments passed between fdcattach and fdprobe.
*/
struct fdc_attach_args {
int fa_drive;
- struct bootpath *fa_bootpath;
struct fd_type *fa_deftype;
};
@@ -362,14 +463,18 @@
return (QUIET);
}
-static void
+/*
+ * Configure several parameters and features on the FDC.
+ * Return 0 on success.
+ */
+static int
fdconf(fdc)
struct fdc_softc *fdc;
{
int vroom;
- if (out_fdc(fdc, NE7CMD_DUMPREG) || fdcresult(fdc) != 10)
- return;
+ if (fdc_wrfifo(fdc, NE7CMD_DUMPREG) || fdcresult(fdc) != 10)
+ return (-1);
/*
* dumpreg[7] seems to be a motor-off timeout; set it to whatever
@@ -379,18 +484,37 @@
vroom = 0x64;
/* Configure controller to use FIFO and Implied Seek */
- out_fdc(fdc, NE7CMD_CFG);
- out_fdc(fdc, vroom);
- out_fdc(fdc, fdc->sc_cfg);
- out_fdc(fdc, 0); /* PRETRK */
- /* No result phase */
+ if (fdc_wrfifo(fdc, NE7CMD_CFG) != 0)
+ return (-1);
+ if (fdc_wrfifo(fdc, vroom) != 0)
+ return (-1);
Home |
Main Index |
Thread Index |
Old Index