1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
.\" $OpenBSD: cd.4,v 1.25 2015/08/27 18:58:05 jmc Exp $
.\" $NetBSD: cd.4,v 1.3 1996/10/20 23:15:21 explorer Exp $
.\"
.\" Copyright (c) 1996
.\" Julian Elischer <julian@freebsd.org>. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: August 27 2015 $
.Dt CD 4
.Os
.Sh NAME
.Nm cd
.Nd ATAPI and SCSI CD-ROM driver
.Sh SYNOPSIS
.Cd "cd* at scsibus?"
.Cd "#cd0 at scsibus0 target 6 lun 0" Pq fixed-configuration example
.Sh DESCRIPTION
The
.Nm
driver provides support for ATAPI and SCSI CD-ROM
.Pq Compact Disc Read-Only Memory
drives, via
.Xr scsibus 4 .
In an attempt to look like a regular disk, the
.Nm
driver synthesizes a partition table, with one partition covering the entire
CD-ROM.
It is possible to modify this partition table using
.Xr disklabel 8 ,
but it will only last until the CD-ROM is unmounted.
In general the interfaces are similar to those described by
.Xr wd 4
and
.Xr sd 4 .
.Pp
As the SCSI adapter is probed during boot, the SCSI bus is scanned for devices.
Any devices found which answer as
.Dq Read-only
and
.Dq removable
CD-ROM or WORM devices will be
.Dq attached
to the
.Nm
driver.
.Pp
The system utility
.Xr disklabel 8
may be used to read the synthesized
disk label
structure, which will contain correct figures for the size of the
CD-ROM should that information be required.
.Sh IOCTLS
The following
.Xr ioctl 2
calls which apply to CD-ROM drives are defined in the header files
.In sys/cdio.h
and
.In sys/dkio.h .
.Bl -tag -width Ds
.It Dv DIOCGDINFO , DIOCSDINFO Fa "struct disklabel *"
Read or write the in-core copy of the disklabel for the drive.
The disklabel is initialized with information read from the SCSI inquiry
commands, and should be the same as the information printed at boot.
This structure is defined in
.Xr disklabel 5 .
.\".It Dv CDIOCCAPABILITY
.\".Pq Li "struct ioc_capability"
.\"Retrieve information from the drive on what features it supports. The
.\"information is returned in the following structure:
.\".Bd -literal -offset indent
.\"struct ioc_capability {
.\" u_long play_function;
.\"#define CDDOPLAYTRK 0x00000001
.\" /* Can play tracks/index */
.\"#define CDDOPLAYMSF 0x00000002
.\" /* Can play msf to msf */
.\"#define CDDOPLAYBLOCKS 0x00000004
.\" /* Can play range of blocks */
.\"#define CDDOPAUSE 0x00000100
.\" /* Output can be paused */
.\"#define CDDORESUME 0x00000200
.\" /* Output can be resumed */
.\"#define CDDORESET 0x00000400
.\" /* Drive can be completely reset */
.\"#define CDDOSTART 0x00000800
.\" /* Audio can be started */
.\"#define CDDOSTOP 0x00001000
.\" /* Audio can be stopped */
.\"#define CDDOPITCH 0x00002000
.\" /* Audio pitch can be changed */
.\"
.\" u_long routing_function;
.\"#define CDREADVOLUME 0x00000001
.\" /* Volume settings can be read */
.\"#define CDSETVOLUME 0x00000002
.\" /* Volume settings can be set */
.\"#define CDSETMONO 0x00000100
.\" /* Output can be set to mono */
.\"#define CDSETSTEREO 0x00000200
.\" /* Output can be set to stereo (def) */
.\"#define CDSETLEFT 0x00000400
.\" /* Output can be set to left only */
.\"#define CDSETRIGHT 0x00000800
.\" /* Output can be set to right only */
.\"#define CDSETMUTE 0x00001000
.\" /* Output can be muted */
.\"#define CDSETPATCH 0x00008000
.\" /* Direct routing control allowed */
.\"
.\" u_long special_function;
.\"#define CDDOEJECT 0x00000001
.\" /* The tray can be opened */
.\"#define CDDOCLOSE 0x00000002
.\" /* The tray can be closed */
.\"#define CDDOLOCK 0x00000004
.\" /* The tray can be locked */
.\"#define CDREADHEADER 0x00000100
.\" /* Can read Table of Contents */
.\"#define CDREADENTRIES 0x00000200
.\" /* Can read TOC Entries */
.\"#define CDREADSUBQ 0x00000200
.\" /* Can read Subchannel info */
.\"#define CDREADRW 0x00000400
.\" /* Can read subcodes R-W */
.\"#define CDHASDEBUG 0x00004000
.\" /* The tray has dynamic debugging */
.\"};
.\".Ed
.It Dv CDIOCPLAYTRACKS Fa "struct ioc_play_track *"
Start audio playback given a track address and length.
The structure is defined as follows:
.Bd -literal -offset indent
struct ioc_play_track {
u_char start_track;
u_char start_index;
u_char end_track;
u_char end_index;
};
.Ed
.It Dv CDIOCPLAYBLOCKS Fa "struct ioc_play_blocks *"
Start audio playback given a block address and length.
The structure is defined as follows:
.Bd -literal -offset indent
struct ioc_play_blocks {
int blk;
int len;
};
.Ed
.It Dv CDIOCPLAYMSF Fa "struct ioc_play_msf *"
Start audio playback given a
.Dq minutes-seconds-frames
address and length.
The structure is defined as follows:
.Bd -literal -offset indent
struct ioc_play_msf {
u_char start_m;
u_char start_s;
u_char start_f;
u_char end_m;
u_char end_s;
u_char end_f;
};
.Ed
.It Dv CDIOCREADSUBCHANNEL Fa "struct ioc_read_subchannel *"
Read information from the subchannel at the location specified by this
structure:
.Bd -literal -offset indent
struct ioc_read_subchannel {
u_char address_format;
#define CD_LBA_FORMAT 1
#define CD_MSF_FORMAT 2
u_char data_format;
#define CD_SUBQ_DATA 0
#define CD_CURRENT_POSITION 1
#define CD_MEDIA_CATALOG 2
#define CD_TRACK_INFO 3
u_char track;
int data_len;
struct cd_sub_channel_info *data;
};
.Ed
.It Dv CDIOREADTOCHEADER Fa "struct ioc_toc_header *"
Return summary information about the table of contents for the
mounted CD-ROM.
The information is returned into the following structure:
.Bd -literal -offset indent
struct ioc_toc_header {
u_short len;
u_char starting_track;
u_char ending_track;
};
.Ed
.It Dv CDIOREADTOCENTRIES Fa "struct ioc_read_toc_entry *"
Return information from the table of contents entries mentioned.
The argument structure is defined as follows:
.Bd -literal -offset indent
struct ioc_read_toc_entry {
u_char address_format;
u_char starting_track;
u_short data_len;
struct cd_toc_entry *data;
};
.Ed
.Pp
The requested data is written into an area of size
.Li data_len
and pointed to by
.Li data .
.It Dv CDIOCSETPATCH Fa "struct ioc_patch *"
Attach various audio channels to various output channels.
The argument structure is defined thusly:
.Bd -literal -offset indent
struct ioc_patch {
u_char patch[4];
/* one for each channel */
};
.Ed
.It Dv CDIOCGETVOL , CDIOCSETVOL Fa "struct ioc_vol *"
Get (set) information about the volume settings of the output channels.
The argument structure is as follows:
.Bd -literal -offset indent
struct ioc_vol {
u_char vol[4];
/* one for each channel */
};
.Ed
.It Dv CDIOCSETMONO
Patch all output channels to all source channels.
.It Dv CDIOCSETSTEREO
Patch left source channel to the left output channel and the right
source channel to the right output channel.
.It Dv CDIOCSETMUTE
Mute output without changing the volume settings.
.It Dv CDIOCSETLEFT , CDIOCSETRIGHT
Attach both output channels to the left (right) source channel.
.It Dv CDIOCSETDEBUG , CDIOCCLRDEBUG
Turn on (off) debugging for the appropriate device.
.It Dv CDIOCPAUSE , CDIOCRESUME
Pause (resume) audio play, without resetting the location of the read-head.
.It Dv CDIOCRESET
Reset the drive.
.It Dv CDIOCSTART , CDIOCSTOP
Tell the drive to spin-up (-down) the CD-ROM.
.It Dv CDIOCALLOW , CDIOCPREVENT
Tell the drive to allow (prevent) manual ejection of the CD-ROM disc.
Not all drives support this feature.
.It Dv CDIOCEJECT
Eject the CD-ROM.
.\".It Dv CDIOCCLOSE
.\"Tell the drive to close its door and load the media. Not all drives
.\"support this feature.
.\"
.\".It Dv CDIOCPITCH
.\".Pq Li "struct ioc_pitch"
.\"For drives that support it, this command instructs the drive to play
.\"the audio at a faster or slower rate than normal. Values of
.\".Li speed
.\"between -32767 and -1 result in slower playback; a zero value
.\"indicates normal speed; and values from 1 to 32767 give faster
.\"playback. Drives with less than 16 bits of resolution will silently
.\"ignore less-significant bits. The structure is defined thusly:
.\".Bd -literal -offset indent
.\"struct ioc_pitch {
.\" short speed;
.\"};
.\".Ed
.El
.Pp
In addition the general
.Xr scsi 4
ioctls may be used with the
.Nm
driver, if used against the `whole disk' partition (i.e.,
.Pa /dev/rcd0c ) .
.Sh NOTES
When a CD-ROM is changed in a drive controlled by the
.Nm
driver, then the act of changing the media will invalidate the
disklabel and information held within the kernel.
To stop corruption, all accesses to the device will be discarded until
there are no more open file descriptors referencing the device.
During this period, all new open attempts will be rejected.
When no more open file descriptors reference the device, the first next open
will load a new set of parameters (including disklabel) for the drive.
.Pp
The audio code in the
.Nm
driver only supports SCSI-2 standard audio commands.
Because many CD-ROM manufacturers have not followed the standard, there are
many CD-ROM drives for which audio will not work.
Some work is planned to support some of the more common
.Dq broken
CD-ROM drives; however, this is not yet under way.
.Sh FILES
.Bl -tag -width /dev/rcd[0-9][a-p] -compact
.It Pa /dev/cd[0-9][a-p]
block mode CD-ROM devices
.It Pa /dev/rcd[0-9][a-p]
raw mode CD-ROM devices
.El
.Sh DIAGNOSTICS
None.
.Sh SEE ALSO
.Xr cdio 1 ,
.Xr eject 1 ,
.Xr ioctl 2 ,
.Xr intro 4 ,
.Xr scsi 4 ,
.Xr scsibus 4 ,
.Xr sd 4 ,
.Xr wd 4 ,
.Xr disklabel 5 ,
.Xr disklabel 8
.Sh HISTORY
The
.Nm
driver appeared in 386BSD 0.1.
.Sh BUGS
The names of the structures used for the third argument to
.Fn ioctl
were poorly chosen, and a number of spelling errors have survived in
the names of the
.Fn ioctl
commands.
|