Integrate fdc.h into fd.c.

This commit is contained in:
Yoshihiro Takahashi 2001-07-23 13:07:24 +00:00
parent 27e79ba285
commit 99df3e3b1a
2 changed files with 250 additions and 4 deletions

View File

@ -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 */

View File

@ -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 */