CD(4)

NAME
cd - scsi cdrom driver

SYNOPSIS
device cd
device cd1 target 4 lun 0

DESCRIPTION
The cd driver provides support for a scsi cdrom. It allows the cdrom to be divided up into a set of pseudo devices called partitions. In an attempt to look like regular disks the cd driver synthesises a partition table, with one partition covering the entire cdrom. A user might (for some amazing reason) add another partition to the cdrom by using disklabel, but it will last only until the cdrom is unmounted. A Partition can have both a raw interface and a Block mode interface. In general the interfaces are similar to those described by wd(4) or sd(4).

Where the wd(4) device has a fairly low level interface to the system, SCSI devices have a much higher level interface and talk to the system via a SCSI Adapter and a Scsi Adapter driver e.g. AHA1542. A scsi adapter must also be separatly configured into the system before a scsi cdrom can be configured.

As the scsi adapter is probed during boot, the SCSI bus is scanned for devices. Any devices found which answer as 'Readonly' type devices will be 'attached' to the cd driver. In FreeBSD releases prior to 2.1, the first found will be attached as cd0 and the next, cd1 etc. Beginning in 2.1 it is possible to specify what cd unit a device should come on line as; refer to scsi(4) for details on kernel configuration.

The system utility disklabel(1) may be used to read the synthesized disklabel(5) structure, which will contain correct figures for the size of the cdrom should that information be required.

KERNEL CONFIGURATION
Any number of cdroms may be attached to the system regardless of system configuration as all resources are dynamically allocated.

IOCTLS
The following ioctl(2) calls apply to scsi cdroms in the header files sys/cdio.h. and sys/disklabel.h

DIOCGDINFO
    Read, from the kernel, the in-core copy of the disklabel for the drive. This will be a ficticious disklabel it will contain information read from the scsi inquiry commands, and should be the same as the information printed at boot.

DIOCSDINFO
    Give the driver a new disklabel to use. The driver will NOT try write the new disklabel to the disk. (ok?)

CDIOCPLAYTRACKS
    Start Audio playback given a track address and length.

CDIOCPLAYBLOCKS
    Start Audio playback given a block address and length.

CDIOCPLAYMSF
    Start Audio playback given a 'Minutes/ seconds/ frames' address and length.

CDIOCREADSUBCHANNEL
    Read information from the subchannel at the location specified.

CDIOREADTOCHEADER
    Return summary information about the table of contents for the mounted cdrom.

CDIOREADTOCENTRYS
    Return information from the table of contents entries mentionned.

CDIOCSETPATCH
    Attach various audio channels to various output channels.

CDIOCGETVOL
    Get information about the volume settings of the output channels.

CDIOCSETVOL
    Change the volume settings of the output channels.

CDIOCSETMONO
    Patch all out[put channels to all source channels.

CDIOCSETSTERIO
    Patch left source channel to the left output channel and the right source channel to the right output channel.

CDIOCSETMUTE
    Mute output without changing the volume settings.

CDIOCSETLEFT
    Attach both output channels to the left source channel.

CDIOCSETRIGHT
    Attach both output channels to the right source channel.

CDIOCSETDEBUG
    Turn on debugging for the appropriate device.

CDIOCCLRDEBUG
    Turn off debugging for the appropriate device.

CDIOCPAUSE
    Pause audio play, do not reset the location of the read-head.

CDIOCRESUME
    Resume audio play, Start at the location of the pause.

CDIOCRESET
    Reset the drive.

CDIOCSTART
    Tell the drive to spin-up the cdrom.

CDIOCSTOP
    Tell the drive to spin-down the cdrom.

CDIOCEJECT
    Eject the cdrom.

In addition the general scsi(4) ioctls may be used with the cd driver, if used against the fourth (raw/whole disk) partiton. (e.g. rcd0d)

NOTES
When a cdrom is changed in a drive controlled by the cd 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 figures (including disklabel) for the drive. The Audio code in the cd driver only support SCSI2 standard audio commands. As there are many cdrom manufacturers who have not followed the standard well, there are many cdroms for which audio will not work. Some work is planned to support some of the more common 'broken' cdrom drives however this is not yet under way.

FILES
/dev/cd[0-9][a-h]
    block mode scsi disks
/dev/rcd[0-9][a-h]
    raw scsi disks

DIAGNOSTICS
None.

SEE ALSO
disklabel(1) disklabel(5) wd(4) sd(4)

HISTORY
This cd driver appeared in 386BSD 0.1.