1 /*-
2 * Copyright (c) 1998 Søren Schmidt
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: src/sys/i386/isa/atapi-cd.h,v 1.2.2.2 1999/09/05 08:12:26 peter Exp $
29 */
30
31 /*
32 * CDROM Table Of Contents
33 */
34 #define MAXTRK 99
35 struct toc {
36 struct ioc_toc_header hdr;
37 struct cd_toc_entry tab[MAXTRK + 1];
38 };
39
40 /*
41 * CDROM Audio Control Parameters Page
42 */
43 struct audiopage {
44 /* Mode Page data header */
45 u_short data_length;
46 u_char medium_type;
47 u_char dev_spec;
48 u_char unused[2];
49 u_short blk_desc_len;
50
51 /* Audio control page */
52 u_char page_code;
53 #define CDROM_AUDIO_PAGE 0x0e
54 #define CDROM_AUDIO_PAGE_MASK 0x4e
55
56 u_char param_len;
57 u_char flags;
58 #define CD_PA_SOTC 0x02
59 #define CD_PA_IMMED 0x04
60
61 u_char reserved3;
62 u_char reserved4;
63 u_char reserved5;
64 u_short lb_per_sec;
65 struct port_control {
66 u_char channels:4;
67 #define CHANNEL_0 1
68 #define CHANNEL_1 2
69 #define CHANNEL_2 4
70 #define CHANNEL_3 8
71 u_char volume;
72 } port[4];
73 };
74
75 /*
76 * CDROM Capabilities and Mechanical Status Page
77 */
78 struct cappage {
79 /* Mode data header */
80 u_short data_length;
81 u_char medium_type; /* Present media type */
82 #define MST_TYPE_MASK_LOW 0x0f
83 #define MST_FMT_NONE 0x00
84 #define MST_DATA_120 0x01
85 #define MST_AUDIO_120 0x02
86 #define MST_COMB_120 0x03
87 #define MST_PHOTO_120 0x04
88 #define MST_DATA_80 0x05
89 #define MST_AUDIO_80 0x06
90 #define MST_COMB_80 0x07
91 #define MST_PHOTO_80 0x08
92
93 #define MST_TYPE_MASK_HIGH 0x70
94 #define MST_CDROM 0x00
95 #define MST_CDR 0x10
96 #define MST_CDRW 0x20
97
98 #define MST_NO_DISC 0x70
99 #define MST_DOOR_OPEN 0x71
100 #define MST_FMT_ERROR 0x72
101
102 u_char dev_spec;
103 u_char unused[2];
104 u_short blk_desc_len;
105
106 /* Capabilities page */
107 u_char page_code;
108 #define ATAPI_CDROM_CAP_PAGE 0x2a
109
110 u_char param_len;
111 u_char read_cdr:1; /* Supports CD-R read */
112 u_char read_cdrw:1; /* Supports CD-RW read */
113 u_char method2:1; /* Supports reading packet tracks */
114 u_char byte2_37:5;
115 u_char write_cdr:1; /* Supports CD-R write */
116 u_char write_cdrw:1; /* Supports CD-RW write */
117 u_char test_write:1; /* Supports test writing */
118 u_char byte3_37:5;
119 u_char audio_play:1; /* Audio play supported */
120 u_char composite:1; /* Composite audio/video supported */
121 u_char dport1:1; /* Digital audio on port 1 */
122 u_char dport2:1; /* Digital audio on port 2 */
123 u_char mode2_form1:1; /* Mode 2 form 1 (XA) read */
124 u_char mode2_form2:1; /* Mode 2 form 2 format */
125 u_char multisession:1; /* Multi-session photo-CD */
126 u_char:1;
127 u_char cd_da:1; /* Audio-CD read supported */
128 u_char cd_da_stream:1; /* CD-DA streaming */
129 u_char rw:1; /* Combined R-W subchannels */
130 u_char rw_corr:1; /* R-W subchannel data corrected */
131 u_char c2:1; /* C2 error pointers supported */
132 u_char isrc:1; /* Can return the ISRC info */
133 u_char upc:1; /* Can return the catalog number UPC */
134 u_char:1;
135 u_char lock:1; /* Can be locked */
136 u_char locked:1; /* Current lock state */
137 u_char prevent:1; /* Prevent jumper installed */
138 u_char eject:1; /* Can eject */
139 u_char:1;
140 u_char mech:3; /* Loading mechanism type */
141 #define MST_MECH_CADDY 0
142 #define MST_MECH_TRAY 1
143 #define MST_MECH_POPUP 2
144 #define MST_MECH_CHANGER 4
145 #define MST_MECH_CARTRIDGE 5
146
147 u_char sep_vol:1; /* Independent volume of channels */
148 u_char sep_mute:1; /* Independent mute of channels */
149 u_char:6;
150
151 u_short max_speed; /* Max raw data rate in bytes/1000 */
152 u_short max_vol_levels; /* Number of discrete volume levels */
153 u_short buf_size; /* Internal buffer size in bytes/1024 */
154 u_short cur_speed; /* Current data rate in bytes/1000 */
155
156 u_char reserved3;
157 u_char bckf:1; /* Data valid on failing edge of BCK */
158 u_char rch:1; /* High LRCK indicates left channel */
159 u_char lsbf:1; /* Set if LSB first */
160 u_char dlen:2;
161 #define MST_DLEN_32 0
162 #define MST_DLEN_16 1
163 #define MST_DLEN_24 2
164 #define MST_DLEN_24_I2S 3
165
166 u_char:3;
167 u_char reserved4[2];
168 };
169
170 /*
171 * CDROM Changer mechanism status structure
172 */
173 struct changer {
174 u_char current_slot:5; /* Active changer slot */
175 u_char mech_state:2; /* Current changer state */
176 #define CH_READY 0
177 #define CH_LOADING 1
178 #define CH_UNLOADING 2
179 #define CH_INITIALIZING 3
180
181 u_char fault:1; /* Fault in last operation */
182 u_char reserved0:5;
183 u_char cd_state:3; /* Current mechanism state */
184 #define CD_IDLE 0
185 #define CD_AUDIO_ACTIVE 1
186 #define CD_AUDIO_SCAN 2
187 #define CD_HOST_ACTIVE 3
188 #define CD_NO_STATE 7
189
190 u_char current_lba[3]; /* Current LBA */
191 u_char slots; /* Number of available slots */
192 u_short table_length; /* Slot table length */
193 struct {
194 u_char changed:1; /* Media has changed in this slot */
195 u_char unused:6;
196 u_char present:1; /* Slot has a CD present */
197 u_char reserved0;
198 u_char reserved1;
199 u_char reserved2;
200 } slot[32];
201 };
202
203 /*
204 * CDROM Write Parameters Mode Page (Burners ONLY)
205 */
206 struct write_param {
207 /* Mode Page data header */
208 u_short data_length;
209 u_char medium_type;
210 u_char dev_spec;
211 u_char unused[2];
212 u_short blk_desc_len;
213
214 /* Write Parameters mode page */
215 u_char page_code; /* 0x05 */
216 u_char page_length; /* 0x32 */
217 u_char write_type:4; /* Write stream type */
218 #define CDR_WTYPE_PACKET 0x00
219 #define CDR_WTYPE_TRACK 0x01
220 #define CDR_WTYPE_SESSION 0x02
221 #define CDR_WTYPE_RAW 0x03
222
223 u_char test_write:1; /* Test write enable */
224 u_char reserved2_567:3;
225 u_char track_mode:4; /* Track mode */
226 #define CDR_TMODE_AUDIO 0x01
227 #define CDR_TMODE_INCR_DATA 0x01
228 #define CDR_TMODE_ALLOW_COPY 0x02
229 #define CDR_TMODE_DATA 0x04
230 #define CDR_TMODE_QUAD_AUDIO 0x08
231
232 u_char copy:1; /* Generation stamp */
233 u_char fp:1; /* Fixed packet type */
234 u_char multi_session:2; /* Multi-session type */
235 #define CDR_MSES_NONE 0x00
236 #define CDR_MSES_FINAL 0x01
237 #define CDR_MSES_RESERVED 0x02
238 #define CDR_MSES_NULTI 0x03
239
240 u_char data_block_type:4; /* Data block type code */
241 #define CDR_DB_RAW 0x0 /* 2352 bytes of raw data */
242 #define CDR_DB_RAW_PQ 0x1 /* 2368 bytes raw data + P/Q subchan */
243 #define CDR_DB_RAW_PW 0x2 /* 2448 bytes raw data + P-W subchan */
244 #define CDR_DB_RAW_PW_R 0x3 /* 2448 bytes raw data + P-W raw sub */
245 #define CDR_DB_RES_4 0x4 /* Reserved */
246 #define CDR_DB_RES_5 0x5 /* Reserved */
247 #define CDR_DB_RES_6 0x6 /* Reserved */
248 #define CDR_DB_VS_7 0x7 /* Vendor specific */
249 #define CDR_DB_ROM_MODE1 0x8 /* 2048 bytes Mode 1 (ISO/IEC 10149) */
250 #define CDR_DB_ROM_MODE2 0x9 /* 2336 bytes Mode 2 (ISO/IEC 10149) */
251 #define CDR_DB_XA_MODE1 0x10 /* 2048 bytes Mode 1 (CD-ROM XA 1) */
252 #define CDR_DB_XA_MODE2_F1 0x11 /* 2056 bytes Mode 2 (CD-ROM XA 1) */
253 #define CDR_DB_XA_MODE2_F2 0x12 /* 2324 bytes Mode 2 (CD-ROM XA 2) */
254 #define CDR_DB_XA_MODE2_MIX 0x13 /* 2332 bytes Mode 2 (CD-ROM XA 1/2) */
255 #define CDR_DB_RES_14 0x14 /* Reserved */
256 #define CDR_DB_VS_15 0x15 /* Vendor specific */
257
258 u_char reserved4_4567:4;
259 u_char reserved5;
260 u_char reserved6;
261 u_char host_app_code:6; /* Host application code */
262 u_char reserved7_67:2;
263 u_char session_format; /* Session format */
264 #define CDR_SESS_CDROM 0x00
265 #define CDR_SESS_CDI 0x10
266 #define CDR_SESS_CDROM_XA 0x20
267
268 u_char reserved9;
269 u_int packet_size; /* Packet size in bytes */
270 u_short audio_pause_length; /* Audio pause length in secs */
271 u_char media_catalog_number[16];
272 u_char isr_code[16];
273 u_char sub_hdr_byte0;
274 u_char sub_hdr_byte1;
275 u_char sub_hdr_byte2;
276 u_char sub_hdr_byte3;
277 #if 0 /* these are reserved bytes, should not be read */
278 u_char vendor_specific_byte0;
279 u_char vendor_specific_byte1;
280 u_char vendor_specific_byte2;
281 u_char vendor_specific_byte3;
282 #endif
283
284 } __attribute__((packed));
285 /*
286 * CDROM Read Track Information structure
287 */
288 struct acd_track_info {
289 u_short data_length;
290 u_char track_number; /* Current track number */
291 u_char session_number; /* Current session number */
292 u_char reserved4;
293 u_char track_mode:4; /* Mode of this track */
294 u_char copy:1; /* Generation stamp */
295 u_char damage:1; /* Damaged track */
296 u_char reserved5_67:2;
297 u_char data_mode:4; /* Data mode of this disc */
298 u_char fp:1; /* Fixed packet */
299 u_char packet:1; /* Packet track */
300 u_char blank:1; /* Blank (empty) track */
301 u_char rt:1; /* Reserved track */
302 u_char nwa_valid:1; /* next_writeable_addr field valid */
303 u_char reserved7_17:7;
304 u_int track_start_addr; /* Start of this track */
305 u_int next_writeable_addr; /* Next writeable addr on this disc */
306 u_int free_blocks; /* Free block on this disc */
307 u_int fixed_packet_size; /* Size of packets on this track */
308 u_int track_length; /* Length of this track */
309 };
310
311 /*
312 * Structure describing an ATAPI CDROM device
313 */
314 struct acd {
315 int unit; /* IDE bus drive unit */
316 int lun; /* Logical device unit */
317 int flags; /* Device state flags */
318 int refcnt; /* The number of raw opens */
319 struct atapi *ata; /* Controller structure */
320 struct buf_queue_head buf_queue; /* Queue of i/o requests */
321 struct atapi_params *param; /* Drive parameters table */
322 struct toc toc; /* Table of disc contents */
323 struct {
324 u_long volsize; /* Volume size in blocks */
325 u_long blksize; /* Block size in bytes */
326 } info;
327 struct audiopage au; /* Audio page info */
328 struct cappage cap; /* Capabilities page info */
329 struct audiopage aumask; /* Audio page mask */
330 struct { /* Subchannel info */
331 u_char void0;
332 u_char audio_status;
333 u_short data_length;
334 u_char data_format;
335 u_char control;
336 u_char track;
337 u_char indx;
338 u_long abslba;
339 u_long rellba;
340 } subchan;
341 struct changer *changer_info; /* Changer info */
342 int slot; /* This lun's slot number */
343 u_int block_size; /* Blocksize currently used */
344 u_char dummy; /* Use dummy writes */
345 u_char speed; /* Select drive speed */
346 u_int next_writeable_lba; /* Next writable position */
347 struct wormio_prepare_track preptrack; /* Scratch region */
348
349 u_long starting_lba ; /* for multitrack */
350 #ifdef DEVFS
351 void *ra_devfs_token;
352 void *rc_devfs_token;
353 void *a_devfs_token;
354 void *c_devfs_token;
355 #endif
356 };
357
358 struct atapireq {
359 u_char cmd[16];
360 caddr_t databuf;
361 int datalen;
362 struct atapires result;
363 };
364
365 #define CDRIOCBLANK _IO('c',100) /* Blank a CDRW disc */
366 #define CDRIOCNEXTWRITEABLEADDR _IOR('c',101,int)
367 #define CDRIOCATAPIREQ _IOWR('c',102,struct atapireq)
Cache object: 2a8388c0353cd484ac97dd86c023c8d3
|