home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / fd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  8.0 KB  |  251 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8. #ident    "@(#)head.sys:fd.h    1.4.1.6"
  9.  
  10. #define    FD0    0    /* major device number for floppy disk */
  11.  
  12. /*
  13.  * the floppy disk minor device number is interpreted as follows:
  14.  *     bits:
  15.  *     7  4 3 21 0
  16.  *     +----+-+--+-+
  17.  *     |fmt |s|pt|u|
  18.  *     +----+-+--+-+
  19.  *     codes:
  20.  *    u   - unit no. (0 or 1)
  21.  *    pt  - partition no. (0 - 3)
  22.  *    s   - single/double sided (1 = single)
  23.  *    fmt - format code, no. of bytes per sector/ no. of sectors per trk.
  24.  */
  25.  
  26. #define    PARTITION(x)    ((minor(x) & 0x06) >> 1)
  27. #define UNIT(x)        (minor(x) & 0x01)
  28. #define    FRMT(x)        ((minor(x) & 0xf0) >> 4)
  29. #define    SIDES(x)    ((minor(x) & 0x08) ? 1 : 2)
  30.  
  31. /*
  32.  * Defines for controller access.
  33.  */
  34. #define    FDSTAT    0x3f4    /* I/O port addr of floppy controller status port */
  35. #define    FDDATA    0x3f5    /* I/O port addr of floppy controller data port */
  36.  
  37. #define    FCBUSY    0x10    /* controller busy bit */
  38. #define    IODIR    0x40    /* data reg I/O direction, 1 = read, 0 = write */
  39. #define    IORDY    0x80    /* data register ready to xfer bit */
  40.  
  41. #define    FCRETRY    2000    /* this many ten microseconds equals 20ms. */
  42.  
  43. #define    CTIMOUT    0x02    /* Timed out waiting for IORDY in fdcmd */
  44. #define    RTIMOUT    0x03    /* Timed out waiting for IORDY in fdresult*/
  45. #define    NECERR    0x04    /* Controller wont go idle error flag */
  46.  
  47. #define ONESIDE 0x08    /* indicates in minor dev that we want single sided */
  48.  
  49. #define NUMDRV  2           /* maximum number of drives supported */
  50. #define NHDS    2           /* default number of heads */
  51. #define NSECS   9           /* default number of sectors per track */
  52. #define NCYLS   40          /* default number of cylinders */
  53. #define SECSIZE 512         /* default sector size */
  54. #define SECSHFT 9
  55. #define SECMASK (SECSIZE-1)
  56.  
  57. #define FD          ('R'<<8)
  58. #define FDSPARAM    (FD | 00)   /* set the drive paramaters */
  59. #define FDGPARAM    (FD | 01)   /* get the drive paramaters */
  60. #define FDFMTTRK    (FD | 02)   /* format a single track */
  61.  
  62. #define OPEN_EMAX   1       /* max number of retries during open processing */
  63. #define FORM_EMAX   3       /* max number of retries during format */
  64. #define TRYRESET    5       /* try a reset after this many errrors */
  65. #define NORM_EMAX   10      /* normal max number of retries */
  66.  
  67. #define RUNTIM  3
  68. #define WAITTIM 4
  69. #define LOADTIM 10
  70. #define MTIME   100    /* no. of clock ticks in one second */
  71. #define ETIMOUT 50    /* no. of clock ticks in 1/2 second */
  72. #define T25MS   3    /* no. of clock ticks in 25 milliseconds */
  73. #define T500MS  50    /* no. of clock ticks in 500 milliseconds */
  74. #define T50MS   5    /* no. of clock ticks in 50 milliseconds */
  75. #define T750MS  75    /* no. of clock ticks in 750 milliseconds */
  76.  
  77. #define OPENED  0x01
  78. #define OPENING 0x02
  79. #define RECAL   0x04
  80. #define CLOSING 0x08
  81. #define EXCLUSV 0x10
  82. #define RSTDOPN 0x20
  83.  
  84. #define WINTR   0x01
  85. #define    WRESET    0x02
  86.  
  87. #define D_NTRK  40      /* 40 tracks - double density */
  88. #define Q_NTRK  80      /* 80 tracks - quad density */
  89.  
  90. #define DMA_RD      0x46
  91. #define DMA_WR      0x4A
  92.  
  93. #define FDCSR1      0x03F7
  94. #define DOOROPEN    0x80
  95. #define FDCTRL      0x03F2
  96. #define NORESET     0x04
  97. #define ENABINT     0x08
  98. #define ENABMOTOR   0x10
  99.  
  100. #define FD0BSY      0x01    /* drive is seeking */
  101. #define FD1BSY      0x02
  102. #define FD2BSY      0x04
  103. #define FD3BSY      0x08
  104. #define FCBSY       0x10    /* controller is busy */
  105. #define NODMA       0x20    /* controller in non-DMA mode */
  106.  
  107. /*
  108.  * Floppy controller commands
  109.  */
  110. #define RDCMD       0x26
  111. #define SEEK        0x0F
  112. #define FORMAT      0x0D
  113. #define READID      0x0A
  114. #define SENSE_INT   0x08
  115. #define REZERO      0x07
  116. #define WRCMD       0x05
  117. #define SENSE_DRV   0x04        /* read status register 3 */
  118. #define SPECIFY     0x03
  119.  
  120. #define READDEL     0x0C
  121. #define WRITEDEL    0x09
  122. #define READTRACK   0x02
  123. #define RAWCMD      0x7F    /* command is thru raw I/O ioctl */
  124.  
  125. #define INVALID     0x80        /* status register 0 */
  126. #define ABNRMTERM   0x40
  127. #define SEEKEND     0x20
  128. #define EQCHK       0x10
  129. #define NOTRDY      0x08
  130.  
  131. #define EOCYL       0x80        /* status register 1 */
  132. #define CRCERR      0x20
  133. #define OVRRUN      0x10
  134. #define NODATA      0x04
  135. #define MADR        0x01
  136.  
  137. #define FAULT       0x80        /* status register 3 */
  138. #define WPROT       0x40
  139. #define RDY         0x20
  140. #define TWOSIDE     0x08
  141.  
  142. /* NEW_HARDWARE CMOS drive descriptions */
  143. #define DRV_NONE    0x00
  144. #define DRV_DBL     0x01
  145. #define DRV_QUAD    0x02
  146.  
  147.         /* encodings for the 'fdf_den' field in structure 'fdparam' */
  148. #define DEN_MFM 0x40        /* double density disks */
  149. #define DEN_FM  0x00        /* single density disks */
  150.  
  151.         /* encodings for the 'fdf_bps' field in structure 'fdparam' */
  152. #define BPS128  0           /* 128 bytes per sector */
  153. #define BPS256  1           /* 256 bytes per sector */
  154. #define BPS512  2           /* 512 bytes per sector */
  155. #define BPS1024 3           /* 1024 bytes per sector */
  156. #define MAXBPS  3           /* maximum value of the 'fdf_bps' field */
  157.  
  158. #define    FDNPART    3    /* number of partitions supported */
  159. #define    FDMEMSIZE    (36*512)
  160. /*
  161.  * partition table for floppy disks
  162.  * we support, 3 different partitions:
  163.  *     0 - the whole disk;
  164.  *    1 - the first cylinder on the disk
  165.  *    2 - the whole disk minus the first cylinder
  166.  */
  167. struct fdpartab {
  168.     int    startcyl;    /* cylinder no. where partition starts */
  169.     int    numcyls;    /* number of cylinders in partition */
  170. };
  171.  
  172. #define    FDNSECT    8    /* no. of sector size/count types supported */
  173. /*
  174.  * sector table for floppy disks,
  175.  * specifies number of bytes per sector and
  176.  * number of sectors per track.
  177.  */
  178. struct fdsectab {
  179.     unsigned short    fd_ssize;    /* number of bytes in a sector */
  180.     unsigned short    fd_sshift;    /* shift to convert bytes to sectors */
  181.     unsigned char    fd_nsect;    /* number of sectors per track */
  182.     unsigned char    fd_drvs;    /* bitmask of drive types supporting */
  183.     unsigned char    fd_gpln;    /* normal gap length */
  184.     unsigned char    fd_gplf;    /* format gap length */
  185. };
  186.  
  187. struct fdstate {
  188.     char     fd_status;
  189.     char     fd_maxerr;
  190.     unsigned char  fd_drvtype;
  191.     unsigned char  fd_trnsfr;
  192.     unsigned char  fd_hst;
  193.     unsigned char  fd_mst;
  194.     unsigned char  fd_dstep;
  195.     unsigned short fd_cylskp;
  196.     unsigned short fd_ncyls;
  197.     unsigned short fd_secsiz;
  198.     unsigned short fd_secmsk;
  199.     unsigned char  fd_secsft;
  200.     unsigned char  fd_nsides;
  201.     unsigned char  fd_nsects;
  202.     unsigned char  fd_cylsiz;
  203.     unsigned char  fd_curcyl;
  204.     unsigned char  fd_lsterr;
  205.     unsigned short fd_n512b;
  206.     dev_t           fd_device;
  207.     struct   proc *fd_proc;
  208.     unsigned char  fd_fmt;        /* auto format detection */
  209.     unsigned char  fd_dskchg;    /* if == 0, format is up to date */
  210. };
  211.  
  212. struct fdparam {        /* used by FDSPARAM and FDGPARAM commands */
  213.     char    fdf_bps;    /* number of bytes per sector - encoded */
  214.     char    fdf_spt;    /* number of sectors per track */
  215.     char    fdf_gpln;   /* gap length for normal R/W operations */
  216.     char    fdf_gplf;   /* gap length for format operations */
  217.     char    fdf_dtl;    /* length of sector if 'fdf_bps' = 0 */
  218.     char    fdf_fil;    /* fill byte to use while formatting */
  219.     char    fdf_den;    /* FM or MFM encoding */
  220.     char    fdf_nhd;    /* number of heads */
  221.     short   fdf_ncyl;   /* number of cylinders */
  222. };
  223.  
  224. struct fdformid {       /* used by FDFMTTRK command */
  225.     char    fdf_track;
  226.     char    fdf_head;
  227.     char    fdf_sec;
  228.     char    fdf_secsiz;
  229. };
  230.  
  231. #define FIOC        ('F'<<8)
  232. #define    F_DTYP        (FIOC|60)    /* returns fd_drvtype */
  233. #define F_FCR        (FIOC|61)    /* output to Floppy Control Register */
  234. #define F_DOR        (FIOC|62)    /* output to Digital Output Register */
  235. #define F_RAW        (FIOC|63)    /* general raw controller interface */
  236.  
  237. struct fdraw {            /* used by F_RAW command */
  238.     char    fr_cmd[10];    /* user-supplied command bytes */
  239.     short    fr_cnum;    /* number of command bytes */
  240.     char    fr_result[10];    /* controller-supplied result bytes */
  241.     short    fr_nbytes;    /* number to transfer if read/write command */
  242.     char   *fr_addr;    /* where to transfer if read/write command */
  243. };
  244.  
  245. struct  fdbufstruct {
  246.     int         fbs_flags;
  247.     caddr_t     fbs_addr;
  248.     unsigned    int     fbs_size;
  249. };
  250.  
  251.