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