Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/isa Traditionally, the floppy controller was configu...



details:   https://anonhg.NetBSD.org/src/rev/30bd20ed275e
branches:  trunk
changeset: 485601:30bd20ed275e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue May 02 03:33:45 2000 +0000

description:
Traditionally, the floppy controller was configured at 0x3f0 for 8 ports,
but the registers actually begin at 0x3f2, and this is what PNPBIOS reports
for the floppy controller resources.  Adjust the register offsets and the
mapping of them for the ISA front-end to compensate, so that the PNPBIOS
attachment of the floppy controller actually works.

diffstat:

 sys/dev/isa/fdc_isa.c |  37 ++++++++++++++++++++++++++++---------
 sys/dev/isa/fdreg.h   |  19 +++++++++++++------
 2 files changed, 41 insertions(+), 15 deletions(-)

diffs (140 lines):

diff -r c6bdfe76d195 -r 30bd20ed275e sys/dev/isa/fdc_isa.c
--- a/sys/dev/isa/fdc_isa.c     Tue May 02 03:32:09 2000 +0000
+++ b/sys/dev/isa/fdc_isa.c     Tue May 02 03:33:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdc_isa.c,v 1.1 2000/04/23 16:47:45 thorpej Exp $      */
+/*     $NetBSD: fdc_isa.c,v 1.2 2000/05/02 03:33:45 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -98,8 +98,14 @@
 int    fdc_isa_probe(struct device *, struct cfdata *, void *);
 void   fdc_isa_attach(struct device *, struct device *, void *);
 
+struct fdc_isa_softc {
+       struct fdc_softc sc_fdc;        /* base fdc device */
+
+       bus_space_handle_t sc_baseioh;  /* base I/O handle */
+};
+
 struct cfattach fdc_isa_ca = {
-       sizeof(struct fdc_softc), fdc_isa_probe, fdc_isa_attach
+       sizeof(struct fdc_isa_softc), fdc_isa_probe, fdc_isa_attach
 };
 
 #ifdef NEWCONFIG
@@ -113,7 +119,7 @@
 {
        struct isa_attach_args *ia = aux;
        bus_space_tag_t iot;
-       bus_space_handle_t ioh, ctl_ioh;
+       bus_space_handle_t ioh, ctl_ioh, base_ioh;
        int rv;
 
        iot = ia->ia_iot;
@@ -124,11 +130,16 @@
                return (0);
 
        /* Map the I/O space. */
-       if (bus_space_map(iot, ia->ia_iobase, 6 /* FDC_NPORT */, 0, &ioh))
+       if (bus_space_map(iot, ia->ia_iobase, 6 /* FDC_NPORT */, 0, &base_ioh))
                return (0);
 
-       if (bus_space_map(iot, ia->ia_iobase + fdctl, 1, 0, &ctl_ioh)) {
-               bus_space_unmap(iot, ioh, 6);
+       if (bus_space_subregion(iot, base_ioh, 2, 4, &ioh)) {
+               bus_space_unmap(iot, base_ioh, 6);
+               return (0);
+       }
+
+       if (bus_space_map(iot, ia->ia_iobase + fdctl + 2, 1, 0, &ctl_ioh)) {
+               bus_space_unmap(iot, base_ioh, 6);
                return (0);
        }
 
@@ -167,7 +178,7 @@
        ia->ia_msize = 0;
 
  out:
-       bus_space_unmap(iot, ioh, 6 /* FDC_NPORT */);
+       bus_space_unmap(iot, base_ioh, 6 /* FDC_NPORT */);
        return (rv);
 }
 
@@ -198,6 +209,7 @@
     void *aux)
 {
        struct fdc_softc *fdc = (void *) self;
+       struct fdc_isa_softc *isc = (void *) self;
        struct isa_attach_args *ia = aux;
 
        printf("\n");
@@ -207,12 +219,19 @@
        fdc->sc_drq = ia->ia_drq;
 
        if (bus_space_map(fdc->sc_iot, ia->ia_iobase, 6 /* FDC_NPORT */, 0,
-           &fdc->sc_ioh)) {
+           &isc->sc_baseioh)) {
                printf("%s: unable to map I/O space\n", fdc->sc_dev.dv_xname);
                return;
        }
 
-       if (bus_space_map(fdc->sc_iot, ia->ia_iobase + fdctl, 1, 0,
+       if (bus_space_subregion(fdc->sc_iot, isc->sc_baseioh, 2, 4,
+           &fdc->sc_ioh)) {
+               printf("%s: unable to subregion I/O space\n",
+                   fdc->sc_dev.dv_xname);
+               return;
+       }
+
+       if (bus_space_map(fdc->sc_iot, ia->ia_iobase + fdctl + 2, 1, 0,
            &fdc->sc_fdctlioh)) {
                printf("%s: unable to map CTL I/O space\n",
                    fdc->sc_dev.dv_xname);
diff -r c6bdfe76d195 -r 30bd20ed275e sys/dev/isa/fdreg.h
--- a/sys/dev/isa/fdreg.h       Tue May 02 03:32:09 2000 +0000
+++ b/sys/dev/isa/fdreg.h       Tue May 02 03:33:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdreg.h,v 1.1 2000/04/07 16:32:03 thorpej Exp $        */
+/*     $NetBSD: fdreg.h,v 1.2 2000/05/02 03:33:45 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -43,25 +43,32 @@
 #include <dev/ic/nec765reg.h>
 
 /* registers */
-#define        fdout   2       /* Digital Output Register (W) */
+#define        fdout   0       /* Digital Output Register (W) */
 #define        FDO_FDSEL       0x03    /*  floppy device select */
 #define        FDO_FRST        0x04    /*  floppy controller reset */
 #define        FDO_FDMAEN      0x08    /*  enable floppy DMA and Interrupt */
 #define        FDO_MOEN(n)     ((1 << n) * 0x10)       /* motor enable */
 
-#define        fdsts   4       /* NEC 765 Main Status Register (R) */
-#define        fddata  5       /* NEC 765 Data Register (R/W) */
+#define        fdsts   2       /* NEC 765 Main Status Register (R) */
+#define        fddata  3       /* NEC 765 Data Register (R/W) */
 
-#define        fdctl   7       /* Control Register (W) */
+#define        fdctl   5       /* Control Register (W) */
 #define        FDC_500KBPS     0x00    /* 500KBPS MFM drive transfer rate */
 #define        FDC_300KBPS     0x01    /* 300KBPS MFM drive transfer rate */
 #define        FDC_250KBPS     0x02    /* 250KBPS MFM drive transfer rate */
 #define        FDC_125KBPS     0x03    /* 125KBPS FM drive transfer rate */
 
-#define        fdin    7       /* Digital Input Register (R) */
+#define        fdin    5       /* Digital Input Register (R) */
 #define        FDI_DCHG        0x80    /* diskette has been changed */
 
 #define        FDC_BSIZE       512
+
+/*
+ * This constant is a little misleading.  Historically, the floppy
+ * controller is located at 0x3f0-0x3f7, but the actual registers
+ * are 0x3f2, 0x3f3, 0x3f4, and 0x3f7.  This constant assumes the
+ * historic range, but the offsets above reflect the `real' offsets.
+ */
 #define        FDC_NPORT       8
 
 /*



Home | Main Index | Thread Index | Old Index