xref: /freebsd/share/man/man4/cd.4 (revision 57718be8)
1.\" Copyright (c) 1996
2.\"	Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\"
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd April 9, 2014
29.Dt CD 4
30.Os
31.Sh NAME
32.Nm cd
33.Nd SCSI CD-ROM driver
34.Sh SYNOPSIS
35.Cd device cd
36.Sh DESCRIPTION
37The
38.Nm
39driver provides support for a
40.Tn SCSI
41.Tn CD-ROM
42(Compact Disc-Read Only Memory) drive.
43In an attempt to look like a regular disk, the
44.Nm
45driver synthesizes a partition table, with one partition covering the entire
46.Tn CD-ROM .
47It is possible to modify this partition table using
48.Xr disklabel 8 ,
49but it will only last until the
50.Tn CD-ROM
51is unmounted.
52In general the interfaces are similar to those described by
53.Xr ada 4
54and
55.Xr da 4 .
56.Pp
57As the
58.Tn SCSI
59adapter is probed during boot, the
60.Tn SCSI
61bus is scanned for devices.
62Any devices found which answer as CDROM
63(type 5) or WORM (type 4) type devices will be `attached' to the
64.Nm
65driver.
66Prior to
67.Fx 2.1 ,
68the first device found will be attached as
69.Li cd0
70the next,
71.Li cd1 ,
72etc.
73Beginning in
74.Fx 2.1
75it is possible to specify what cd unit a device should
76come on line as; refer to
77.Xr scsi 4
78for details on kernel configuration.
79.Pp
80The system utility
81.Xr disklabel 8
82may be used to read the synthesized
83disk label
84structure, which will contain correct figures for the size of the
85.Tn CD-ROM
86should that information be required.
87.Sh KERNEL CONFIGURATION
88Any number of
89.Tn CD-ROM
90devices may be attached to the system regardless of system
91configuration as all resources are dynamically allocated.
92.Sh IOCTLS
93The following
94.Xr ioctl 2
95calls which apply to
96.Tn SCSI
97.Tn CD-ROM
98drives are defined
99in the header files
100.In sys/cdio.h
101and
102.In sys/disklabel.h .
103.Bl -tag -width CDIOCREADSUBCHANNEL
104.It Dv DIOCGDINFO
105.It Dv DIOCSDINFO
106.Pq Li "struct disklabel"
107Read or write the in-core copy of the disklabel for the
108drive.
109The disklabel is initialized with information
110read from the scsi inquiry commands, and should be the same as
111the information printed at boot.
112This structure is defined in the header file
113.In sys/disklabel.h .
114.It Dv CDIOCPLAYTRACKS
115.Pq Li "struct ioc_play_track"
116Start audio playback given a track address and length.
117The structure is defined as follows:
118.Bd -literal -offset indent
119struct ioc_play_track
120{
121	u_char	start_track;
122	u_char	start_index;
123	u_char	end_track;
124	u_char	end_index;
125};
126.Ed
127.It Dv CDIOCPLAYBLOCKS
128.Pq Li "struct ioc_play_blocks"
129Start audio playback given a block address and length.
130The structure is defined as follows:
131.Bd -literal -offset indent
132struct ioc_play_blocks
133{
134	int	blk;
135	int	len;
136};
137.Ed
138.It Dv CDIOCPLAYMSF
139.Pq Li "struct ioc_play_msf"
140Start audio playback given a `minutes-seconds-frames' address and
141length.
142The structure is defined as follows:
143.Bd -literal -offset indent
144struct ioc_play_msf
145{
146	u_char	start_m;
147	u_char	start_s;
148	u_char	start_f;
149	u_char	end_m;
150	u_char	end_s;
151	u_char	end_f;
152};
153.Ed
154.It Dv CDIOCREADSUBCHANNEL
155.Pq Li "struct ioc_read_subchannel"
156Read information from the subchannel at the location specified by this
157structure:
158.Bd -literal -offset indent
159struct ioc_read_subchannel {
160	u_char address_format;
161#define CD_LBA_FORMAT	1
162#define CD_MSF_FORMAT	2
163	u_char data_format;
164#define CD_SUBQ_DATA		0
165#define CD_CURRENT_POSITION	1
166#define CD_MEDIA_CATALOG	2
167#define CD_TRACK_INFO		3
168	u_char track;
169	int	data_len;
170	struct  cd_sub_channel_info *data;
171};
172.Ed
173.It Dv CDIOREADTOCHEADER
174.Pq Li "struct ioc_toc_header"
175Return summary information about the table of contents for the mounted
176.Tn CD-ROM .
177The information is returned into the following structure:
178.Bd -literal -offset indent
179struct ioc_toc_header {
180	u_short len;
181	u_char  starting_track;
182	u_char  ending_track;
183};
184.Ed
185.It Dv CDIOREADTOCENTRYS
186.Pq Li "struct ioc_read_toc_entry"
187Return information from the table of contents entries mentioned.
188.Pq Yes, this command name is misspelled.
189The argument structure is defined as follows:
190.Bd -literal -offset indent
191struct ioc_read_toc_entry {
192	u_char	address_format;
193	u_char	starting_track;
194	u_short	data_len;
195	struct  cd_toc_entry *data;
196};
197.Ed
198The requested data is written into an area of size
199.Li data_len
200and pointed to by
201.Li data .
202.It Dv CDIOCSETPATCH
203.Pq Li "struct ioc_patch"
204Attach various audio channels to various output channels.
205The argument structure is defined thusly:
206.Bd -literal -offset indent
207struct ioc_patch {
208	u_char	patch[4];
209	/* one for each channel */
210};
211.Ed
212.It Dv CDIOCGETVOL
213.It Dv CDIOCSETVOL
214.Pq Li "struct ioc_vol"
215Get (set) information about the volume settings of the output channels.
216The argument structure is as follows:
217.Bd -literal -offset indent
218struct	ioc_vol
219{
220	u_char	vol[4];
221	/* one for each channel */
222};
223.Ed
224.It Dv CDIOCSETMONO
225Patch all output channels to all source channels.
226.It Dv CDIOCSETSTEREO
227Patch left source channel to the left output channel and the right
228source channel to the right output channel.
229.It Dv CDIOCSETMUTE
230Mute output without changing the volume settings.
231.It Dv CDIOCSETLEFT
232.It Dv CDIOCSETRIGHT
233Attach both output channels to the left (right) source channel.
234.It Dv CDIOCSETDEBUG
235.It Dv CDIOCCLRDEBUG
236Turn on (off) debugging for the appropriate device.
237.It Dv CDIOCPAUSE
238.It Dv CDIOCRESUME
239Pause (resume) audio play, without resetting the location of the read-head.
240.It Dv CDIOCRESET
241Reset the drive.
242.It Dv CDIOCSTART
243.It Dv CDIOCSTOP
244Tell the drive to spin-up (-down) the
245.Tn CD-ROM .
246.It Dv CDIOCALLOW
247.It Dv CDIOCPREVENT
248Tell the drive to allow (prevent) manual ejection of the
249.Tn CD-ROM
250disc.
251Not all drives support this feature.
252.It Dv CDIOCEJECT
253Eject the
254.Tn CD-ROM .
255.It Dv CDIOCCLOSE
256Tell the drive to close its door and load the media.
257Not all drives support this feature.
258.El
259.Sh NOTES
260When a
261.Tn CD-ROM
262is changed in a drive controlled by the
263.Nm
264driver, then the act of changing the media will invalidate the
265disklabel and information held within the kernel.
266To stop corruption,
267all accesses to the device will be discarded until there are no more
268open file descriptors referencing the device.
269During this period, all
270new open attempts will be rejected.
271When no more open file descriptors
272reference the device, the first next open will load a new set of
273parameters (including disklabel) for the drive.
274.Pp
275The audio code in the
276.Nm
277driver only support
278.Tn SCSI-2
279standard audio commands.
280As many
281.Tn CD-ROM
282manufacturers have not followed the standard, there are many
283.Tn CD-ROM
284drives for which audio will not work.
285Some work is planned to support
286some of the more common `broken'
287.Tn CD-ROM
288drives; however, this is not yet under way.
289.Sh SYSCTL VARIABLES
290The following variables are available as both
291.Xr sysctl 8
292variables and
293.Xr loader 8
294tunables:
295.Bl -tag -width 12
296.It kern.cam.cd.retry_count
297.Pp
298This variable determines how many times the
299.Nm
300driver will retry a READ or WRITE command.
301This does not affect the number of retries used during probe time or for
302the
303.Nm
304driver dump routine.
305This value currently defaults to 4.
306.It kern.cam.cd.%d.minimum_cmd_size
307.Pp
308The
309.Nm
310driver attempts to automatically determine whether the drive it is talking
311to supports 6 byte or 10 byte MODE SENSE/MODE SELECT operations.
312Many
313.Tn SCSI
314drives only support 6 byte commands, and
315.Tn ATAPI
316drives only support 10 byte commands.
317The
318.Nm
319driver first attempts to determine whether the protocol in use typically
320supports 6 byte commands by issuing a CAM Path Inquiry CCB.
321It will then default to 6 byte or 10 byte commands as appropriate.
322After that, the
323.Nm
324driver defaults to using 6 byte commands (assuming the protocol the drive
325speaks claims to support 6 byte commands), until one fails with a
326.Tn SCSI
327ILLEGAL REQUEST error.
328Then it tries the 10 byte version of the command to
329see if that works instead.
330Users can change the default via per-drive
331sysctl variables and loader tunables.
332Where
333.Dq %d
334is the unit number of the drive in question.
335Valid minimum command sizes
336are 6 and 10.
337Any value above 6 will be rounded to 10, and any value below
3386 will be rounded to 6.
339.El
340.Sh FILES
341.Bl -tag -width /dev/cd[0-9][a-h] -compact
342.It Pa /dev/cd[0-9][a-h]
343raw mode
344.Tn CD-ROM
345devices
346.El
347.Sh DIAGNOSTICS
348None.
349.Sh SEE ALSO
350.Xr cam 4 ,
351.Xr da 4 ,
352.Xr disklabel 8 ,
353.Xr cd 9
354.Sh HISTORY
355This
356.Nm
357driver is based upon the
358.Nm
359driver written by Julian Elischer, which appeared in
360.Bx 386 0.1 .
361The
362CAM version of the
363.Nm
364driver was written by Kenneth Merry and first appeared in
365.Fx 3.0 .
366.Sh BUGS
367The names of the structures used for the third argument to
368.Fn ioctl
369were poorly chosen, and a number of spelling errors have survived in
370the names of the
371.Fn ioctl
372commands.
373