/atapi/atareg.h

http://rtems-atapi.googlecode.com/ · C++ Header · 557 lines · 411 code · 43 blank · 103 comment · 6 complexity · 45e38748ed0fa919509fb25b91e3072a MD5 · raw file

  1. /* $NetBSD: atareg.h,v 1.38 2010/01/25 00:39:51 jakllsch Exp $ */
  2. /*
  3. * Copyright (c) 1998, 2001 Manuel Bouyer.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  16. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*-
  26. * Copyright (c) 1991 The Regents of the University of California.
  27. * All rights reserved.
  28. *
  29. * This code is derived from software contributed to Berkeley by
  30. * William Jolitz.
  31. *
  32. * Redistribution and use in source and binary forms, with or without
  33. * modification, are permitted provided that the following conditions
  34. * are met:
  35. * 1. Redistributions of source code must retain the above copyright
  36. * notice, this list of conditions and the following disclaimer.
  37. * 2. Redistributions in binary form must reproduce the above copyright
  38. * notice, this list of conditions and the following disclaimer in the
  39. * documentation and/or other materials provided with the distribution.
  40. * 3. Neither the name of the University nor the names of its contributors
  41. * may be used to endorse or promote products derived from this software
  42. * without specific prior written permission.
  43. *
  44. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  45. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  46. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  47. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  48. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  49. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  50. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  51. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  52. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  53. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  54. * SUCH DAMAGE.
  55. *
  56. * @(#)wdreg.h 7.1 (Berkeley) 5/9/91
  57. */
  58. #ifndef _DEV_ATA_ATAREG_H_
  59. #define _DEV_ATA_ATAREG_H_
  60. /*
  61. * ATA Task File register definitions.
  62. */
  63. /* Status bits. */
  64. #define WDCS_BSY 0x80 /* busy */
  65. #define WDCS_DRDY 0x40 /* drive ready */
  66. #define WDCS_DWF 0x20 /* drive write fault */
  67. #define WDCS_DSC 0x10 /* drive seek complete */
  68. #define WDCS_DRQ 0x08 /* data request */
  69. #define WDCS_CORR 0x04 /* corrected data */
  70. #define WDCS_IDX 0x02 /* index */
  71. #define WDCS_ERR 0x01 /* error */
  72. #define WDCS_BITS \
  73. "\020\010bsy\007drdy\006dwf\005dsc\004drq\003corr\002idx\001err"
  74. /* Error bits. */
  75. #define WDCE_BBK 0x80 /* bad block detected */
  76. #define WDCE_CRC 0x80 /* CRC error (Ultra-DMA only) */
  77. #define WDCE_UNC 0x40 /* uncorrectable data error */
  78. #define WDCE_MC 0x20 /* media changed */
  79. #define WDCE_IDNF 0x10 /* id not found */
  80. #define WDCE_MCR 0x08 /* media change requested */
  81. #define WDCE_ABRT 0x04 /* aborted command */
  82. #define WDCE_TK0NF 0x02 /* track 0 not found */
  83. #define WDCE_AMNF 0x01 /* address mark not found */
  84. /* Commands for Disk Controller. */
  85. #define WDCC_NOP 0x00 /* Always fail with "aborted command" */
  86. #define WDCC_RECAL 0x10 /* disk restore code -- resets cntlr */
  87. #define WDCC_READ 0x20 /* disk read code */
  88. #define WDCC_WRITE 0x30 /* disk write code */
  89. #define WDCC__LONG 0x02 /* modifier -- access ecc bytes */
  90. #define WDCC__NORETRY 0x01 /* modifier -- no retrys */
  91. #define WDCC_FORMAT 0x50 /* disk format code */
  92. #define WDCC_DIAGNOSE 0x90 /* controller diagnostic */
  93. #define WDCC_IDP 0x91 /* initialize drive parameters */
  94. #define WDCC_SMART 0xb0 /* Self Mon, Analysis, Reporting Tech */
  95. #define WDCC_READMULTI 0xc4 /* read multiple */
  96. #define WDCC_WRITEMULTI 0xc5 /* write multiple */
  97. #define WDCC_SETMULTI 0xc6 /* set multiple mode */
  98. #define WDCC_READDMA 0xc8 /* read with DMA */
  99. #define WDCC_WRITEDMA 0xca /* write with DMA */
  100. #define WDCC_ACKMC 0xdb /* acknowledge media change */
  101. #define WDCC_LOCK 0xde /* lock drawer */
  102. #define WDCC_UNLOCK 0xdf /* unlock drawer */
  103. #define WDCC_FLUSHCACHE 0xe7 /* Flush cache */
  104. #define WDCC_FLUSHCACHE_EXT 0xea /* Flush cache ext */
  105. #define WDCC_IDENTIFY 0xec /* read parameters from controller */
  106. #define SET_FEATURES 0xef /* set features */
  107. #define WDCC_IDLE 0xe3 /* set idle timer & enter idle mode */
  108. #define WDCC_IDLE_IMMED 0xe1 /* enter idle mode */
  109. #define WDCC_SLEEP 0xe6 /* enter sleep mode */
  110. #define WDCC_STANDBY 0xe2 /* set standby timer & enter standby */
  111. #define WDCC_STANDBY_IMMED 0xe0 /* enter standby mode */
  112. #define WDCC_CHECK_PWR 0xe5 /* check power mode */
  113. #define WDCC_SECURITY_FREEZE 0xf5 /* freeze locking state */
  114. /* Big Drive support */
  115. #define WDCC_READ_EXT 0x24 /* read 48-bit addressing */
  116. #define WDCC_WRITE_EXT 0x34 /* write 48-bit addressing */
  117. #define WDCC_READMULTI_EXT 0x29 /* read multiple 48-bit addressing */
  118. #define WDCC_WRITEMULTI_EXT 0x39 /* write multiple 48-bit addressing */
  119. #define WDCC_READDMA_EXT 0x25 /* read 48-bit addressing with DMA */
  120. #define WDCC_WRITEDMA_EXT 0x35 /* write 48-bit addressing with DMA */
  121. #if defined(_KERNEL) || defined(_STANDALONE)
  122. #include "ataconf.h"
  123. /* Convert a 32-bit command to a 48-bit command. */
  124. static __inline int
  125. atacmd_to48(int cmd32)
  126. {
  127. switch (cmd32) {
  128. case WDCC_READ:
  129. return WDCC_READ_EXT;
  130. case WDCC_WRITE:
  131. return WDCC_WRITE_EXT;
  132. case WDCC_READMULTI:
  133. return WDCC_READMULTI_EXT;
  134. case WDCC_WRITEMULTI:
  135. return WDCC_WRITEMULTI_EXT;
  136. #if NATA_DMA
  137. case WDCC_READDMA:
  138. return WDCC_READDMA_EXT;
  139. case WDCC_WRITEDMA:
  140. return WDCC_WRITEDMA_EXT;
  141. #endif
  142. default:
  143. return 0;
  144. //panic("atacmd_to48: illegal 32-bit command: %d", cmd32); cdcs
  145. /* NOTREACHED */
  146. }
  147. }
  148. #endif /* _KERNEL || _STANDALONE */
  149. /* Native SATA command queueing */
  150. #define WDCC_READ_FPDMA_QUEUED 0x60 /* SATA native queued read (48bit) */
  151. #define WDCC_WRITE_FPDMA_QUEUED 0x61 /* SATA native queued write (48bit) */
  152. #ifdef _KERNEL
  153. /* Convert a 32-bit command to a Native SATA Queued command. */
  154. static __inline int
  155. atacmd_tostatq(int cmd32)
  156. {
  157. switch (cmd32) {
  158. case WDCC_READDMA:
  159. return WDCC_READ_FPDMA_QUEUED;
  160. case WDCC_WRITEDMA:
  161. return WDCC_WRITE_FPDMA_QUEUED;
  162. default:
  163. return 0;
  164. //panic("atacmd_tosataq: illegal 32-bit command: %d", cmd32); cdcs
  165. /* NOTREACHED */
  166. }
  167. }
  168. #endif /* _KERNEL */
  169. /* Subcommands for SET_FEATURES (features register) */
  170. #define WDSF_8BIT_PIO_EN 0x01
  171. #define WDSF_WRITE_CACHE_EN 0x02
  172. #define WDSF_SET_MODE 0x03
  173. #define WDSF_REASSIGN_EN 0x04
  174. #define WDSF_APM_EN 0x05
  175. #define WDSF_RETRY_DS 0x33
  176. #define WDSF_SET_CACHE_SGMT 0x54
  177. #define WDSF_READAHEAD_DS 0x55
  178. #define WDSF_POD_DS 0x66
  179. #define WDSF_ECC_DS 0x77
  180. #define WDSF_WRITE_CACHE_DS 0x82
  181. #define WDSF_REASSIGN_DS 0x84
  182. #define WDSF_APM_DS 0x85
  183. #define WDSF_ECC_EN 0x88
  184. #define WDSF_RETRY_EN 0x99
  185. #define WDSF_SET_CURRENT 0x9a
  186. #define WDSF_READAHEAD_EN 0xaa
  187. #define WDSF_PREFETCH_SET 0xab
  188. #define WDSF_POD_EN 0xcc
  189. /* Subcommands for SMART (features register) */
  190. #define WDSM_RD_DATA 0xd0
  191. #define WDSM_RD_THRESHOLDS 0xd1
  192. #define WDSM_ATTR_AUTOSAVE_EN 0xd2
  193. #define WDSM_SAVE_ATTR 0xd3
  194. #define WDSM_EXEC_OFFL_IMM 0xd4
  195. #define WDSM_RD_LOG 0xd5
  196. #define WDSM_ENABLE_OPS 0xd8
  197. #define WDSM_DISABLE_OPS 0xd9
  198. #define WDSM_STATUS 0xda
  199. #define WDSMART_CYL 0xc24f
  200. /* parameters uploaded to device/heads register */
  201. #define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */
  202. #define WDSD_CHS 0x00 /* cylinder/head/sector addressing */
  203. #define WDSD_LBA 0x40 /* logical block addressing */
  204. /* Commands for ATAPI devices */
  205. #define ATAPI_CHECK_POWER_MODE 0xe5
  206. #define ATAPI_EXEC_DRIVE_DIAGS 0x90
  207. #define ATAPI_IDLE_IMMEDIATE 0xe1
  208. #define ATAPI_NOP 0x00
  209. #define ATAPI_PKT_CMD 0xa0
  210. #define ATAPI_IDENTIFY_DEVICE 0xa1
  211. #define ATAPI_SOFT_RESET 0x08
  212. #define ATAPI_SLEEP 0xe6
  213. #define ATAPI_STANDBY_IMMEDIATE 0xe0
  214. /* Bytes used by ATAPI_PACKET_COMMAND (feature register) */
  215. #define ATAPI_PKT_CMD_FTRE_DMA 0x01
  216. #define ATAPI_PKT_CMD_FTRE_OVL 0x02
  217. /* ireason */
  218. #define WDCI_CMD 0x01 /* command(1) or data(0) */
  219. #define WDCI_IN 0x02 /* transfer to(1) or from(0) the host */
  220. #define WDCI_RELEASE 0x04 /* bus released until completion */
  221. #define PHASE_CMDOUT (WDCS_DRQ | WDCI_CMD)
  222. #define PHASE_DATAIN (WDCS_DRQ | WDCI_IN)
  223. #define PHASE_DATAOUT (WDCS_DRQ)
  224. #define PHASE_COMPLETED (WDCI_IN | WDCI_CMD)
  225. #define PHASE_ABORTED (0)
  226. /*
  227. * Drive parameter structure for ATA/ATAPI.
  228. * Bit fields: WDC_* : common to ATA/ATAPI
  229. * ATA_* : ATA only
  230. * ATAPI_* : ATAPI only.
  231. */
  232. struct ataparams {
  233. /* drive info */
  234. uint16_t atap_config; /* 0: general configuration */
  235. #define WDC_CFG_ATAPI_MASK 0xc000
  236. #define WDC_CFG_ATAPI 0x8000
  237. #define ATA_CFG_REMOVABLE 0x0080
  238. #define ATA_CFG_FIXED 0x0040
  239. #define ATAPI_CFG_TYPE_MASK 0x1f00
  240. #define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8)
  241. #define ATAPI_CFG_REMOV 0x0080
  242. #define ATAPI_CFG_DRQ_MASK 0x0060
  243. #define ATAPI_CFG_STD_DRQ 0x0000
  244. #define ATAPI_CFG_IRQ_DRQ 0x0020
  245. #define ATAPI_CFG_ACCEL_DRQ 0x0040
  246. #define ATAPI_CFG_CMD_MASK 0x0003
  247. #define ATAPI_CFG_CMD_12 0x0000
  248. #define ATAPI_CFG_CMD_16 0x0001
  249. /* words 1-9 are ATA only */
  250. uint16_t atap_cylinders; /* 1: # of non-removable cylinders */
  251. uint16_t __reserved1;
  252. uint16_t atap_heads; /* 3: # of heads */
  253. uint16_t __retired1[2]; /* 4-5: # of unform. bytes/track */
  254. uint16_t atap_sectors; /* 6: # of sectors */
  255. uint16_t __retired2[3];
  256. uint8_t atap_serial[20]; /* 10-19: serial number */
  257. uint16_t __retired3[2];
  258. uint16_t __obsolete1;
  259. uint8_t atap_revision[8]; /* 23-26: firmware revision */
  260. uint8_t atap_model[40]; /* 27-46: model number */
  261. uint16_t atap_multi; /* 47: maximum sectors per irq (ATA) */
  262. uint16_t __reserved2;
  263. uint16_t atap_capabilities1; /* 49: capability flags */
  264. #define WDC_CAP_IORDY 0x0800
  265. #define WDC_CAP_IORDY_DSBL 0x0400
  266. #define WDC_CAP_LBA 0x0200
  267. #define WDC_CAP_DMA 0x0100
  268. #define ATA_CAP_STBY 0x2000
  269. #define ATAPI_CAP_INTERL_DMA 0x8000
  270. #define ATAPI_CAP_CMD_QUEUE 0x4000
  271. #define ATAPI_CAP_OVERLP 0X2000
  272. #define ATAPI_CAP_ATA_RST 0x1000
  273. uint16_t atap_capabilities2; /* 50: capability flags (ATA) */
  274. #if BYTE_ORDER == LITTLE_ENDIAN
  275. uint8_t __junk2;
  276. uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */
  277. uint8_t __junk3;
  278. uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */
  279. #else
  280. uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */
  281. uint8_t __junk2;
  282. uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */
  283. uint8_t __junk3;
  284. #endif
  285. uint16_t atap_extensions; /* 53: extensions supported */
  286. #define WDC_EXT_UDMA_MODES 0x0004
  287. #define WDC_EXT_MODES 0x0002
  288. #define WDC_EXT_GEOM 0x0001
  289. /* words 54-62 are ATA only */
  290. uint16_t atap_curcylinders; /* 54: current logical cylinders */
  291. uint16_t atap_curheads; /* 55: current logical heads */
  292. uint16_t atap_cursectors; /* 56: current logical sectors/tracks */
  293. uint16_t atap_curcapacity[2]; /* 57-58: current capacity */
  294. uint16_t atap_curmulti; /* 59: current multi-sector setting */
  295. #define WDC_MULTI_VALID 0x0100
  296. #define WDC_MULTI_MASK 0x00ff
  297. uint16_t atap_capacity[2]; /* 60-61: total capacity (LBA only) */
  298. uint16_t __retired4;
  299. #if BYTE_ORDER == LITTLE_ENDIAN
  300. uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */
  301. uint8_t atap_dmamode_act; /* multiword DMA mode active */
  302. uint8_t atap_piomode_supp; /* 64: PIO mode supported */
  303. uint8_t __junk4;
  304. #else
  305. uint8_t atap_dmamode_act; /* multiword DMA mode active */
  306. uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */
  307. uint8_t __junk4;
  308. uint8_t atap_piomode_supp; /* 64: PIO mode supported */
  309. #endif
  310. uint16_t atap_dmatiming_mimi; /* 65: minimum DMA cycle time */
  311. uint16_t atap_dmatiming_recom; /* 66: recommended DMA cycle time */
  312. uint16_t atap_piotiming; /* 67: mini PIO cycle time without FC */
  313. uint16_t atap_piotiming_iordy; /* 68: mini PIO cycle time with IORDY FC */
  314. uint16_t __reserved3[2];
  315. /* words 71-72 are ATAPI only */
  316. uint16_t atap_pkt_br; /* 71: time (ns) to bus release */
  317. uint16_t atap_pkt_bsyclr; /* 72: tme to clear BSY after service */
  318. uint16_t __reserved4[2];
  319. uint16_t atap_queuedepth; /* 75: */
  320. #define WDC_QUEUE_DEPTH_MASK 0x1F
  321. uint16_t atap_sata_caps; /* 76: */
  322. #define SATA_SIGNAL_GEN1 0x02
  323. #define SATA_SIGNAL_GEN2 0x04
  324. #define SATA_NATIVE_CMDQ 0x0100
  325. #define SATA_HOST_PWR_MGMT 0x0200
  326. #define SATA_PHY_EVNT_CNT 0x0400
  327. uint16_t atap_sata_reserved; /* 77: */
  328. uint16_t atap_sata_features_supp; /* 78: */
  329. #define SATA_NONZERO_OFFSETS 0x02
  330. #define SATA_DMA_SETUP_AUTO 0x04
  331. #define SATA_DRIVE_PWR_MGMT 0x08
  332. #define SATA_IN_ORDER_DATA 0x10
  333. #define SATA_SW_STTNGS_PRS 0x40
  334. uint16_t atap_sata_features_en; /* 79: */
  335. uint16_t atap_ata_major; /* 80: Major version number */
  336. #define WDC_VER_ATA1 0x0002
  337. #define WDC_VER_ATA2 0x0004
  338. #define WDC_VER_ATA3 0x0008
  339. #define WDC_VER_ATA4 0x0010
  340. #define WDC_VER_ATA5 0x0020
  341. #define WDC_VER_ATA6 0x0040
  342. #define WDC_VER_ATA7 0x0080
  343. uint16_t atap_ata_minor; /* 81: Minor version number */
  344. uint16_t atap_cmd_set1; /* 82: command set supported */
  345. #define WDC_CMD1_NOP 0x4000 /* NOP */
  346. #define WDC_CMD1_RB 0x2000 /* READ BUFFER */
  347. #define WDC_CMD1_WB 0x1000 /* WRITE BUFFER */
  348. /* 0x0800 Obsolete */
  349. #define WDC_CMD1_HPA 0x0400 /* Host Protected Area */
  350. #define WDC_CMD1_DVRST 0x0200 /* DEVICE RESET */
  351. #define WDC_CMD1_SRV 0x0100 /* SERVICE */
  352. #define WDC_CMD1_RLSE 0x0080 /* release interrupt */
  353. #define WDC_CMD1_AHEAD 0x0040 /* look-ahead */
  354. #define WDC_CMD1_CACHE 0x0020 /* write cache */
  355. #define WDC_CMD1_PKT 0x0010 /* PACKET */
  356. #define WDC_CMD1_PM 0x0008 /* Power Management */
  357. #define WDC_CMD1_REMOV 0x0004 /* Removable Media */
  358. #define WDC_CMD1_SEC 0x0002 /* Security Mode */
  359. #define WDC_CMD1_SMART 0x0001 /* SMART */
  360. uint16_t atap_cmd_set2; /* 83: command set supported */
  361. #define ATA_CMD2_FCE 0x2000 /* FLUSH CACHE EXT */
  362. #define WDC_CMD2_FC 0x1000 /* FLUSH CACHE */
  363. #define WDC_CMD2_DCO 0x0800 /* Device Configuration Overlay */
  364. #define ATA_CMD2_LBA48 0x0400 /* 48-bit Address */
  365. #define WDC_CMD2_AAM 0x0200 /* Automatic Acoustic Management */
  366. #define WDC_CMD2_SM 0x0100 /* SET MAX security extension */
  367. #define WDC_CMD2_SFREQ 0x0040 /* SET FEATURE is required
  368. to spin-up after power-up */
  369. #define WDC_CMD2_PUIS 0x0020 /* Power-Up In Standby */
  370. #define WDC_CMD2_RMSN 0x0010 /* Removable Media Status Notify */
  371. #define ATA_CMD2_APM 0x0008 /* Advanced Power Management */
  372. #define ATA_CMD2_CFA 0x0004 /* CFA */
  373. #define ATA_CMD2_RWQ 0x0002 /* READ/WRITE DMA QUEUED */
  374. #define WDC_CMD2_DM 0x0001 /* DOWNLOAD MICROCODE */
  375. uint16_t atap_cmd_ext; /* 84: command/features supp. ext. */
  376. #define ATA_CMDE_TLCONT 0x1000 /* Time-limited R/W Continuous */
  377. #define ATA_CMDE_TL 0x0800 /* Time-limited R/W */
  378. #define ATA_CMDE_URGW 0x0400 /* URG for WRITE STREAM DMA/PIO */
  379. #define ATA_CMDE_URGR 0x0200 /* URG for READ STREAM DMA/PIO */
  380. #define ATA_CMDE_WWN 0x0100 /* World Wide name */
  381. #define ATA_CMDE_WQFE 0x0080 /* WRITE DMA QUEUED FUA EXT */
  382. #define ATA_CMDE_WFE 0x0040 /* WRITE DMA/MULTIPLE FUA EXT */
  383. #define ATA_CMDE_GPL 0x0020 /* General Purpose Logging */
  384. #define ATA_CMDE_STREAM 0x0010 /* Streaming */
  385. #define ATA_CMDE_MCPTC 0x0008 /* Media Card Pass Through Cmd */
  386. #define ATA_CMDE_MS 0x0004 /* Media serial number */
  387. #define ATA_CMDE_SST 0x0002 /* SMART self-test */
  388. #define ATA_CMDE_SEL 0x0001 /* SMART error logging */
  389. uint16_t atap_cmd1_en; /* 85: cmd/features enabled */
  390. /* bits are the same as atap_cmd_set1 */
  391. uint16_t atap_cmd2_en; /* 86: cmd/features enabled */
  392. /* bits are the same as atap_cmd_set2 */
  393. uint16_t atap_cmd_def; /* 87: cmd/features default */
  394. #if BYTE_ORDER == LITTLE_ENDIAN
  395. uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */
  396. uint8_t atap_udmamode_act; /* Ultra-DMA mode active */
  397. #else
  398. uint8_t atap_udmamode_act; /* Ultra-DMA mode active */
  399. uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */
  400. #endif
  401. /* 89-92 are ATA-only */
  402. uint16_t atap_seu_time; /* 89: Sec. Erase Unit compl. time */
  403. uint16_t atap_eseu_time; /* 90: Enhanced SEU compl. time */
  404. uint16_t atap_apm_val; /* 91: current APM value */
  405. uint16_t __reserved5[8]; /* 92-99: reserved */
  406. uint16_t atap_max_lba[4]; /* 100-103: Max. user LBA addr */
  407. uint16_t __reserved6[2]; /* 104-105: reserved */
  408. uint16_t atap_secsz; /* 106: physical/logical sector size */
  409. #define ATA_SECSZ_VALID_MASK 0xc000
  410. #define ATA_SECSZ_VALID 0x4000
  411. #define ATA_SECSZ_LPS 0x2000 /* long physical sectors */
  412. #define ATA_SECSZ_LLS 0x1000 /* long logical sectors */
  413. #define ATA_SECSZ_LPS_SZMSK 0x000f /* 2**N logical per physical */
  414. uint16_t atap_iso7779_isd; /* 107: ISO 7779 inter-seek delay */
  415. uint16_t atap_wwn[4]; /* 108-111: World Wide Name */
  416. uint16_t __reserved7[5]; /* 112-116 */
  417. uint16_t atap_lls_secsz[2]; /* 117-118: long logical sector size */
  418. uint16_t __reserved8[8]; /* 119-126 */
  419. uint16_t atap_rmsn_supp; /* 127: remov. media status notif. */
  420. #define WDC_RMSN_SUPP_MASK 0x0003
  421. #define WDC_RMSN_SUPP 0x0001
  422. uint16_t atap_sec_st; /* 128: security status */
  423. #define WDC_SEC_LEV_MAX 0x0100
  424. #define WDC_SEC_ESE_SUPP 0x0020
  425. #define WDC_SEC_EXP 0x0010
  426. #define WDC_SEC_FROZEN 0x0008
  427. #define WDC_SEC_LOCKED 0x0004
  428. #define WDC_SEC_EN 0x0002
  429. #define WDC_SEC_SUPP 0x0001
  430. uint16_t __reserved9[31]; /* 129-159: vendor specific */
  431. uint16_t atap_cfa_power; /* 160: CFA powermode */
  432. #define ATA_CFA_MAX_MASK 0x0fff
  433. #define ATA_CFA_MODE1_DIS 0x1000 /* CFA Mode 1 Disabled */
  434. #define ATA_CFA_MODE1_REQ 0x2000 /* CFA Mode 1 Required */
  435. #define ATA_CFA_WORD160 0x8000 /* Word 160 supported */
  436. uint16_t __reserved10[15]; /* 161-175: reserved for CFA */
  437. uint8_t atap_media_serial[60]; /* 176-205: media serial number */
  438. uint16_t __reserved11[3]; /* 206-208: */
  439. uint16_t atap_logical_align; /* 209: logical/physical alignment */
  440. #define ATA_LA_VALID_MASK 0xc000
  441. #define ATA_LA_VALID 0x4000
  442. #define ATA_LA_MASK 0x3fff /* offset of sector LBA 0 in PBA 0 */
  443. uint16_t __reserved12[45]; /* 210-254: */
  444. uint16_t atap_integrity; /* 255: Integrity word */
  445. #define WDC_INTEGRITY_MAGIC_MASK 0x00ff
  446. #define WDC_INTEGRITY_MAGIC 0x00a5
  447. };
  448. /*
  449. * If WDSM_ATTR_ADVISORY, device exceeded intended design life period.
  450. * If not WDSM_ATTR_ADVISORY, imminent data loss predicted.
  451. */
  452. #define WDSM_ATTR_ADVISORY 1
  453. /*
  454. * If WDSM_ATTR_COLLECTIVE, attribute only updated in off-line testing.
  455. * If not WDSM_ATTR_COLLECTIVE, attribute updated also in on-line testing.
  456. */
  457. #define WDSM_ATTR_COLLECTIVE 2
  458. /*
  459. * ATA SMART attributes
  460. */
  461. struct ata_smart_attr {
  462. uint8_t id; /* attribute id number */
  463. uint16_t flags;
  464. uint8_t value; /* attribute value */
  465. uint8_t worst;
  466. uint8_t raw[6];
  467. uint8_t reserved;
  468. } ;
  469. struct ata_smart_attributes {
  470. uint16_t data_structure_revision;
  471. struct ata_smart_attr attributes[30];
  472. uint8_t offline_data_collection_status;
  473. uint8_t self_test_exec_status;
  474. uint16_t total_time_to_complete_off_line;
  475. uint8_t vendor_specific_366;
  476. uint8_t offline_data_collection_capability;
  477. uint16_t smart_capability;
  478. uint8_t errorlog_capability;
  479. uint8_t vendor_specific_371;
  480. uint8_t short_test_completion_time;
  481. uint8_t extend_test_completion_time;
  482. uint8_t reserved_374_385[12];
  483. uint8_t vendor_specific_386_509[125];
  484. int8_t checksum;
  485. } ;
  486. struct ata_smart_thresh {
  487. uint8_t id;
  488. uint8_t value;
  489. uint8_t reserved[10];
  490. } ;
  491. struct ata_smart_thresholds {
  492. uint16_t data_structure_revision;
  493. struct ata_smart_thresh thresholds[30];
  494. uint8_t reserved[18];
  495. uint8_t vendor_specific[131];
  496. int8_t checksum;
  497. } ;
  498. struct ata_smart_selftest {
  499. uint8_t number;
  500. uint8_t status;
  501. uint16_t time_stamp;
  502. uint8_t failure_check_point;
  503. uint32_t lba_first_error;
  504. uint8_t vendor_specific[15];
  505. } ;
  506. struct ata_smart_selftestlog {
  507. uint16_t data_structure_revision;
  508. struct ata_smart_selftest log_entries[21];
  509. uint8_t vendorspecific[2];
  510. uint8_t mostrecenttest;
  511. uint8_t reserved[2];
  512. uint8_t checksum;
  513. } ;
  514. #endif /* _DEV_ATA_ATAREG_H_ */