atareg.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* $OpenBSD: atareg.h,v 1.14 2010/07/23 07:47:13 jsg Exp $ */
  2. /* $NetBSD: atareg.h,v 1.5 1999/01/18 20:06:24 bouyer Exp $ */
  3. /*
  4. * Copyright (c) 1998, 2001 Manuel Bouyer.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _DEV_ATA_ATAREG_H_
  27. #define _DEV_ATA_ATAREG_H_
  28. /*
  29. * Drive parameter structure for ATA/ATAPI.
  30. * Bit fields: WDC_* : common to ATA/ATAPI
  31. * ATA_* : ATA only
  32. * ATAPI_* : ATAPI only.
  33. */
  34. struct ataparams {
  35. /* drive info */
  36. u_int16_t atap_config; /* 0: general configuration */
  37. #define WDC_CFG_ATAPI_MASK 0xc000
  38. #define WDC_CFG_ATAPI 0x8000
  39. #define ATA_CFG_REMOVABLE 0x0080
  40. #define ATA_CFG_FIXED 0x0040
  41. #define ATAPI_CFG_TYPE_MASK 0x1f00
  42. #define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8)
  43. #define ATAPI_CFG_TYPE_DIRECT 0x00
  44. #define ATAPI_CFG_TYPE_SEQUENTIAL 0x01
  45. #define ATAPI_CFG_TYPE_CDROM 0x05
  46. #define ATAPI_CFG_TYPE_OPTICAL 0x07
  47. #define ATAPI_CFG_TYPE_NODEVICE 0x1F
  48. #define ATAPI_CFG_REMOV 0x0080
  49. #define ATAPI_CFG_DRQ_MASK 0x0060
  50. #define ATAPI_CFG_STD_DRQ 0x0000
  51. #define ATAPI_CFG_IRQ_DRQ 0x0020
  52. #define ATAPI_CFG_ACCEL_DRQ 0x0040
  53. #define ATAPI_CFG_CMD_MASK 0x0003
  54. #define ATAPI_CFG_CMD_12 0x0000
  55. #define ATAPI_CFG_CMD_16 0x0001
  56. /* words 1-9 are ATA only */
  57. u_int16_t atap_cylinders; /* 1: # of non-removable cylinders */
  58. u_int16_t __reserved1;
  59. u_int16_t atap_heads; /* 3: # of heads */
  60. u_int16_t __retired1[2]; /* 4-5: # of unform. bytes/track */
  61. u_int16_t atap_sectors; /* 6: # of sectors */
  62. u_int16_t __retired2[3];
  63. u_int8_t atap_serial[20]; /* 10-19: serial number */
  64. u_int16_t __retired3[2];
  65. u_int16_t __obsolete1;
  66. u_int8_t atap_revision[8]; /* 23-26: firmware revision */
  67. u_int8_t atap_model[40]; /* 27-46: model number */
  68. u_int16_t atap_multi; /* 47: maximum sectors per irq (ATA) */
  69. u_int16_t __reserved2;
  70. u_int16_t atap_capabilities1; /* 49: capability flags */
  71. #define WDC_CAP_IORDY 0x0800
  72. #define WDC_CAP_IORDY_DSBL 0x0400
  73. #define WDC_CAP_LBA 0x0200
  74. #define WDC_CAP_DMA 0x0100
  75. #define ATA_CAP_STBY 0x2000
  76. #define ATAPI_CAP_INTERL_DMA 0x8000
  77. #define ATAPI_CAP_CMD_QUEUE 0x4000
  78. #define ATAPI_CAP_OVERLP 0x2000
  79. #define ATAPI_CAP_ATA_RST 0x1000
  80. u_int16_t atap_capabilities2; /* 50: capability flags (ATA) */
  81. #if BYTE_ORDER == LITTLE_ENDIAN
  82. u_int8_t __junk2;
  83. u_int8_t atap_oldpiotiming; /* 51: old PIO timing mode */
  84. u_int8_t __junk3;
  85. u_int8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */
  86. #else
  87. u_int8_t atap_oldpiotiming; /* 51: old PIO timing mode */
  88. u_int8_t __junk2;
  89. u_int8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */
  90. u_int8_t __junk3;
  91. #endif
  92. u_int16_t atap_extensions; /* 53: extensions supported */
  93. #define WDC_EXT_UDMA_MODES 0x0004
  94. #define WDC_EXT_MODES 0x0002
  95. #define WDC_EXT_GEOM 0x0001
  96. /* words 54-62 are ATA only */
  97. u_int16_t atap_curcylinders; /* 54: current logical cylinders */
  98. u_int16_t atap_curheads; /* 55: current logical heads */
  99. u_int16_t atap_cursectors; /* 56: current logical sectors/tracks */
  100. u_int16_t atap_curcapacity[2]; /* 57-58: current capacity */
  101. u_int16_t atap_curmulti; /* 59: current multi-sector setting */
  102. #define WDC_MULTI_VALID 0x0100
  103. #define WDC_MULTI_MASK 0x00ff
  104. u_int16_t atap_capacity[2]; /* 60-61: total capacity (LBA only) */
  105. u_int16_t __retired4;
  106. #if BYTE_ORDER == LITTLE_ENDIAN
  107. u_int8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */
  108. u_int8_t atap_dmamode_act; /* multiword DMA mode active */
  109. u_int8_t atap_piomode_supp; /* 64: PIO mode supported */
  110. u_int8_t __junk4;
  111. #else
  112. u_int8_t atap_dmamode_act; /* multiword DMA mode active */
  113. u_int8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */
  114. u_int8_t __junk4;
  115. u_int8_t atap_piomode_supp; /* 64: PIO mode supported */
  116. #endif
  117. u_int16_t atap_dmatiming_mimi; /* 65: minimum DMA cycle time */
  118. u_int16_t atap_dmatiming_recom; /* 66: recommended DMA cycle time */
  119. u_int16_t atap_piotiming; /* 67: mini PIO cycle time without FC */
  120. u_int16_t atap_piotiming_iordy; /* 68: mini PIO cycle time with IORDY FC */
  121. u_int16_t __reserved3[2];
  122. /* words 71-72 are ATAPI only */
  123. u_int16_t atap_pkt_br; /* 71: time (ns) to bus release */
  124. u_int16_t atap_pkt_bsyclr; /* 72: tme to clear BSY after service */
  125. u_int16_t __reserved4[2];
  126. u_int16_t atap_queuedepth; /* 75: */
  127. #define WDC_QUEUE_DEPTH_MASK 0x1f
  128. u_int16_t atap_sata_caps; /* 76: SATA capabilities */
  129. #define SATA_SIGNAL_GEN1 0x0002 /* SATA Gen-1 signaling speed */
  130. #define SATA_SIGNAL_GEN2 0x0004 /* SATA Gen-2 signaling speed */
  131. #define SATA_NATIVE_CMDQ 0x0100 /* native command queuing */
  132. #define SATA_HOST_PWR_MGMT 0x0200 /* power management (host) */
  133. u_int16_t atap_sata_reserved; /* 77: reserved */
  134. u_int16_t atap_sata_features_supp;/* 78: SATA features supported */
  135. #define SATA_NONZERO_OFFSETS 0x0002 /* non-zero buffer offsets */
  136. #define SATA_DMA_SETUP_AUTO 0x0004 /* DMA setup auto-activate */
  137. #define SATA_DRIVE_PWR_MGMT 0x0008 /* power management (device) */
  138. u_int16_t atap_sata_features_en; /* 79: SATA features enabled */
  139. u_int16_t atap_ata_major; /* 80: Major version number */
  140. #define WDC_VER_ATA1 0x0002
  141. #define WDC_VER_ATA2 0x0004
  142. #define WDC_VER_ATA3 0x0008
  143. #define WDC_VER_ATA4 0x0010
  144. #define WDC_VER_ATA5 0x0020
  145. #define WDC_VER_ATA6 0x0040
  146. #define WDC_VER_ATA7 0x0080
  147. #define WDC_VER_ATA8 0x0100
  148. #define WDC_VER_ATA9 0x0200
  149. #define WDC_VER_ATA10 0x0400
  150. #define WDC_VER_ATA11 0x0800
  151. #define WDC_VER_ATA12 0x1000
  152. #define WDC_VER_ATA13 0x2000
  153. #define WDC_VER_ATA14 0x4000
  154. u_int16_t atap_ata_minor; /* 81: Minor version number */
  155. u_int16_t atap_cmd_set1; /* 82: command set supported */
  156. #define WDC_CMD1_NOP 0x4000
  157. #define WDC_CMD1_RB 0x2000
  158. #define WDC_CMD1_WB 0x1000
  159. #define WDC_CMD1_HPA 0x0400
  160. #define WDC_CMD1_DVRST 0x0200
  161. #define WDC_CMD1_SRV 0x0100
  162. #define WDC_CMD1_RLSE 0x0080
  163. #define WDC_CMD1_AHEAD 0x0040
  164. #define WDC_CMD1_CACHE 0x0020
  165. #define WDC_CMD1_PKT 0x0010
  166. #define WDC_CMD1_PM 0x0008
  167. #define WDC_CMD1_REMOV 0x0004
  168. #define WDC_CMD1_SEC 0x0002
  169. #define WDC_CMD1_SMART 0x0001
  170. u_int16_t atap_cmd_set2; /* 83: command set supported */
  171. #define ATAPI_CMD2_FCE 0x2000 /* Flush Cache Ext supported */
  172. #define ATAPI_CMD2_FC 0x1000 /* Flush Cache supported */
  173. #define ATAPI_CMD2_DCO 0x0800 /* Device Configuration Overlay supported */
  174. #define ATAPI_CMD2_48AD 0x0400 /* 48bit address supported */
  175. #define ATAPI_CMD2_AAM 0x0200 /* Automatic Acoustic Management supported */
  176. #define ATAPI_CMD2_SM 0x0100 /* Set Max security extension supported */
  177. #define ATAPI_CMD2_SF 0x0040 /* Set Features subcommand required */
  178. #define ATAPI_CMD2_PUIS 0x0020 /* Power up in standby supported */
  179. #define WDC_CMD2_RMSN 0x0010
  180. #define ATA_CMD2_APM 0x0008
  181. #define ATA_CMD2_CFA 0x0004
  182. #define ATA_CMD2_RWQ 0x0002
  183. #define WDC_CMD2_DM 0x0001 /* Download Microcode supported */
  184. u_int16_t atap_cmd_ext; /* 84: command/features supp. ext. */
  185. #define ATAPI_CMDE_IIUF 0x2000 /* IDLE IMMEDIATE with UNLOAD FEATURE */
  186. #define ATAPI_CMDE_MSER 0x0004 /* Media serial number supported */
  187. #define ATAPI_CMDE_TEST 0x0002 /* SMART self-test supported */
  188. #define ATAPI_CMDE_SLOG 0x0001 /* SMART error logging supported */
  189. u_int16_t atap_cmd1_en; /* 85: cmd/features enabled */
  190. /* bits are the same as atap_cmd_set1 */
  191. u_int16_t atap_cmd2_en; /* 86: cmd/features enabled */
  192. /* bits are the same as atap_cmd_set2 */
  193. u_int16_t atap_cmd_def; /* 87: cmd/features default */
  194. /* bits are NOT the same as atap_cmd_ext */
  195. #if BYTE_ORDER == LITTLE_ENDIAN
  196. u_int8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */
  197. u_int8_t atap_udmamode_act; /* Ultra-DMA mode active */
  198. #else
  199. u_int8_t atap_udmamode_act; /* Ultra-DMA mode active */
  200. u_int8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */
  201. #endif
  202. /* 89-92 are ATA-only */
  203. u_int16_t atap_seu_time; /* 89: Sec. Erase Unit compl. time */
  204. u_int16_t atap_eseu_time; /* 90: Enhanced SEU compl. time */
  205. u_int16_t atap_apm_val; /* 91: current APM value */
  206. u_int16_t atap_mpasswd_rev; /* 92: Master Password revision */
  207. u_int16_t atap_hwreset_res; /* 93: Hardware reset value */
  208. #define ATA_HWRES_CBLID 0x2000 /* CBLID above Vih */
  209. #define ATA_HWRES_D1_PDIAG 0x0800 /* Device 1 PDIAG detect OK */
  210. #define ATA_HWRES_D1_CSEL 0x0400 /* Device 1 used CSEL for address */
  211. #define ATA_HWRES_D1_JUMP 0x0200 /* Device 1 jumpered to address */
  212. #define ATA_HWRES_D0_SEL 0x0040 /* Device 0 responds when Dev 1 selected */
  213. #define ATA_HWRES_D0_DASP 0x0020 /* Device 0 DASP detect OK */
  214. #define ATA_HWRES_D0_PDIAG 0x0010 /* Device 0 PDIAG detect OK */
  215. #define ATA_HWRES_D0_DIAG 0x0008 /* Device 0 diag OK */
  216. #define ATA_HWRES_D0_CSEL 0x0004 /* Device 0 used CSEL for address */
  217. #define ATA_HWRES_D0_JUMP 0x0002 /* Device 0 jumpered to address */
  218. #if BYTE_ORDER == LITTLE_ENDIAN
  219. u_int8_t atap_acoustic_val; /* 94: Current acoustic level */
  220. u_int8_t atap_acoustic_def; /* recommended level */
  221. #else
  222. u_int8_t atap_acoustic_def; /* recommended level */
  223. u_int8_t atap_acoustic_val; /* 94: Current acoustic level */
  224. #endif
  225. u_int16_t __reserved6[5]; /* 95-99: reserved */
  226. u_int16_t atap_max_lba[4]; /* 100-103: Max. user LBA add */
  227. u_int16_t __reserved7[23]; /* 104-126: reserved */
  228. u_int16_t atap_rmsn_supp; /* 127: remov. media status notif. */
  229. #define WDC_RMSN_SUPP_MASK 0x0003
  230. #define WDC_RMSN_SUPP 0x0001
  231. u_int16_t atap_sec_st; /* 128: security status */
  232. #define WDC_SEC_LEV_MAX 0x0100
  233. #define WDC_SEC_ESE_SUPP 0x0020
  234. #define WDC_SEC_EXP 0x0010
  235. #define WDC_SEC_FROZEN 0x0008
  236. #define WDC_SEC_LOCKED 0x0004
  237. #define WDC_SEC_EN 0x0002
  238. #define WDC_SEC_SUPP 0x0001
  239. u_int16_t __reserved8[31]; /* 129-159: vendor specific */
  240. u_int16_t atap_cfa_power; /* 160: CFA powermode */
  241. #define ATAPI_CFA_MAX_MASK 0x0FFF
  242. #define ATAPI_CFA_MODE1_DIS 0x1000 /* CFA Mode 1 Disabled */
  243. #define ATAPI_CFA_MODE1_REQ 0x2000 /* CFA Mode 1 Required */
  244. #define ATAPI_CFA_WORD160 0x8000 /* Word 160 supported */
  245. u_int16_t __reserved9[15]; /* 161-175: reserved for CFA */
  246. u_int8_t atap_media_serial[60]; /* 176-205: media serial number */
  247. u_int16_t __reserved10[49]; /* 206-254: reserved */
  248. #if BYTE_ORDER == LITTLE_ENDIAN
  249. u_int8_t atap_signature; /* 255: Signature */
  250. u_int8_t atap_checksum; /* Checksum */
  251. #else
  252. u_int8_t atap_checksum; /* Checksum */
  253. u_int8_t atap_signature; /* 255: Signature */
  254. #endif
  255. };
  256. #endif /* !_DEV_ATA_ATAREG_H_ */