home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / hd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.4 KB  |  176 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_HD_H
  11. #define _SYS_HD_H
  12.  
  13. #ident    "@(#)/usr/include/sys/hd.h.sl 1.1 4.0 12/08/90 65122 AT&T-USL"
  14.  
  15. /*
  16.  * PC AT Hard disk controller definitions.
  17.  */
  18.  
  19.  
  20. #define    HD0    0x1f0    /* base for hard controller I/O port addresses */
  21. #define    FDR    0x3f6    /* I/O port address for fixed disk register */
  22.  
  23. /*
  24.  * Bit 3 of the fixed disk register must be set to 1 to access heads
  25.  * 8 - 15 of a hard disk.
  26.  */
  27. #define    HD_EXTRAHDS    0x08    /* set into FDR to access high disk heads */
  28. #define    HD_NOEXTRAHDS    0x00    /* set into FDR if no high disk heads */
  29.  
  30. /*
  31.  * port offsets from base above.
  32.  */
  33. #define    HD_DATA        0x00    /* data register */
  34. #define    HD_ERROR    0x01    /* error register/write precomp */
  35. #define    HD_PRECOMP    0x01    /* error register/write precomp */
  36. #define    HD_NSECT    0x02    /* sector count */
  37. #define    HD_SECT        0x03    /* sector number */
  38. #define    HD_LCYL        0x04    /* cylinder low byte */
  39. #define    HD_HCYL        0x05    /* cylinder high byte */
  40. #define    HD_DRV        0x06    /* drive/head register */
  41. #define    HD_STATUS    0x07    /* status/command register */
  42. #define    HD_CMD        0x07    /* status/command register */
  43.  
  44. /*
  45.  * Status bits
  46.  */
  47. #define    BUSY        0x80    /* controller busy */
  48. #define    READY        0x40    /* drive ready */
  49. #define    WRFAULT        0x20    /* write fault */
  50. #define    SEEKDONE    0x10    /* seek operation complete */
  51. #define    DATARQ        0x08    /* data request */
  52. #define    ECC        0x04    /* ECC correction applied */
  53. #define    INDEX        0x02    /* disk revolution index */
  54. #define ERROR        0x01    /* error flag */
  55.  
  56. /*
  57.  * Drive selectors
  58.  */
  59. #define    HD_DHFIXED    0xa0    /* bits always set in drive/head reg. */
  60. #define    HD_DRIVE0    0x00    /* or into HD_DHFIXED to select drive 0 */
  61. #define    HD_DRIVE1    0x10    /* or into HD_DHFIXED to select drive 1 */
  62.  
  63. /*
  64.  * Hard disk commands. 
  65.  */
  66. #define    HD_RESTORE    0x10    /* restore cmd, bottom 4 bits set step rate */
  67. #define    HD_SEEK        0x70    /* seek cmd, bottom 4 bits set step rate */
  68. #define    HD_RDSEC    0x20    /* read sector cmd, bottom 2 bits set ECC and
  69.                     retry modes */
  70. #define    HD_WRSEC    0x30    /* write sector cmd, bottom 2 bits set ECC and
  71.                     retry modes */
  72. #define    HD_FORMAT    0x50    /* format track command */
  73. #define    HD_RDVER    0x40    /* read verify cmd, bot. bit sets retry mode */
  74. #define    HD_DIAG        0x90    /* diagnose command */
  75. #define    HD_SETPARAM    0x91    /* set parameters command */
  76.  
  77. #define    HDTIMOUT    25000    /* how many 10usecs in a 1/4 sec.*/
  78.  
  79. #define NUMDRV  2    /* maximum number of drives */
  80. #define SECSIZE 512    /* default sector size */
  81. #define SECSHFT 9
  82. #define SECMASK (SECSIZE-1)
  83. #define cylin   av_back
  84.  
  85. /* Values of hd_state */
  86. #define HD_OPEN        0x01    /* drive is open */
  87. #define HD_OPENING    0x02    /* drive is being opened */
  88. #define HD_DO_RST    0x04    /* hardware restore command should be issued */
  89. #define HD_DO_FMT    0x08    /* track is being formatted */
  90. #define HD_VTOC_OK    0x10    /* VTOC (pdinfo, vtoc, alts table) OK */
  91. #define HD_FMT_RST    0x20    /* restore needs to happen before format */
  92. #define HD_BADBLK    0x40    /* bad block is being remapped */
  93. #define HD_BBH_VFY    0x0080    /* potential bad block is being verified */
  94. #define HD_BBH_MAP    0x0100    /* bad block is being assigned an alt.  */
  95. #define HD_DO_VFY    0x0200    /* Sector(s) being verified.            */
  96. #define HD_BADTRK    0x0400    /* bad block is in alt trk area being remapped */
  97.  
  98. /*
  99.  * the hard disk minor device number is interpreted as follows:
  100.  *     bits:
  101.  *     7 5 4 3  0
  102.  *     +---+-+----+
  103.  *     |   |u|part|
  104.  *     +---+-+--+-+
  105.  *     codes:
  106.  *    u     - unit no. (0 or 1)
  107.  *    part  - partition no. (0 - 15)
  108.  */
  109. #define PARTITION(x)    (getminor(x) & 0x0F)
  110. #define UNIT(x)        ((getminor(x) >> 4) & 0x01)
  111. #define BASEDEV(x)    (dev_t)((x) & ~0x0F)
  112.  
  113. /*
  114.  * Logical blocks to physical blocks
  115.  */
  116. #define lbtopb(lb) (((lb) << BSHIFT) >> SECSHFT)
  117. #define pbtolb(pb) (((pb) << SECSHFT) >> BSHIFT)
  118.  
  119. /*
  120.  * controller interface templates
  121.  */
  122. struct AT_cmd {
  123.     unsigned char nhd_precomp;    /* write precomp */
  124.         unsigned char nhd_nsect; /* decremented during operation - 0 == 256 */
  125.     unsigned char nhd_sect;                   /* starting sector number */
  126.     unsigned int  nhd_cyl;                      /* up to 1024 cylinders */
  127.     /*
  128.      * must have
  129.      *    bit    7    1
  130.      *    bit    6    0
  131.      *    bit    5    1
  132.      *    bit    4    drive number
  133.      *    bits  3-0    head number
  134.      */
  135.     unsigned char nhd_drv;
  136.     unsigned char nhd_cmd;
  137. };
  138.  
  139. /*
  140.  * r3, r2, r1, r0 is stepping rate:
  141.  *    0         .35 micro-seconds
  142.  *    1         .5    milli-seconds
  143.  *    2        1.0    milli-seconds
  144.  *    2        1.0    milli-seconds
  145.  *    .
  146.  *    .
  147.  *    .
  148.  *    15        7.5    milli-seconds
  149.  */
  150.  
  151. /*
  152.  * bit    definition        value
  153.  *            0            1
  154.  * L    data mode    data only        data plus 4 byte ECC
  155.  * T    retry mode    retries enabled        retries disabled
  156.  */
  157.  
  158. /*
  159.  * operational mode
  160.  */
  161. #define    DAM_NOT_FOUND    0x01    /* Data Address Mark not found   */
  162. #define    TR000_ERR    0x02    /* Track 0 not found             */
  163. #define    ABORTED        0x04    /* Command Aborted               */
  164. #define    ID_NOT_FOUND    0x10    /* Sector ID not found           */
  165. #define    ECC_ERR        0x40    /* Uncorrectable data read error */
  166. #define    BAD_BLK        0x80    /* Bad block flag detected       */
  167.  
  168. #define HDPDLOC        29    /* Sector number on disk where pdinfo is */
  169.  
  170. /* New ioctls to be used for the purpose of testing BBH */
  171. #define HIOC    ('H'<<8)
  172. #define GETALTTBL    (HIOC | 1)    /* get alt_table from kernel memory */
  173. #define FMTBAD        (HIOC | 2)    /* format tracks as bad             */
  174.  
  175. #endif    /* _SYS_HD_H */
  176.