2 * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
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 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/sys/sys/ata.h,v 1.8.2.4 2002/04/02 14:47:35 sos Exp $
29 * $DragonFly: src/sys/sys/ata.h,v 1.2 2003/06/17 04:28:58 dillon Exp $
35 #include <sys/ioccom.h>
37 /* ATA/ATAPI device parameter information */
39 /*000*/ u_int16_t packet_size :2; /* packet command size */
40 #define ATAPI_PSIZE_12 0 /* 12 bytes */
41 #define ATAPI_PSIZE_16 1 /* 16 bytes */
43 u_int16_t incomplete :1;
45 u_int16_t drq_type :2; /* DRQ type */
46 #define ATAPI_DRQT_MPROC 0 /* cpu 3 ms delay */
47 #define ATAPI_DRQT_INTR 1 /* intr 10 ms delay */
48 #define ATAPI_DRQT_ACCEL 2 /* accel 50 us delay */
50 u_int16_t removable :1; /* device is removable */
51 u_int16_t type :5; /* device type */
52 #define ATAPI_TYPE_DIRECT 0 /* disk/floppy */
53 #define ATAPI_TYPE_TAPE 1 /* streaming tape */
54 #define ATAPI_TYPE_CDROM 5 /* CD-ROM device */
55 #define ATAPI_TYPE_OPTICAL 7 /* optical disk */
58 u_int16_t cmd_protocol :1; /* command protocol */
59 #define ATA_PROTO_ATA 0
60 #define ATA_PROTO_ATAPI 1
62 /*001*/ u_int16_t cylinders; /* # of cylinders */
64 /*003*/ u_int16_t heads; /* # heads */
67 /*006*/ u_int16_t sectors; /* # sectors/track */
68 /*007*/ u_int16_t vendor7[3];
69 /*010*/ u_int8_t serial[20]; /* serial number */
73 /*023*/ u_int8_t revision[8]; /* firmware revision */
74 /*027*/ u_int8_t model[40]; /* model name */
75 /*047*/ u_int16_t sectors_intr:8; /* sectors per interrupt */
78 /*048*/ u_int16_t usedmovsd; /* double word read/write? */
79 /*049*/ u_int16_t retired49:8;
80 u_int16_t support_dma :1; /* DMA supported */
81 u_int16_t support_lba :1; /* LBA supported */
82 u_int16_t disable_iordy :1; /* IORDY may be disabled */
83 u_int16_t support_iordy :1; /* IORDY supported */
84 u_int16_t softreset :1; /* needs softreset when busy */
85 u_int16_t stdby_ovlap :1; /* standby/overlap supported */
86 u_int16_t support_queueing:1; /* supports queuing overlap */
87 u_int16_t support_idma :1; /* interleaved DMA supported */
89 /*050*/ u_int16_t device_stdby_min:1;
91 u_int16_t capability_one:1;
92 u_int16_t capability_zero:1;
94 /*051*/ u_int16_t vendor51:8;
95 u_int16_t retired_piomode:8; /* PIO modes 0-2 */
96 /*052*/ u_int16_t vendor52:8;
97 u_int16_t retired_dmamode:8; /* DMA modes, not ATA-3 */
98 /*053*/ u_int16_t atavalid; /* fields valid */
99 #define ATA_FLAG_54_58 1 /* words 54-58 valid */
100 #define ATA_FLAG_64_70 2 /* words 64-70 valid */
101 #define ATA_FLAG_88 4 /* word 88 valid */
103 u_int16_t obsolete54[5];
104 /*059*/ u_int16_t multi_count:8;
105 u_int16_t multi_valid:1;
108 /*060*/ u_int32_t lba_size;
109 u_int16_t obsolete62;
110 /*063*/ u_int16_t mwdmamodes; /* multiword DMA modes */
111 /*064*/ u_int16_t apiomodes; /* advanced PIO modes */
113 /*065*/ u_int16_t mwdmamin; /* min. M/W DMA time/word ns */
114 /*066*/ u_int16_t mwdmarec; /* rec. M/W DMA time ns */
115 /*067*/ u_int16_t pioblind; /* min. PIO cycle w/o flow */
116 /*068*/ u_int16_t pioiordy; /* min. PIO cycle IORDY flow */
117 u_int16_t reserved69;
118 u_int16_t reserved70;
119 /*071*/ u_int16_t rlsovlap; /* rel time (us) for overlap */
120 /*072*/ u_int16_t rlsservice; /* rel time (us) for service */
121 u_int16_t reserved73;
122 u_int16_t reserved74;
124 /*075*/ u_int16_t queuelen:5;
127 u_int16_t reserved76;
128 u_int16_t reserved77;
129 u_int16_t reserved78;
130 u_int16_t reserved79;
131 /*080*/ u_int16_t version_major;
132 /*081*/ u_int16_t version_minor;
134 /*082/085*/ u_int16_t smart:1;
135 u_int16_t security:1;
136 u_int16_t removable:1;
137 u_int16_t power_mngt:1;
139 u_int16_t write_cache:1;
140 u_int16_t look_ahead:1;
141 u_int16_t release_irq:1;
142 u_int16_t service_irq:1;
144 u_int16_t protected:1;
146 u_int16_t write_buffer:1;
147 u_int16_t read_buffer:1;
151 /*083/086*/ u_int16_t microcode:1;
159 u_int16_t max_security:1;
160 u_int16_t auto_acoustic:1;
161 u_int16_t address48:1;
162 u_int16_t config_overlay:1;
163 u_int16_t flush_cache:1;
164 u_int16_t flush_cache48:1;
165 u_int16_t support_one:1;
166 u_int16_t support_zero:1;
168 /*084/087*/ u_int16_t smart_error_log:1;
169 u_int16_t smart_self_test:1;
170 u_int16_t media_serial_no:1;
171 u_int16_t media_card_pass:1;
172 u_int16_t streaming:1;
175 u_int16_t extended_one:1;
176 u_int16_t extended_zero:1;
179 /*088*/ u_int16_t udmamodes; /* UltraDMA modes */
180 /*089*/ u_int16_t erase_time;
181 /*090*/ u_int16_t enhanced_erase_time;
182 /*091*/ u_int16_t apm_value;
183 /*092*/ u_int16_t master_passwd_revision;
185 /*093*/ u_int16_t hwres_master :8;
186 u_int16_t hwres_slave :5;
187 u_int16_t hwres_cblid :1;
188 u_int16_t hwres_valid:2;
190 /*094*/ u_int16_t current_acoustic:8;
191 u_int16_t vendor_acoustic:8;
193 /*095*/ u_int16_t stream_min_req_size;
194 /*096*/ u_int16_t stream_transfer_time;
195 /*097*/ u_int16_t stream_access_latency;
196 /*098*/ u_int32_t stream_granularity;
197 /*100*/ u_int64_t lba_size48;
198 u_int16_t reserved104[23];
199 /*127*/ u_int16_t removable_status;
200 /*128*/ u_int16_t security_status;
201 u_int16_t reserved129[31];
202 /*160*/ u_int16_t cfa_powermode1;
203 u_int16_t reserved161[14];
204 /*176*/ u_int16_t media_serial[30];
205 u_int16_t reserved206[49];
206 /*255*/ u_int16_t integrity;
209 #define ATA_MODE_MASK 0x0f
210 #define ATA_DMA_MASK 0xf0
212 #define ATA_PIO0 0x08
213 #define ATA_PIO1 0x09
214 #define ATA_PIO2 0x0a
215 #define ATA_PIO3 0x0b
216 #define ATA_PIO4 0x0c
218 #define ATA_WDMA 0x20
219 #define ATA_WDMA2 0x22
220 #define ATA_UDMA 0x40
221 #define ATA_UDMA2 0x42
222 #define ATA_UDMA4 0x44
223 #define ATA_UDMA5 0x45
224 #define ATA_UDMA6 0x46
237 #define ATARAIDREBUILD 8
238 #define ATARAIDCREATE 9
239 #define ATARAIDDELETE 10
240 #define ATARAIDSTATUS 11
241 #define ATAENCSTAT 12
250 struct ata_params params[2];
270 #define AR_DEGRADED 2
271 #define AR_REBUILDING 4
286 #define ATAPI_CMD_CTRL 0x00
287 #define ATAPI_CMD_READ 0x01
288 #define ATAPI_CMD_WRITE 0x02
297 #define IOCATA _IOWR('a', 1, struct ata_cmd)
299 #endif /* _SYS_ATA_H_ */