summaryrefslogtreecommitdiffstats
path: root/sys/pc98
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2001-07-23 13:07:24 +0000
committernyan <nyan@FreeBSD.org>2001-07-23 13:07:24 +0000
commit0f7dc27de9fff9ad17977cb9952c731a79a99fc1 (patch)
treedc8e4a4947cba99de7c8e19706eb40e8aa0518bc /sys/pc98
parent6ea84229c5f8eab2f284cdc3ec0d8d60fdbc4b87 (diff)
downloadFreeBSD-src-0f7dc27de9fff9ad17977cb9952c731a79a99fc1.zip
FreeBSD-src-0f7dc27de9fff9ad17977cb9952c731a79a99fc1.tar.gz
Integrate fdc.h into fd.c.
Diffstat (limited to 'sys/pc98')
-rw-r--r--sys/pc98/cbus/fdc.c127
-rw-r--r--sys/pc98/pc98/fd.c127
2 files changed, 250 insertions, 4 deletions
diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c
index 5b6b6a5..e3d6ea2 100644
--- a/sys/pc98/cbus/fdc.c
+++ b/sys/pc98/cbus/fdc.c
@@ -81,14 +81,137 @@
#include <pc98/pc98/pc98_machdep.h>
#include <pc98/pc98/epsonio.h>
#include <pc98/pc98/fdreg.h>
-#include <isa/fdc.h>
#else
#include <isa/isareg.h>
#include <isa/fdreg.h>
-#include <isa/fdc.h>
#include <isa/rtc.h>
#endif
+enum fdc_type
+{
+ FDC_NE765, FDC_I82077, FDC_NE72065, FDC_UNKNOWN = -1
+};
+
+enum fdc_states {
+ DEVIDLE,
+ FINDWORK,
+ DOSEEK,
+ SEEKCOMPLETE ,
+ IOCOMPLETE,
+ RECALCOMPLETE,
+ STARTRECAL,
+ RESETCTLR,
+ SEEKWAIT,
+ RECALWAIT,
+ MOTORWAIT,
+ IOTIMEDOUT,
+ RESETCOMPLETE,
+ PIOREAD
+};
+
+#ifdef FDC_DEBUG
+static char const * const fdstates[] = {
+ "DEVIDLE",
+ "FINDWORK",
+ "DOSEEK",
+ "SEEKCOMPLETE",
+ "IOCOMPLETE",
+ "RECALCOMPLETE",
+ "STARTRECAL",
+ "RESETCTLR",
+ "SEEKWAIT",
+ "RECALWAIT",
+ "MOTORWAIT",
+ "IOTIMEDOUT",
+ "RESETCOMPLETE",
+ "PIOREAD"
+};
+#endif
+
+/*
+ * Per controller structure (softc).
+ */
+struct fdc_data
+{
+ int fdcu; /* our unit number */
+ int dmachan;
+ int flags;
+#define FDC_ATTACHED 0x01
+#define FDC_STAT_VALID 0x08
+#define FDC_HAS_FIFO 0x10
+#define FDC_NEEDS_RESET 0x20
+#define FDC_NODMA 0x40
+#define FDC_ISPNP 0x80
+#define FDC_ISPCMCIA 0x100
+ struct fd_data *fd;
+ int fdu; /* the active drive */
+ enum fdc_states state;
+ int retry;
+#ifndef PC98
+ int fdout; /* mirror of the w/o digital output reg */
+#endif
+ u_int status[7]; /* copy of the registers */
+ enum fdc_type fdct; /* chip version of FDC */
+ int fdc_errs; /* number of logged errors */
+ int dma_overruns; /* number of DMA overruns */
+ struct bio_queue_head head;
+ struct bio *bp; /* active buffer */
+#ifdef PC98
+ struct resource *res_ioport, *res_fdsio, *res_fdemsio;
+ struct resource *res_irq, *res_drq;
+ int rid_ioport, rid_irq, rid_drq;
+#else
+ struct resource *res_ioport, *res_ctl, *res_irq, *res_drq;
+ int rid_ioport, rid_ctl, rid_irq, rid_drq;
+#endif
+ int port_off;
+ bus_space_tag_t portt;
+ bus_space_handle_t porth;
+#ifdef PC98
+ bus_space_tag_t sc_fdsiot;
+ bus_space_handle_t sc_fdsioh;
+ bus_space_tag_t sc_fdemsiot;
+ bus_space_handle_t sc_fdemsioh;
+#else
+ bus_space_tag_t ctlt;
+ bus_space_handle_t ctlh;
+#endif
+ void *fdc_intr;
+ struct device *fdc_dev;
+#ifndef PC98
+ void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v);
+#endif
+};
+
+typedef int fdu_t;
+typedef int fdcu_t;
+typedef int fdsu_t;
+typedef struct fd_data *fd_p;
+typedef struct fdc_data *fdc_p;
+typedef enum fdc_type fdc_t;
+
+#define FDUNIT(s) (((s) >> 6) & 3)
+#define FDTYPE(s) ((s) & 0x3f)
+
+/*
+ * fdc maintains a set (1!) of ivars per child of each controller.
+ */
+enum fdc_device_ivars {
+ FDC_IVAR_FDUNIT,
+};
+
+/*
+ * Simple access macros for the ivars.
+ */
+#define FDC_ACCESSOR(A, B, T) \
+static __inline T fdc_get_ ## A(device_t dev) \
+{ \
+ uintptr_t v; \
+ BUS_READ_IVAR(device_get_parent(dev), dev, FDC_IVAR_ ## B, &v); \
+ return (T) v; \
+}
+FDC_ACCESSOR(fdunit, FDUNIT, int)
+
/* configuration flags */
#define FDC_PRETEND_D0 (1 << 0) /* pretend drive 0 to be there */
#define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */
diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c
index 5b6b6a5..e3d6ea2 100644
--- a/sys/pc98/pc98/fd.c
+++ b/sys/pc98/pc98/fd.c
@@ -81,14 +81,137 @@
#include <pc98/pc98/pc98_machdep.h>
#include <pc98/pc98/epsonio.h>
#include <pc98/pc98/fdreg.h>
-#include <isa/fdc.h>
#else
#include <isa/isareg.h>
#include <isa/fdreg.h>
-#include <isa/fdc.h>
#include <isa/rtc.h>
#endif
+enum fdc_type
+{
+ FDC_NE765, FDC_I82077, FDC_NE72065, FDC_UNKNOWN = -1
+};
+
+enum fdc_states {
+ DEVIDLE,
+ FINDWORK,
+ DOSEEK,
+ SEEKCOMPLETE ,
+ IOCOMPLETE,
+ RECALCOMPLETE,
+ STARTRECAL,
+ RESETCTLR,
+ SEEKWAIT,
+ RECALWAIT,
+ MOTORWAIT,
+ IOTIMEDOUT,
+ RESETCOMPLETE,
+ PIOREAD
+};
+
+#ifdef FDC_DEBUG
+static char const * const fdstates[] = {
+ "DEVIDLE",
+ "FINDWORK",
+ "DOSEEK",
+ "SEEKCOMPLETE",
+ "IOCOMPLETE",
+ "RECALCOMPLETE",
+ "STARTRECAL",
+ "RESETCTLR",
+ "SEEKWAIT",
+ "RECALWAIT",
+ "MOTORWAIT",
+ "IOTIMEDOUT",
+ "RESETCOMPLETE",
+ "PIOREAD"
+};
+#endif
+
+/*
+ * Per controller structure (softc).
+ */
+struct fdc_data
+{
+ int fdcu; /* our unit number */
+ int dmachan;
+ int flags;
+#define FDC_ATTACHED 0x01
+#define FDC_STAT_VALID 0x08
+#define FDC_HAS_FIFO 0x10
+#define FDC_NEEDS_RESET 0x20
+#define FDC_NODMA 0x40
+#define FDC_ISPNP 0x80
+#define FDC_ISPCMCIA 0x100
+ struct fd_data *fd;
+ int fdu; /* the active drive */
+ enum fdc_states state;
+ int retry;
+#ifndef PC98
+ int fdout; /* mirror of the w/o digital output reg */
+#endif
+ u_int status[7]; /* copy of the registers */
+ enum fdc_type fdct; /* chip version of FDC */
+ int fdc_errs; /* number of logged errors */
+ int dma_overruns; /* number of DMA overruns */
+ struct bio_queue_head head;
+ struct bio *bp; /* active buffer */
+#ifdef PC98
+ struct resource *res_ioport, *res_fdsio, *res_fdemsio;
+ struct resource *res_irq, *res_drq;
+ int rid_ioport, rid_irq, rid_drq;
+#else
+ struct resource *res_ioport, *res_ctl, *res_irq, *res_drq;
+ int rid_ioport, rid_ctl, rid_irq, rid_drq;
+#endif
+ int port_off;
+ bus_space_tag_t portt;
+ bus_space_handle_t porth;
+#ifdef PC98
+ bus_space_tag_t sc_fdsiot;
+ bus_space_handle_t sc_fdsioh;
+ bus_space_tag_t sc_fdemsiot;
+ bus_space_handle_t sc_fdemsioh;
+#else
+ bus_space_tag_t ctlt;
+ bus_space_handle_t ctlh;
+#endif
+ void *fdc_intr;
+ struct device *fdc_dev;
+#ifndef PC98
+ void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v);
+#endif
+};
+
+typedef int fdu_t;
+typedef int fdcu_t;
+typedef int fdsu_t;
+typedef struct fd_data *fd_p;
+typedef struct fdc_data *fdc_p;
+typedef enum fdc_type fdc_t;
+
+#define FDUNIT(s) (((s) >> 6) & 3)
+#define FDTYPE(s) ((s) & 0x3f)
+
+/*
+ * fdc maintains a set (1!) of ivars per child of each controller.
+ */
+enum fdc_device_ivars {
+ FDC_IVAR_FDUNIT,
+};
+
+/*
+ * Simple access macros for the ivars.
+ */
+#define FDC_ACCESSOR(A, B, T) \
+static __inline T fdc_get_ ## A(device_t dev) \
+{ \
+ uintptr_t v; \
+ BUS_READ_IVAR(device_get_parent(dev), dev, FDC_IVAR_ ## B, &v); \
+ return (T) v; \
+}
+FDC_ACCESSOR(fdunit, FDUNIT, int)
+
/* configuration flags */
#define FDC_PRETEND_D0 (1 << 0) /* pretend drive 0 to be there */
#define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */
OpenPOWER on IntegriCloud