| Commit | Line | Data |
|---|---|---|
| c1b3d7c5 TS |
1 | /*- |
| 2 | * Copyright (c) 2000 - 2006 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 | * | |
| 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 | * | |
| 50f757e8 MD |
26 | * $FreeBSD: src/sys/sys/ata.h,v 1.35 2006/03/31 08:09:04 sos Exp $ |
| 27 | * $DragonFly: src/sys/sys/nata.h,v 1.2 2007/06/02 19:17:01 dillon Exp $ | |
| c1b3d7c5 TS |
28 | */ |
| 29 | ||
| 30 | /* XXX TGEN Don't define anything if sys/ata.h is being included. This makes | |
| 31 | various tools like kdump(1) which grovel headers for e.g. ioctl numbers | |
| 32 | compile/work. The check will be removed once NATA is mature enough to | |
| 33 | replace the older ATA code. */ | |
| 34 | #ifndef _SYS_ATA_H_ | |
| 35 | #ifndef _SYS_NATA_H_ | |
| 36 | #define _SYS_NATA_H_ | |
| 37 | ||
| 38 | #ifndef _SYS_TYPES_H_ | |
| 39 | #include <sys/types.h> | |
| 40 | #endif | |
| 41 | #ifndef _SYS_IOCCOM_H_ | |
| 42 | #include <sys/ioccom.h> | |
| 43 | #endif | |
| 44 | ||
| 45 | /* ATA/ATAPI device parameters */ | |
| 46 | struct ata_params { | |
| 47 | /*000*/ u_int16_t config; /* configuration info */ | |
| 48 | #define ATA_PROTO_MASK 0x8003 | |
| 49 | #define ATA_PROTO_ATAPI 0x8000 | |
| 50 | #define ATA_PROTO_ATAPI_12 0x8000 | |
| 51 | #define ATA_PROTO_ATAPI_16 0x8001 | |
| 52 | #define ATA_ATAPI_TYPE_MASK 0x1f00 | |
| 53 | #define ATA_ATAPI_TYPE_DIRECT 0x0000 /* disk/floppy */ | |
| 54 | #define ATA_ATAPI_TYPE_TAPE 0x0100 /* streaming tape */ | |
| 55 | #define ATA_ATAPI_TYPE_CDROM 0x0500 /* CD-ROM device */ | |
| 56 | #define ATA_ATAPI_TYPE_OPTICAL 0x0700 /* optical disk */ | |
| 57 | #define ATA_DRQ_MASK 0x0060 | |
| 58 | #define ATA_DRQ_SLOW 0x0000 /* cpu 3 ms delay */ | |
| 59 | #define ATA_DRQ_INTR 0x0020 /* interrupt 10 ms delay */ | |
| 60 | #define ATA_DRQ_FAST 0x0040 /* accel 50 us delay */ | |
| 61 | ||
| 62 | /*001*/ u_int16_t cylinders; /* # of cylinders */ | |
| 63 | u_int16_t reserved2; | |
| 64 | /*003*/ u_int16_t heads; /* # heads */ | |
| 65 | u_int16_t obsolete4; | |
| 66 | u_int16_t obsolete5; | |
| 67 | /*006*/ u_int16_t sectors; /* # sectors/track */ | |
| 68 | /*007*/ u_int16_t vendor7[3]; | |
| 69 | /*010*/ u_int8_t serial[20]; /* serial number */ | |
| 70 | /*020*/ u_int16_t retired20; | |
| 71 | u_int16_t retired21; | |
| 72 | u_int16_t obsolete22; | |
| 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; /* sectors per interrupt */ | |
| 76 | /*048*/ u_int16_t usedmovsd; /* double word read/write? */ | |
| 77 | /*049*/ u_int16_t capabilities1; | |
| 78 | #define ATA_SUPPORT_DMA 0x0100 | |
| 79 | #define ATA_SUPPORT_LBA 0x0200 | |
| 80 | #define ATA_SUPPORT_OVERLAP 0x4000 | |
| 81 | ||
| 82 | /*050*/ u_int16_t capabilities2; | |
| 83 | /*051*/ u_int16_t retired_piomode; /* PIO modes 0-2 */ | |
| 84 | #define ATA_RETIRED_PIO_MASK 0x0300 | |
| 85 | ||
| 86 | /*052*/ u_int16_t retired_dmamode; /* DMA modes */ | |
| 87 | #define ATA_RETIRED_DMA_MASK 0x0003 | |
| 88 | ||
| 89 | /*053*/ u_int16_t atavalid; /* fields valid */ | |
| 90 | #define ATA_FLAG_54_58 0x0001 /* words 54-58 valid */ | |
| 91 | #define ATA_FLAG_64_70 0x0002 /* words 64-70 valid */ | |
| 92 | #define ATA_FLAG_88 0x0004 /* word 88 valid */ | |
| 93 | ||
| 94 | /*054*/ u_int16_t current_cylinders; | |
| 95 | /*055*/ u_int16_t current_heads; | |
| 96 | /*056*/ u_int16_t current_sectors; | |
| 97 | /*057*/ u_int16_t current_size_1; | |
| 98 | /*058*/ u_int16_t current_size_2; | |
| 99 | /*059*/ u_int16_t multi; | |
| 100 | #define ATA_MULTI_VALID 0x0100 | |
| 101 | ||
| 102 | /*060*/ u_int16_t lba_size_1; | |
| 103 | u_int16_t lba_size_2; | |
| 104 | u_int16_t obsolete62; | |
| 105 | /*063*/ u_int16_t mwdmamodes; /* multiword DMA modes */ | |
| 106 | /*064*/ u_int16_t apiomodes; /* advanced PIO modes */ | |
| 107 | ||
| 108 | /*065*/ u_int16_t mwdmamin; /* min. M/W DMA time/word ns */ | |
| 109 | /*066*/ u_int16_t mwdmarec; /* rec. M/W DMA time ns */ | |
| 110 | /*067*/ u_int16_t pioblind; /* min. PIO cycle w/o flow */ | |
| 111 | /*068*/ u_int16_t pioiordy; /* min. PIO cycle IORDY flow */ | |
| 112 | u_int16_t reserved69; | |
| 113 | u_int16_t reserved70; | |
| 114 | /*071*/ u_int16_t rlsovlap; /* rel time (us) for overlap */ | |
| 115 | /*072*/ u_int16_t rlsservice; /* rel time (us) for service */ | |
| 116 | u_int16_t reserved73; | |
| 117 | u_int16_t reserved74; | |
| 118 | /*075*/ u_int16_t queue; | |
| 119 | #define ATA_QUEUE_LEN(x) ((x) & 0x001f) | |
| 120 | ||
| 121 | u_int16_t satacapabilities; | |
| 122 | #define ATA_SATA_GEN1 0x0002 | |
| 123 | #define ATA_SATA_GEN2 0x0004 | |
| 124 | #define ATA_SUPPORT_NCQ 0x0100 | |
| 125 | #define ATA_SUPPORT_IFPWRMNGTRCV 0x0200 | |
| 126 | ||
| 127 | u_int16_t reserved77; | |
| 128 | u_int16_t satasupport; | |
| 129 | #define ATA_SUPPORT_NONZERO 0x0002 | |
| 130 | #define ATA_SUPPORT_AUTOACTIVATE 0x0004 | |
| 131 | #define ATA_SUPPORT_IFPWRMNGT 0x0008 | |
| 132 | #define ATA_SUPPORT_INORDERDATA 0x0010 | |
| 133 | u_int16_t sataenabled; | |
| 134 | ||
| 135 | /*080*/ u_int16_t version_major; | |
| 136 | /*081*/ u_int16_t version_minor; | |
| 137 | ||
| 138 | struct { | |
| 139 | /*082/085*/ u_int16_t command1; | |
| 140 | #define ATA_SUPPORT_SMART 0x0001 | |
| 141 | #define ATA_SUPPORT_SECURITY 0x0002 | |
| 142 | #define ATA_SUPPORT_REMOVABLE 0x0004 | |
| 143 | #define ATA_SUPPORT_POWERMGT 0x0008 | |
| 144 | #define ATA_SUPPORT_PACKET 0x0010 | |
| 145 | #define ATA_SUPPORT_WRITECACHE 0x0020 | |
| 146 | #define ATA_SUPPORT_LOOKAHEAD 0x0040 | |
| 147 | #define ATA_SUPPORT_RELEASEIRQ 0x0080 | |
| 148 | #define ATA_SUPPORT_SERVICEIRQ 0x0100 | |
| 149 | #define ATA_SUPPORT_RESET 0x0200 | |
| 150 | #define ATA_SUPPORT_PROTECTED 0x0400 | |
| 151 | #define ATA_SUPPORT_WRITEBUFFER 0x1000 | |
| 152 | #define ATA_SUPPORT_READBUFFER 0x2000 | |
| 153 | #define ATA_SUPPORT_NOP 0x4000 | |
| 154 | ||
| 155 | /*083/086*/ u_int16_t command2; | |
| 156 | #define ATA_SUPPORT_MICROCODE 0x0001 | |
| 157 | #define ATA_SUPPORT_QUEUED 0x0002 | |
| 158 | #define ATA_SUPPORT_CFA 0x0004 | |
| 159 | #define ATA_SUPPORT_APM 0x0008 | |
| 160 | #define ATA_SUPPORT_NOTIFY 0x0010 | |
| 161 | #define ATA_SUPPORT_STANDBY 0x0020 | |
| 162 | #define ATA_SUPPORT_SPINUP 0x0040 | |
| 163 | #define ATA_SUPPORT_MAXSECURITY 0x0100 | |
| 164 | #define ATA_SUPPORT_AUTOACOUSTIC 0x0200 | |
| 165 | #define ATA_SUPPORT_ADDRESS48 0x0400 | |
| 166 | #define ATA_SUPPORT_OVERLAY 0x0800 | |
| 167 | #define ATA_SUPPORT_FLUSHCACHE 0x1000 | |
| 168 | #define ATA_SUPPORT_FLUSHCACHE48 0x2000 | |
| 169 | ||
| 170 | /*084/087*/ u_int16_t extension; | |
| 171 | } __packed support, enabled; | |
| 172 | ||
| 173 | /*088*/ u_int16_t udmamodes; /* UltraDMA modes */ | |
| 174 | /*089*/ u_int16_t erase_time; | |
| 175 | /*090*/ u_int16_t enhanced_erase_time; | |
| 176 | /*091*/ u_int16_t apm_value; | |
| 177 | /*092*/ u_int16_t master_passwd_revision; | |
| 178 | /*093*/ u_int16_t hwres; | |
| 179 | #define ATA_CABLE_ID 0x2000 | |
| 180 | ||
| 181 | /*094*/ u_int16_t acoustic; | |
| 182 | #define ATA_ACOUSTIC_CURRENT(x) ((x) & 0x00ff) | |
| 183 | #define ATA_ACOUSTIC_VENDOR(x) (((x) & 0xff00) >> 8) | |
| 184 | ||
| 185 | /*095*/ u_int16_t stream_min_req_size; | |
| 186 | /*096*/ u_int16_t stream_transfer_time; | |
| 187 | /*097*/ u_int16_t stream_access_latency; | |
| 188 | /*098*/ u_int32_t stream_granularity; | |
| 189 | /*100*/ u_int16_t lba_size48_1; | |
| 190 | u_int16_t lba_size48_2; | |
| 191 | u_int16_t lba_size48_3; | |
| 192 | u_int16_t lba_size48_4; | |
| 193 | u_int16_t reserved104[23]; | |
| 194 | /*127*/ u_int16_t removable_status; | |
| 195 | /*128*/ u_int16_t security_status; | |
| 196 | u_int16_t reserved129[31]; | |
| 197 | /*160*/ u_int16_t cfa_powermode1; | |
| 198 | u_int16_t reserved161[15]; | |
| 199 | /*176*/ u_int16_t media_serial[30]; | |
| 200 | u_int16_t reserved206[49]; | |
| 201 | /*255*/ u_int16_t integrity; | |
| 202 | } __packed; | |
| 203 | ||
| 204 | ||
| 205 | /* ATA transfer modes */ | |
| 206 | #define ATA_MODE_MASK 0x0f | |
| 207 | #define ATA_DMA_MASK 0xf0 | |
| 208 | #define ATA_PIO 0x00 | |
| 209 | #define ATA_PIO0 0x08 | |
| 210 | #define ATA_PIO1 0x09 | |
| 211 | #define ATA_PIO2 0x0a | |
| 212 | #define ATA_PIO3 0x0b | |
| 213 | #define ATA_PIO4 0x0c | |
| 214 | #define ATA_PIO_MAX 0x0f | |
| 215 | #define ATA_DMA 0x10 | |
| 216 | #define ATA_WDMA0 0x20 | |
| 217 | #define ATA_WDMA1 0x21 | |
| 218 | #define ATA_WDMA2 0x22 | |
| 219 | #define ATA_UDMA0 0x40 | |
| 220 | #define ATA_UDMA1 0x41 | |
| 221 | #define ATA_UDMA2 0x42 | |
| 222 | #define ATA_UDMA3 0x43 | |
| 223 | #define ATA_UDMA4 0x44 | |
| 224 | #define ATA_UDMA5 0x45 | |
| 225 | #define ATA_UDMA6 0x46 | |
| 226 | #define ATA_SA150 0x47 | |
| 227 | #define ATA_SA300 0x48 | |
| 228 | #define ATA_DMA_MAX 0x4f | |
| 229 | #define ATA_USB 0x80 | |
| 230 | #define ATA_USB1 0x81 | |
| 231 | #define ATA_USB2 0x82 | |
| 232 | ||
| 233 | ||
| 234 | /* ATA commands */ | |
| 235 | #define ATA_NOP 0x00 /* NOP */ | |
| 236 | #define ATA_NF_FLUSHQUEUE 0x00 /* flush queued cmd's */ | |
| 237 | #define ATA_NF_AUTOPOLL 0x01 /* start autopoll function */ | |
| 238 | #define ATA_DEVICE_RESET 0x08 /* reset device */ | |
| 239 | #define ATA_READ 0x20 /* read */ | |
| 240 | #define ATA_READ48 0x24 /* read 48bit LBA */ | |
| 241 | #define ATA_READ_DMA48 0x25 /* read DMA 48bit LBA */ | |
| 242 | #define ATA_READ_DMA_QUEUED48 0x26 /* read DMA QUEUED 48bit LBA */ | |
| 243 | #define ATA_READ_NATIVE_MAX_ADDDRESS48 0x27 /* read native max addr 48bit */ | |
| 244 | #define ATA_READ_MUL48 0x29 /* read multi 48bit LBA */ | |
| 245 | #define ATA_WRITE 0x30 /* write */ | |
| 246 | #define ATA_WRITE48 0x34 /* write 48bit LBA */ | |
| 247 | #define ATA_WRITE_DMA48 0x35 /* write DMA 48bit LBA */ | |
| 248 | #define ATA_WRITE_DMA_QUEUED48 0x36 /* write DMA QUEUED 48bit LBA*/ | |
| 249 | #define ATA_SET_MAX_ADDRESS48 0x37 /* set max address 48bit */ | |
| 250 | #define ATA_WRITE_MUL48 0x39 /* write multi 48bit LBA */ | |
| 251 | #define ATA_READ_FPDMA_QUEUED 0x60 /* read DMA NCQ */ | |
| 252 | #define ATA_WRITE_FPDMA_QUEUED 0x61 /* write DMA NCQ */ | |
| 253 | #define ATA_SEEK 0x70 /* seek */ | |
| 254 | #define ATA_PACKET_CMD 0xa0 /* packet command */ | |
| 255 | #define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ | |
| 256 | #define ATA_SERVICE 0xa2 /* service command */ | |
| 50f757e8 | 257 | #define ATA_SMART_CMD 0xb0 /* SMART command */ |
| c1b3d7c5 TS |
258 | #define ATA_CFA_ERASE 0xc0 /* CFA erase */ |
| 259 | #define ATA_READ_MUL 0xc4 /* read multi */ | |
| 260 | #define ATA_WRITE_MUL 0xc5 /* write multi */ | |
| 261 | #define ATA_SET_MULTI 0xc6 /* set multi size */ | |
| 262 | #define ATA_READ_DMA_QUEUED 0xc7 /* read DMA QUEUED */ | |
| 263 | #define ATA_READ_DMA 0xc8 /* read DMA */ | |
| 264 | #define ATA_WRITE_DMA 0xca /* write DMA */ | |
| 265 | #define ATA_WRITE_DMA_QUEUED 0xcc /* write DMA QUEUED */ | |
| 266 | #define ATA_STANDBY_IMMEDIATE 0xe0 /* standby immediate */ | |
| 267 | #define ATA_IDLE_IMMEDIATE 0xe1 /* idle immediate */ | |
| 268 | #define ATA_STANDBY_CMD 0xe2 /* standby */ | |
| 269 | #define ATA_IDLE_CMD 0xe3 /* idle */ | |
| 270 | #define ATA_READ_BUFFER 0xe4 /* read buffer */ | |
| 271 | #define ATA_SLEEP 0xe6 /* sleep */ | |
| 272 | #define ATA_FLUSHCACHE 0xe7 /* flush cache to disk */ | |
| 273 | #define ATA_FLUSHCACHE48 0xea /* flush cache to disk */ | |
| 274 | #define ATA_ATA_IDENTIFY 0xec /* get ATA params */ | |
| 275 | #define ATA_SETFEATURES 0xef /* features command */ | |
| 276 | #define ATA_SF_SETXFER 0x03 /* set transfer mode */ | |
| 277 | #define ATA_SF_ENAB_WCACHE 0x02 /* enable write cache */ | |
| 278 | #define ATA_SF_DIS_WCACHE 0x82 /* disable write cache */ | |
| 279 | #define ATA_SF_ENAB_RCACHE 0xaa /* enable readahead cache */ | |
| 280 | #define ATA_SF_DIS_RCACHE 0x55 /* disable readahead cache */ | |
| 281 | #define ATA_SF_ENAB_RELIRQ 0x5d /* enable release interrupt */ | |
| 282 | #define ATA_SF_DIS_RELIRQ 0xdd /* disable release interrupt */ | |
| 283 | #define ATA_SF_ENAB_SRVIRQ 0x5e /* enable service interrupt */ | |
| 284 | #define ATA_SF_DIS_SRVIRQ 0xde /* disable service interrupt */ | |
| 285 | #define ATA_SECURITY_FREEE_LOCK 0xf5 /* freeze security config */ | |
| 286 | #define ATA_READ_NATIVE_MAX_ADDDRESS 0xf8 /* read native max address */ | |
| 287 | #define ATA_SET_MAX_ADDRESS 0xf9 /* set max address */ | |
| 288 | ||
| 289 | ||
| 290 | /* ATAPI commands */ | |
| 291 | #define ATAPI_TEST_UNIT_READY 0x00 /* check if device is ready */ | |
| 292 | #define ATAPI_REZERO 0x01 /* rewind */ | |
| 293 | #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */ | |
| 294 | #define ATAPI_FORMAT 0x04 /* format unit */ | |
| 295 | #define ATAPI_READ 0x08 /* read data */ | |
| 296 | #define ATAPI_WRITE 0x0a /* write data */ | |
| 297 | #define ATAPI_WEOF 0x10 /* write filemark */ | |
| 298 | #define ATAPI_WF_WRITE 0x01 | |
| 299 | #define ATAPI_SPACE 0x11 /* space command */ | |
| 300 | #define ATAPI_SP_FM 0x01 | |
| 301 | #define ATAPI_SP_EOD 0x03 | |
| 302 | #define ATAPI_INQUIRY 0x12 /* get inquiry data */ | |
| 303 | #define ATAPI_MODE_SELECT 0x15 /* mode select */ | |
| 304 | #define ATAPI_ERASE 0x19 /* erase */ | |
| 305 | #define ATAPI_MODE_SENSE 0x1a /* mode sense */ | |
| 306 | #define ATAPI_START_STOP 0x1b /* start/stop unit */ | |
| 307 | #define ATAPI_SS_LOAD 0x01 | |
| 308 | #define ATAPI_SS_RETENSION 0x02 | |
| 309 | #define ATAPI_SS_EJECT 0x04 | |
| 310 | #define ATAPI_PREVENT_ALLOW 0x1e /* media removal */ | |
| 311 | #define ATAPI_READ_FORMAT_CAPACITIES 0x23 /* get format capacities */ | |
| 312 | #define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */ | |
| 313 | #define ATAPI_READ_BIG 0x28 /* read data */ | |
| 314 | #define ATAPI_WRITE_BIG 0x2a /* write data */ | |
| 315 | #define ATAPI_LOCATE 0x2b /* locate to position */ | |
| 316 | #define ATAPI_READ_POSITION 0x34 /* read position */ | |
| 317 | #define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush buf, close channel */ | |
| 318 | #define ATAPI_WRITE_BUFFER 0x3b /* write device buffer */ | |
| 319 | #define ATAPI_READ_BUFFER 0x3c /* read device buffer */ | |
| 320 | #define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */ | |
| 321 | #define ATAPI_READ_TOC 0x43 /* get table of contents */ | |
| 322 | #define ATAPI_PLAY_10 0x45 /* play by lba */ | |
| 323 | #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */ | |
| 324 | #define ATAPI_PLAY_TRACK 0x48 /* play by track number */ | |
| 325 | #define ATAPI_PAUSE 0x4b /* pause audio operation */ | |
| 326 | #define ATAPI_READ_DISK_INFO 0x51 /* get disk info structure */ | |
| 327 | #define ATAPI_READ_TRACK_INFO 0x52 /* get track info structure */ | |
| 328 | #define ATAPI_RESERVE_TRACK 0x53 /* reserve track */ | |
| 329 | #define ATAPI_SEND_OPC_INFO 0x54 /* send OPC structurek */ | |
| 330 | #define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */ | |
| 331 | #define ATAPI_REPAIR_TRACK 0x58 /* repair track */ | |
| 332 | #define ATAPI_READ_MASTER_CUE 0x59 /* read master CUE info */ | |
| 333 | #define ATAPI_MODE_SENSE_BIG 0x5a /* get device parameters */ | |
| 334 | #define ATAPI_CLOSE_TRACK 0x5b /* close track/session */ | |
| 335 | #define ATAPI_READ_BUFFER_CAPACITY 0x5c /* get buffer capicity */ | |
| 336 | #define ATAPI_SEND_CUE_SHEET 0x5d /* send CUE sheet */ | |
| 337 | #define ATAPI_SERVICE_ACTION_IN 0x96 /* get service data */ | |
| 56235534 | 338 | #define ATAPI_READ_CAPACITY_16 0x96 /* get service data */ |
| c1b3d7c5 TS |
339 | #define ATAPI_BLANK 0xa1 /* blank the media */ |
| 340 | #define ATAPI_SEND_KEY 0xa3 /* send DVD key structure */ | |
| 341 | #define ATAPI_REPORT_KEY 0xa4 /* get DVD key structure */ | |
| 342 | #define ATAPI_PLAY_12 0xa5 /* play by lba */ | |
| 343 | #define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ | |
| 344 | #define ATAPI_READ_STRUCTURE 0xad /* get DVD structure */ | |
| 345 | #define ATAPI_PLAY_CD 0xb4 /* universal play command */ | |
| 346 | #define ATAPI_SET_SPEED 0xbb /* set drive speed */ | |
| 347 | #define ATAPI_MECH_STATUS 0xbd /* get changer status */ | |
| 348 | #define ATAPI_READ_CD 0xbe /* read data */ | |
| 349 | #define ATAPI_POLL_DSC 0xff /* poll DSC status bit */ | |
| 350 | ||
| 351 | ||
| 352 | struct ata_ioc_devices { | |
| 353 | int channel; | |
| 354 | char name[2][32]; | |
| 355 | struct ata_params params[2]; | |
| 356 | }; | |
| 357 | ||
| 358 | /* pr channel ATA ioctl calls */ | |
| 359 | #define IOCATAGMAXCHANNEL _IOR('a', 1, int) | |
| 360 | #define IOCATAREINIT _IOW('a', 2, int) | |
| 361 | #define IOCATAATTACH _IOW('a', 3, int) | |
| 362 | #define IOCATADETACH _IOW('a', 4, int) | |
| 363 | #define IOCATADEVICES _IOWR('a', 5, struct ata_ioc_devices) | |
| 364 | ||
| 365 | /* ATAPI request sense structure */ | |
| 366 | struct atapi_sense { | |
| 367 | u_int8_t error; /* current or deferred errors */ | |
| 368 | #define ATA_SENSE_VALID 0x80 | |
| 369 | ||
| 370 | u_int8_t segment; /* segment number */ | |
| 371 | u_int8_t key; /* sense key */ | |
| 372 | #define ATA_SENSE_KEY_MASK 0x0f /* sense key mask */ | |
| 373 | #define ATA_SENSE_NO_SENSE 0x00 /* no specific sense key info */ | |
| 374 | #define ATA_SENSE_RECOVERED_ERROR 0x01 /* command OK, data recovered */ | |
| 375 | #define ATA_SENSE_NOT_READY 0x02 /* no access to drive */ | |
| 376 | #define ATA_SENSE_MEDIUM_ERROR 0x03 /* non-recovered data error */ | |
| 377 | #define ATA_SENSE_HARDWARE_ERROR 0x04 /* non-recoverable HW failure */ | |
| 378 | #define ATA_SENSE_ILLEGAL_REQUEST 0x05 /* invalid command param(s) */ | |
| 379 | #define ATA_SENSE_UNIT_ATTENTION 0x06 /* media changed */ | |
| 380 | #define ATA_SENSE_DATA_PROTECT 0x07 /* write protect */ | |
| 381 | #define ATA_SENSE_BLANK_CHECK 0x08 /* blank check */ | |
| 382 | #define ATA_SENSE_VENDOR_SPECIFIC 0x09 /* vendor specific skey */ | |
| 383 | #define ATA_SENSE_COPY_ABORTED 0x0a /* copy aborted */ | |
| 384 | #define ATA_SENSE_ABORTED_COMMAND 0x0b /* command aborted, try again */ | |
| 385 | #define ATA_SENSE_EQUAL 0x0c /* equal */ | |
| 386 | #define ATA_SENSE_VOLUME_OVERFLOW 0x0d /* volume overflow */ | |
| 387 | #define ATA_SENSE_MISCOMPARE 0x0e /* data dont match the medium */ | |
| 388 | #define ATA_SENSE_RESERVED 0x0f | |
| 389 | #define ATA_SENSE_ILI 0x20; | |
| 390 | #define ATA_SENSE_EOM 0x40; | |
| 391 | #define ATA_SENSE_FILEMARK 0x80; | |
| 392 | ||
| 393 | u_int32_t cmd_info; /* cmd information */ | |
| 394 | u_int8_t sense_length; /* additional sense len (n-7) */ | |
| 395 | u_int32_t cmd_specific_info; /* additional cmd spec info */ | |
| 396 | u_int8_t asc; /* additional sense code */ | |
| 397 | u_int8_t ascq; /* additional sense code qual */ | |
| 398 | u_int8_t replaceable_unit_code; /* replaceable unit code */ | |
| 399 | u_int8_t specific; /* sense key specific */ | |
| 400 | #define ATA_SENSE_SPEC_VALID 0x80 | |
| 401 | #define ATA_SENSE_SPEC_MASK 0x7f | |
| 402 | ||
| 403 | u_int8_t specific1; /* sense key specific */ | |
| 404 | u_int8_t specific2; /* sense key specific */ | |
| 405 | } __packed; | |
| 406 | ||
| 407 | struct ata_ioc_request { | |
| 408 | union { | |
| 409 | struct { | |
| 410 | u_int8_t command; | |
| 411 | u_int8_t feature; | |
| 412 | u_int64_t lba; | |
| 413 | u_int16_t count; | |
| 414 | } ata; | |
| 415 | struct { | |
| 416 | char ccb[16]; | |
| 417 | struct atapi_sense sense; | |
| 418 | } atapi; | |
| 419 | } u; | |
| 420 | caddr_t data; | |
| 421 | int count; | |
| 422 | int flags; | |
| 423 | #define ATA_CMD_CONTROL 0x01 | |
| 424 | #define ATA_CMD_READ 0x02 | |
| 425 | #define ATA_CMD_WRITE 0x04 | |
| 426 | #define ATA_CMD_ATAPI 0x08 | |
| 427 | ||
| 428 | int timeout; | |
| 429 | int error; | |
| 430 | }; | |
| 431 | ||
| 432 | /* pr device ATA ioctl calls */ | |
| 433 | #define IOCATAREQUEST _IOWR('a', 100, struct ata_ioc_request) | |
| 434 | #define IOCATAGPARM _IOR('a', 101, struct ata_params) | |
| 435 | #define IOCATAGMODE _IOR('a', 102, int) | |
| 436 | #define IOCATASMODE _IOW('a', 103, int) | |
| 437 | ||
| 438 | ||
| 439 | struct ata_ioc_raid_config { | |
| 440 | int lun; | |
| 441 | int type; | |
| 442 | #define AR_JBOD 0x0001 | |
| 443 | #define AR_SPAN 0x0002 | |
| 444 | #define AR_RAID0 0x0004 | |
| 445 | #define AR_RAID1 0x0008 | |
| 446 | #define AR_RAID01 0x0010 | |
| 447 | #define AR_RAID3 0x0020 | |
| 448 | #define AR_RAID4 0x0040 | |
| 449 | #define AR_RAID5 0x0080 | |
| 450 | ||
| 451 | int interleave; | |
| 452 | int status; | |
| 453 | #define AR_READY 1 | |
| 454 | #define AR_DEGRADED 2 | |
| 455 | #define AR_REBUILDING 4 | |
| 456 | ||
| 457 | int progress; | |
| 458 | int total_disks; | |
| 459 | int disks[16]; | |
| 460 | }; | |
| 461 | ||
| 462 | /* ATA RAID ioctl calls */ | |
| 463 | #define IOCATARAIDCREATE _IOWR('a', 200, struct ata_ioc_raid_config) | |
| 464 | #define IOCATARAIDDELETE _IOW('a', 201, int) | |
| 465 | #define IOCATARAIDSTATUS _IOWR('a', 202, struct ata_ioc_raid_config) | |
| 466 | #define IOCATARAIDADDSPARE _IOW('a', 203, struct ata_ioc_raid_config) | |
| 467 | #define IOCATARAIDREBUILD _IOW('a', 204, int) | |
| 468 | ||
| 469 | #endif /* _SYS_NATA_H_ */ | |
| 470 | #endif /* _SYS_ATA_H_ */ |