1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 2 #ifndef _UAPI_LINUX_FD_H 3 #define _UAPI_LINUX_FD_H 4 5 #include <linux/ioctl.h> 6 #include <linux/compiler.h> 7 8 /* New file layout: Now the ioctl definitions 9 * definitions of the structures that they use 10 11 /* 12 * Geometry 13 */ 14 struct floppy_struct { 15 unsigned int size, /* nr 16 sect, /* sec 17 head, /* nr 18 track, /* nr 19 stretch; /* bit 20 /* bit 21 /* bit 22 /* nu 23 #define FD_STRETCH 1 24 #define FD_SWAPSIDES 2 25 #define FD_ZEROBASED 4 26 #define FD_SECTBASEMASK 0x3FC 27 #define FD_MKSECTBASE(s) (((s) ^ 1) << 2) 28 #define FD_SECTBASE(floppy) ((((floppy)->stret 29 30 unsigned char gap, /* gap 31 32 rate, /* dat 33 #define FD_2M 0x4 34 #define FD_SIZECODEMASK 0x38 35 #define FD_SIZECODE(floppy) (((((floppy)->rate 36 #define FD_SECTSIZE(floppy) ( (floppy)->rate & 37 512 : 128 << FD_S 38 #define FD_PERP 0x40 39 40 spec1, /* ste 41 fmt_gap; /* gap 42 const char * name; /* used only f 43 }; 44 45 46 /* commands needing write access have 0x40 set 47 /* commands needing super user access have 0x8 48 49 #define FDCLRPRM _IO(2, 0x41) 50 /* clear user-defined parameters */ 51 52 #define FDSETPRM _IOW(2, 0x42, struct floppy_s 53 #define FDSETMEDIAPRM FDSETPRM 54 /* set user-defined parameters for current med 55 56 #define FDDEFPRM _IOW(2, 0x43, struct floppy_s 57 #define FDGETPRM _IOR(2, 0x04, struct floppy_s 58 #define FDDEFMEDIAPRM FDDEFPRM 59 #define FDGETMEDIAPRM FDGETPRM 60 /* set/get disk parameters */ 61 62 63 #define FDMSGON _IO(2,0x45) 64 #define FDMSGOFF _IO(2,0x46) 65 /* issue/don't issue kernel messages on media 66 67 68 /* 69 * Formatting (obsolete) 70 */ 71 #define FD_FILL_BYTE 0xF6 /* format fill byte. 72 73 struct format_descr { 74 unsigned int device,head,track; 75 }; 76 77 #define FDFMTBEG _IO(2,0x47) 78 /* begin formatting a disk */ 79 #define FDFMTTRK _IOW(2,0x48, struct format_de 80 /* format the specified track */ 81 #define FDFMTEND _IO(2,0x49) 82 /* end formatting a disk */ 83 84 85 /* 86 * Error thresholds 87 */ 88 struct floppy_max_errors { 89 unsigned int 90 abort, /* number of errors to b 91 read_track, /* maximal number of err 92 * entire track at once 93 reset, /* maximal number of err 94 recal, /* maximal number of err 95 * tried */ 96 97 /* 98 * Threshold for reporting FDC error 99 * Setting this to zero may flood yo 100 * ultra cheap floppies ;-) 101 */ 102 reporting; 103 104 }; 105 106 #define FDSETEMSGTRESH _IO(2,0x4a) 107 /* set fdc error reporting threshold */ 108 109 #define FDFLUSH _IO(2,0x4b) 110 /* flush buffers for media; either for verifyi 111 * handling a media change without closing the 112 113 #define FDSETMAXERRS _IOW(2, 0x4c, struct flop 114 #define FDGETMAXERRS _IOR(2, 0x0e, struct flop 115 /* set/get abortion and read_track threshold. 116 * structure */ 117 118 119 typedef char floppy_drive_name[16]; 120 #define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive 121 /* get drive type: 5 1/4 or 3 1/2 */ 122 123 124 /* 125 * Drive parameters (user modifiable) 126 */ 127 struct floppy_drive_params { 128 signed char cmos; /* CMO 129 130 /* Spec2 is (HLD<<1 | ND), where HLD i 131 * etc) and ND is set means no DMA. Ha 132 */ 133 unsigned long max_dtr; /* Ste 134 unsigned long hlt; /* Hea 135 unsigned long hut; /* Hea 136 * 8" 137 unsigned long srt; /* Ste 138 139 unsigned long spinup; /* tim 140 * in 141 unsigned long spindown; /* tim 142 unsigned char spindown_offset; /* dec 143 * wil 144 unsigned char select_delay; /* del 145 unsigned char rps; /* rot 146 unsigned char tracks; /* max 147 unsigned long timeout; /* tim 148 149 unsigned char interleave_sect; /* if 150 * int 151 152 struct floppy_max_errors max_errors; 153 154 char flags; /* var 155 /* 156 * Announce successful media type detection an 157 * disk changes. 158 * Also used to enable/disable printing of ove 159 */ 160 161 #define FTD_MSG 0x10 162 #define FD_BROKEN_DCL 0x20 163 #define FD_DEBUG 0x02 164 #define FD_SILENT_DCL_CLEAR 0x4 165 #define FD_INVERTED_DCL 0x80 /* must be 0x80, 166 considerations 167 168 char read_track; /* use 169 170 /* 171 * Auto-detection. Each drive type has eight f 172 * used in succession to try to read the disk. 173 * the disk, the next format is tried. This us 174 */ 175 176 #define FD_AUTODETECT_SIZE 8 177 178 short autodetect[FD_AUTODETECT_SIZE]; 179 180 int checkfreq; /* how often should the 181 * changes */ 182 int native_format; /* native format of 183 }; 184 185 enum { 186 FD_NEED_TWADDLE_BIT, /* more magic 187 FD_VERIFY_BIT, /* inquire for 188 FD_DISK_NEWCHANGE_BIT, /* change dete 189 * to clear me 190 FD_UNUSED_BIT, 191 FD_DISK_CHANGED_BIT, /* disk has be 192 FD_DISK_WRITABLE_BIT, /* disk is wri 193 FD_OPEN_SHOULD_FAIL_BIT 194 }; 195 196 #define FDSETDRVPRM _IOW(2, 0x90, struct flopp 197 #define FDGETDRVPRM _IOR(2, 0x11, struct flopp 198 /* set/get drive parameters */ 199 200 201 /* 202 * Current drive state (not directly modifiabl 203 */ 204 struct floppy_drive_struct { 205 unsigned long flags; 206 /* values for these flags */ 207 #define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_ 208 #define FD_VERIFY (1 << FD_VERIFY_BIT) 209 #define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHA 210 #define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_ 211 #define FD_DISK_WRITABLE (1 << FD_DISK_WRITABL 212 213 unsigned long spinup_date; 214 unsigned long select_date; 215 unsigned long first_read_date; 216 short probed_format; 217 short track; /* current track */ 218 short maxblock; /* id of highest block 219 short maxtrack; /* id of highest half 220 int generation; /* how many diskchange 221 222 /* 223 * (User-provided) media information is _not_ 224 * if the corresponding keep_data flag is non- 225 * decremented after each probe. 226 */ 227 int keep_data; 228 229 /* Prevent "aliased" accesses. */ 230 int fd_ref; 231 int fd_device; 232 unsigned long last_checked; /* when wa 233 * change? */ 234 235 char *dmabuf; 236 int bufblocks; 237 }; 238 239 #define FDGETDRVSTAT _IOR(2, 0x12, struct flop 240 #define FDPOLLDRVSTAT _IOR(2, 0x13, struct flo 241 /* get drive state: GET returns the cached sta 242 243 244 /* 245 * reset FDC 246 */ 247 enum reset_mode { 248 FD_RESET_IF_NEEDED, /* reset only 249 FD_RESET_IF_RAWCMD, /* obsolete */ 250 FD_RESET_ALWAYS /* reset alway 251 }; 252 #define FDRESET _IO(2, 0x54) 253 254 255 /* 256 * FDC state 257 */ 258 struct floppy_fdc_state { 259 int spec1; /* spec1 value 260 int spec2; /* spec2 value 261 int dtr; 262 unsigned char version; /* FDC version 263 unsigned char dor; 264 unsigned long address; /* io address 265 unsigned int rawcmd:2; 266 unsigned int reset:1; 267 unsigned int need_configure:1; 268 unsigned int perp_mode:2; 269 unsigned int has_fifo:1; 270 unsigned int driver_version; /* ver 271 #define FD_DRIVER_VERSION 0x100 272 /* user programs using the floppy API should u 273 * get the version number of the floppy driver 274 * on. If this version number is bigger than t 275 * user program (the FD_DRIVER_VERSION define) 276 * to bigger structures 277 */ 278 279 unsigned char track[4]; 280 /* Position of the heads of the 4 unit 281 * as stored on the FDC. In the future 282 * on the FDC might not agree with the 283 * position of these drive heads. By a 284 * disagreement, it will be possible t 285 * incurring the expensive cost of rep 286 * Right now, these positions are hard 287 288 }; 289 290 #define FDGETFDCSTAT _IOR(2, 0x15, struct flop 291 292 293 /* 294 * Asynchronous Write error tracking 295 */ 296 struct floppy_write_errors { 297 /* Write error logging. 298 * 299 * These fields can be cleared with th 300 * Only writes that were attempted but 301 * error are logged. write(2) calls t 302 * to the user process are not counted 303 */ 304 305 unsigned int write_errors; /* number 306 * encount 307 308 /* position of first and last write er 309 unsigned long first_error_sector; 310 int first_error_generation; 311 unsigned long last_error_sector; 312 int last_error_generation; 313 314 unsigned int badness; /* highest retry 315 * operation */ 316 }; 317 318 #define FDWERRORCLR _IO(2, 0x56) 319 /* clear write error and badness information * 320 #define FDWERRORGET _IOR(2, 0x17, struct flop 321 /* get write error and badness information */ 322 323 324 /* 325 * Raw commands 326 */ 327 /* new interface flag: now we can do them in b 328 #define FDHAVEBATCHEDRAWCMD 329 330 struct floppy_raw_cmd { 331 unsigned int flags; 332 #define FD_RAW_READ 1 333 #define FD_RAW_WRITE 2 334 #define FD_RAW_NO_MOTOR 4 335 #define FD_RAW_DISK_CHANGE 4 /* out: disk chan 336 #define FD_RAW_INTR 8 /* wait for an interr 337 #define FD_RAW_SPIN 0x10 /* spin up the disk f 338 #define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch t 339 * completi 340 #define FD_RAW_NEED_DISK 0x40 /* this command 341 #define FD_RAW_NEED_SEEK 0x80 /* this command 342 343 /* more "in" flags */ 344 #define FD_RAW_MORE 0x100 /* more records fol 345 #define FD_RAW_STOP_IF_FAILURE 0x200 /* stop i 346 #define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop i 347 #define FD_RAW_SOFTFAILURE 0x800 /* consider t 348 * detection 349 350 /* more "out" flags */ 351 #define FD_RAW_FAILURE 0x10000 /* command sent 352 #define FD_RAW_HARDFAILURE 0x20000 /* fdc had 353 354 void __user *data; 355 char *kernel_data; /* location of data 356 struct floppy_raw_cmd *next; /* used f 357 * within 358 long length; /* in: length of dma tran 359 long phys_length; /* physical length, 360 int buffer_length; /* length of alloca 361 362 unsigned char rate; 363 364 #define FD_RAW_CMD_SIZE 16 365 #define FD_RAW_REPLY_SIZE 16 366 #define FD_RAW_CMD_FULLSIZE (FD_RAW_CMD_SIZE + 367 368 /* The command may take up the space i 369 * and the reply count. Needed for lon 370 * which takes 17 command bytes. 371 */ 372 373 unsigned char cmd_count; 374 union { 375 struct { 376 unsigned char cmd[FD_R 377 unsigned char reply_co 378 unsigned char reply[FD 379 }; 380 unsigned char fullcmd[FD_RAW_C 381 }; 382 int track; 383 int resultcode; 384 385 int reserved1; 386 int reserved2; 387 }; 388 389 #define FDRAWCMD _IO(2, 0x58) 390 /* send a raw command to the fdc. Structure si 391 * batches */ 392 393 #define FDTWADDLE _IO(2, 0x59) 394 /* flicker motor-on bit before reading a secto 395 396 397 #define FDEJECT _IO(2, 0x5a) 398 /* eject the disk */ 399 400 401 402 #endif /* _UAPI_LINUX_FD_H */ 403
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.