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

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