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