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