1 #ifndef _LINUX_FD_H 2 #define _LINUX_FD_H 3 4 #define FDCLRPRM 0 /* clear user-defined parameters */ 5 #define FDSETPRM 1 /* set user-defined parameters for current media */ 6 #define FDSETMEDIAPRM 1 7 #define FDDEFPRM 2 /* set user-defined parameters until explicitly cleared */ 8 #define FDDEFMEDIAPRM 2 9 #define FDGETPRM 3 /* get disk parameters */ 10 #define FDGETMEDIAPRM 3 11 #define FDMSGON 4 /* issue kernel messages on media type change */ 12 #define FDMSGOFF 5 /* don't issue kernel messages on media type change */ 13 #define FDFMTBEG 6 /* begin formatting a disk */ 14 #define FDFMTTRK 7 /* format the specified track */ 15 #define FDFMTEND 8 /* end formatting a disk */ 16 #define FDSETEMSGTRESH 10 /* set fdc error reporting threshold */ 17 #define FDFLUSH 11 /* flush buffers for media; either for verifying media, or for 18 handling a media change without closing the file 19 descriptor */ 20 #define FDSETMAXERRS 12 /* set abortion and read_track threshold */ 21 #define FDGETMAXERRS 14 /* get abortion and read_track threshold */ 22 #define FDGETDRVTYP 16 /* get drive type: 5 1/4 or 3 1/2 */ 23 24 #define FDSETDRVPRM 20 /* set drive parameters */ 25 #define FDGETDRVPRM 21 /* get drive parameters */ 26 #define FDGETDRVSTAT 22 /* get drive state */ 27 #define FDPOLLDRVSTAT 23 /* get drive state */ 28 #define FDGETFDCSTAT 25 /* get fdc state */ 29 #define FDWERRORCLR 27 /* clear write error and badness information */ 30 #define FDWERRORGET 28 /* get write error and badness information */ 31 32 #define FDRESET 24 /* reset FDC */ 33 #define FD_RESET_IF_NEEDED 0 34 #define FD_RESET_IF_RAWCMD 1 35 #define FD_RESET_ALWAYS 2 36 37 #define FDBAILOUT 26 /* release all fdc locks */ 38 #define FD_CLEAR_RESET 0 39 #define FD_COMPLETE_FORMAT 1 40 #define FD_UNLOCK_FDC 2 41 42 #define FDRAWCMD 30 /* send a raw command to the fdc */ 43 44 #define FDTWADDLE 40 /* flicker motor-on bit before reading a sector */ 45 46 /* 47 * Maximum number of sectors in a track buffer. Track buffering is disabled 48 * if tracks are bigger. 49 */ 50 #define MAX_BUFFER_SECTORS 24 /* was 18 -bb */ 51 52 #define FD_FILL_BYTE 0xF6 /* format fill byte */ 53 54 #define FD_2M 0x4 55 #define FD_SIZECODEMASK 0x38 56 #define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) 57 #define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ 58 512 : 128 << FD_SIZECODE(floppy) ) 59 #define FD_PERP 0x40 60 61 #ifndef ASSEMBLER 62 struct floppy_struct { 63 unsigned int size, /* nr of sectors total */ 64 sect, /* sectors per track */ 65 head, /* nr of heads */ 66 track, /* nr of tracks */ 67 stretch; /* !=0 means double track steps */ 68 unsigned char gap, /* gap1 size */ 69 rate, /* data rate. |= 0x40 for perpendicular */ 70 spec1, /* stepping rate, head unload time */ 71 fmt_gap; /* gap2 size */ 72 char * name; /* used only for predefined formats */ 73 }; 74 75 struct format_descr { 76 unsigned int device,head,track; 77 }; 78 79 struct floppy_max_errors { 80 unsigned int 81 abort, /* number of errors to be reached before aborting */ 82 read_track, /* maximal number of errors permitted to read an 83 * entire track at once */ 84 reset, /* maximal number of errors before a reset is tried */ 85 recal, /* maximal number of errors before a recalibrate is 86 * tried */ 87 88 /* 89 * Threshold for reporting FDC errors to the console. 90 * Setting this to zero may flood your screen when using 91 * ultra cheap floppies ;-) 92 */ 93 reporting; 94 95 }; 96 97 struct floppy_drive_params { 98 char cmos; /* cmos type */ 99 100 /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc) 101 * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). 102 */ 103 unsigned long max_dtr; /* Step rate, usec */ 104 unsigned long hlt; /* Head load/settle time, msec */ 105 unsigned long hut; /* Head unload time (remnant of 8" drives) */ 106 unsigned long srt; /* Step rate, usec */ 107 108 unsigned long spinup; /* time needed for spinup ( in jiffies) */ 109 unsigned long spindown; /* timeout needed for spindown */ 110 unsigned char spindown_offset;/* decides in which position the disk 111 * will stop */ 112 unsigned char select_delay; /* delay to wait after select */ 113 unsigned char rps; /* rotations per second */ 114 unsigned char tracks; /* maximum number of tracks */ 115 unsigned long timeout; /* timeout for interrupt requests */ 116 117 unsigned char interleave_sect;/* if there are more sectors, use interleave */ 118 119 struct floppy_max_errors max_errors; 120 121 char flags; /* various flags, including ftd_msg */ 122 /* 123 * Announce successful media type detection and media information loss after 124 * disk changes. 125 * Also used to enable/disable printing of overrun warnings. 126 */ 127 #define FTD_MSG 0x10 128 129 char read_track; /* use readtrack during probing? */ 130 131 /* 132 * Auto-detection. Each drive type has eight formats which are 133 * used in succession to try to read the disk. If the FDC cannot lock onto 134 * the disk, the next format is tried. This uses the variable 'probing'. 135 */ 136 short autodetect[8]; /* autodetected formats */ 137 138 int checkfreq; /* how often should the drive be checked for disk changes */ 139 int native_format; /* native format of this drive */ 140 }; 141 142 struct floppy_drive_struct { 143 signed char flags; 144 145 /* values for these flags */ 146 #define FD_NEED_TWADDLE 1 /* more magic */ 147 #define FD_VERIFY 2 /* this is set at bootup to force an initial drive status 148 inquiry*/ 149 #define FD_DISK_NEWCHANGE 4 /* change detected, and no action undertaken yet to 150 clear media change status */ 151 #define FD_DRIVE_PRESENT 8 152 #define FD_DISK_WRITABLE 32 153 154 unsigned long volatile spinup_date; 155 unsigned long volatile select_date; 156 unsigned long volatile first_read_date; 157 short probed_format; 158 short track; /* current track */ 159 short maxblock; /* id of highest block read */ 160 short maxtrack; /* id of highest half track read */ 161 int generation; /* how many diskchanges? */ 162 163 /* 164 * (User-provided) media information is _not_ discarded after a media change 165 * if the corresponding keep_data flag is non-zero. Positive values are 166 * decremented after each probe. 167 */ 168 int keep_data; 169 170 /* Prevent "aliased" accesses. */ 171 int fd_ref; 172 int fd_device; 173 int last_checked; /* when was the drive last checked for a disk change? */ 174 175 176 }; 177 178 struct floppy_write_errors { 179 /* Write error logging. 180 * 181 * These fields can be cleared with the FDWERRORCLR ioctl. 182 * Only writes that were attempted but failed due to a physical media 183 * error are logged. write(2) calls that fail and return an error code 184 * to the user process are not counted. 185 */ 186 187 unsigned int write_errors; /* number of physical write errors encountered */ 188 189 /* position of first and last write errors */ 190 unsigned long first_error_sector; 191 int first_error_generation; 192 unsigned long last_error_sector; 193 int last_error_generation; 194 195 unsigned int badness; /* highest retry count for a read or write operation */ 196 }; 197 198 struct floppy_fdc_state { 199 int spec1; /* spec1 value last used */ 200 int spec2; /* spec2 value last used */ 201 int dtr; 202 unsigned char version; /* FDC version code */ 203 unsigned char dor; 204 int address; /* io address */ 205 unsigned int rawcmd:2; 206 unsigned int reset:1; 207 unsigned int need_configure:1; 208 unsigned int perp_mode:2; 209 unsigned int has_fifo:1; 210 }; 211 212 struct floppy_raw_cmd { 213 void *data; 214 long length; 215 216 unsigned char rate; 217 unsigned char flags; 218 unsigned char cmd_count; 219 unsigned char cmd[9]; 220 unsigned char reply_count; 221 unsigned char reply[7]; 222 int track; 223 }; 224 #endif 225 226 /* meaning of the various bytes */ 227 228 /* flags */ 229 #define FD_RAW_READ 1 230 #define FD_RAW_WRITE 2 231 #define FD_RAW_INTR 8 232 #define FD_RAW_SPIN 16 233 #define FD_RAW_NEED_DISK 64 234 #define FD_RAW_NEED_SEEK 128 235 #define FD_RAW_USER_SUPPLIED 256 236 237 #endif