1#ifndef _LINUX_FD_H
2#define _LINUX_FD_H
3
4#include <linux/ioctl.h>
5#include <linux/compiler.h>
6
7
8
9
10
11
12
13struct floppy_struct {
14 unsigned int size,
15 sect,
16 head,
17 track,
18 stretch;
19
20
21
22#define FD_STRETCH 1
23#define FD_SWAPSIDES 2
24#define FD_ZEROBASED 4
25#define FD_SECTBASEMASK 0x3FC
26#define FD_MKSECTBASE(s) (((s) ^ 1) << 2)
27#define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1)
28
29 unsigned char gap,
30
31 rate,
32#define FD_2M 0x4
33#define FD_SIZECODEMASK 0x38
34#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
35#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
36 512 : 128 << FD_SIZECODE(floppy) )
37#define FD_PERP 0x40
38
39 spec1,
40 fmt_gap;
41 const char * name;
42};
43
44
45
46
47
48#define FDCLRPRM _IO(2, 0x41)
49
50
51#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
52#define FDSETMEDIAPRM FDSETPRM
53
54
55#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
56#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
57#define FDDEFMEDIAPRM FDDEFPRM
58#define FDGETMEDIAPRM FDGETPRM
59
60
61
62#define FDMSGON _IO(2,0x45)
63#define FDMSGOFF _IO(2,0x46)
64
65
66
67
68
69
70#define FD_FILL_BYTE 0xF6
71
72struct format_descr {
73 unsigned int device,head,track;
74};
75
76#define FDFMTBEG _IO(2,0x47)
77
78#define FDFMTTRK _IOW(2,0x48, struct format_descr)
79
80#define FDFMTEND _IO(2,0x49)
81
82
83
84
85
86
87struct floppy_max_errors {
88 unsigned int
89 abort,
90 read_track,
91
92 reset,
93 recal,
94
95
96
97
98
99
100
101 reporting;
102
103};
104
105#define FDSETEMSGTRESH _IO(2,0x4a)
106
107
108#define FDFLUSH _IO(2,0x4b)
109
110
111
112#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors)
113#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors)
114
115
116
117
118typedef char floppy_drive_name[16];
119#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
120
121
122
123
124
125
126struct floppy_drive_params {
127 signed char cmos;
128
129
130
131
132 unsigned long max_dtr;
133 unsigned long hlt;
134 unsigned long hut;
135
136 unsigned long srt;
137
138 unsigned long spinup;
139
140 unsigned long spindown;
141 unsigned char spindown_offset;
142
143 unsigned char select_delay;
144 unsigned char rps;
145 unsigned char tracks;
146 unsigned long timeout;
147
148 unsigned char interleave_sect;
149
150
151 struct floppy_max_errors max_errors;
152
153 char flags;
154
155
156
157
158
159
160#define FTD_MSG 0x10
161#define FD_BROKEN_DCL 0x20
162#define FD_DEBUG 0x02
163#define FD_SILENT_DCL_CLEAR 0x4
164#define FD_INVERTED_DCL 0x80
165
166
167 char read_track;
168
169
170
171
172
173
174 short autodetect[8];
175
176 int checkfreq;
177
178 int native_format;
179};
180
181enum {
182 FD_NEED_TWADDLE_BIT,
183 FD_VERIFY_BIT,
184 FD_DISK_NEWCHANGE_BIT,
185
186 FD_UNUSED_BIT,
187 FD_DISK_CHANGED_BIT,
188 FD_DISK_WRITABLE_BIT
189};
190
191#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
192#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
193
194
195
196
197
198
199struct floppy_drive_struct {
200 unsigned long flags;
201
202#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
203#define FD_VERIFY (1 << FD_VERIFY_BIT)
204#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
205#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
206#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
207
208 unsigned long spinup_date;
209 unsigned long select_date;
210 unsigned long first_read_date;
211 short probed_format;
212 short track;
213 short maxblock;
214 short maxtrack;
215 int generation;
216
217
218
219
220
221
222 int keep_data;
223
224
225 int fd_ref;
226 int fd_device;
227 unsigned long last_checked;
228
229
230 char *dmabuf;
231 int bufblocks;
232};
233
234#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
235#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
236
237
238
239
240
241
242enum reset_mode {
243 FD_RESET_IF_NEEDED,
244 FD_RESET_IF_RAWCMD,
245 FD_RESET_ALWAYS
246};
247#define FDRESET _IO(2, 0x54)
248
249
250
251
252
253struct floppy_fdc_state {
254 int spec1;
255 int spec2;
256 int dtr;
257 unsigned char version;
258 unsigned char dor;
259 unsigned long address;
260 unsigned int rawcmd:2;
261 unsigned int reset:1;
262 unsigned int need_configure:1;
263 unsigned int perp_mode:2;
264 unsigned int has_fifo:1;
265 unsigned int driver_version;
266#define FD_DRIVER_VERSION 0x100
267
268
269
270
271
272
273
274 unsigned char track[4];
275
276
277
278
279
280
281
282
283};
284
285#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
286
287
288
289
290
291struct floppy_write_errors {
292
293
294
295
296
297
298
299
300 unsigned int write_errors;
301
302
303
304 unsigned long first_error_sector;
305 int first_error_generation;
306 unsigned long last_error_sector;
307 int last_error_generation;
308
309 unsigned int badness;
310
311};
312
313#define FDWERRORCLR _IO(2, 0x56)
314
315#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors)
316
317
318
319
320
321
322
323#define FDHAVEBATCHEDRAWCMD
324
325struct floppy_raw_cmd {
326 unsigned int flags;
327#define FD_RAW_READ 1
328#define FD_RAW_WRITE 2
329#define FD_RAW_NO_MOTOR 4
330#define FD_RAW_DISK_CHANGE 4
331#define FD_RAW_INTR 8
332#define FD_RAW_SPIN 0x10
333#define FD_RAW_NO_MOTOR_AFTER 0x20
334
335#define FD_RAW_NEED_DISK 0x40
336#define FD_RAW_NEED_SEEK 0x80
337
338
339#define FD_RAW_MORE 0x100
340#define FD_RAW_STOP_IF_FAILURE 0x200
341#define FD_RAW_STOP_IF_SUCCESS 0x400
342#define FD_RAW_SOFTFAILURE 0x800
343
344
345
346#define FD_RAW_FAILURE 0x10000
347#define FD_RAW_HARDFAILURE 0x20000
348
349 void __user *data;
350 char *kernel_data;
351 struct floppy_raw_cmd *next;
352
353 long length;
354 long phys_length;
355 int buffer_length;
356
357 unsigned char rate;
358 unsigned char cmd_count;
359 unsigned char cmd[16];
360 unsigned char reply_count;
361 unsigned char reply[16];
362 int track;
363 int resultcode;
364
365 int reserved1;
366 int reserved2;
367};
368
369#define FDRAWCMD _IO(2, 0x58)
370
371
372
373#define FDTWADDLE _IO(2, 0x59)
374
375
376
377#define FDEJECT _IO(2, 0x5a)
378
379
380
381#ifdef __KERNEL__
382#ifdef CONFIG_COMPAT
383#include <linux/compat.h>
384
385struct compat_floppy_struct {
386 compat_uint_t size;
387 compat_uint_t sect;
388 compat_uint_t head;
389 compat_uint_t track;
390 compat_uint_t stretch;
391 unsigned char gap;
392 unsigned char rate;
393 unsigned char spec1;
394 unsigned char fmt_gap;
395 const compat_caddr_t name;
396};
397
398#define FDGETPRM32 _IOR(2, 0x04, struct compat_floppy_struct)
399#endif
400#endif
401
402#endif
403