ata.h revision 166287
174298Ssos/*- 2154705Ssos * Copyright (c) 2000 - 2006 S�ren Schmidt <sos@FreeBSD.org> 374298Ssos * All rights reserved. 474298Ssos * 574298Ssos * Redistribution and use in source and binary forms, with or without 674298Ssos * modification, are permitted provided that the following conditions 774298Ssos * are met: 874298Ssos * 1. Redistributions of source code must retain the above copyright 974298Ssos * notice, this list of conditions and the following disclaimer, 1074298Ssos * without modification, immediately at the beginning of the file. 1174298Ssos * 2. Redistributions in binary form must reproduce the above copyright 1274298Ssos * notice, this list of conditions and the following disclaimer in the 1374298Ssos * documentation and/or other materials provided with the distribution. 1474298Ssos * 1574298Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1674298Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1774298Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1874298Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1974298Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2074298Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2174298Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2274298Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2374298Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2474298Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2574298Ssos * 2674298Ssos * $FreeBSD: head/sys/sys/ata.h 166287 2007-01-27 21:15:59Z remko $ 2774298Ssos */ 2874298Ssos 2974298Ssos#ifndef _SYS_ATA_H_ 3074298Ssos#define _SYS_ATA_H_ 3174298Ssos 3274298Ssos#include <sys/ioccom.h> 3374298Ssos 34119404Ssos/* ATA/ATAPI device parameters */ 3593881Ssosstruct ata_params { 36146266Ssos/*000*/ u_int16_t config; /* configuration info */ 37146266Ssos#define ATA_PROTO_MASK 0x8003 38146266Ssos#define ATA_PROTO_ATAPI 0x8000 39146266Ssos#define ATA_PROTO_ATAPI_12 0x8000 40146266Ssos#define ATA_PROTO_ATAPI_16 0x8001 41146266Ssos#define ATA_ATAPI_TYPE_MASK 0x1f00 42146266Ssos#define ATA_ATAPI_TYPE_DIRECT 0x0000 /* disk/floppy */ 43146266Ssos#define ATA_ATAPI_TYPE_TAPE 0x0100 /* streaming tape */ 44146266Ssos#define ATA_ATAPI_TYPE_CDROM 0x0500 /* CD-ROM device */ 45146266Ssos#define ATA_ATAPI_TYPE_OPTICAL 0x0700 /* optical disk */ 46146266Ssos#define ATA_DRQ_MASK 0x0060 47146266Ssos#define ATA_DRQ_SLOW 0x0000 /* cpu 3 ms delay */ 48146266Ssos#define ATA_DRQ_INTR 0x0020 /* interrupt 10 ms delay */ 49146266Ssos#define ATA_DRQ_FAST 0x0040 /* accel 50 us delay */ 5093881Ssos 51146266Ssos/*001*/ u_int16_t cylinders; /* # of cylinders */ 52146266Ssos u_int16_t reserved2; 53146266Ssos/*003*/ u_int16_t heads; /* # heads */ 54146266Ssos u_int16_t obsolete4; 55146266Ssos u_int16_t obsolete5; 56146266Ssos/*006*/ u_int16_t sectors; /* # sectors/track */ 57146266Ssos/*007*/ u_int16_t vendor7[3]; 58146266Ssos/*010*/ u_int8_t serial[20]; /* serial number */ 59146266Ssos/*020*/ u_int16_t retired20; 60146266Ssos u_int16_t retired21; 61146266Ssos u_int16_t obsolete22; 62146266Ssos/*023*/ u_int8_t revision[8]; /* firmware revision */ 63146266Ssos/*027*/ u_int8_t model[40]; /* model name */ 64146266Ssos/*047*/ u_int16_t sectors_intr; /* sectors per interrupt */ 65146266Ssos/*048*/ u_int16_t usedmovsd; /* double word read/write? */ 66146266Ssos/*049*/ u_int16_t capabilities1; 67146266Ssos#define ATA_SUPPORT_DMA 0x0100 68146266Ssos#define ATA_SUPPORT_LBA 0x0200 69146266Ssos#define ATA_SUPPORT_OVERLAP 0x4000 7093881Ssos 71146266Ssos/*050*/ u_int16_t capabilities2; 72146266Ssos/*051*/ u_int16_t retired_piomode; /* PIO modes 0-2 */ 73146266Ssos#define ATA_RETIRED_PIO_MASK 0x0300 7474298Ssos 75146266Ssos/*052*/ u_int16_t retired_dmamode; /* DMA modes */ 76146266Ssos#define ATA_RETIRED_DMA_MASK 0x0003 7774298Ssos 78146266Ssos/*053*/ u_int16_t atavalid; /* fields valid */ 79146266Ssos#define ATA_FLAG_54_58 0x0001 /* words 54-58 valid */ 80146266Ssos#define ATA_FLAG_64_70 0x0002 /* words 64-70 valid */ 81146266Ssos#define ATA_FLAG_88 0x0004 /* word 88 valid */ 8274298Ssos 83146266Ssos/*054*/ u_int16_t current_cylinders; 84146266Ssos/*055*/ u_int16_t current_heads; 85146266Ssos/*056*/ u_int16_t current_sectors; 86146266Ssos/*057*/ u_int16_t current_size_1; 87146266Ssos/*058*/ u_int16_t current_size_2; 88146266Ssos/*059*/ u_int16_t multi; 89146266Ssos#define ATA_MULTI_VALID 0x0100 9093881Ssos 91146266Ssos/*060*/ u_int16_t lba_size_1; 92146266Ssos u_int16_t lba_size_2; 93146266Ssos u_int16_t obsolete62; 94146266Ssos/*063*/ u_int16_t mwdmamodes; /* multiword DMA modes */ 95146266Ssos/*064*/ u_int16_t apiomodes; /* advanced PIO modes */ 9674298Ssos 97146266Ssos/*065*/ u_int16_t mwdmamin; /* min. M/W DMA time/word ns */ 98146266Ssos/*066*/ u_int16_t mwdmarec; /* rec. M/W DMA time ns */ 99146266Ssos/*067*/ u_int16_t pioblind; /* min. PIO cycle w/o flow */ 100146266Ssos/*068*/ u_int16_t pioiordy; /* min. PIO cycle IORDY flow */ 101146266Ssos u_int16_t reserved69; 102146266Ssos u_int16_t reserved70; 103146266Ssos/*071*/ u_int16_t rlsovlap; /* rel time (us) for overlap */ 104146266Ssos/*072*/ u_int16_t rlsservice; /* rel time (us) for service */ 105146266Ssos u_int16_t reserved73; 106146266Ssos u_int16_t reserved74; 107146266Ssos/*075*/ u_int16_t queue; 108146266Ssos#define ATA_QUEUE_LEN(x) ((x) & 0x001f) 10974298Ssos 110146266Ssos u_int16_t satacapabilities; 111146266Ssos#define ATA_SATA_GEN1 0x0002 112146266Ssos#define ATA_SATA_GEN2 0x0004 113146266Ssos#define ATA_SUPPORT_NCQ 0x0100 114146266Ssos#define ATA_SUPPORT_IFPWRMNGTRCV 0x0200 115127021Ssos 116146266Ssos u_int16_t reserved77; 117146266Ssos u_int16_t satasupport; 118146266Ssos#define ATA_SUPPORT_NONZERO 0x0002 119146266Ssos#define ATA_SUPPORT_AUTOACTIVATE 0x0004 120146266Ssos#define ATA_SUPPORT_IFPWRMNGT 0x0008 121146266Ssos#define ATA_SUPPORT_INORDERDATA 0x0010 122146266Ssos u_int16_t sataenabled; 123127021Ssos 124146266Ssos/*080*/ u_int16_t version_major; 125146266Ssos/*081*/ u_int16_t version_minor; 126119404Ssos 12784584Ssos struct { 128146266Ssos/*082/085*/ u_int16_t command1; 129146266Ssos#define ATA_SUPPORT_SMART 0x0001 130146266Ssos#define ATA_SUPPORT_SECURITY 0x0002 131146266Ssos#define ATA_SUPPORT_REMOVABLE 0x0004 132146266Ssos#define ATA_SUPPORT_POWERMGT 0x0008 133146266Ssos#define ATA_SUPPORT_PACKET 0x0010 134146266Ssos#define ATA_SUPPORT_WRITECACHE 0x0020 135146266Ssos#define ATA_SUPPORT_LOOKAHEAD 0x0040 136146266Ssos#define ATA_SUPPORT_RELEASEIRQ 0x0080 137146266Ssos#define ATA_SUPPORT_SERVICEIRQ 0x0100 138146266Ssos#define ATA_SUPPORT_RESET 0x0200 139146266Ssos#define ATA_SUPPORT_PROTECTED 0x0400 140146266Ssos#define ATA_SUPPORT_WRITEBUFFER 0x1000 141146266Ssos#define ATA_SUPPORT_READBUFFER 0x2000 142146266Ssos#define ATA_SUPPORT_NOP 0x4000 14384584Ssos 144146266Ssos/*083/086*/ u_int16_t command2; 145146266Ssos#define ATA_SUPPORT_MICROCODE 0x0001 146146266Ssos#define ATA_SUPPORT_QUEUED 0x0002 147146266Ssos#define ATA_SUPPORT_CFA 0x0004 148146266Ssos#define ATA_SUPPORT_APM 0x0008 149146266Ssos#define ATA_SUPPORT_NOTIFY 0x0010 150146266Ssos#define ATA_SUPPORT_STANDBY 0x0020 151146266Ssos#define ATA_SUPPORT_SPINUP 0x0040 152146266Ssos#define ATA_SUPPORT_MAXSECURITY 0x0100 153146266Ssos#define ATA_SUPPORT_AUTOACOUSTIC 0x0200 154146266Ssos#define ATA_SUPPORT_ADDRESS48 0x0400 155146266Ssos#define ATA_SUPPORT_OVERLAY 0x0800 156146266Ssos#define ATA_SUPPORT_FLUSHCACHE 0x1000 157146266Ssos#define ATA_SUPPORT_FLUSHCACHE48 0x2000 15884584Ssos 159146266Ssos/*084/087*/ u_int16_t extension; 160144330Ssos } __packed support, enabled; 16184584Ssos 162146266Ssos/*088*/ u_int16_t udmamodes; /* UltraDMA modes */ 163146266Ssos/*089*/ u_int16_t erase_time; 164146266Ssos/*090*/ u_int16_t enhanced_erase_time; 165146266Ssos/*091*/ u_int16_t apm_value; 166146266Ssos/*092*/ u_int16_t master_passwd_revision; 167146266Ssos/*093*/ u_int16_t hwres; 168146266Ssos#define ATA_CABLE_ID 0x2000 16984584Ssos 170146266Ssos/*094*/ u_int16_t acoustic; 171146266Ssos#define ATA_ACOUSTIC_CURRENT(x) ((x) & 0x00ff) 172146266Ssos#define ATA_ACOUSTIC_VENDOR(x) (((x) & 0xff00) >> 8) 17384584Ssos 174146266Ssos/*095*/ u_int16_t stream_min_req_size; 175146266Ssos/*096*/ u_int16_t stream_transfer_time; 176146266Ssos/*097*/ u_int16_t stream_access_latency; 177146266Ssos/*098*/ u_int32_t stream_granularity; 178146266Ssos/*100*/ u_int16_t lba_size48_1; 179146266Ssos u_int16_t lba_size48_2; 180146266Ssos u_int16_t lba_size48_3; 181146266Ssos u_int16_t lba_size48_4; 182146266Ssos u_int16_t reserved104[23]; 183146266Ssos/*127*/ u_int16_t removable_status; 184146266Ssos/*128*/ u_int16_t security_status; 185146266Ssos u_int16_t reserved129[31]; 186146266Ssos/*160*/ u_int16_t cfa_powermode1; 187146266Ssos u_int16_t reserved161[15]; 188146266Ssos/*176*/ u_int16_t media_serial[30]; 189146266Ssos u_int16_t reserved206[49]; 190146266Ssos/*255*/ u_int16_t integrity; 191144330Ssos} __packed; 19274298Ssos 193146266Ssos 194119404Ssos/* ATA transfer modes */ 195146266Ssos#define ATA_MODE_MASK 0x0f 196146266Ssos#define ATA_DMA_MASK 0xf0 197146266Ssos#define ATA_PIO 0x00 198146266Ssos#define ATA_PIO0 0x08 199146266Ssos#define ATA_PIO1 0x09 200146266Ssos#define ATA_PIO2 0x0a 201146266Ssos#define ATA_PIO3 0x0b 202146266Ssos#define ATA_PIO4 0x0c 203146266Ssos#define ATA_PIO_MAX 0x0f 204146266Ssos#define ATA_DMA 0x10 205146266Ssos#define ATA_WDMA0 0x20 206146266Ssos#define ATA_WDMA1 0x21 207146266Ssos#define ATA_WDMA2 0x22 208146266Ssos#define ATA_UDMA0 0x40 209146266Ssos#define ATA_UDMA1 0x41 210146266Ssos#define ATA_UDMA2 0x42 211146266Ssos#define ATA_UDMA3 0x43 212146266Ssos#define ATA_UDMA4 0x44 213146266Ssos#define ATA_UDMA5 0x45 214146266Ssos#define ATA_UDMA6 0x46 215146266Ssos#define ATA_SA150 0x47 216148991Ssos#define ATA_SA300 0x48 217146266Ssos#define ATA_DMA_MAX 0x4f 218156325Ssos#define ATA_USB 0x80 219156325Ssos#define ATA_USB1 0x81 220156325Ssos#define ATA_USB2 0x82 22174298Ssos 222146266Ssos 223119404Ssos/* ATA commands */ 224146266Ssos#define ATA_NOP 0x00 /* NOP */ 225146266Ssos#define ATA_NF_FLUSHQUEUE 0x00 /* flush queued cmd's */ 226146266Ssos#define ATA_NF_AUTOPOLL 0x01 /* start autopoll function */ 227146266Ssos#define ATA_DEVICE_RESET 0x08 /* reset device */ 228146266Ssos#define ATA_READ 0x20 /* read */ 229146266Ssos#define ATA_READ48 0x24 /* read 48bit LBA */ 230146266Ssos#define ATA_READ_DMA48 0x25 /* read DMA 48bit LBA */ 231146266Ssos#define ATA_READ_DMA_QUEUED48 0x26 /* read DMA QUEUED 48bit LBA */ 232152270Ssos#define ATA_READ_NATIVE_MAX_ADDDRESS48 0x27 /* read native max addr 48bit */ 233146266Ssos#define ATA_READ_MUL48 0x29 /* read multi 48bit LBA */ 234146266Ssos#define ATA_WRITE 0x30 /* write */ 235146266Ssos#define ATA_WRITE48 0x34 /* write 48bit LBA */ 236146266Ssos#define ATA_WRITE_DMA48 0x35 /* write DMA 48bit LBA */ 237146266Ssos#define ATA_WRITE_DMA_QUEUED48 0x36 /* write DMA QUEUED 48bit LBA*/ 238152270Ssos#define ATA_SET_MAX_ADDRESS48 0x37 /* set max address 48bit */ 239146266Ssos#define ATA_WRITE_MUL48 0x39 /* write multi 48bit LBA */ 240146266Ssos#define ATA_READ_FPDMA_QUEUED 0x60 /* read DMA NCQ */ 241146266Ssos#define ATA_WRITE_FPDMA_QUEUED 0x61 /* write DMA NCQ */ 242146266Ssos#define ATA_SEEK 0x70 /* seek */ 243146266Ssos#define ATA_PACKET_CMD 0xa0 /* packet command */ 244146266Ssos#define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ 245146266Ssos#define ATA_SERVICE 0xa2 /* service command */ 246166287Sremko#define ATA_SMART_CMD 0xb0 /* SMART command */ 247146266Ssos#define ATA_CFA_ERASE 0xc0 /* CFA erase */ 248146266Ssos#define ATA_READ_MUL 0xc4 /* read multi */ 249146266Ssos#define ATA_WRITE_MUL 0xc5 /* write multi */ 250146266Ssos#define ATA_SET_MULTI 0xc6 /* set multi size */ 251146266Ssos#define ATA_READ_DMA_QUEUED 0xc7 /* read DMA QUEUED */ 252146266Ssos#define ATA_READ_DMA 0xc8 /* read DMA */ 253146266Ssos#define ATA_WRITE_DMA 0xca /* write DMA */ 254146266Ssos#define ATA_WRITE_DMA_QUEUED 0xcc /* write DMA QUEUED */ 255146266Ssos#define ATA_STANDBY_IMMEDIATE 0xe0 /* standby immediate */ 256146266Ssos#define ATA_IDLE_IMMEDIATE 0xe1 /* idle immediate */ 257146266Ssos#define ATA_STANDBY_CMD 0xe2 /* standby */ 258146266Ssos#define ATA_IDLE_CMD 0xe3 /* idle */ 259146266Ssos#define ATA_READ_BUFFER 0xe4 /* read buffer */ 260146266Ssos#define ATA_SLEEP 0xe6 /* sleep */ 261146266Ssos#define ATA_FLUSHCACHE 0xe7 /* flush cache to disk */ 262146266Ssos#define ATA_FLUSHCACHE48 0xea /* flush cache to disk */ 263146266Ssos#define ATA_ATA_IDENTIFY 0xec /* get ATA params */ 264146266Ssos#define ATA_SETFEATURES 0xef /* features command */ 265146266Ssos#define ATA_SF_SETXFER 0x03 /* set transfer mode */ 266146266Ssos#define ATA_SF_ENAB_WCACHE 0x02 /* enable write cache */ 267146266Ssos#define ATA_SF_DIS_WCACHE 0x82 /* disable write cache */ 268146266Ssos#define ATA_SF_ENAB_RCACHE 0xaa /* enable readahead cache */ 269146266Ssos#define ATA_SF_DIS_RCACHE 0x55 /* disable readahead cache */ 270146266Ssos#define ATA_SF_ENAB_RELIRQ 0x5d /* enable release interrupt */ 271146266Ssos#define ATA_SF_DIS_RELIRQ 0xdd /* disable release interrupt */ 272146266Ssos#define ATA_SF_ENAB_SRVIRQ 0x5e /* enable service interrupt */ 273146266Ssos#define ATA_SF_DIS_SRVIRQ 0xde /* disable service interrupt */ 274146266Ssos#define ATA_SECURITY_FREEE_LOCK 0xf5 /* freeze security config */ 275146266Ssos#define ATA_READ_NATIVE_MAX_ADDDRESS 0xf8 /* read native max address */ 276146266Ssos#define ATA_SET_MAX_ADDRESS 0xf9 /* set max address */ 277119404Ssos 278146266Ssos 279119404Ssos/* ATAPI commands */ 280146266Ssos#define ATAPI_TEST_UNIT_READY 0x00 /* check if device is ready */ 281146266Ssos#define ATAPI_REZERO 0x01 /* rewind */ 282146266Ssos#define ATAPI_REQUEST_SENSE 0x03 /* get sense data */ 283146266Ssos#define ATAPI_FORMAT 0x04 /* format unit */ 284146266Ssos#define ATAPI_READ 0x08 /* read data */ 285146266Ssos#define ATAPI_WRITE 0x0a /* write data */ 286146266Ssos#define ATAPI_WEOF 0x10 /* write filemark */ 287146266Ssos#define ATAPI_WF_WRITE 0x01 288146266Ssos#define ATAPI_SPACE 0x11 /* space command */ 289146266Ssos#define ATAPI_SP_FM 0x01 290146266Ssos#define ATAPI_SP_EOD 0x03 291156317Ssos#define ATAPI_INQUIRY 0x12 /* get inquiry data */ 292146266Ssos#define ATAPI_MODE_SELECT 0x15 /* mode select */ 293146266Ssos#define ATAPI_ERASE 0x19 /* erase */ 294146266Ssos#define ATAPI_MODE_SENSE 0x1a /* mode sense */ 295146266Ssos#define ATAPI_START_STOP 0x1b /* start/stop unit */ 296146266Ssos#define ATAPI_SS_LOAD 0x01 297146266Ssos#define ATAPI_SS_RETENSION 0x02 298146266Ssos#define ATAPI_SS_EJECT 0x04 299146266Ssos#define ATAPI_PREVENT_ALLOW 0x1e /* media removal */ 300146266Ssos#define ATAPI_READ_FORMAT_CAPACITIES 0x23 /* get format capacities */ 301146266Ssos#define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */ 302146266Ssos#define ATAPI_READ_BIG 0x28 /* read data */ 303146266Ssos#define ATAPI_WRITE_BIG 0x2a /* write data */ 304146266Ssos#define ATAPI_LOCATE 0x2b /* locate to position */ 305146266Ssos#define ATAPI_READ_POSITION 0x34 /* read position */ 306146266Ssos#define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush buf, close channel */ 307146266Ssos#define ATAPI_WRITE_BUFFER 0x3b /* write device buffer */ 308146266Ssos#define ATAPI_READ_BUFFER 0x3c /* read device buffer */ 309146266Ssos#define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */ 310146266Ssos#define ATAPI_READ_TOC 0x43 /* get table of contents */ 311146266Ssos#define ATAPI_PLAY_10 0x45 /* play by lba */ 312146266Ssos#define ATAPI_PLAY_MSF 0x47 /* play by MSF address */ 313146266Ssos#define ATAPI_PLAY_TRACK 0x48 /* play by track number */ 314146266Ssos#define ATAPI_PAUSE 0x4b /* pause audio operation */ 315146266Ssos#define ATAPI_READ_DISK_INFO 0x51 /* get disk info structure */ 316146266Ssos#define ATAPI_READ_TRACK_INFO 0x52 /* get track info structure */ 317146266Ssos#define ATAPI_RESERVE_TRACK 0x53 /* reserve track */ 318146266Ssos#define ATAPI_SEND_OPC_INFO 0x54 /* send OPC structurek */ 319146266Ssos#define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */ 320146266Ssos#define ATAPI_REPAIR_TRACK 0x58 /* repair track */ 321146266Ssos#define ATAPI_READ_MASTER_CUE 0x59 /* read master CUE info */ 322146266Ssos#define ATAPI_MODE_SENSE_BIG 0x5a /* get device parameters */ 323146266Ssos#define ATAPI_CLOSE_TRACK 0x5b /* close track/session */ 324146266Ssos#define ATAPI_READ_BUFFER_CAPACITY 0x5c /* get buffer capicity */ 325146266Ssos#define ATAPI_SEND_CUE_SHEET 0x5d /* send CUE sheet */ 326156317Ssos#define ATAPI_SERVICE_ACTION_IN 0x96 /* get service data */ 327146266Ssos#define ATAPI_BLANK 0xa1 /* blank the media */ 328146266Ssos#define ATAPI_SEND_KEY 0xa3 /* send DVD key structure */ 329146266Ssos#define ATAPI_REPORT_KEY 0xa4 /* get DVD key structure */ 330146266Ssos#define ATAPI_PLAY_12 0xa5 /* play by lba */ 331146266Ssos#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ 332146266Ssos#define ATAPI_READ_STRUCTURE 0xad /* get DVD structure */ 333146266Ssos#define ATAPI_PLAY_CD 0xb4 /* universal play command */ 334146266Ssos#define ATAPI_SET_SPEED 0xbb /* set drive speed */ 335146266Ssos#define ATAPI_MECH_STATUS 0xbd /* get changer status */ 336146266Ssos#define ATAPI_READ_CD 0xbe /* read data */ 337146266Ssos#define ATAPI_POLL_DSC 0xff /* poll DSC status bit */ 338119404Ssos 33974298Ssos 340146266Ssosstruct ata_ioc_devices { 341146266Ssos int channel; 342146266Ssos char name[2][32]; 343146266Ssos struct ata_params params[2]; 344146266Ssos}; 345119404Ssos 346146266Ssos/* pr channel ATA ioctl calls */ 347146266Ssos#define IOCATAGMAXCHANNEL _IOR('a', 1, int) 348146266Ssos#define IOCATAREINIT _IOW('a', 2, int) 349146266Ssos#define IOCATAATTACH _IOW('a', 3, int) 350146266Ssos#define IOCATADETACH _IOW('a', 4, int) 351146266Ssos#define IOCATADEVICES _IOWR('a', 5, struct ata_ioc_devices) 352119404Ssos 353157329Ssos/* ATAPI request sense structure */ 354157329Ssosstruct atapi_sense { 355157329Ssos u_int8_t error; /* current or deferred errors */ 356157329Ssos#define ATA_SENSE_VALID 0x80 357157329Ssos 358157329Ssos u_int8_t segment; /* segment number */ 359157329Ssos u_int8_t key; /* sense key */ 360157329Ssos#define ATA_SENSE_KEY_MASK 0x0f /* sense key mask */ 361157329Ssos#define ATA_SENSE_NO_SENSE 0x00 /* no specific sense key info */ 362157329Ssos#define ATA_SENSE_RECOVERED_ERROR 0x01 /* command OK, data recovered */ 363157329Ssos#define ATA_SENSE_NOT_READY 0x02 /* no access to drive */ 364157329Ssos#define ATA_SENSE_MEDIUM_ERROR 0x03 /* non-recovered data error */ 365157329Ssos#define ATA_SENSE_HARDWARE_ERROR 0x04 /* non-recoverable HW failure */ 366157329Ssos#define ATA_SENSE_ILLEGAL_REQUEST 0x05 /* invalid command param(s) */ 367157329Ssos#define ATA_SENSE_UNIT_ATTENTION 0x06 /* media changed */ 368157329Ssos#define ATA_SENSE_DATA_PROTECT 0x07 /* write protect */ 369157329Ssos#define ATA_SENSE_BLANK_CHECK 0x08 /* blank check */ 370157329Ssos#define ATA_SENSE_VENDOR_SPECIFIC 0x09 /* vendor specific skey */ 371157329Ssos#define ATA_SENSE_COPY_ABORTED 0x0a /* copy aborted */ 372157329Ssos#define ATA_SENSE_ABORTED_COMMAND 0x0b /* command aborted, try again */ 373157329Ssos#define ATA_SENSE_EQUAL 0x0c /* equal */ 374157329Ssos#define ATA_SENSE_VOLUME_OVERFLOW 0x0d /* volume overflow */ 375157329Ssos#define ATA_SENSE_MISCOMPARE 0x0e /* data dont match the medium */ 376157329Ssos#define ATA_SENSE_RESERVED 0x0f 377157329Ssos#define ATA_SENSE_ILI 0x20; 378157329Ssos#define ATA_SENSE_EOM 0x40; 379157329Ssos#define ATA_SENSE_FILEMARK 0x80; 380157329Ssos 381157329Ssos u_int32_t cmd_info; /* cmd information */ 382157329Ssos u_int8_t sense_length; /* additional sense len (n-7) */ 383157329Ssos u_int32_t cmd_specific_info; /* additional cmd spec info */ 384157329Ssos u_int8_t asc; /* additional sense code */ 385157329Ssos u_int8_t ascq; /* additional sense code qual */ 386157329Ssos u_int8_t replaceable_unit_code; /* replaceable unit code */ 387157329Ssos u_int8_t specific; /* sense key specific */ 388157329Ssos#define ATA_SENSE_SPEC_VALID 0x80 389157329Ssos#define ATA_SENSE_SPEC_MASK 0x7f 390157329Ssos 391157329Ssos u_int8_t specific1; /* sense key specific */ 392157329Ssos u_int8_t specific2; /* sense key specific */ 393157329Ssos} __packed; 394157329Ssos 395146266Ssosstruct ata_ioc_request { 396146266Ssos union { 397119404Ssos struct { 398146266Ssos u_int8_t command; 399146266Ssos u_int8_t feature; 400146266Ssos u_int64_t lba; 401146266Ssos u_int16_t count; 402146266Ssos } ata; 403119404Ssos struct { 404146266Ssos char ccb[16]; 405157329Ssos struct atapi_sense sense; 406146266Ssos } atapi; 407146266Ssos } u; 408146266Ssos caddr_t data; 409146266Ssos int count; 410146266Ssos int flags; 411146266Ssos#define ATA_CMD_CONTROL 0x01 412146266Ssos#define ATA_CMD_READ 0x02 413146266Ssos#define ATA_CMD_WRITE 0x04 414146266Ssos#define ATA_CMD_ATAPI 0x08 415119404Ssos 416146266Ssos int timeout; 417146266Ssos int error; 418146266Ssos}; 419119404Ssos 420146266Ssos/* pr device ATA ioctl calls */ 421146266Ssos#define IOCATAREQUEST _IOWR('a', 100, struct ata_ioc_request) 422146266Ssos#define IOCATAGPARM _IOR('a', 101, struct ata_params) 423146266Ssos#define IOCATAGMODE _IOR('a', 102, int) 424146266Ssos#define IOCATASMODE _IOW('a', 103, int) 42593662Ssos 426119404Ssos 427146266Ssosstruct ata_ioc_raid_config { 428146266Ssos int lun; 429146266Ssos int type; 430146266Ssos#define AR_JBOD 0x0001 431146266Ssos#define AR_SPAN 0x0002 432146266Ssos#define AR_RAID0 0x0004 433146266Ssos#define AR_RAID1 0x0008 434146266Ssos#define AR_RAID01 0x0010 435146266Ssos#define AR_RAID3 0x0020 436146266Ssos#define AR_RAID4 0x0040 437146266Ssos#define AR_RAID5 0x0080 43893662Ssos 439146266Ssos int interleave; 440146266Ssos int status; 441146266Ssos#define AR_READY 1 442146266Ssos#define AR_DEGRADED 2 443146266Ssos#define AR_REBUILDING 4 444119404Ssos 445146266Ssos int progress; 446146266Ssos int total_disks; 447146266Ssos int disks[16]; 44874298Ssos}; 44974298Ssos 450146266Ssos/* ATA RAID ioctl calls */ 451148737Ssos#define IOCATARAIDCREATE _IOWR('a', 200, struct ata_ioc_raid_config) 452146266Ssos#define IOCATARAIDDELETE _IOW('a', 201, int) 453148729Ssos#define IOCATARAIDSTATUS _IOWR('a', 202, struct ata_ioc_raid_config) 454146266Ssos#define IOCATARAIDADDSPARE _IOW('a', 203, struct ata_ioc_raid_config) 455146266Ssos#define IOCATARAIDREBUILD _IOW('a', 204, int) 45674298Ssos 45774298Ssos#endif /* _SYS_ATA_H_ */ 458