fd.h
001: #ifndef _LINUX_FD_H
002: #define _LINUX_FD_H
003:
004: #include <linux/ioctl.h>
005:
006:
007:
008:
009:
010:
011:
012:
013: struct floppy_struct {
014: unsigned int size,
015: sect,
016: head,
017: track,
018: stretch;
019:
020:
021:
022: #define FD_STRETCH 1
023: #define FD_SWAPSIDES 2
024: #define FD_ZEROBASED 4
025: #define FD_SECTBASEMASK 0x3FC
026: #define FD_MKSECTBASE(s) (((s) ^ 1) << 2)
027: #define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1)
028:
029: unsigned char gap,
030:
031: rate,
032: #define FD_2M 0x4
033: #define FD_SIZECODEMASK 0x38
034: #define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
035: #define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
036: 512 : 128 << FD_SIZECODE(floppy) )
037: #define FD_PERP 0x40
038:
039: spec1,
040: fmt_gap;
041: const char * name;
042: };
043:
044:
045:
046:
047:
048: #define FDCLRPRM _IO(2, 0x41)
049:
050:
051: #define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
052: #define FDSETMEDIAPRM FDSETPRM
053:
054:
055: #define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
056: #define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
057: #define FDDEFMEDIAPRM FDDEFPRM
058: #define FDGETMEDIAPRM FDGETPRM
059:
060:
061:
062: #define FDMSGON _IO(2,0x45)
063: #define FDMSGOFF _IO(2,0x46)
064:
065:
066:
067:
068:
069:
070: #define FD_FILL_BYTE 0xF6
071:
072: struct format_descr {
073: unsigned int device,head,track;
074: };
075:
076: #define FDFMTBEG _IO(2,0x47)
077:
078: #define FDFMTTRK _IOW(2,0x48, struct format_descr)
079:
080: #define FDFMTEND _IO(2,0x49)
081:
082:
083:
084:
085:
086:
087: struct floppy_max_errors {
088: unsigned int
089: abort,
090: read_track,
091:
092: reset,
093: recal,
094:
095:
096:
097:
098:
099:
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:
118: typedef char floppy_drive_name[16];
119: #define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
120:
121:
122:
123:
124:
125:
126: struct 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:
181: enum {
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:
199: struct 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:
242: enum 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:
253: struct 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:
291: struct 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:
325: struct 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 *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:
382: #endif
383:
© Andrew Scott 2006 -
2025,
All Rights Reserved