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 #define FDCLRPRM 0 /* clear user-defined parameters */
   5 #define FDSETPRM 1 /* set user-defined parameters for current media */
   6 #define FDSETMEDIAPRM 1
   7 #define FDDEFPRM 2 /* set user-defined parameters until explicitly cleared */
   8 #define FDDEFMEDIAPRM 2
   9 #define FDGETPRM 3 /* get disk parameters */
  10 #define FDGETMEDIAPRM 3
  11 #define FDMSGON  4 /* issue kernel messages on media type change */
  12 #define FDMSGOFF 5 /* don't issue kernel messages on media type change */
  13 #define FDFMTBEG 6 /* begin formatting a disk */
  14 #define FDFMTTRK 7 /* format the specified track */
  15 #define FDFMTEND 8 /* end formatting a disk */
  16 #define FDSETEMSGTRESH  10      /* set fdc error reporting threshold */
  17 #define FDFLUSH  11 /* flush buffers for media; either for verifying media, or for
  18                        handling a media change without closing the file
  19                        descriptor */
  20 #define FDSETMAXERRS 12 /* set abortion and read_track threshold */
  21 #define FDGETMAXERRS 14 /* get abortion and read_track threshold */
  22 #define FDGETDRVTYP 16          /* get drive type: 5 1/4 or 3 1/2 */
  23 
  24 #define FDSETDRVPRM 20 /* set drive parameters */
  25 #define FDGETDRVPRM 21 /* get drive parameters */
  26 #define FDGETDRVSTAT 22 /* get drive state */
  27 #define FDPOLLDRVSTAT 23 /* get drive state */
  28 #define FDRESET 24 /* reset FDC */
  29 
  30 #define FD_RESET_IF_NEEDED 0
  31 #define FD_RESET_IF_RAWCMD 1
  32 #define FD_RESET_ALWAYS 2
  33 
  34 #define FDGETFDCSTAT 25 /* get fdc state */
  35 #define FDWERRORCLR  27 /* clear write error and badness information */
  36 #define FDWERRORGET  28 /* get write error and badness information */
  37 
  38 #define FDRAWCMD 30 /* send a raw command to the fdc */
  39 
  40 #define FDTWADDLE 40 /* flicker motor-on bit before reading a sector */
  41 
  42 /*
  43  * Maximum number of sectors in a track buffer. Track buffering is disabled
  44  * if tracks are bigger.
  45  */
  46 #define MAX_BUFFER_SECTORS 24 /* was 18 -bb */
  47 
  48 #define FD_FILL_BYTE 0xF6 /* format fill byte */
  49 
  50 #define FD_2M 0x4
  51 #define FD_SIZECODEMASK 0x38
  52 #define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
  53 #define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
  54                              512 : 128 << FD_SIZECODE(floppy) )
  55 #define FD_PERP 0x40
  56 
  57 #ifndef __ASSEMBLY__
  58 /* the following structure is used by FDSETPRM, FDDEFPRM and FDGETPRM */
  59 struct floppy_struct {
  60         unsigned int    size,           /* nr of sectors total */
  61                         sect,           /* sectors per track */
  62                         head,           /* nr of heads */
  63                         track,          /* nr of tracks */
  64                         stretch;        /* !=0 means double track steps */
  65         unsigned char   gap,            /* gap1 size */
  66                         rate,           /* data rate. |= 0x40 for perpendicular */
  67                         spec1,          /* stepping rate, head unload time */
  68                         fmt_gap;        /* gap2 size */
  69         char          * name; /* used only for predefined formats */
  70 };
  71 
  72 struct format_descr {
  73         unsigned int device,head,track;
  74 };
  75 
  76 struct floppy_max_errors {
  77   unsigned int
  78           abort,      /* number of errors to be reached before aborting */
  79           read_track, /* maximal number of errors permitted to read an
  80                        * entire track at once */
  81           reset,      /* maximal number of errors before a reset is tried */
  82           recal,      /* maximal number of errors before a recalibrate is
  83                        * tried */
  84 
  85           /*
  86            * Threshold for reporting FDC errors to the console.
  87            * Setting this to zero may flood your screen when using
  88            * ultra cheap floppies ;-)
  89            */
  90           reporting;
  91 
  92 };
  93 
  94 /* the following structure is used by FDSETDRVPRM and FDGETDRVPRM */
  95 struct floppy_drive_params {
  96   char cmos;                    /* cmos type */
  97 
  98   /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc)
  99    * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).
 100    */
 101   unsigned long max_dtr;        /* Step rate, usec */
 102   unsigned long hlt;            /* Head load/settle time, msec */
 103   unsigned long hut;            /* Head unload time (remnant of 8" drives) */
 104   unsigned long srt;            /* Step rate, usec */
 105 
 106   unsigned long spinup;         /* time needed for spinup ( in jiffies) */
 107   unsigned long spindown;       /* timeout needed for spindown */
 108   unsigned char spindown_offset;/* decides in which position the disk
 109                                  * will stop */
 110   unsigned char select_delay;   /* delay to wait after select */
 111   unsigned char rps;            /* rotations per second */
 112   unsigned char tracks;         /* maximum number of tracks */
 113   unsigned long timeout;        /* timeout for interrupt requests */
 114 
 115   unsigned char interleave_sect;/* if there are more sectors, use interleave */
 116 
 117   struct floppy_max_errors max_errors;
 118 
 119   char flags;                   /* various flags, including ftd_msg */
 120 /*
 121  * Announce successful media type detection and media information loss after
 122  * disk changes.
 123  * Also used to enable/disable printing of overrun warnings.
 124  */
 125 
 126 #define FTD_MSG 0x10
 127 #define FD_BROKEN_DCL 0x20
 128 #define FD_DEBUG 0x02
 129 #define FD_SILENT_DCL_CLEAR 0x4
 130 #define FD_INVERTED_DCL 0x80
 131 
 132   char read_track;              /* use readtrack during probing? */
 133 
 134 /*
 135  * Auto-detection. Each drive type has eight formats which are
 136  * used in succession to try to read the disk. If the FDC cannot lock onto
 137  * the disk, the next format is tried. This uses the variable 'probing'.
 138  */
 139   short autodetect[8];          /* autodetected formats */
 140 
 141   int checkfreq; /* how often should the drive be checked for disk changes */
 142   int native_format; /* native format of this drive */
 143 };
 144 
 145 enum {
 146 FD_NEED_TWADDLE_BIT, /* more magic */
 147 FD_VERIFY_BIT, /* inquire for write protection */
 148 FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet to
 149                           clear media change status */
 150 FD_UNUSED_BIT,
 151 FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */
 152 FD_DISK_WRITABLE_BIT /* disk is writable */
 153 };
 154 
 155 /* values for these flags */
 156 #define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
 157 #define FD_VERIFY (1 << FD_VERIFY_BIT)
 158 #define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
 159 #define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
 160 #define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
 161 
 162 #define FD_DRIVE_PRESENT 0 /* keep fdpatch utils compiling */
 163 
 164 struct floppy_drive_struct {
 165   signed char flags;
 166   unsigned long spinup_date;
 167   unsigned long select_date;
 168   unsigned long first_read_date;
 169   short probed_format;
 170   short track; /* current track */
 171   short maxblock; /* id of highest block read */
 172   short maxtrack; /* id of highest half track read */
 173   int generation; /* how many diskchanges? */
 174 
 175 /*
 176  * (User-provided) media information is _not_ discarded after a media change
 177  * if the corresponding keep_data flag is non-zero. Positive values are
 178  * decremented after each probe.
 179  */
 180   int keep_data;
 181 
 182   /* Prevent "aliased" accesses. */
 183   int fd_ref;
 184   int fd_device;
 185   int last_checked; /* when was the drive last checked for a disk change? */
 186 
 187 
 188 };
 189 
 190 struct floppy_write_errors {
 191   /* Write error logging.
 192    *
 193    * These fields can be cleared with the FDWERRORCLR ioctl.
 194    * Only writes that were attempted but failed due to a physical media
 195    * error are logged.  write(2) calls that fail and return an error code
 196    * to the user process are not counted.
 197    */
 198 
 199   unsigned int write_errors;  /* number of physical write errors encountered */
 200 
 201   /* position of first and last write errors */
 202   unsigned long first_error_sector;
 203   int           first_error_generation;
 204   unsigned long last_error_sector;
 205   int           last_error_generation;
 206 
 207   unsigned int badness; /* highest retry count for a read or write operation */
 208 };
 209 
 210 struct floppy_fdc_state {       
 211         int spec1; /* spec1 value last used */
 212         int spec2; /* spec2 value last used */
 213         int dtr;
 214         unsigned char version;  /* FDC version code */
 215         unsigned char dor;
 216         int address; /* io address */
 217         unsigned int rawcmd:2;
 218         unsigned int reset:1;
 219         unsigned int need_configure:1;
 220         unsigned int perp_mode:2;
 221         unsigned int has_fifo:1;
 222 };
 223 
 224 struct floppy_raw_cmd {
 225   void *data;
 226   long length;
 227 
 228   unsigned char rate;
 229   unsigned char flags;
 230   unsigned char cmd_count;
 231   unsigned char cmd[9];
 232   unsigned char reply_count;
 233   unsigned char reply[7];
 234   int track;
 235 };
 236 #endif
 237 
 238 /* meaning of the various bytes */
 239 
 240 /* flags */
 241 #define FD_RAW_READ 1
 242 #define FD_RAW_WRITE 2
 243 #define FD_RAW_NO_MOTOR 4
 244 #define FD_RAW_DISK_CHANGE 4
 245 #define FD_RAW_INTR 8
 246 #define FD_RAW_SPIN 16
 247 #define FD_RAW_NO_MOTOR_AFTER 32
 248 #define FD_RAW_NEED_DISK 64
 249 #define FD_RAW_NEED_SEEK 128
 250 
 251 #endif

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