FreeBSD/Linux Kernel Cross Reference
sys/sys/ata.h
1 /*-
2 * Copyright (c) 2000 - 2003 Søren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
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 * 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.
16 *
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.
27 *
28 * $FreeBSD: releng/5.2/sys/sys/ata.h 119877 2003-09-08 08:30:43Z sos $
29 */
30
31 #ifndef _SYS_ATA_H_
32 #define _SYS_ATA_H_
33
34 #include <sys/ioccom.h>
35
36 /* ATA/ATAPI device parameters */
37 struct ata_params {
38 /*000*/ u_int16_t config; /* configuration info */
39 #define ATA_PROTO_MASK 0x8003
40 #define ATA_PROTO_ATA 0x0002
41 #define ATA_PROTO_ATAPI_12 0x8000
42 #define ATA_PROTO_ATAPI_16 0x8001
43 #define ATA_ATAPI_TYPE_MASK 0x1f00
44 #define ATA_ATAPI_TYPE_DIRECT 0x0000 /* disk/floppy */
45 #define ATA_ATAPI_TYPE_TAPE 0x0100 /* streaming tape */
46 #define ATA_ATAPI_TYPE_CDROM 0x0500 /* CD-ROM device */
47 #define ATA_ATAPI_TYPE_OPTICAL 0x0700 /* optical disk */
48 #define ATA_DRQ_MASK 0x0060
49 #define ATA_DRQ_SLOW 0x0000 /* cpu 3 ms delay */
50 #define ATA_DRQ_INTR 0x0020 /* interrupt 10 ms delay */
51 #define ATA_DRQ_FAST 0x0040 /* accel 50 us delay */
52
53 /*001*/ u_int16_t cylinders; /* # of cylinders */
54 u_int16_t reserved2;
55 /*003*/ u_int16_t heads; /* # heads */
56 u_int16_t obsolete4;
57 u_int16_t obsolete5;
58 /*006*/ u_int16_t sectors; /* # sectors/track */
59 /*007*/ u_int16_t vendor7[3];
60 /*010*/ u_int8_t serial[20]; /* serial number */
61 /*020*/ u_int16_t retired20;
62 u_int16_t retired21;
63 u_int16_t obsolete22;
64 /*023*/ u_int8_t revision[8]; /* firmware revision */
65 /*027*/ u_int8_t model[40]; /* model name */
66 /*047*/ u_int16_t sectors_intr; /* sectors per interrupt */
67 /*048*/ u_int16_t usedmovsd; /* double word read/write? */
68 /*049*/ u_int16_t capabilities1;
69 #define ATA_SUPPORT_DMA 0x0100
70 #define ATA_SUPPORT_LBA 0x0200
71 #define ATA_SUPPORT_OVERLAP 0x4000
72
73 /*050*/ u_int16_t capabilities2;
74 /*051*/ u_int16_t retired_piomode; /* PIO modes 0-2 */
75 #define ATA_RETIRED_PIO_MASK 0x0300
76
77 /*052*/ u_int16_t retired_dmamode; /* DMA modes */
78 #define ATA_RETIRED_DMA_MASK 0x0003
79
80 /*053*/ u_int16_t atavalid; /* fields valid */
81 #define ATA_FLAG_54_58 0x0001 /* words 54-58 valid */
82 #define ATA_FLAG_64_70 0x0002 /* words 64-70 valid */
83 #define ATA_FLAG_88 0x0004 /* word 88 valid */
84
85 /*054*/ u_int16_t obsolete54[5];
86 /*059*/ u_int16_t multi;
87 #define ATA_MULTI_VALID 0x0100
88
89 /*060*/ u_int16_t lba_size_1;
90 u_int16_t lba_size_2;
91 u_int16_t obsolete62;
92 /*063*/ u_int16_t mwdmamodes; /* multiword DMA modes */
93 /*064*/ u_int16_t apiomodes; /* advanced PIO modes */
94
95 /*065*/ u_int16_t mwdmamin; /* min. M/W DMA time/word ns */
96 /*066*/ u_int16_t mwdmarec; /* rec. M/W DMA time ns */
97 /*067*/ u_int16_t pioblind; /* min. PIO cycle w/o flow */
98 /*068*/ u_int16_t pioiordy; /* min. PIO cycle IORDY flow */
99 u_int16_t reserved69;
100 u_int16_t reserved70;
101 /*071*/ u_int16_t rlsovlap; /* rel time (us) for overlap */
102 /*072*/ u_int16_t rlsservice; /* rel time (us) for service */
103 u_int16_t reserved73;
104 u_int16_t reserved74;
105 /*075*/ u_int16_t queue;
106 #define ATA_QUEUE_LEN(x) ((x) & 0x001f)
107
108 u_int16_t reserved76;
109 u_int16_t reserved77;
110 u_int16_t reserved78;
111 u_int16_t reserved79;
112 /*080*/ u_int16_t version_major;
113 /*081*/ u_int16_t version_minor;
114
115 struct {
116 /*082/085*/ u_int16_t command1;
117 #define ATA_SUPPORT_SMART 0x0001
118 #define ATA_SUPPORT_SECURITY 0x0002
119 #define ATA_SUPPORT_REMOVABLE 0x0004
120 #define ATA_SUPPORT_POWERMGT 0x0008
121 #define ATA_SUPPORT_PACKET 0x0010
122 #define ATA_SUPPORT_WRITECACHE 0x0020
123 #define ATA_SUPPORT_LOOKAHEAD 0x0040
124 #define ATA_SUPPORT_RELEASEIRQ 0x0080
125 #define ATA_SUPPORT_SERVICEIRQ 0x0100
126 #define ATA_SUPPORT_RESET 0x0200
127 #define ATA_SUPPORT_PROTECTED 0x0400
128 #define ATA_SUPPORT_WRITEBUFFER 0x1000
129 #define ATA_SUPPORT_READBUFFER 0x2000
130 #define ATA_SUPPORT_NOP 0x4000
131
132 /*083/086*/ u_int16_t command2;
133 #define ATA_SUPPORT_MICROCODE 0x0001
134 #define ATA_SUPPORT_QUEUED 0x0002
135 #define ATA_SUPPORT_CFA 0x0004
136 #define ATA_SUPPORT_APM 0x0008
137 #define ATA_SUPPORT_NOTIFY 0x0010
138 #define ATA_SUPPORT_STANDBY 0x0020
139 #define ATA_SUPPORT_SPINUP 0x0040
140 #define ATA_SUPPORT_MAXSECURITY 0x0100
141 #define ATA_SUPPORT_AUTOACOUSTIC 0x0200
142 #define ATA_SUPPORT_ADDRESS48 0x0400
143 #define ATA_SUPPORT_OVERLAY 0x0800
144 #define ATA_SUPPORT_FLUSHCACHE 0x1000
145 #define ATA_SUPPORT_FLUSHCACHE48 0x2000
146
147 /*084/087*/ u_int16_t extension;
148 } support, enabled;
149
150 /*088*/ u_int16_t udmamodes; /* UltraDMA modes */
151 /*089*/ u_int16_t erase_time;
152 /*090*/ u_int16_t enhanced_erase_time;
153 /*091*/ u_int16_t apm_value;
154 /*092*/ u_int16_t master_passwd_revision;
155 /*093*/ u_int16_t hwres;
156 #define ATA_CABLE_ID 0x2000
157
158 /*094*/ u_int16_t acoustic;
159 #define ATA_ACOUSTIC_CURRENT(x) ((x) & 0x00ff)
160 #define ATA_ACOUSTIC_VENDOR(x) (((x) & 0xff00) >> 8)
161
162 /*095*/ u_int16_t stream_min_req_size;
163 /*096*/ u_int16_t stream_transfer_time;
164 /*097*/ u_int16_t stream_access_latency;
165 /*098*/ u_int32_t stream_granularity;
166 /*100*/ u_int16_t lba_size48_1;
167 u_int16_t lba_size48_2;
168 u_int16_t lba_size48_3;
169 u_int16_t lba_size48_4;
170 u_int16_t reserved104[23];
171 /*127*/ u_int16_t removable_status;
172 /*128*/ u_int16_t security_status;
173 u_int16_t reserved129[31];
174 /*160*/ u_int16_t cfa_powermode1;
175 u_int16_t reserved161[14];
176 /*176*/ u_int16_t media_serial[30];
177 u_int16_t reserved206[49];
178 /*255*/ u_int16_t integrity;
179 };
180
181 /* ATA transfer modes */
182 #define ATA_MODE_MASK 0x0f
183 #define ATA_DMA_MASK 0xf0
184 #define ATA_PIO 0x00
185 #define ATA_PIO0 0x08
186 #define ATA_PIO1 0x09
187 #define ATA_PIO2 0x0a
188 #define ATA_PIO3 0x0b
189 #define ATA_PIO4 0x0c
190 #define ATA_PIO_MAX 0x0f
191 #define ATA_DMA 0x10
192 #define ATA_WDMA0 0x20
193 #define ATA_WDMA1 0x21
194 #define ATA_WDMA2 0x22
195 #define ATA_UDMA0 0x40
196 #define ATA_UDMA1 0x41
197 #define ATA_UDMA2 0x42
198 #define ATA_UDMA3 0x43
199 #define ATA_UDMA4 0x44
200 #define ATA_UDMA5 0x45
201 #define ATA_UDMA6 0x46
202 #define ATA_SA150 0x47
203 #define ATA_DMA_MAX 0x4f
204
205 /* ATA commands */
206 #define ATA_NOP 0x00 /* NOP command */
207 #define ATA_NF_FLUSHQUEUE 0x00 /* flush queued cmd's */
208 #define ATA_NF_AUTOPOLL 0x01 /* start autopoll function */
209 #define ATA_ATAPI_RESET 0x08 /* reset ATAPI device */
210 #define ATA_READ 0x20 /* read command */
211 #define ATA_READ48 0x24 /* read command */
212 #define ATA_READ_DMA48 0x25 /* read w/DMA command */
213 #define ATA_READ_DMA_QUEUED48 0x26 /* read w/DMA QUEUED command */
214 #define ATA_READ_MUL48 0x29 /* read multi command */
215 #define ATA_WRITE 0x30 /* write command */
216 #define ATA_WRITE48 0x34 /* write command */
217 #define ATA_WRITE_DMA48 0x35 /* write w/DMA command */
218 #define ATA_WRITE_DMA_QUEUED48 0x36 /* write w/DMA QUEUED command */
219 #define ATA_WRITE_MUL48 0x39 /* write multi command */
220 #define ATA_PACKET_CMD 0xa0 /* packet command */
221 #define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/
222 #define ATA_SERVICE 0xa2 /* service command */
223 #define ATA_READ_MUL 0xc4 /* read multi command */
224 #define ATA_WRITE_MUL 0xc5 /* write multi command */
225 #define ATA_SET_MULTI 0xc6 /* set multi size command */
226 #define ATA_READ_DMA_QUEUED 0xc7 /* read w/DMA QUEUED command */
227 #define ATA_READ_DMA 0xc8 /* read w/DMA command */
228 #define ATA_WRITE_DMA 0xca /* write w/DMA command */
229 #define ATA_WRITE_DMA_QUEUED 0xcc /* write w/DMA QUEUED command */
230 #define ATA_SLEEP 0xe6 /* sleep command */
231 #define ATA_FLUSHCACHE 0xe7 /* flush cache to disk */
232 #define ATA_FLUSHCACHE48 0xea /* flush cache to disk */
233 #define ATA_ATA_IDENTIFY 0xec /* get ATA params */
234 #define ATA_SETFEATURES 0xef /* features command */
235 #define ATA_SF_SETXFER 0x03 /* set transfer mode */
236 #define ATA_SF_ENAB_WCACHE 0x02 /* enable write cache */
237 #define ATA_SF_DIS_WCACHE 0x82 /* disable write cache */
238 #define ATA_SF_ENAB_RCACHE 0xaa /* enable readahead cache */
239 #define ATA_SF_DIS_RCACHE 0x55 /* disable readahead cache */
240 #define ATA_SF_ENAB_RELIRQ 0x5d /* enable release interrupt */
241 #define ATA_SF_DIS_RELIRQ 0xdd /* disable release interrupt */
242 #define ATA_SF_ENAB_SRVIRQ 0x5e /* enable service interrupt */
243 #define ATA_SF_DIS_SRVIRQ 0xde /* disable service interrupt */
244
245 /* ATAPI commands */
246 #define ATAPI_TEST_UNIT_READY 0x00 /* check if device is ready */
247 #define ATAPI_REZERO 0x01 /* rewind */
248 #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */
249 #define ATAPI_FORMAT 0x04 /* format unit */
250 #define ATAPI_READ 0x08 /* read data */
251 #define ATAPI_WRITE 0x0a /* write data */
252 #define ATAPI_WEOF 0x10 /* write filemark */
253 #define ATAPI_WF_WRITE 0x01
254 #define ATAPI_SPACE 0x11 /* space command */
255 #define ATAPI_SP_FM 0x01
256 #define ATAPI_SP_EOD 0x03
257 #define ATAPI_MODE_SELECT 0x15 /* mode select */
258 #define ATAPI_ERASE 0x19 /* erase */
259 #define ATAPI_MODE_SENSE 0x1a /* mode sense */
260 #define ATAPI_START_STOP 0x1b /* start/stop unit */
261 #define ATAPI_SS_LOAD 0x01
262 #define ATAPI_SS_RETENSION 0x02
263 #define ATAPI_SS_EJECT 0x04
264 #define ATAPI_PREVENT_ALLOW 0x1e /* media removal */
265 #define ATAPI_READ_FORMAT_CAPACITIES 0x23 /* get format capacities */
266 #define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */
267 #define ATAPI_READ_BIG 0x28 /* read data */
268 #define ATAPI_WRITE_BIG 0x2a /* write data */
269 #define ATAPI_LOCATE 0x2b /* locate to position */
270 #define ATAPI_READ_POSITION 0x34 /* read position */
271 #define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush buf, close channel */
272 #define ATAPI_WRITE_BUFFER 0x3b /* write device buffer */
273 #define ATAPI_READ_BUFFER 0x3c /* read device buffer */
274 #define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */
275 #define ATAPI_READ_TOC 0x43 /* get table of contents */
276 #define ATAPI_PLAY_10 0x45 /* play by lba */
277 #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */
278 #define ATAPI_PLAY_TRACK 0x48 /* play by track number */
279 #define ATAPI_PAUSE 0x4b /* pause audio operation */
280 #define ATAPI_READ_DISK_INFO 0x51 /* get disk info structure */
281 #define ATAPI_READ_TRACK_INFO 0x52 /* get track info structure */
282 #define ATAPI_RESERVE_TRACK 0x53 /* reserve track */
283 #define ATAPI_SEND_OPC_INFO 0x54 /* send OPC structurek */
284 #define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */
285 #define ATAPI_REPAIR_TRACK 0x58 /* repair track */
286 #define ATAPI_READ_MASTER_CUE 0x59 /* read master CUE info */
287 #define ATAPI_MODE_SENSE_BIG 0x5a /* get device parameters */
288 #define ATAPI_CLOSE_TRACK 0x5b /* close track/session */
289 #define ATAPI_READ_BUFFER_CAPACITY 0x5c /* get buffer capicity */
290 #define ATAPI_SEND_CUE_SHEET 0x5d /* send CUE sheet */
291 #define ATAPI_BLANK 0xa1 /* blank the media */
292 #define ATAPI_SEND_KEY 0xa3 /* send DVD key structure */
293 #define ATAPI_REPORT_KEY 0xa4 /* get DVD key structure */
294 #define ATAPI_PLAY_12 0xa5 /* play by lba */
295 #define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */
296 #define ATAPI_READ_STRUCTURE 0xad /* get DVD structure */
297 #define ATAPI_PLAY_CD 0xb4 /* universal play command */
298 #define ATAPI_SET_SPEED 0xbb /* set drive speed */
299 #define ATAPI_MECH_STATUS 0xbd /* get changer status */
300 #define ATAPI_READ_CD 0xbe /* read data */
301 #define ATAPI_POLL_DSC 0xff /* poll DSC status bit */
302
303 struct ata_cmd {
304 int channel;
305 int device;
306 int cmd;
307 #define ATAGMAXCHANNEL 0x0101
308 #define ATAGPARM 0x0102
309 #define ATAGMODE 0x0103
310 #define ATASMODE 0x0104
311 #define ATAREQUEST 0x0108
312 #define ATAREINIT 0x0110
313 #define ATAATTACH 0x0111
314 #define ATADETACH 0x0112
315 #define ATARAIDCREATE 0x0120
316 #define ATARAIDDELETE 0x0121
317 #define ATARAIDSTATUS 0x0122
318 #define ATARAIDADDSPARE 0x0123
319 #define ATARAIDREBUILD 0x0124
320 #define ATAENCSTAT 0x0130
321
322 union {
323 int maxchan;
324
325 struct {
326 int type[2];
327 char name[2][32];
328 struct ata_params params[2];
329 } param;
330
331 struct {
332 int mode[2];
333 } mode;
334
335 struct {
336 union {
337 struct {
338 u_int8_t command;
339 u_int8_t feature;
340 u_int64_t lba;
341 u_int16_t count;
342 } ata;
343 struct {
344 char ccb[16];
345 } atapi;
346 } u;
347 caddr_t data;
348 int count;
349 int flags;
350 #define ATA_CMD_CONTROL 0x01
351 #define ATA_CMD_READ 0x02
352 #define ATA_CMD_WRITE 0x04
353 #define ATA_CMD_ATAPI 0x08
354
355 int timeout;
356 int error;
357 } request;
358
359 struct raid_setup {
360 int type;
361 #define AR_RAID0 1
362 #define AR_RAID1 2
363 #define AR_SPAN 4
364
365 int total_disks;
366 int disks[16];
367 int interleave;
368 int unit;
369 } raid_setup;
370
371 struct raid_status {
372 int type;
373 int total_disks;
374 int disks[16];
375 int interleave;
376 int status;
377 #define AR_READY 1
378 #define AR_DEGRADED 2
379 #define AR_REBUILDING 4
380
381 int progress;
382 } raid_status;
383
384 struct {
385 int disk;
386 } raid_spare;
387
388 struct {
389 int fan;
390 int temp;
391 int v05;
392 int v12;
393 } enclosure;
394 } u;
395 };
396
397 #define IOCATA _IOWR('a', 1, struct ata_cmd)
398
399 #endif /* _SYS_ATA_H_ */
Cache object: 6e0925d032cfe0f50c69d96d0b8c4a1d
|