NFE - Change default RX ring size from 128 -> 256, Adjust moderation timer.
[dragonfly.git] / sys / dev / disk / ata / atapi-all.h
blob0cdcafb4a5d1c020dd5c6ec742bc6ed282d1f5a6
1 /*-
2 * Copyright (c) 1998,1999,2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
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.
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/dev/ata/atapi-all.h,v 1.22.2.10 2002/10/31 23:10:33 thomas Exp $
29 * $DragonFly: src/sys/dev/disk/ata/atapi-all.h,v 1.6 2005/10/26 13:59:41 sephe Exp $
32 /* ATAPI misc defines */
33 #define ATAPI_MAGIC_LSB 0x14
34 #define ATAPI_MAGIC_MSB 0xeb
35 #define ATAPI_P_READ (ATA_S_DRQ | ATA_I_IN)
36 #define ATAPI_P_WRITE (ATA_S_DRQ)
37 #define ATAPI_P_CMDOUT (ATA_S_DRQ | ATA_I_CMD)
38 #define ATAPI_P_DONEDRQ (ATA_S_DRQ | ATA_I_CMD | ATA_I_IN)
39 #define ATAPI_P_DONE (ATA_I_CMD | ATA_I_IN)
40 #define ATAPI_P_ABORT 0
42 /* error register bits */
43 #define ATAPI_E_MASK 0x0f /* error mask */
44 #define ATAPI_E_ILI 0x01 /* illegal length indication */
45 #define ATAPI_E_EOM 0x02 /* end of media detected */
46 #define ATAPI_E_ABRT 0x04 /* command aborted */
47 #define ATAPI_E_MCR 0x08 /* media change requested */
48 #define ATAPI_SK_MASK 0xf0 /* sense key mask */
49 #define ATAPI_SK_NO_SENSE 0x00 /* no specific sense key info */
50 #define ATAPI_SK_RECOVERED_ERROR 0x10 /* command OK, data recovered */
51 #define ATAPI_SK_NOT_READY 0x20 /* no access to drive */
52 #define ATAPI_SK_MEDIUM_ERROR 0x30 /* non-recovered data error */
53 #define ATAPI_SK_HARDWARE_ERROR 0x40 /* non-recoverable HW failure */
54 #define ATAPI_SK_ILLEGAL_REQUEST 0x50 /* invalid command param(s) */
55 #define ATAPI_SK_UNIT_ATTENTION 0x60 /* media changed */
56 #define ATAPI_SK_DATA_PROTECT 0x70 /* write protect */
57 #define ATAPI_SK_BLANK_CHECK 0x80 /* blank check */
58 #define ATAPI_SK_VENDOR_SPECIFIC 0x90 /* vendor specific skey */
59 #define ATAPI_SK_COPY_ABORTED 0xa0 /* copy aborted */
60 #define ATAPI_SK_ABORTED_COMMAND 0xb0 /* command aborted, try again */
61 #define ATAPI_SK_EQUAL 0xc0 /* equal */
62 #define ATAPI_SK_VOLUME_OVERFLOW 0xd0 /* volume overflow */
63 #define ATAPI_SK_MISCOMPARE 0xe0 /* data dont match the medium */
64 #define ATAPI_SK_RESERVED 0xf0
66 /* ATAPI commands */
67 #define ATAPI_TEST_UNIT_READY 0x00 /* check if device is ready */
68 #define ATAPI_REZERO 0x01 /* rewind */
69 #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */
70 #define ATAPI_FORMAT 0x04 /* format unit */
71 #define ATAPI_READ 0x08 /* read data */
72 #define ATAPI_WRITE 0x0a /* write data */
73 #define ATAPI_WEOF 0x10 /* write filemark */
74 #define WF_WRITE 0x01
75 #define ATAPI_SPACE 0x11 /* space command */
76 #define SP_FM 0x01
77 #define SP_EOD 0x03
78 #define ATAPI_MODE_SELECT 0x15 /* mode select */
79 #define ATAPI_ERASE 0x19 /* erase */
80 #define ATAPI_MODE_SENSE 0x1a /* mode sense */
81 #define ATAPI_START_STOP 0x1b /* start/stop unit */
82 #define SS_LOAD 0x01
83 #define SS_RETENSION 0x02
84 #define SS_EJECT 0x04
85 #define ATAPI_PREVENT_ALLOW 0x1e /* media removal */
86 #define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */
87 #define ATAPI_READ_BIG 0x28 /* read data */
88 #define ATAPI_WRITE_BIG 0x2a /* write data */
89 #define ATAPI_LOCATE 0x2b /* locate to position */
90 #define ATAPI_READ_POSITION 0x34 /* read position */
91 #define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush buf, close channel */
92 #define ATAPI_WRITE_BUFFER 0x3b /* write device buffer */
93 #define ATAPI_READ_BUFFER 0x3c /* read device buffer */
94 #define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */
95 #define ATAPI_READ_TOC 0x43 /* get table of contents */
96 #define ATAPI_PLAY_10 0x45 /* play by lba */
97 #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */
98 #define ATAPI_PLAY_TRACK 0x48 /* play by track number */
99 #define ATAPI_PAUSE 0x4b /* pause audio operation */
100 #define ATAPI_READ_DISK_INFO 0x51 /* get disk info structure */
101 #define ATAPI_READ_TRACK_INFO 0x52 /* get track info structure */
102 #define ATAPI_RESERVE_TRACK 0x53 /* reserve track */
103 #define ATAPI_SEND_OPC_INFO 0x54 /* send OPC structurek */
104 #define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */
105 #define ATAPI_REPAIR_TRACK 0x58 /* repair track */
106 #define ATAPI_READ_MASTER_CUE 0x59 /* read master CUE info */
107 #define ATAPI_MODE_SENSE_BIG 0x5a /* get device parameters */
108 #define ATAPI_CLOSE_TRACK 0x5b /* close track/session */
109 #define ATAPI_READ_BUFFER_CAPACITY 0x5c /* get buffer capicity */
110 #define ATAPI_SEND_CUE_SHEET 0x5d /* send CUE sheet */
111 #define ATAPI_BLANK 0xa1 /* blank the media */
112 #define ATAPI_SEND_KEY 0xa3 /* send DVD key structure */
113 #define ATAPI_REPORT_KEY 0xa4 /* get DVD key structure */
114 #define ATAPI_PLAY_12 0xa5 /* play by lba */
115 #define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */
116 #define ATAPI_READ_STRUCTURE 0xad /* get DVD structure */
117 #define ATAPI_PLAY_CD 0xb4 /* universal play command */
118 #define ATAPI_SET_SPEED 0xbb /* set drive speed */
119 #define ATAPI_MECH_STATUS 0xbd /* get changer status */
120 #define ATAPI_READ_CD 0xbe /* read data */
121 #define ATAPI_POLL_DSC 0xff /* poll DSC status bit */
123 struct atapi_request;
124 struct ata_channel;
126 /* ATAPI request sense structure */
127 struct atapi_reqsense {
128 u_int8_t error_code :7; /* current or deferred errors */
129 u_int8_t valid :1; /* follows ATAPI spec */
130 u_int8_t segment; /* Segment number */
131 u_int8_t sense_key :4; /* sense key */
132 u_int8_t reserved2_4 :1; /* reserved */
133 u_int8_t ili :1; /* incorrect length indicator */
134 u_int8_t eom :1; /* end of medium */
135 u_int8_t filemark :1; /* filemark */
136 /* cmd information */
137 u_int32_t cmd_info __attribute__((packed));
138 u_int8_t sense_length; /* additional sense len (n-7) */
139 /* additional cmd spec info */
140 u_int32_t cmd_specific_info __attribute__((packed));
141 u_int8_t asc; /* additional sense code */
142 u_int8_t ascq; /* additional sense code qual */
143 u_int8_t replaceable_unit_code; /* replaceable unit code */
144 u_int8_t sk_specific :7; /* sense key specific */
145 u_int8_t sksv :1; /* sense key specific info OK */
146 u_int8_t sk_specific1; /* sense key specific */
147 u_int8_t sk_specific2; /* sense key specific */
150 typedef int atapi_callback_t(struct atapi_request *);
152 struct atapi_request {
153 struct ata_device *device; /* ptr to parent softc */
154 u_int8_t ccb[16]; /* command control block */
155 int ccbsize; /* size of ccb (12 | 16) */
156 u_int32_t bytecount; /* bytes to transfer */
157 u_int32_t donecount; /* bytes transferred */
158 int timeout; /* timeout for this cmd */
159 struct callout callout;
160 int retries; /* retry count */
161 int result; /* result of this cmd */
162 int error; /* result translated to errno */
163 struct atapi_reqsense sense; /* sense data if error */
164 int flags;
165 #define ATPR_F_READ 0x0001
166 #define ATPR_F_DMA_USED 0x0002
167 #define ATPR_F_AT_HEAD 0x0004
168 #define ATPR_F_INTERNAL 0x0008
169 #define ATPR_F_QUIET 0x0010
171 caddr_t data; /* pointer to data buf */
172 atapi_callback_t *callback; /* ptr to callback func */
173 void *driver; /* driver specific */
174 TAILQ_ENTRY(atapi_request) chain; /* list management */
177 void atapi_attach(struct ata_device *, int);
178 void atapi_cam_attach_bus(struct ata_channel *);
179 void atapi_detach(struct ata_device *);
180 void atapi_cam_detach_bus(struct ata_channel *);
181 void atapi_cam_reinit_bus(struct ata_channel *);
182 void atapi_reinit(struct ata_device *);
183 void atapi_start(struct ata_device *);
184 int atapi_transfer(struct atapi_request *);
185 int atapi_interrupt(struct atapi_request *);
186 int atapi_queue_cmd(struct ata_device *, int8_t [], caddr_t, int, int, int, atapi_callback_t, void *);
187 int atapi_test_ready(struct ata_device *);
188 int atapi_wait_dsc(struct ata_device *, int);
189 void atapi_request_sense(struct ata_device *, struct atapi_reqsense *);
190 void atapi_dump(char *, void *, int);
191 int acdattach(struct ata_device *);
192 void acddetach(struct ata_device *);
193 void acd_start(struct ata_device *);
194 int afdattach(struct ata_device *);
195 void afddetach(struct ata_device *);
196 void afd_start(struct ata_device *);
197 int astattach(struct ata_device *);
198 void astdetach(struct ata_device *);
199 void ast_start(struct ata_device *);