1 typedef struct FController FController;
2 typedef struct FDrive FDrive;
3 typedef struct FType FType;
5 static void floppyintr(Ureg*);
6 static int floppyon(FDrive*);
7 static void floppyoff(FDrive*);
8 static void floppysetdef(FDrive*);
15 FType *t; /* floppy type */
16 int dt; /* drive type */
19 ulong lasttouched; /* time last touched */
20 int cyl; /* current arm position */
21 int confused; /* needs to be recalibrated */
23 int maxtries; /* max read attempts before Eio */
25 int tcyl; /* target cylinder */
26 int thead; /* target head */
27 int tsec; /* target sector */
28 long len; /* size of xfer */
30 uchar *cache; /* track cache */
34 Rendez r; /* waiting here for motor to spin up */
38 * controller for 4 floppys
42 QLock; /* exclusive access to the contoller */
45 FDrive *d; /* the floppy drives */
47 int rate; /* current rate selected */
48 uchar cmd[14]; /* command */
49 int ncmd; /* # command bytes */
50 uchar stat[14]; /* command status */
51 int nstat; /* # status bytes */
52 int confused; /* controler needs to be reset */
53 Rendez r; /* wait here for command termination */
54 int motor; /* bit mask of spinning disks */
55 Rendez kr; /* for motor watcher */
59 * floppy types (all MFM encoding)
64 int dt; /* compatible drive type */
65 int bytes; /* bytes/sector */
66 int sectors; /* sectors/track */
67 int heads; /* number of heads */
68 int steps; /* steps per cylinder */
69 int tracks; /* tracks/disk */
70 int gpl; /* intersector gap length for read/write */
71 int fgpl; /* intersector gap length for format */
72 int rate; /* rate code */
75 * these depend on previous entries and are set filled in
78 int bcode; /* coded version of bytes for the controller */
79 long cap; /* drive capacity in bytes */
80 long tsize; /* track size in bytes */
82 /* bits in the registers */
85 /* status registers a & b */
89 /* digital output register */
91 Fintena= 0x8, /* enable floppy interrupt */
92 Fena= 0x4, /* 0 == reset controller */
94 /* main status register */
96 Fready= 0x80, /* ready to be touched */
97 Ffrom= 0x40, /* data from controller */
98 Ffloppybusy= 0x10, /* operation not over */
102 Frecal= 0x07, /* recalibrate cmd */
103 Fseek= 0x0f, /* seek cmd */
104 Fsense= 0x08, /* sense cmd */
105 Fread= 0x66, /* read cmd */
106 Freadid= 0x4a, /* read track id */
107 Fspec= 0x03, /* set hold times */
108 Fwrite= 0x45, /* write cmd */
109 Fformat= 0x4d, /* format cmd */
110 Fmulti= 0x80, /* or'd with Fread or Fwrite for multi-head */
111 Fdumpreg= 0x0e, /* dump internal registers */
113 /* digital input register */
114 Pdir= 0x3F7, /* disk changed port (read only) */
115 Pdsr= 0x3F7, /* data rate select port (write only) */
116 Fchange= 0x80, /* disk has changed */
121 Codemask= (3<<6)|(3<<3),
130 pcfloppyintr(Ureg *ur, void *a)
138 floppysetup0(FController *fl)
141 if(ioalloc(Psra, 6, 0, "floppy") < 0)
143 if(ioalloc(Pdir, 1, 0, "floppy") < 0){
151 floppysetup1(FController *fl)
155 floppysetdef(&fl->d[0]);
159 floppysetdef(&fl->d[1]);
162 intrenable(IrqFLOPPY, pcfloppyintr, fl, BUSUNKNOWN, "floppy");
169 floppyeject(FDrive *dp)
177 floppyexec(char *a, long b, int c)