scsipi_cd.h revision 1.15 1 1.15 christos /* $NetBSD: scsipi_cd.h,v 1.15 2006/11/30 16:23:20 christos Exp $ */
2 1.2 bouyer
3 1.2 bouyer /*
4 1.2 bouyer * Written by Julian Elischer (julian (at) tfs.com)
5 1.2 bouyer * for TRW Financial Systems.
6 1.2 bouyer *
7 1.2 bouyer * TRW Financial Systems, in accordance with their agreement with Carnegie
8 1.2 bouyer * Mellon University, makes this software available to CMU to distribute
9 1.3 enami * or use in any manner that they see fit as long as this message is kept with
10 1.2 bouyer * the software. For this reason TFS also grants any other persons or
11 1.2 bouyer * organisations permission to use or modify this software.
12 1.2 bouyer *
13 1.2 bouyer * TFS supplies this software to be publicly redistributed
14 1.2 bouyer * on the understanding that TFS is not responsible for the correct
15 1.2 bouyer * functioning of this software in any circumstances.
16 1.2 bouyer *
17 1.2 bouyer * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
18 1.2 bouyer */
19 1.4 enami
20 1.2 bouyer /*
21 1.2 bouyer * Define two bits always in the same place in byte 2 (flag byte)
22 1.2 bouyer */
23 1.2 bouyer #define CD_RELADDR 0x01
24 1.2 bouyer #define CD_MSF 0x02
25 1.2 bouyer
26 1.2 bouyer /*
27 1.2 bouyer * SCSI and SCSI-like command format
28 1.2 bouyer */
29 1.2 bouyer
30 1.7 mycroft #define LOAD_UNLOAD 0xa6
31 1.7 mycroft struct scsipi_load_unload {
32 1.10 reinoud u_int8_t opcode;
33 1.10 reinoud u_int8_t unused1[3];
34 1.10 reinoud u_int8_t options;
35 1.10 reinoud u_int8_t unused2[3];
36 1.10 reinoud u_int8_t slot;
37 1.10 reinoud u_int8_t unused3[3];
38 1.15 christos } __attribute__((__packed__, __aligned__(4)));
39 1.7 mycroft
40 1.2 bouyer #define PAUSE 0x4b /* cdrom pause in 'play audio' mode */
41 1.2 bouyer struct scsipi_pause {
42 1.10 reinoud u_int8_t opcode;
43 1.10 reinoud u_int8_t byte2;
44 1.10 reinoud u_int8_t unused[6];
45 1.10 reinoud u_int8_t resume;
46 1.10 reinoud u_int8_t control;
47 1.15 christos } __attribute__((__packed__, __aligned__(4)));
48 1.2 bouyer #define PA_PAUSE 0x00
49 1.2 bouyer #define PA_RESUME 0x01
50 1.2 bouyer
51 1.2 bouyer #define PLAY_MSF 0x47 /* cdrom play Min,Sec,Frames mode */
52 1.2 bouyer struct scsipi_play_msf {
53 1.10 reinoud u_int8_t opcode;
54 1.10 reinoud u_int8_t byte2;
55 1.10 reinoud u_int8_t unused;
56 1.10 reinoud u_int8_t start_m;
57 1.10 reinoud u_int8_t start_s;
58 1.10 reinoud u_int8_t start_f;
59 1.10 reinoud u_int8_t end_m;
60 1.10 reinoud u_int8_t end_s;
61 1.10 reinoud u_int8_t end_f;
62 1.10 reinoud u_int8_t control;
63 1.15 christos } __attribute__((__packed__, __aligned__(4)));
64 1.2 bouyer
65 1.2 bouyer #define PLAY 0x45 /* cdrom play 'play audio' mode */
66 1.2 bouyer struct scsipi_play {
67 1.10 reinoud u_int8_t opcode;
68 1.10 reinoud u_int8_t byte2;
69 1.10 reinoud u_int8_t blk_addr[4];
70 1.10 reinoud u_int8_t unused;
71 1.10 reinoud u_int8_t xfer_len[2];
72 1.10 reinoud u_int8_t control;
73 1.15 christos } __attribute__((__packed__, __aligned__(4)));
74 1.2 bouyer
75 1.2 bouyer #define READ_HEADER 0x44 /* cdrom read header */
76 1.2 bouyer struct scsipi_read_header {
77 1.10 reinoud u_int8_t opcode;
78 1.10 reinoud u_int8_t byte2;
79 1.10 reinoud u_int8_t blk_addr[4];
80 1.10 reinoud u_int8_t unused;
81 1.10 reinoud u_int8_t data_len[2];
82 1.10 reinoud u_int8_t control;
83 1.15 christos } __attribute__((__packed__, __aligned__(4)));
84 1.2 bouyer
85 1.2 bouyer #define READ_SUBCHANNEL 0x42 /* cdrom read Subchannel */
86 1.2 bouyer struct scsipi_read_subchannel {
87 1.10 reinoud u_int8_t opcode;
88 1.10 reinoud u_int8_t byte2;
89 1.10 reinoud u_int8_t byte3;
90 1.2 bouyer #define SRS_SUBQ 0x40
91 1.10 reinoud u_int8_t subchan_format;
92 1.10 reinoud u_int8_t unused[2];
93 1.10 reinoud u_int8_t track;
94 1.10 reinoud u_int8_t data_len[2];
95 1.10 reinoud u_int8_t control;
96 1.15 christos } __attribute__((__packed__, __aligned__(4)));
97 1.2 bouyer
98 1.2 bouyer #define READ_TOC 0x43 /* cdrom read TOC */
99 1.2 bouyer struct scsipi_read_toc {
100 1.10 reinoud u_int8_t opcode;
101 1.10 reinoud u_int8_t addr_mode;
102 1.10 reinoud u_int8_t resp_format;
103 1.10 reinoud u_int8_t unused[3];
104 1.12 reinoud u_int8_t from_track; /* session nr in format 2 */
105 1.10 reinoud u_int8_t data_len[2];
106 1.10 reinoud u_int8_t control;
107 1.15 christos } __attribute__((__packed__, __aligned__(4)));
108 1.2 bouyer
109 1.12 reinoud struct scsipi_toc_header {
110 1.12 reinoud uint8_t length[2];
111 1.12 reinoud uint8_t first; /* track or session */
112 1.12 reinoud uint8_t last;
113 1.15 christos } __attribute__((__packed__, __aligned__(4)));
114 1.12 reinoud
115 1.12 reinoud /* read TOC form 0 result entries */
116 1.12 reinoud struct scsipi_toc_formatted {
117 1.12 reinoud uint8_t unused1;
118 1.12 reinoud uint8_t adrcontol;
119 1.12 reinoud uint8_t tracknr;
120 1.12 reinoud uint8_t unused2;
121 1.12 reinoud uint8_t msf_lba[4]; /* union msf_lba from cdio.h */
122 1.15 christos } __attribute__((__packed__, __aligned__(4)));
123 1.12 reinoud
124 1.12 reinoud /* read TOC form 1 result entries */
125 1.12 reinoud struct scsipi_toc_msinfo {
126 1.12 reinoud uint8_t unused1;
127 1.12 reinoud uint8_t adrcontol;
128 1.12 reinoud uint8_t tracknr; /* first track last compl. session */
129 1.12 reinoud uint8_t unused2;
130 1.12 reinoud uint8_t msf_lba[4]; /* union msf_lba from cdio.h */
131 1.15 christos } __attribute__((__packed__, __aligned__(4)));
132 1.12 reinoud
133 1.12 reinoud /* read TOC form 2 result entries */
134 1.12 reinoud struct scsipi_toc_rawtoc {
135 1.12 reinoud uint8_t sessionnr;
136 1.12 reinoud uint8_t adrcontrol;
137 1.12 reinoud uint8_t tno;
138 1.12 reinoud uint8_t point;
139 1.12 reinoud uint8_t min;
140 1.12 reinoud uint8_t sec;
141 1.12 reinoud uint8_t frame;
142 1.12 reinoud uint8_t zero; /* zero/unused */
143 1.12 reinoud uint8_t pmin;
144 1.12 reinoud uint8_t psec;
145 1.12 reinoud uint8_t pframe;
146 1.15 christos } __attribute__((__packed__, __aligned__(4)));
147 1.12 reinoud
148 1.12 reinoud /* read TOC form 3, 4 and 5 obmitted yet */
149 1.12 reinoud
150 1.12 reinoud #define GET_CONFIGURATION 0x46 /* Get configuration */
151 1.12 reinoud #define GET_CONF_NO_FEATURES_LEN 8
152 1.12 reinoud struct scsipi_get_configuration {
153 1.12 reinoud uint8_t opcode;
154 1.12 reinoud uint8_t request_type;
155 1.12 reinoud uint8_t start_at_feature[2];
156 1.12 reinoud uint8_t unused[3];
157 1.12 reinoud uint8_t data_len[2];
158 1.12 reinoud uint8_t control;
159 1.15 christos } __attribute__((__packed__, __aligned__(4)));
160 1.12 reinoud
161 1.12 reinoud struct scsipi_get_conf_data {
162 1.12 reinoud uint8_t data_len[4];
163 1.12 reinoud uint8_t unused[2];
164 1.12 reinoud uint8_t mmc_profile[2]; /* current mmc profile for disk */
165 1.12 reinoud uint8_t feature_desc[1]; /* feature descriptors follow */
166 1.15 christos } __attribute__((__packed__, __aligned__(4)));
167 1.12 reinoud
168 1.12 reinoud struct scsipi_get_conf_feature { /* feature descriptor */
169 1.12 reinoud uint8_t featurecode[2];
170 1.12 reinoud uint8_t flags;
171 1.12 reinoud uint8_t additional_length; /* length of feature dependent */
172 1.12 reinoud uint8_t feature_dependent[256];
173 1.15 christos } __attribute__((__packed__, __aligned__(4)));
174 1.12 reinoud #define FEATUREFLAG_CURRENT 1
175 1.12 reinoud #define FEATUREFLAG_PERSISTENT 2
176 1.12 reinoud
177 1.12 reinoud
178 1.12 reinoud #define READ_DISCINFO 0x51
179 1.12 reinoud struct scsipi_read_discinfo {
180 1.12 reinoud uint8_t opcode;
181 1.12 reinoud uint8_t unused[6];
182 1.12 reinoud uint8_t data_len[2];
183 1.12 reinoud uint8_t control;
184 1.15 christos } __attribute__((__packed__, __aligned__(4)));
185 1.12 reinoud
186 1.12 reinoud #define READ_DISCINFO_SMALLSIZE 12
187 1.12 reinoud #define READ_DISCINFO_BIGSIZE 34 /* + entries */
188 1.12 reinoud struct scsipi_read_discinfo_data {
189 1.12 reinoud uint8_t data_len[2];
190 1.12 reinoud uint8_t disc_state;
191 1.12 reinoud uint8_t first_track;
192 1.12 reinoud uint8_t num_sessions_lsb;
193 1.12 reinoud uint8_t first_track_last_session_lsb;
194 1.12 reinoud uint8_t last_track_last_session_lsb;
195 1.12 reinoud uint8_t disc_state2;
196 1.12 reinoud uint8_t disc_type;
197 1.12 reinoud uint8_t num_sessions_msb;
198 1.12 reinoud uint8_t first_track_last_session_msb;
199 1.12 reinoud uint8_t last_track_last_session_msb;
200 1.12 reinoud uint8_t discid[4];
201 1.12 reinoud uint8_t last_session_leadin_hmsf[4];
202 1.12 reinoud uint8_t last_possible_start_leadout_hmsf[4];
203 1.12 reinoud uint8_t disc_bar_code[8];
204 1.14 reinoud uint8_t application_code;
205 1.12 reinoud uint8_t num_opc_table_entries;
206 1.12 reinoud uint8_t opc_table_entries[1]; /* opc table entries follow */
207 1.15 christos } __attribute__((__packed__, __aligned__(4)));
208 1.12 reinoud
209 1.12 reinoud
210 1.12 reinoud #define READ_TRACKINFO 0x52
211 1.12 reinoud struct scsipi_read_trackinfo {
212 1.12 reinoud uint8_t opcode;
213 1.12 reinoud uint8_t addr_type;
214 1.12 reinoud uint8_t address[4];
215 1.12 reinoud uint8_t nothing;
216 1.12 reinoud uint8_t data_len[2];
217 1.12 reinoud uint8_t control;
218 1.15 christos } __attribute__((__packed__, __aligned__(4)));
219 1.12 reinoud #define READ_TRACKINFO_ADDR_LBA 0
220 1.12 reinoud #define READ_TRACKINFO_ADDR_TRACK 1
221 1.12 reinoud #define READ_TRACKINFO_ADDR_SESS 2
222 1.12 reinoud
223 1.12 reinoud struct scsipi_read_trackinfo_data {
224 1.12 reinoud uint8_t data_len[2];
225 1.12 reinoud uint8_t track_lsb;
226 1.12 reinoud uint8_t session_lsb;
227 1.12 reinoud uint8_t unused1;
228 1.12 reinoud uint8_t track_info_1;
229 1.12 reinoud uint8_t track_info_2;
230 1.12 reinoud uint8_t data_valid;
231 1.12 reinoud uint8_t track_start[4];
232 1.12 reinoud uint8_t next_writable[4];
233 1.12 reinoud uint8_t free_blocks[4];
234 1.12 reinoud uint8_t packet_size[4];
235 1.12 reinoud uint8_t track_size[4];
236 1.12 reinoud uint8_t last_recorded[4];
237 1.12 reinoud uint8_t track_msb;
238 1.12 reinoud uint8_t session_msb;
239 1.12 reinoud uint8_t unused2[2];
240 1.15 christos } __attribute__((__packed__, __aligned__(4)));
241 1.12 reinoud #define READ_TRACKINFO_RETURNSIZE 36
242 1.12 reinoud
243 1.12 reinoud
244 1.2 bouyer #define READ_CD_CAPACITY 0x25 /* slightly different from disk */
245 1.2 bouyer struct scsipi_read_cd_capacity {
246 1.10 reinoud u_int8_t opcode;
247 1.10 reinoud u_int8_t byte2;
248 1.10 reinoud u_int8_t addr[4];
249 1.10 reinoud u_int8_t unused[3];
250 1.10 reinoud u_int8_t control;
251 1.15 christos } __attribute__((__packed__, __aligned__(4)));
252 1.2 bouyer
253 1.2 bouyer struct scsipi_read_cd_cap_data {
254 1.10 reinoud u_int8_t addr[4];
255 1.10 reinoud u_int8_t length[4];
256 1.15 christos } __attribute__((__packed__, __aligned__(4)));
257 1.2 bouyer
258 1.12 reinoud
259 1.2 bouyer /* mod pages common to scsi and atapi */
260 1.2 bouyer struct cd_audio_page {
261 1.10 reinoud u_int8_t pg_code;
262 1.3 enami #define AUDIO_PAGE 0x0e
263 1.10 reinoud u_int8_t pg_length;
264 1.10 reinoud u_int8_t flags;
265 1.2 bouyer #define CD_PA_SOTC 0x02
266 1.2 bouyer #define CD_PA_IMMED 0x04
267 1.10 reinoud u_int8_t unused[2];
268 1.10 reinoud u_int8_t format_lba; /* valid only for SCSI CDs */
269 1.3 enami #define CD_PA_FORMAT_LBA 0x0F
270 1.2 bouyer #define CD_PA_APR_VALID 0x80
271 1.10 reinoud u_int8_t lb_per_sec[2];
272 1.3 enami struct port_control {
273 1.10 reinoud u_int8_t channels;
274 1.2 bouyer #define CHANNEL 0x0F
275 1.2 bouyer #define CHANNEL_0 1
276 1.2 bouyer #define CHANNEL_1 2
277 1.2 bouyer #define CHANNEL_2 4
278 1.2 bouyer #define CHANNEL_3 8
279 1.3 enami #define LEFT_CHANNEL CHANNEL_0
280 1.3 enami #define RIGHT_CHANNEL CHANNEL_1
281 1.3 enami #define MUTE_CHANNEL 0x0
282 1.3 enami #define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL
283 1.10 reinoud u_int8_t volume;
284 1.2 bouyer } port[4];
285 1.2 bouyer #define LEFT_PORT 0
286 1.2 bouyer #define RIGHT_PORT 1
287 1.2 bouyer };
288