cd.4 revision 6813
1.Dd August 27, 1993
2.Dt CD 4
3.Os FreeBSD
4.Sh NAME
5.Nm cd
6.Nd scsi cdrom driver
7.Sh SYNOPSIS
8.Nm device cd
9.Nm device cd1 target 4 lun 0
10.Sh DESCRIPTION
11The
12.Xr cd
13driver provides support for a 
14.Em scsi
15cdrom. It allows the cdrom
16to be divided up into a set of pseudo devices called
17.Em partitions.
18In an attempt to look like regular disks the 
19.Nm
20driver synthesises a partition table, with one partition covering the entire
21cdrom. A user might (for some amazing reason) add another partition to the
22cdrom by using disklabel, but it will last only until the cdrom is unmounted.
23A Partition can have both a 
24.Em raw
25interface
26and a
27.Em Block mode
28interface.
29In general the interfaces are similar to those described by 
30.Xr wd 4 
31or 
32.Xr sd 4 .
33
34.Pp
35Where the 
36.Xr wd 4
37device has a fairly low level interface to the system, 
38.Em SCSI
39devices have a much higher level interface and talk to the system via
40a 
41.Em SCSI Adapter
42and a
43.Em Scsi Adapter driver
44e.g. 
45.Xr AHA1542 .
46A scsi adapter must also be separatly configured into the system
47before a scsi cdrom can be configured.
48.Pp
49As the scsi adapter is probed during boot, the 
50.Em SCSI
51bus is scanned for devices. Any devices found which answer as 'Readonly'
52type devices will be 'attached' to the 
53.Nm
54driver.
55In FreeBSD releases prior to 2.1, the first found will be attached as
56.Em cd0
57and the next, 
58.Em cd1
59etc.
60Beginning in 2.1 it is possible to specify what cd unit a device should
61come on line as; refer to
62.Xr scsi 4
63for details on kernel configuration.
64.Pp
65The system utility
66.Xr disklabel 1
67may be used to read the synthesized
68.Xr disklabel 5
69structure, which will contain correct figures for the size of the cdrom
70should that information be required.
71.Pp
72.Sh KERNEL CONFIGURATION
73Any number of cdroms may be attached to the system regardless of system
74configuration as all resources are dynamically allocated.
75
76.Pp
77.Sh IOCTLS
78The following 
79.Xr ioctl 2
80calls apply to scsi cdroms
81in the header files
82.Em sys/cdio.h.
83and
84.Em sys/disklabel.h
85
86.Bl -tag -width CDIOCPLAYAUDIO____
87
88.It Dv DIOCGDINFO
89Read, from the kernel, the in-core copy of the disklabel for the
90drive. This will be a ficticious disklabel it will contain information
91read from the scsi inquiry commands, and should be the same as
92the information printed at boot.
93.It Dv DIOCSDINFO
94Give the driver a new disklabel to use. The driver will NOT try write the new
95disklabel to the disk. (ok?)
96.It CDIOCPLAYTRACKS	
97Start Audio playback given a track address and length.
98.It CDIOCPLAYBLOCKS	
99Start Audio playback given a block address and length.
100.It CDIOCPLAYMSF	
101Start Audio playback given a 'Minutes/ seconds/ frames' address and length.
102.It CDIOCREADSUBCHANNEL 
103Read information from the subchannel at the location specified.
104.It CDIOREADTOCHEADER 
105Return summary information about the table of contents for the mounted cdrom.
106.It CDIOREADTOCENTRYS 
107Return information from the table of contents entries mentionned.
108.It CDIOCSETPATCH	
109Attach various audio channels to various output channels.
110.It CDIOCGETVOL	
111Get information about the volume settings of the output channels.
112.It CDIOCSETVOL	
113Change the volume settings of the output channels.
114.It CDIOCSETMONO	
115Patch all out[put channels to all source channels.
116.It CDIOCSETSTERIO	
117Patch left source channel to the left output channel and the right
118source channel to the right output channel.
119.It CDIOCSETMUTE	
120Mute output without changing the volume settings.
121.It CDIOCSETLEFT	
122Attach both output channels to the left source channel.
123.It CDIOCSETRIGHT	
124Attach both output channels to the right source channel.
125.It CDIOCSETDEBUG	
126Turn on debugging for the appropriate device.
127.It CDIOCCLRDEBUG	
128Turn off debugging for the appropriate device.
129.It CDIOCPAUSE	
130Pause audio play, do not reset the location of the read-head.
131.It CDIOCRESUME	
132Resume audio play, Start at the location of the pause.
133.It CDIOCRESET	
134Reset the drive.
135.It CDIOCSTART	
136Tell the drive to spin-up the cdrom.
137.It CDIOCSTOP	
138Tell the drive to spin-down the cdrom.
139.It CDIOCEJECT	
140Eject the cdrom.
141.El
142.Pp
143In addition the general 
144.Xr scsi 4
145ioctls may be used with the 
146.Nm
147driver, if used against the fourth (raw/whole disk) partiton. (e.g. rcd0d)
148.Sh NOTES
149When a cdrom is changed in a drive controlled by the
150.Nm
151driver, then the act of changing the media will invalidate the 
152disklabel and information held within the kernel. To stop corruption,
153All accesses to the device will be discarded until there are no more
154open file descriptors referencing the device. During this period, all 
155new open attempts will be rejected. When No more open file descriptors
156reference the device, the first next open will load a new set of
157figures (including disklabel) for the drive.
158
159The Audio code in the
160.Nm
161driver only support SCSI2 standard audio commands. As there are many cdrom
162manufacturers who have not followed the standard well, there are many
163cdroms for which audio will not work. Some work is planned to support
164some of the more common 'broken' cdrom drives however this is not yet
165under way.
166
167.Sh FILES
168.Bl -tag -width /dev/rcd[0-9][a-h] -compact
169.It Pa /dev/cd[0-9][a-h]
170block mode scsi disks
171.It Pa /dev/rcd[0-9][a-h]
172raw scsi disks
173.El
174.Sh DIAGNOSTICS
175None.
176.Sh SEE ALSO
177.Xr disklabel 1
178.Xr disklabel 5
179.Xr wd 4
180.Xr sd 4
181.Sh HISTORY
182This
183.Nm
184driver appeared in 386BSD 0.1.
185