1 #ifndef_LINUX_FD_H 2 #define_LINUX_FD_H 3
4 #defineFDCLRPRM 0 /* clear user-defined parameters */ 5 #defineFDSETPRM 1 /* set user-defined parameters for current media */ 6 #define FDSETMEDIAPRM 1
7 #defineFDDEFPRM 2 /* set user-defined parameters until explicitly cleared */ 8 #define FDDEFMEDIAPRM 2
9 #defineFDGETPRM 3 /* get disk parameters */ 10 #define FDGETMEDIAPRM 3
11 #defineFDMSGON 4 /* issue kernel messages on media type change */ 12 #defineFDMSGOFF 5 /* don't issue kernel messages on media type change */ 13 #defineFDFMTBEG 6 /* begin formatting a disk */ 14 #defineFDFMTTRK 7 /* format the specified track */ 15 #defineFDFMTEND 8 /* end formatting a disk */ 16 #defineFDSETEMSGTRESH 10 /* set fdc error reporting threshold */ 17 #defineFDFLUSH 11 /* flush buffers for media; either for verifying media, or for 18 handling a media change without closing the file 19 descriptor */ 20 #defineFDSETMAXERRS 12 /* set abortion and read_track threshold */ 21 #defineFDGETMAXERRS 14 /* get abortion and read_track threshold */ 22 #defineFDGETDRVTYP 16 /* get drive type: 5 1/4 or 3 1/2 */ 23
24 #defineFDSETDRVPRM 20 /* set drive parameters */ 25 #defineFDGETDRVPRM 21 /* get drive parameters */ 26 #defineFDGETDRVSTAT 22 /* get drive state */ 27 #defineFDPOLLDRVSTAT 23 /* get drive state */ 28 #defineFDRESET 24 /* reset FDC */ 29
30 #defineFD_RESET_IF_NEEDED 0
31 #define FD_RESET_IF_RAWCMD 1
32 #defineFD_RESET_ALWAYS 2
33
34 #defineFDGETFDCSTAT 25 /* get fdc state */ 35 #defineFDWERRORCLR 27 /* clear write error and badness information */ 36 #defineFDWERRORGET 28 /* get write error and badness information */ 37
38 #defineFDRAWCMD 30 /* send a raw command to the fdc */ 39
40 #defineFDTWADDLE 40 /* flicker motor-on bit before reading a sector */ 41
42 /* 43 * Maximum number of sectors in a track buffer. Track buffering is disabled 44 * if tracks are bigger. 45 */ 46 #defineMAX_BUFFER_SECTORS 24 /* was 18 -bb */ 47
48 #defineFD_FILL_BYTE 0xF6 /* format fill byte */ 49
50 #defineFD_2M 0x4
51 #defineFD_SIZECODEMASK 0x38
52 #defineFD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
53 #define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
54 512 : 128 << FD_SIZECODE(floppy) )
55 #define FD_PERP 0x40
56
57 #ifndef__ASSEMBLY__ 58 /* the following structure is used by FDSETPRM, FDDEFPRM and FDGETPRM */ 59 structfloppy_struct{ 60 unsignedintsize, /* nr of sectors total */ 61 sect, /* sectors per track */ 62 head, /* nr of heads */ 63 track, /* nr of tracks */ 64 stretch; /* !=0 means double track steps */ 65 unsignedchargap, /* gap1 size */ 66 rate, /* data rate. |= 0x40 for perpendicular */ 67 spec1, /* stepping rate, head unload time */ 68 fmt_gap; /* gap2 size */ 69 char * name; /* used only for predefined formats */ 70 };
71
72 structformat_descr{ 73 unsignedintdevice,head,track;
74 };
75
76 structfloppy_max_errors{ 77 unsignedint 78 abort, /* number of errors to be reached before aborting */ 79 read_track, /* maximal number of errors permitted to read an 80 * entire track at once */ 81 reset, /* maximal number of errors before a reset is tried */ 82 recal, /* maximal number of errors before a recalibrate is 83 * tried */ 84
85 /* 86 * Threshold for reporting FDC errors to the console. 87 * Setting this to zero may flood your screen when using 88 * ultra cheap floppies ;-) 89 */ 90 reporting;
91
92 };
93
94 /* the following structure is used by FDSETDRVPRM and FDGETDRVPRM */ 95 structfloppy_drive_params{ 96 char cmos; /* cmos type */ 97
98 /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc) 99 * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). 100 */ 101 unsignedlong max_dtr; /* Step rate, usec */ 102 unsignedlonghlt; /* Head load/settle time, msec */ 103 unsignedlonghut; /* Head unload time (remnant of 8" drives) */ 104 unsignedlongsrt; /* Step rate, usec */ 105
106 unsignedlongspinup; /* time needed for spinup ( in jiffies) */ 107 unsignedlongspindown; /* timeout needed for spindown */ 108 unsignedcharspindown_offset;/* decides in which position the disk 109 * will stop */ 110 unsignedcharselect_delay; /* delay to wait after select */ 111 unsignedcharrps; /* rotations per second */ 112 unsignedchartracks; /* maximum number of tracks */ 113 unsignedlongtimeout; /* timeout for interrupt requests */ 114
115 unsignedcharinterleave_sect;/* if there are more sectors, use interleave */ 116
117 structfloppy_max_errorsmax_errors;
118
119 charflags; /* various flags, including ftd_msg */ 120 /* 121 * Announce successful media type detection and media information loss after 122 * disk changes. 123 * Also used to enable/disable printing of overrun warnings. 124 */ 125
126 #defineFTD_MSG 0x10
127 #defineFD_BROKEN_DCL 0x20
128 #defineFD_DEBUG 0x02
129 #defineFD_SILENT_DCL_CLEAR 0x4
130
131 charread_track; /* use readtrack during probing? */ 132
133 /* 134 * Auto-detection. Each drive type has eight formats which are 135 * used in succession to try to read the disk. If the FDC cannot lock onto 136 * the disk, the next format is tried. This uses the variable 'probing'. 137 */ 138 shortautodetect[8]; /* autodetected formats */ 139
140 intcheckfreq; /* how often should the drive be checked for disk changes */ 141 intnative_format; /* native format of this drive */ 142 };
143
144 enum{ 145 FD_NEED_TWADDLE_BIT, /* more magic */ 146 FD_VERIFY_BIT, /* inquire for write protection */ 147 FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet to 148 clear media change status */ 149 FD_UNUSED_BIT,
150 FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ 151 FD_DISK_WRITABLE_BIT/* disk is writable */ 152 };
153
154 /* values for these flags */ 155 #defineFD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
156 #defineFD_VERIFY (1 << FD_VERIFY_BIT)
157 #defineFD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
158 #defineFD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
159 #defineFD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
160
161 #define FD_DRIVE_PRESENT 0 /* keep fdpatch utils compiling */ 162
163 structfloppy_drive_struct{ 164 signedcharflags;
165 unsignedlongspinup_date;
166 unsignedlongselect_date;
167 unsignedlongfirst_read_date;
168 shortprobed_format;
169 shorttrack; /* current track */ 170 shortmaxblock; /* id of highest block read */ 171 shortmaxtrack; /* id of highest half track read */ 172 intgeneration; /* how many diskchanges? */ 173
174 /* 175 * (User-provided) media information is _not_ discarded after a media change 176 * if the corresponding keep_data flag is non-zero. Positive values are 177 * decremented after each probe. 178 */ 179 intkeep_data;
180
181 /* Prevent "aliased" accesses. */ 182 intfd_ref;
183 intfd_device;
184 intlast_checked; /* when was the drive last checked for a disk change? */ 185
186
187 };
188
189 structfloppy_write_errors{ 190 /* Write error logging. 191 * 192 * These fields can be cleared with the FDWERRORCLR ioctl. 193 * Only writes that were attempted but failed due to a physical media 194 * error are logged. write(2) calls that fail and return an error code 195 * to the user process are not counted. 196 */ 197
198 unsignedintwrite_errors; /* number of physical write errors encountered */ 199
200 /* position of first and last write errors */ 201 unsignedlongfirst_error_sector;
202 intfirst_error_generation;
203 unsignedlonglast_error_sector;
204 intlast_error_generation;
205
206 unsignedintbadness; /* highest retry count for a read or write operation */ 207 };
208
209 structfloppy_fdc_state{ 210 intspec1; /* spec1 value last used */ 211 intspec2; /* spec2 value last used */ 212 intdtr;
213 unsignedcharversion; /* FDC version code */ 214 unsignedchardor;
215 intaddress; /* io address */ 216 unsignedintrawcmd:2;
217 unsignedintreset:1;
218 unsignedintneed_configure:1;
219 unsignedintperp_mode:2;
220 unsignedinthas_fifo:1;
221 };
222
223 structfloppy_raw_cmd{ 224 void *data;
225 longlength;
226
227 unsignedcharrate;
228 unsignedcharflags;
229 unsignedcharcmd_count;
230 unsignedcharcmd[9];
231 unsignedcharreply_count;
232 unsignedcharreply[7];
233 inttrack;
234 };
235 #endif 236
237 /* meaning of the various bytes */ 238
239 /* flags */ 240 #defineFD_RAW_READ 1
241 #defineFD_RAW_WRITE 2
242 #defineFD_RAW_NO_MOTOR 4
243 #defineFD_RAW_DISK_CHANGE 4
244 #defineFD_RAW_INTR 8
245 #defineFD_RAW_SPIN 16
246 #defineFD_RAW_NO_MOTOR_AFTER 32
247 #defineFD_RAW_NEED_DISK 64
248 #defineFD_RAW_NEED_SEEK 128
249
250 #endif