home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / linux-2.0.34 / cdrom / ide-cd < prev    next >
Encoding:
Text File  |  1997-06-03  |  16.7 KB  |  439 lines

  1. IDE-CD driver documentation
  2. 19 May 1996
  3. scott snyder  <snyder@fnald0.fnal.gov>
  4.  
  5. 1. Introduction
  6. ---------------
  7.  
  8. The ide-cd driver should work with all ATAPI 1.2 compliant cdrom
  9. drives which attach to an IDE interface.  Note that some cdrom vendors
  10. (including Mitsumi, Sony, Creative, Aztech, and Goldstar) have made
  11. both ATAPI-compliant drives and drives which use a proprietary
  12. interface.  If your drive uses one of those proprietary interfaces,
  13. this driver will not work with it (but one of the other cdrom drivers
  14. probably will).  This driver will not work with `ATAPI' drives which
  15. attach to the parallel port.  In addition, there is at least one drive
  16. (CyCDROM CR520ie) which attaches to the IDE port but is not ATAPI;
  17. this driver will not work with drives like that either (but see the
  18. aztcd driver).
  19.  
  20. This driver provides the following features:
  21.  
  22.  - Reading from data tracks, and mounting iso9660 filesystems.
  23.  
  24.  - Playing audio tracks.  Most of the cdrom player programs floating
  25.    around should work; i usually use Workman.
  26.  
  27.  - Multisession support.
  28.  
  29.  - On drives which support it, reading digital audio data directly
  30.    from audio tracks.  The program cdda2wav can be used for this.
  31.    Note, however, that only a few drives actually support this
  32.    function; the only ones which i've heard of successes with are Sony
  33.    and Toshiba drives.
  34.  
  35.  - There is now rudimentary support for cdrom changers which comply
  36.    with the ATAPI 2.6 draft standard (such as the NEC CDR-251).  This
  37.    merely adds a function to switch between the slots of the changer
  38.    under control of an external program.  A sample such program is
  39.    appended to the end of this file.  The Sanyo 3-disc changer
  40.    (which does not conform to the standard) is also now supported.
  41.    Please note the driver refers to the first CD as slot # 0.
  42.  
  43.  
  44. 2. Installation
  45. ---------------
  46.  
  47. 0. The ide-cd relies on the ide disk driver.  See
  48.    Documentation/ide.txt for up-to-date information on the ide
  49.    driver.
  50.  
  51. 1. Make sure that the ide and ide-cd drivers are compiled into the
  52.    kernel you're using.  When configuring the kernel, say `yes' to the
  53.    options 
  54.  
  55.       Enhanced IDE/MFM/RLL disk/cdrom/tape support
  56.       Include IDE/ATAPI CDROM support
  57.  
  58.    and `no' to
  59.  
  60.       Use old disk-only driver on primary interface
  61.  
  62.    Depending on what type of IDE interface you have, you may need to
  63.    specify additional configuration options.  See
  64.    Documentation/ide.txt.
  65.  
  66. 2. You should also ensure that the iso9660 filesystem is either
  67.    compiled into the kernel or available as a loadable module.  You
  68.    can see if a filesystem is known to the kernel by cat'ing the file
  69.    /proc/filesystems.
  70.  
  71. 3. The cdrom drive should be connected to the host on an IDE
  72.    interface.  Each interface on a system is defined by an I/O port
  73.    address and an IRQ number, the standard assignments being
  74.    0x170 and 14 for the primary interface and 0x1f0 and 15 for the
  75.    secondary interface.  Each interface can control up to two devices,
  76.    where each device can be either a hard drive, a cdrom drive, or a
  77.    tape drive.  The two devices on an interface are called `master'
  78.    and `slave'; this is usually selectable via a jumper on the drive.
  79.  
  80.    Linux names these devices as follows.  The master and slave devices
  81.    on the primary IDE interface are called `hda' and `hdb',
  82.    respectively.  The drives on the secondary interface are called
  83.    `hdc' and `hdd'.  (Interfaces at other locations get other letters
  84.    in the third position; see Documentation/ide.txt.)
  85.  
  86.    If you want your cdrom drive to be found automatically by the
  87.    driver, you should make sure your IDE interface uses either the
  88.    primary or secondary addresses mentioned above.  In addition, if
  89.    the cdrom drive is the only device on the IDE interface, it should
  90.    be jumpered as `master'.  (If for some reason you cannot configure
  91.    your system in this manner, you can probably still use the driver.
  92.    You may have to pass extra configuration information to the kernel
  93.    when you boot, however.  See Documentation/ide.txt for more
  94.    information.)
  95.  
  96. 4. Boot the system.  If the drive is recognized, you should see a
  97.    message which looks like
  98.  
  99.      hdb: NEC CD-ROM DRIVE:260, ATAPI CDROM drive
  100.  
  101.    If you do not see this, see section 5 below.
  102.  
  103. 5. You may want to create a symbolic link /dev/cdrom pointing to the
  104.    actual device.  You can do this with the command
  105.  
  106.      ln -s  /dev/hdX  /dev/cdrom
  107.  
  108.    where X should be replaced by the letter indicating where your
  109.    drive is installed.
  110.  
  111. 6. You should be able to see any error messages from the driver with
  112.    the `dmesg' command.
  113.  
  114.  
  115. 3. Basic usage
  116. --------------
  117.  
  118. An iso9660 format cdrom can be mounted by putting the disc in the
  119. drive and typing (as root)
  120.  
  121.   mount -t iso9660 /dev/cdrom /mnt/cdrom
  122.  
  123. where it is assumed that /dev/cdrom is a link pointing to the actual
  124. device (as described in step 5 of the last section) and /mnt/cdrom is
  125. an empty directory.  You should now be able to see the contents of the
  126. cdrom under the /mnt/cdrom directory.  If you want to eject the cdrom,
  127. you must first dismount it with a command like
  128.  
  129.   umount /mnt/cdrom
  130.  
  131. Note that audio cds cannot be mounted.
  132.  
  133. Some distributions set up /etc/fstab to always try to mount a cdrom
  134. filesystem on bootup.  It is not required to mount the cdrom in this
  135. manner, though, and it may be a nuisance if you change cdroms often.
  136. You should feel free to remove the cdrom line from /etc/fstab and
  137. mount cdroms manually if that suits you better.
  138.  
  139. Multisession and photocd discs should work with no special handling.
  140. The hpcdtoppm package (ftp.gwdg.de:/pub/linux/hpcdtoppm/) may be
  141. useful for reading photocds.
  142.  
  143. To play an audio cd, you should first unmount and remove any data
  144. cdrom.  Any of the cdrom player programs should then work (workman,
  145. workbone, cdplayer, etc.).  Lacking anything else, you could use the
  146. cdtester program in Documentation/cdrom/sbpcd.
  147.  
  148. On a few drives, you can read digital audio directly using a program
  149. such as cdda2wav.  The only types of drive which i've heard support
  150. this are Sony and Toshiba drives.  You will get errors if you try to
  151. use this function on a drive which does not support it.
  152.  
  153. For supported changers, you can use the `cdload' program (appended to
  154. the end of this file) to switch between changer slots.  Note that the
  155. drive should be unmounted before attempting this.  The program takes
  156. two arguments: the cdrom device, and the slot number to which to change.
  157. If the slot number is -1, the drive is unloaded.
  158.  
  159.  
  160. 4. Compilation options
  161. ----------------------
  162.  
  163. There are a few additional options which can be set when compiling the
  164. driver.  Most people should not need to mess with any of these; they
  165. are listed here simply for completeness.  A compilation option can be
  166. enabled by adding a line of the form `#define <option> 1' to the top
  167. of ide-cd.c.  All these options are disabled by default.
  168.  
  169. VERBOSE_IDE_CD_ERRORS
  170.   If this is set, ATAPI error codes will be translated into textual
  171.   descriptions.  In addition, a dump is made of the command which
  172.   provoked the error.  This is off by default to save the memory used
  173.   by the (somewhat long) table of error descriptions.  
  174.  
  175. STANDARD_ATAPI
  176.   If this is set, the code needed to deal with certain drives which do
  177.   not properly implement the ATAPI spec will be disabled.  If you know
  178.   your drive implements ATAPI properly, you can turn this on to get a
  179.   slightly smaller kernel.
  180.  
  181. NO_DOOR_LOCKING
  182.   If this is set, the driver will never attempt to lock the door of
  183.   the drive.
  184.  
  185. CDROM_NBLOCKS_BUFFER
  186.   This sets the size of the buffer to be used for a CDROMREADAUDIO
  187.   ioctl.  The default is 8.
  188.  
  189. TEST
  190.   This presently enables an additional ioctl which enables a user-mode
  191.   program to execute an arbitrary packet command.  See the source for
  192.   details.  This should be left off unless you know what you're doing.
  193.  
  194.  
  195. 5. Common problems
  196. ------------------
  197.  
  198. This section discusses some common problems encountered when trying to
  199. use the driver, and some possible solutions.  Note that if you are
  200. experiencing problems, you should probably also review
  201. Documentation/ide.txt for current information about the underlying
  202. IDE support code.  Some of these items apply only to earlier versions
  203. of the driver, but are mentioned here for completeness.
  204.  
  205. In most cases, you should probably check with `dmesg' for any errors
  206. from the driver.
  207.  
  208. a. Drive is not detected during booting.
  209.  
  210.    - Review the configuration instructions above and in
  211.      Documentation/ide.txt, and check how your hardware is
  212.      configured.
  213.  
  214.    - If your drive is the only device on an IDE interface, it should
  215.      be jumpered as master, if at all possible.
  216.  
  217.    - If your IDE interface is not at the standard addresses of 0x170
  218.      or 0x1f0, you'll need to explicitly inform the driver using a
  219.      lilo option.  See Documentation/ide.txt.  (This feature was
  220.      added around kernel version 1.3.30.)
  221.  
  222.    - If the autoprobing is not finding your drive, you can tell the
  223.      driver to assume that one exists by using a lilo option of the
  224.      form `hdX=cdrom', where X is the drive letter corresponding to
  225.      where your drive is installed (see section 2).  Note that if you
  226.      do this and you see a boot message like
  227.  
  228.        hdX: ATAPI cdrom (?)
  229.  
  230.      this does _not_ mean that the driver has successfully detected
  231.      the drive; rather, it means that the driver has not detected a
  232.      drive, but is assuming there's one there anyway because you told
  233.      it so.  If you actually try to do I/O to a drive defined at a
  234.      nonexistent or nonresponding I/O address, you'll probably get
  235.      errors with a status value of 0xff.
  236.  
  237.    - Some IDE adapters require a nonstandard initialization sequence
  238.      before they'll function properly.  (If this is the case, there
  239.      will often be a separate MS-DOS driver just for the controller.)
  240.      IDE interfaces on sound cards often fall into this category.
  241.  
  242.      Support for some interfaces needing extra initialization is
  243.      provided in later 1.3.x kernels.  You may need to turn on
  244.      additional kernel configuration options to get them to work;
  245.      see Documentation/ide.txt.
  246.  
  247.      Even if support is not available for your interface, you may be
  248.      able to get it to work with the following procedure.  First boot
  249.      MS-DOS and load the appropriate drivers.  Then warm-boot linux
  250.      (i.e., without powering off).  If this works, it can be automated
  251.      by running loadlin from the MS-DOS autoexec.
  252.  
  253.  
  254. b. Timeout/IRQ errors.
  255.  
  256.   - If you always get timeout errors, interrupts from the drive are
  257.     probably not making it to the host.
  258.  
  259.   - IRQ problems may also be indicated by the message
  260.     `IRQ probe failed (<n>)' while booting.  If <n> is zero, that
  261.     means that the system did not see an interrupt from the drive when
  262.     it was expecting one (on any feasible IRQ).  If <n> is negative,
  263.     that means the system saw interrupts on multiple IRQ lines, when
  264.     it was expecting to receive just one from the cdrom drive.
  265.  
  266.   - Double-check your hardware configuration to make sure that the IRQ
  267.     number of your IDE interface matches what the driver expects.
  268.     (The usual assignments are 14 for the primary (0x170) interface
  269.     and 15 for the secondary (0x1f0) interface.)  Also be sure that
  270.     you don't have some other hardware which might be conflicting with
  271.     the IRQ you're using.  Also check the BIOS setup for your system;
  272.     some have the ability to disable individual IRQ levels, and i've
  273.     had one report of a system which was shipped with IRQ 15 disabled
  274.     by default.
  275.  
  276.   - Note that many MS-DOS cdrom drivers will still function even if
  277.     there are hardware problems with the interrupt setup; they
  278.     apparently don't use interrupts.
  279.  
  280.   - If you own a Pioneer DR-A24X, you _will_ get nasty error messages 
  281.     on boot such as "irq timeout: status=0x50 { DriveReady SeekComplete }"
  282.     The Pioneer DR-A24X cdrom drives are fairly popular these days.
  283.     Unfortunatly, these drives seem to become very confused when we perform
  284.     the standard Linux ATA disk drive probe. If you own one of these drives,
  285.     you can bypass the ATA probing which confuses these cdrom drives, by 
  286.     adding `append="hdX=noprobe hdX=cdrom"' to your lilo.conf file and runing 
  287.     lilo (again where X is the drive letter corresponding to where your drive 
  288.     is installed (see section 2))
  289.     
  290. c. System hangups.
  291.  
  292.   - If the system locks up when you try to access the cdrom, the most
  293.     likely cause is that you have a buggy IDE adapter which doesn't
  294.     properly handle simultaneous transactions on multiple interfaces.
  295.     The most notorious of these is the CMD640B chip.  This problem can
  296.     be worked around by specifying the `serialize' option when
  297.     booting.  Recent kernels should be able to detect the need for
  298.     this automatically in most cases, but the detection is not
  299.     foolproof.  See Documentation/ide.txt for more information
  300.     about the `serialize' option and the CMD640B.
  301.  
  302.   - Note that many MS-DOS cdrom drivers will work with such buggy
  303.     hardware, apparently because they never attempt to overlap cdrom
  304.     operations with other disk activity.
  305.  
  306.  
  307. d. Can't mount a cdrom.
  308.  
  309.   - If you get errors from mount, it may help to check `dmesg' to see
  310.     if there are any more specific errors from the driver or from the
  311.     filesystem.
  312.  
  313.   - Make sure there's a cdrom loaded in the drive, and that's it's an
  314.     iso9660 format disc.  You can't mount an audio cd.
  315.  
  316.   - With the cdrom in the drive and unmounted, try something like
  317.  
  318.       cat /dev/cdrom | od | more
  319.  
  320.     If you see a dump, then the drive and driver are probably working
  321.     ok, and the problem is at the filesystem level (i.e., the cdrom is
  322.     not iso9660 format or has errors in the filesystem structure).
  323.  
  324.   - If you see `not a block device' errors, check that the definitions
  325.     of the device special files are correct.  They should be as
  326.     follows:
  327.  
  328.       brw-rw----   1 root     disk       3,   0 Nov 11 18:48 /dev/hda
  329.       brw-rw----   1 root     disk       3,  64 Nov 11 18:48 /dev/hdb
  330.       brw-rw----   1 root     disk      22,   0 Nov 11 18:48 /dev/hdc
  331.       brw-rw----   1 root     disk      22,  64 Nov 11 18:48 /dev/hdd
  332.  
  333.     Some early Slackware releases had these defined incorrectly.  If
  334.     these are wrong, you can remake them by running the script
  335.     scripts/MAKEDEV.ide.  (You may have to make it executable
  336.     with chmod first.)
  337.  
  338.     If you have a /dev/cdrom symbolic link, check that it is pointing
  339.     to the correct device file.
  340.  
  341.     If you hear people talking of the devices `hd1a' and `hd1b', these
  342.     were old names for what are now called hdc and hdd.  Those names
  343.     should be considered obsolete.
  344.  
  345.   - If mount is complaining that the iso9660 filesystem is not
  346.     available, but you know it is (check /proc/filesystems), you
  347.     probably need a newer version of mount.  Early versions would not
  348.     always give meaningful error messages.
  349.  
  350.  
  351. e. Directory listings are unpredictably truncated, and `dmesg' shows
  352.    `buffer botch' error messages from the driver.
  353.  
  354.   - There was a bug in the version of the driver in 1.2.x kernels
  355.     which could cause this.  It was fixed in 1.3.0.  If you can't
  356.     upgrade, you can probably work around the problem by specifying a
  357.     blocksize of 2048 when mounting.  (Note that you won't be able to
  358.     directly execute binaries off the cdrom in that case.)
  359.  
  360.     If you see this in kernels later than 1.3.0, please report it as a
  361.     bug.
  362.  
  363.  
  364. f. Data corruption.
  365.  
  366.   - Random data corruption was occasionally observed with the Hitachi
  367.     CDR-7730 cdrom. If you experience data corruption, using "hdx=slow"
  368.     as a command line parameter may work around the problem, at the
  369.     expense of low system performance.
  370.  
  371.  
  372. 6. cdload.c
  373. -----------
  374.  
  375. /*
  376.  * cdload.c  <device>  <slot>
  377.  *
  378.  * Load a cdrom from a specified slot in a changer.  The drive should be
  379.  * unmounted before executing this.
  380.  *
  381.  * Based on code originally from Gerhard Zuber <zuber@berlin.snafu.de>.
  382.  */
  383.  
  384. #include <stdlib.h>
  385. #include <errno.h>
  386. #include <string.h>
  387. #include <unistd.h>
  388. #include <stdio.h>
  389. #include <linux/cdrom.h>
  390. #include <linux/ucdrom.h>
  391.  
  392.  
  393. int
  394. main (int argc, char **argv)
  395. {
  396.     char *program;
  397.     char *device;
  398.     int x_slot;
  399.     int fd;           /* file descriptor for CD-ROM device */
  400.     int status;       /* return status for system calls */
  401.  
  402.     program = argv[0];
  403.  
  404.     if (argc != 3) {
  405.         fprintf (stderr, "usage: %s <device> <slot>\n", program);
  406.         exit (1);
  407.     }
  408.  
  409.     device = argv[1];
  410.     x_slot = atoi (argv[2]);
  411.  
  412.     /* open device */ 
  413.     fd = open (device, 0);
  414.     if (fd < 0) {
  415.         fprintf (stderr, "%s: open failed for `%s': %s\n",
  416.              program, device, strerror (errno));
  417.         exit (1);
  418.     }
  419.  
  420.     /* load */ 
  421.     status = ioctl (fd, CDROM_SELECT_DISC, x_slot);
  422.     if (status != 0) {
  423.         fprintf (stderr,
  424.              "%s: CDROM_SELECT_DISC ioctl failed for `%s': %s\n",
  425.              program, device, strerror (errno));
  426.         exit (1);
  427.     }
  428.  
  429.     /* close device */
  430.     status = close (fd);
  431.     if (status != 0) {
  432.         fprintf (stderr, "%s: close failed for `%s': %s\n",
  433.              program, device, strerror (errno));
  434.         exit (1);
  435.     }
  436.  
  437.     exit (0);
  438. }
  439.