root/include/linux/fd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   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         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
 157 
 158         char read_track;                /* use readtrack during probing? */
 159 
 160 /*
 161  * Auto-detection. Each drive type has eight formats which are
 162  * used in succession to try to read the disk. If the FDC cannot lock onto
 163  * the disk, the next format is tried. This uses the variable 'probing'.
 164  */
 165         short autodetect[8];            /* autodetected formats */
 166         
 167         int checkfreq; /* how often should the drive be checked for disk 
 168                         * changes */
 169         int native_format; /* native format of this drive */
 170 };
 171 
 172 enum {
 173         FD_NEED_TWADDLE_BIT,    /* more magic */
 174         FD_VERIFY_BIT,          /* inquire for write protection */
 175         FD_DISK_NEWCHANGE_BIT,  /* change detected, and no action undertaken yet
 176                                  * to clear media change status */
 177         FD_UNUSED_BIT,
 178         FD_DISK_CHANGED_BIT,    /* disk has been changed since last i/o */
 179         FD_DISK_WRITABLE_BIT    /* disk is writable */
 180 };
 181 
 182 #define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
 183 #define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
 184 /* set/get drive parameters */
 185 
 186 
 187 /*
 188  * Current drive state (not directly modifiable by user, readonly)
 189  */
 190 struct floppy_drive_struct {
 191         signed char flags;
 192 /* values for these flags */
 193 #define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
 194 #define FD_VERIFY (1 << FD_VERIFY_BIT)
 195 #define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
 196 #define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
 197 #define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
 198 
 199         unsigned long spinup_date;
 200         unsigned long select_date;
 201         unsigned long first_read_date;
 202         short probed_format;
 203         short track; /* current track */
 204         short maxblock; /* id of highest block read */
 205         short maxtrack; /* id of highest half track read */
 206         int generation; /* how many diskchanges? */
 207 
 208 /*
 209  * (User-provided) media information is _not_ discarded after a media change
 210  * if the corresponding keep_data flag is non-zero. Positive values are
 211  * decremented after each probe.
 212  */
 213         int keep_data;
 214         
 215         /* Prevent "aliased" accesses. */
 216         int fd_ref;
 217         int fd_device;
 218         int last_checked; /* when was the drive last checked for a disk 
 219                            * change? */
 220         
 221         char *dmabuf;
 222         int bufblocks;
 223 };
 224 
 225 #define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
 226 #define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
 227 /* get drive state: GET returns the cached state, POLL polls for new state */
 228 
 229 
 230 /*
 231  * reset FDC
 232  */
 233 enum reset_mode {
 234         FD_RESET_IF_NEEDED,     /* reset only if the reset flags is set */
 235         FD_RESET_IF_RAWCMD,     /* obsolete */
 236         FD_RESET_ALWAYS         /* reset always */
 237 };
 238 #define FDRESET _IO(2, 0x54)
 239 
 240 
 241 /*
 242  * FDC state
 243  */
 244 struct floppy_fdc_state {       
 245         int spec1;              /* spec1 value last used */
 246         int spec2;              /* spec2 value last used */
 247         int dtr;
 248         unsigned char version;  /* FDC version code */
 249         unsigned char dor;
 250         int address;            /* io address */
 251         unsigned int rawcmd:2;
 252         unsigned int reset:1;
 253         unsigned int need_configure:1;
 254         unsigned int perp_mode:2;
 255         unsigned int has_fifo:1;
 256         unsigned int driver_version;    /* version code for floppy driver */
 257 #define FD_DRIVER_VERSION 0x100
 258 /* user programs using the floppy API should use floppy_fdc_state to
 259  * get the version number of the floppy driver that they are running
 260  * on. If this version number is bigger than the one compiled into the
 261  * user program (the FD_DRIVER_VERSION define), it should be prepared
 262  * to bigger structures
 263  */
 264 
 265         unsigned char track[4];
 266         /* Position of the heads of the 4 units attached to this FDC,
 267          * as stored on the FDC. In the future, the position as stored
 268          * on the FDC might not agree with the actual physical
 269          * position of these drive heads. By allowing such
 270          * disagreement, it will be possible to reset the FDC without
 271          * incurring the expensive cost of repositioning all heads.
 272          * Right now, these positions are hard wired to 0. */
 273 
 274 };
 275 
 276 #define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
 277 
 278 
 279 /*
 280  * Asynchronous Write error tracking
 281  */
 282 struct floppy_write_errors {
 283         /* Write error logging.
 284          *
 285          * These fields can be cleared with the FDWERRORCLR ioctl.
 286          * Only writes that were attempted but failed due to a physical media
 287          * error are logged.  write(2) calls that fail and return an error code
 288          * to the user process are not counted.
 289          */
 290 
 291         unsigned int write_errors;  /* number of physical write errors 
 292                                      * encountered */
 293         
 294         /* position of first and last write errors */
 295         unsigned long first_error_sector;
 296         int           first_error_generation;
 297         unsigned long last_error_sector;
 298         int           last_error_generation;
 299         
 300         unsigned int badness; /* highest retry count for a read or write 
 301                                * operation */
 302 };
 303 
 304 #define FDWERRORCLR  _IO(2, 0x56)
 305 /* clear write error and badness information */
 306 #define FDWERRORGET  _IOR(2, 0x17, struct floppy_write_errors)
 307 /* get write error and badness information */
 308 
 309 
 310 /*
 311  * Raw commands
 312  */
 313 /* new interface flag: now we can do them in batches */
 314 #define FDHAVEBATCHEDRAWCMD
 315 
 316 struct floppy_raw_cmd {
 317         unsigned int flags;
 318 #define FD_RAW_READ 1
 319 #define FD_RAW_WRITE 2
 320 #define FD_RAW_NO_MOTOR 4
 321 #define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */
 322 #define FD_RAW_INTR 8    /* wait for an interrupt */
 323 #define FD_RAW_SPIN 0x10 /* spin up the disk for this command */
 324 #define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command 
 325                                     * completion */
 326 #define FD_RAW_NEED_DISK 0x40  /* this command needs a disk to be present */
 327 #define FD_RAW_NEED_SEEK 0x80  /* this command uses an implied seek (soft) */
 328 
 329 /* more "in" flags */
 330 #define FD_RAW_MORE 0x100  /* more records follow */
 331 #define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */
 332 #define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */
 333 #define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure
 334                                   * detection too */
 335 
 336 /* more "out" flags */
 337 #define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */
 338 #define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */
 339 
 340         void *data;
 341         char *kernel_data; /* location of data buffer in the kernel */
 342         struct floppy_raw_cmd *next; /* used for chaining of raw cmd's 
 343                                       * within the kernel */
 344         long length; /* in: length of dma transfer. out: remaining bytes */
 345         long phys_length; /* physical length, if different from dma length */
 346         int buffer_length; /* length of allocated buffer */
 347 
 348         unsigned char rate;
 349         unsigned char cmd_count;
 350         unsigned char cmd[16];
 351         unsigned char reply_count;
 352         unsigned char reply[16];
 353         int track;
 354         int resultcode;
 355 
 356         int reserved1;
 357         int reserved2;
 358 };
 359 
 360 #define FDRAWCMD _IO(2, 0x58)
 361 /* send a raw command to the fdc. Structure size not included, because of
 362  * batches */
 363 
 364 #define FDTWADDLE _IO(2, 0x59)
 365 /* flicker motor-on bit before reading a sector. Experimental */
 366 
 367 
 368 #define FDEJECT _IO(2, 0x5a)
 369 /* eject the disk */
 370 
 371 #endif

/* [previous][next][first][last][top][bottom][index][help] */