Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | #ifndef _LINUX_FD_H |
2 | #define _LINUX_FD_H |
||
3 | |||
4 | #include <linux/ioctl.h> |
||
5 | |||
6 | /* New file layout: Now the ioctl definitions immediately follow the |
||
7 | * definitions of the structures that they use */ |
||
8 | |||
9 | /* |
||
10 | * Geometry |
||
11 | */ |
||
12 | struct floppy_struct { |
||
13 | unsigned int size, /* nr of sectors total */ |
||
14 | sect, /* sectors per track */ |
||
15 | head, /* nr of heads */ |
||
16 | track, /* nr of tracks */ |
||
17 | stretch; /* !=0 means double track steps */ |
||
18 | #define FD_STRETCH 1 |
||
19 | #define FD_SWAPSIDES 2 |
||
20 | |||
21 | unsigned char gap, /* gap1 size */ |
||
22 | |||
23 | rate, /* data rate. |= 0x40 for perpendicular */ |
||
24 | #define FD_2M 0x4 |
||
25 | #define FD_SIZECODEMASK 0x38 |
||
26 | #define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) |
||
27 | #define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ |
||
28 | 512 : 128 << FD_SIZECODE(floppy) ) |
||
29 | #define FD_PERP 0x40 |
||
30 | |||
31 | spec1, /* stepping rate, head unload time */ |
||
32 | fmt_gap; /* gap2 size */ |
||
33 | const char * name; /* used only for predefined formats */ |
||
34 | }; |
||
35 | |||
36 | |||
37 | /* commands needing write access have 0x40 set */ |
||
38 | /* commands needing super user access have 0x80 set */ |
||
39 | |||
40 | #define FDCLRPRM _IO(2, 0x41) |
||
41 | /* clear user-defined parameters */ |
||
42 | |||
43 | #define FDSETPRM _IOW(2, 0x42, struct floppy_struct) |
||
44 | #define FDSETMEDIAPRM FDSETPRM |
||
45 | /* set user-defined parameters for current media */ |
||
46 | |||
47 | #define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) |
||
48 | #define FDGETPRM _IOR(2, 0x04, struct floppy_struct) |
||
49 | #define FDDEFMEDIAPRM FDDEFPRM |
||
50 | #define FDGETMEDIAPRM FDGETPRM |
||
51 | /* set/get disk parameters */ |
||
52 | |||
53 | |||
54 | #define FDMSGON _IO(2,0x45) |
||
55 | #define FDMSGOFF _IO(2,0x46) |
||
56 | /* issue/don't issue kernel messages on media type change */ |
||
57 | |||
58 | |||
59 | /* |
||
60 | * Formatting (obsolete) |
||
61 | */ |
||
62 | #define FD_FILL_BYTE 0xF6 /* format fill byte. */ |
||
63 | |||
64 | struct format_descr { |
||
65 | unsigned int device,head,track; |
||
66 | }; |
||
67 | |||
68 | #define FDFMTBEG _IO(2,0x47) |
||
69 | /* begin formatting a disk */ |
||
70 | #define FDFMTTRK _IOW(2,0x48, struct format_descr) |
||
71 | /* format the specified track */ |
||
72 | #define FDFMTEND _IO(2,0x49) |
||
73 | /* end formatting a disk */ |
||
74 | |||
75 | |||
76 | /* |
||
77 | * Error thresholds |
||
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 | #define FDSETEMSGTRESH _IO(2,0x4a) |
||
98 | /* set fdc error reporting threshold */ |
||
99 | |||
100 | #define FDFLUSH _IO(2,0x4b) |
||
101 | /* flush buffers for media; either for verifying media, or for |
||
102 | * handling a media change without closing the file descriptor */ |
||
103 | |||
104 | #define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) |
||
105 | #define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) |
||
106 | /* set/get abortion and read_track threshold. See also floppy_drive_params |
||
107 | * structure */ |
||
108 | |||
109 | |||
110 | typedef char floppy_drive_name[16]; |
||
111 | #define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) |
||
112 | /* get drive type: 5 1/4 or 3 1/2 */ |
||
113 | |||
114 | |||
115 | /* |
||
116 | * Drive parameters (user modifiable) |
||
117 | */ |
||
118 | struct floppy_drive_params { |
||
119 | signed char cmos; /* CMOS type */ |
||
120 | |||
121 | /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms |
||
122 | * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). |
||
123 | */ |
||
124 | unsigned long max_dtr; /* Step rate, usec */ |
||
125 | unsigned long hlt; /* Head load/settle time, msec */ |
||
126 | unsigned long hut; /* Head unload time (remnant of |
||
127 | * 8" drives) */ |
||
128 | unsigned long srt; /* Step rate, usec */ |
||
129 | |||
130 | unsigned long spinup; /* time needed for spinup (expressed |
||
131 | * in jiffies) */ |
||
132 | unsigned long spindown; /* timeout needed for spindown */ |
||
133 | unsigned char spindown_offset; /* decides in which position the disk |
||
134 | * will stop */ |
||
135 | unsigned char select_delay; /* delay to wait after select */ |
||
136 | unsigned char rps; /* rotations per second */ |
||
137 | unsigned char tracks; /* maximum number of tracks */ |
||
138 | unsigned long timeout; /* timeout for interrupt requests */ |
||
139 | |||
140 | unsigned char interleave_sect; /* if there are more sectors, use |
||
141 | * interleave */ |
||
142 | |||
143 | struct floppy_max_errors max_errors; |
||
144 | |||
145 | char flags; /* various flags, including ftd_msg */ |
||
146 | /* |
||
147 | * Announce successful media type detection and media information loss after |
||
148 | * disk changes. |
||
149 | * Also used to enable/disable printing of overrun warnings. |
||
150 | */ |
||
151 | |||
152 | #define FTD_MSG 0x10 |
||
153 | #define FD_BROKEN_DCL 0x20 |
||
154 | #define FD_DEBUG 0x02 |
||
155 | #define FD_SILENT_DCL_CLEAR 0x4 |
||
156 | #define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware |
||
157 | considerations */ |
||
158 | |||
159 | char read_track; /* use readtrack during probing? */ |
||
160 | |||
161 | /* |
||
162 | * Auto-detection. Each drive type has eight formats which are |
||
163 | * used in succession to try to read the disk. If the FDC cannot lock onto |
||
164 | * the disk, the next format is tried. This uses the variable 'probing'. |
||
165 | */ |
||
166 | short autodetect[8]; /* autodetected formats */ |
||
167 | |||
168 | int checkfreq; /* how often should the drive be checked for disk |
||
169 | * changes */ |
||
170 | int native_format; /* native format of this drive */ |
||
171 | }; |
||
172 | |||
173 | enum { |
||
174 | FD_NEED_TWADDLE_BIT, /* more magic */ |
||
175 | FD_VERIFY_BIT, /* inquire for write protection */ |
||
176 | FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet |
||
177 | * to clear media change status */ |
||
178 | FD_UNUSED_BIT, |
||
179 | FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ |
||
180 | FD_DISK_WRITABLE_BIT /* disk is writable */ |
||
181 | }; |
||
182 | |||
183 | #define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) |
||
184 | #define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) |
||
185 | /* set/get drive parameters */ |
||
186 | |||
187 | |||
188 | /* |
||
189 | * Current drive state (not directly modifiable by user, readonly) |
||
190 | */ |
||
191 | struct floppy_drive_struct { |
||
192 | unsigned long flags; |
||
193 | /* values for these flags */ |
||
194 | #define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) |
||
195 | #define FD_VERIFY (1 << FD_VERIFY_BIT) |
||
196 | #define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) |
||
197 | #define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) |
||
198 | #define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) |
||
199 | |||
200 | unsigned long spinup_date; |
||
201 | unsigned long select_date; |
||
202 | unsigned long first_read_date; |
||
203 | short probed_format; |
||
204 | short track; /* current track */ |
||
205 | short maxblock; /* id of highest block read */ |
||
206 | short maxtrack; /* id of highest half track read */ |
||
207 | int generation; /* how many diskchanges? */ |
||
208 | |||
209 | /* |
||
210 | * (User-provided) media information is _not_ discarded after a media change |
||
211 | * if the corresponding keep_data flag is non-zero. Positive values are |
||
212 | * decremented after each probe. |
||
213 | */ |
||
214 | int keep_data; |
||
215 | |||
216 | /* Prevent "aliased" accesses. */ |
||
217 | int fd_ref; |
||
218 | int fd_device; |
||
219 | unsigned long last_checked; /* when was the drive last checked for a disk |
||
220 | * change? */ |
||
221 | |||
222 | char *dmabuf; |
||
223 | int bufblocks; |
||
224 | }; |
||
225 | |||
226 | #define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) |
||
227 | #define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) |
||
228 | /* get drive state: GET returns the cached state, POLL polls for new state */ |
||
229 | |||
230 | |||
231 | /* |
||
232 | * reset FDC |
||
233 | */ |
||
234 | enum reset_mode { |
||
235 | FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ |
||
236 | FD_RESET_IF_RAWCMD, /* obsolete */ |
||
237 | FD_RESET_ALWAYS /* reset always */ |
||
238 | }; |
||
239 | #define FDRESET _IO(2, 0x54) |
||
240 | |||
241 | |||
242 | /* |
||
243 | * FDC state |
||
244 | */ |
||
245 | struct floppy_fdc_state { |
||
246 | int spec1; /* spec1 value last used */ |
||
247 | int spec2; /* spec2 value last used */ |
||
248 | int dtr; |
||
249 | unsigned char version; /* FDC version code */ |
||
250 | unsigned char dor; |
||
251 | unsigned long address; /* io address */ |
||
252 | unsigned int rawcmd:2; |
||
253 | unsigned int reset:1; |
||
254 | unsigned int need_configure:1; |
||
255 | unsigned int perp_mode:2; |
||
256 | unsigned int has_fifo:1; |
||
257 | unsigned int driver_version; /* version code for floppy driver */ |
||
258 | #define FD_DRIVER_VERSION 0x100 |
||
259 | /* user programs using the floppy API should use floppy_fdc_state to |
||
260 | * get the version number of the floppy driver that they are running |
||
261 | * on. If this version number is bigger than the one compiled into the |
||
262 | * user program (the FD_DRIVER_VERSION define), it should be prepared |
||
263 | * to bigger structures |
||
264 | */ |
||
265 | |||
266 | unsigned char track[4]; |
||
267 | /* Position of the heads of the 4 units attached to this FDC, |
||
268 | * as stored on the FDC. In the future, the position as stored |
||
269 | * on the FDC might not agree with the actual physical |
||
270 | * position of these drive heads. By allowing such |
||
271 | * disagreement, it will be possible to reset the FDC without |
||
272 | * incurring the expensive cost of repositioning all heads. |
||
273 | * Right now, these positions are hard wired to 0. */ |
||
274 | |||
275 | }; |
||
276 | |||
277 | #define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) |
||
278 | |||
279 | |||
280 | /* |
||
281 | * Asynchronous Write error tracking |
||
282 | */ |
||
283 | struct floppy_write_errors { |
||
284 | /* Write error logging. |
||
285 | * |
||
286 | * These fields can be cleared with the FDWERRORCLR ioctl. |
||
287 | * Only writes that were attempted but failed due to a physical media |
||
288 | * error are logged. write(2) calls that fail and return an error code |
||
289 | * to the user process are not counted. |
||
290 | */ |
||
291 | |||
292 | unsigned int write_errors; /* number of physical write errors |
||
293 | * encountered */ |
||
294 | |||
295 | /* position of first and last write errors */ |
||
296 | unsigned long first_error_sector; |
||
297 | int first_error_generation; |
||
298 | unsigned long last_error_sector; |
||
299 | int last_error_generation; |
||
300 | |||
301 | unsigned int badness; /* highest retry count for a read or write |
||
302 | * operation */ |
||
303 | }; |
||
304 | |||
305 | #define FDWERRORCLR _IO(2, 0x56) |
||
306 | /* clear write error and badness information */ |
||
307 | #define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) |
||
308 | /* get write error and badness information */ |
||
309 | |||
310 | |||
311 | /* |
||
312 | * Raw commands |
||
313 | */ |
||
314 | /* new interface flag: now we can do them in batches */ |
||
315 | #define FDHAVEBATCHEDRAWCMD |
||
316 | |||
317 | struct floppy_raw_cmd { |
||
318 | unsigned int flags; |
||
319 | #define FD_RAW_READ 1 |
||
320 | #define FD_RAW_WRITE 2 |
||
321 | #define FD_RAW_NO_MOTOR 4 |
||
322 | #define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ |
||
323 | #define FD_RAW_INTR 8 /* wait for an interrupt */ |
||
324 | #define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ |
||
325 | #define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command |
||
326 | * completion */ |
||
327 | #define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ |
||
328 | #define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ |
||
329 | |||
330 | /* more "in" flags */ |
||
331 | #define FD_RAW_MORE 0x100 /* more records follow */ |
||
332 | #define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ |
||
333 | #define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ |
||
334 | #define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure |
||
335 | * detection too */ |
||
336 | |||
337 | /* more "out" flags */ |
||
338 | #define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ |
||
339 | #define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ |
||
340 | |||
341 | void *data; |
||
342 | char *kernel_data; /* location of data buffer in the kernel */ |
||
343 | struct floppy_raw_cmd *next; /* used for chaining of raw cmd's |
||
344 | * within the kernel */ |
||
345 | long length; /* in: length of dma transfer. out: remaining bytes */ |
||
346 | long phys_length; /* physical length, if different from dma length */ |
||
347 | int buffer_length; /* length of allocated buffer */ |
||
348 | |||
349 | unsigned char rate; |
||
350 | unsigned char cmd_count; |
||
351 | unsigned char cmd[16]; |
||
352 | unsigned char reply_count; |
||
353 | unsigned char reply[16]; |
||
354 | int track; |
||
355 | int resultcode; |
||
356 | |||
357 | int reserved1; |
||
358 | int reserved2; |
||
359 | }; |
||
360 | |||
361 | #define FDRAWCMD _IO(2, 0x58) |
||
362 | /* send a raw command to the fdc. Structure size not included, because of |
||
363 | * batches */ |
||
364 | |||
365 | #define FDTWADDLE _IO(2, 0x59) |
||
366 | /* flicker motor-on bit before reading a sector. Experimental */ |
||
367 | |||
368 | |||
369 | #define FDEJECT _IO(2, 0x5a) |
||
370 | /* eject the disk */ |
||
371 | |||
372 | #endif |