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