home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / SCSIPROG < prev    next >
Encoding:
Text File  |  1995-04-20  |  86.0 KB  |  2,299 lines

  1.   GENERIC SCSI INTERFACE PROGRAMMING HOWTO
  2.   Heiko    Eissfeldt heiko@colossus.escape.de
  3.  
  4.  
  5.   This document    deals with programming the Linux generic SCSI interface.
  6.  
  7.   1.  Introduction
  8.  
  9.   This document    is a guide to the installation and programming of the
  10.   Linux    generic    SCSI interface.
  11.  
  12.   It covers kernel prerequisites, device mappings, and basic interaction
  13.   with devices.    Some simple C programming examples are included.
  14.   General knowledge of the SCSI    command    set is required; for more
  15.   information on the SCSI standard and related information, see    the
  16.   appendix to this document.
  17.  
  18.  
  19.   2.  What Is The Generic SCSI Interface?
  20.  
  21.   The generic SCSI interface has been implemented to provide general
  22.   SCSI access to (possibly exotic) pieces of SCSI hardware. It was
  23.   developed by Lawrence    Foard (    entropy@world.std.com) and sponsored by
  24.   Killy    Corporation (see the comments in drivers/scsi/sg.h).
  25.  
  26.   The interface    makes special device handling possible from user level
  27.   applications (i.e. outside the kernel). Thus,    kernel driver
  28.   development, which is    more risky and difficult to debug, is not
  29.   necessary.
  30.  
  31.   However, if you don't    program    the driver properly it is possible to
  32.   hang the SCSI    bus, the driver, or the    kernel.    Therefore, it is
  33.   important to properly    program    the generic driver and to first    back up
  34.   all files to avoid losing data. Another useful thing to do before
  35.   running your programs    is to issue a sync command to ensure that any
  36.   buffers are flushed to disk, minimizing data loss if the system hangs.
  37.  
  38.   Another advantage of the generic driver is that as long as the
  39.   interface itself does    not change, all    applications are independent of
  40.   new kernel development. In comparison, other low-level kernel    drivers
  41.   have to be synchronized with other internal kernel changes.
  42.  
  43.   Typically, the generic driver    is used    to communicate with new    SCSI
  44.   hardware devices that    require    special    user applications to be    written
  45.   to take advantage of their features (e.g. scanners, printers,    CD-ROM
  46.   jukeboxes). The generic interface allows these to be written quickly.
  47.  
  48.  
  49.   3.  What Are The Requirements    To Use It?
  50.  
  51.  
  52.   3.1.    Kernel Configuration
  53.  
  54.   You must have    a supported SCSI controller, obviously.    Furthermore,
  55.   your kernel must have    controller support as well as generic support
  56.   compiled in. Configuring the Linux kernel (via make config under
  57.   /usr/src/linux) typically looks like the following:
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   *
  68.   * SCSI support
  69.   *
  70.   SCSI support?    (CONFIG_SCSI) [n] y
  71.   *
  72.   * SCSI support type (disk, tape, CDrom)
  73.   *
  74.   Scsi generic support (CONFIG_CHR_DEV_SG) [n] y
  75.   *
  76.   * SCSI low-level drivers
  77.   *
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.   3.2.    Device Files
  85.  
  86.   The generic SCSI driver uses its own device files, separate from those
  87.   used by the other SCSI device    drivers. They can be be    generated using
  88.   the MAKEDEV script, typically    found in the /dev directory. Running
  89.   MAKEDEV sg produces these files:
  90.  
  91.  
  92.  
  93.        crw-------   1 root     system     21,   0 Aug 20    20:09 /dev/sga
  94.        crw-------   1 root     system     21,   1 Aug 20    20:09 /dev/sgb
  95.        crw-------   1 root     system     21,   2 Aug 20    20:09 /dev/sgc
  96.        crw-------   1 root     system     21,   3 Aug 20    20:09 /dev/sgd
  97.        crw-------   1 root     system     21,   4 Aug 20    20:09 /dev/sge
  98.        crw-------   1 root     system     21,   5 Aug 20    20:09 /dev/sgf
  99.        crw-------   1 root     system     21,   6 Aug 20    20:09 /dev/sgg
  100.        crw-------   1 root     system     21,   7 Aug 20    20:09 /dev/sgh
  101.                       |    |
  102.                       major,   minor device numbers
  103.  
  104.  
  105.  
  106.  
  107.   Note that these are character    devices    for raw    access.    On some    systems
  108.   these    devices    may be called /dev/{sg0,sg1,...}, depending on your
  109.   installation,    so adjust the following    examples accordingly.
  110.  
  111.  
  112.   3.3.    Device Mapping
  113.  
  114.   These    device files are dynamically mapped to SCSI id/LUNs on your SCSI
  115.   bus (LUN = logical unit). The    mapping    allocates devices consecutively
  116.   for each LUN of each device on each SCSI bus found at    boot time,
  117.   beginning at the lower LUNs/ids/buses. It starts with    the first SCSI
  118.   controller and continues without interruption    with all following
  119.   controllers.
  120.  
  121.   For example, assuming    you had    three SCSI devices hooked up with ids 1,
  122.   3, and 5 on the first    SCSI bus (each having one LUN),    then the
  123.   following mapping would be in    effect:
  124.  
  125.  
  126.  
  127.        /dev/sga    -> SCSI    id 1
  128.        /dev/sgb    -> SCSI    id 3
  129.        /dev/sgc    -> SCSI    id 5
  130.  
  131.  
  132.  
  133.   If you now add a new device with id 4, then the mapping (after a
  134.   reboot) will be:
  135.  
  136.  
  137.  
  138.        /dev/sga    -> SCSI    id 1
  139.        /dev/sgb    -> SCSI    id 3
  140.        /dev/sgc    -> SCSI    id 4
  141.        /dev/sgd    -> SCSI    id 5
  142.  
  143.  
  144.  
  145.  
  146.   Notice the change for    id 5 --    the corresponding device is no longer
  147.   mapped to /dev/sgc but is now    /dev/sgd.
  148.  
  149.  
  150.   4.  Programmers Guide
  151.  
  152.   The following    sections are for programmers who want to use the generic
  153.   SCSI interface in their own applications. An example will be given
  154.   showing how to access    a SCSI device with the INQUIRY and the
  155.   TESTUNITREADY    commands.
  156.  
  157.  
  158.   When using these code    examples, note the following:
  159.  
  160.   o  the generic SCSI interface    was extended in    kernel version 1.1.68;
  161.      the examples require this version (or later)
  162.  
  163.   o  the constant DEVICE in the    header section describing the accessed
  164.      device should be set according to your available devices (see
  165.      section ``''.
  166.  
  167.  
  168.   5.  Overview Of Device Programming
  169.  
  170.   The header file drivers/scsi/sg.h under the Linux source tree    contains
  171.   a description    of the interface (this is based    on kernel version
  172.   1.1.68):
  173.  
  174.  
  175.  
  176.        struct sg_header
  177.     {
  178.      int pack_len;
  179.               /* length of incoming    packet <4096 (including    header)    */
  180.      int reply_len;      /* maximum length <4096 of expected reply */
  181.      int pack_id;      /* id    number of packet */
  182.      int result;      /* 0==ok, otherwise refer to errno codes */
  183.      unsigned int twelve_byte:1;
  184.               /* Force 12 byte command length for group    6 & 7 commands    */
  185.      unsigned int other_flags:31;               /* for future use */
  186.      unsigned char sense_buffer[16]; /* used only by reads */
  187.      /* command follows then data for command */
  188.     };
  189.  
  190.  
  191.  
  192.  
  193.  
  194.   This structure describes how a SCSI command is to be processed and has
  195.   room to hold the results of the execution of the command.  The
  196.   individual structure components will be discussed later in section
  197.   ``''.
  198.  
  199.   The general way of exchanging    data with the generic driver is    as
  200.   follows: to send a command to    an open    generic    device,    write()    a block
  201.   with this structure to it:
  202.  
  203.  
  204.  
  205.  
  206.  
  207.                     struct sg_header
  208.                       SCSI command
  209.                        input data
  210.  
  211.  
  212.  
  213.  
  214.  
  215.   To obtain the    result of a command, read() a block with this similar
  216.   structure:
  217.  
  218.  
  219.  
  220.                     struct sg_header
  221.                       output data
  222.  
  223.  
  224.  
  225.  
  226.  
  227.   This is a general overview of    the process. The following sections
  228.   describe each    of the steps in    more detail.
  229.  
  230.  
  231.   6.  Opening The Device
  232.  
  233.   A generic device has to be opened for    read and write access:
  234.  
  235.  
  236.  
  237.            int fd =    open (device_name, O_RDWR);
  238.  
  239.  
  240.  
  241.  
  242.   (This    is the case even for a read-only hardware device such as a cdrom
  243.   drive).
  244.  
  245.   We have to perform a write to    send the command and a read to get back
  246.   any results. In the case of an error the return codes    are negative
  247.   (see section ``'' for    a complete list).
  248.  
  249.  
  250.   7.  The Header Structure
  251.  
  252.  
  253.  
  254.   The header structure struct sg_header    serves as a controlling    layer
  255.   between the application and the kernel driver.  We now discuss its
  256.   components in    detail.
  257.  
  258.  
  259.  
  260.      int pack_len
  261.     defines    the size of the    block written to the driver.  This is
  262.     defined    from the application side.
  263.  
  264.  
  265.      int reply_len
  266.     defines    the size of the    block to be accepted at    reply.    This is
  267.     defined    from the application side.
  268.  
  269.  
  270.      int pack_id
  271.     This field helps to assign replies to requests.    The application
  272.     can supply a unique id for each    request. Suppose you have
  273.     written    several    commands (say 4) to one    device.    They may work in
  274.     parallel, one being the    fastest. When getting replies via 4
  275.     reads, the replies do not have to have the order of the
  276.     requests. To identify the correct reply    for a given request one
  277.     can use    the pack_id field. Typically its value is incremented
  278.     after each request (and    wraps eventually).
  279.  
  280.  
  281.      int result
  282.     the result code    of a read or write call.  This is defined from
  283.     the generic driver (kernel) side.  These codes are defined in
  284.     errno.h    (0 meaning no error).
  285.  
  286.  
  287.      unsigned int twelve_byte:1
  288.     This field is necessary    only when using    non-standard vendor
  289.     specific commands (in the range    0xc0 - 0xff). When these
  290.     commands have a    command    length of 12 bytes instead of 10, this
  291.     field has to be    set to one before the write call. Other    command
  292.     lengths    are not    supported.  This is defined from the application
  293.     side.
  294.  
  295.  
  296.      unsigned char sense_buffer16
  297.     This buffer is set after a command is completed    (after a read()
  298.     call) and contains the SCSI sense code.    Some command results
  299.     have to    be read    from here (e.g.    for TESTUNITREADY). Usually it
  300.     contains just zero bytes.  The value in    this field is set by the
  301.     generic    driver (kernel)    side.
  302.  
  303.  
  304.  
  305.   The following    example    function interfaces directly with the generic
  306.   kernel driver. It defines the    header structure, sends    the command via
  307.   write, gets the result via read and does some    (limited) error
  308.   checking.  The sense buffer data is available    in the output buffer
  309.   (unless a NULL pointer has been given, in which case it's in the input
  310.   buffer). We will use it in the examples which    follow.
  311.  
  312.   Note:    Set the    value of DEVICE    to your    device descriptor.
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.   /* Example program to    demonstrate the    generic    SCSI interface */
  332.   #include <stdio.h>
  333.   #include <unistd.h>
  334.   #include <string.h>
  335.   #include <fcntl.h>
  336.   #include <errno.h>
  337.   #include <linux/../../drivers/scsi/sg.h>
  338.  
  339.   #define DEVICE "/dev/sgc"
  340.  
  341.   #define SCSI_OFF sizeof(struct sg_header)
  342.   static unsigned char cmd[SCSI_OFF + 18];    /* SCSI    command    buffer */
  343.   int fd;                /* SCSI    device/file descriptor */
  344.  
  345.   /* process a complete    SCSI cmd. Use the generic SCSI interface. */
  346.   static int handle_SCSI_cmd(unsigned cmd_len,           /* command length */
  347.                  unsigned in_size,           /* input    data size */
  348.                  unsigned char *i_buff,    /* input    buffer */
  349.                  unsigned out_size,           /* output data size */
  350.                  unsigned char *o_buff     /* output buffer    */
  351.                  )
  352.   {
  353.       int status = 0;
  354.       struct sg_header *sg_hd;
  355.  
  356.       /* safety    checks */
  357.       if (!cmd_len) return -1;          /* need a cmd_len != 0 */
  358.       if (!i_buff) return -1;          /* need an input buffer != NULL */
  359.   #ifdef SG_BIG_BUFF
  360.       if (SCSI_OFF + cmd_len + in_size > SG_BIG_BUFF) return -1;
  361.       if (SCSI_OFF + out_size >    SG_BIG_BUFF) return -1;
  362.   #else
  363.       if (SCSI_OFF + cmd_len + in_size > 4096) return -1;
  364.       if (SCSI_OFF + out_size >    4096) return -1;
  365.   #endif
  366.  
  367.       if (!o_buff) out_size = 0;      /* no output buffer, no output size */
  368.  
  369.       /* generic SCSI device header construction */
  370.       sg_hd = (struct sg_header    *) i_buff;
  371.       sg_hd->pack_len     = SCSI_OFF + cmd_len +    in_size;
  372.       sg_hd->reply_len     = SCSI_OFF + out_size;
  373.       sg_hd->twelve_byte = cmd_len == 12;
  374.   #if      0
  375.       sg_hd->pack_id;      /* not used */
  376.       sg_hd->other_flags; /* not used */
  377.   #endif
  378.  
  379.       /* send command */
  380.       status = write( fd, i_buff, SCSI_OFF + cmd_len + in_size );
  381.       if ( status < 0 || status    != SCSI_OFF + cmd_len +    in_size    ||
  382.        sg_hd->result ) {
  383.       /* some error    happened */
  384.       if (status ==    -EPERM)    {
  385.           fprintf( stderr, "Please run this    program    setuid root.\n");
  386.           exit(status);
  387.       } else {
  388.           fprintf( stderr, "write(generic) status =    0x%x, "
  389.                    "result = 0x%x cmd = 0x%x\n",
  390.                status, sg_hd->result, i_buff[SCSI_OFF] );
  391.       }
  392.       return status;
  393.       }
  394.  
  395.       if (!o_buff) o_buff = i_buff;      /* buffer pointer check */
  396.  
  397.       /* retrieve result */
  398.       status = read( fd, o_buff, SCSI_OFF + out_size);
  399.       if ( status < 0 || status    != SCSI_OFF + out_size || sg_hd->result    ) {
  400.       /* some error    happened */
  401.       fprintf( stderr, "read(generic) status = 0x%x, result    = 0x%x,    "
  402.                "cmd    = 0x%x\n",
  403.                status, sg_hd->result, o_buff[SCSI_OFF] );
  404.       fprintf( stderr, "read(generic) sense    "
  405.           "%x %x %x %x %x %x %x    %x %x %x %x %x %x %x %x    %x\n",
  406.           sg_hd->sense_buffer[0],      sg_hd->sense_buffer[1],
  407.           sg_hd->sense_buffer[2],      sg_hd->sense_buffer[3],
  408.           sg_hd->sense_buffer[4],      sg_hd->sense_buffer[5],
  409.           sg_hd->sense_buffer[6],      sg_hd->sense_buffer[7],
  410.           sg_hd->sense_buffer[8],      sg_hd->sense_buffer[9],
  411.           sg_hd->sense_buffer[10],      sg_hd->sense_buffer[11],
  412.           sg_hd->sense_buffer[12],      sg_hd->sense_buffer[13],
  413.           sg_hd->sense_buffer[14],      sg_hd->sense_buffer[15]);
  414.       }
  415.       /* Look if we got    what we    expected to get    */
  416.       if (status == SCSI_OFF + out_size) status    = 0; /*    got them all */
  417.  
  418.       return status;  /* 0 means no error */
  419.   }
  420.  
  421.  
  422.  
  423.  
  424.   While    this may look somewhat complex at first    appearance, most of the
  425.   code is for error checking and reporting (which is useful even after
  426.   the code is working).
  427.  
  428.   Handle_SCSI_cmd has a    generalized form for all SCSI commands types,
  429.   falling into each of these categories:
  430.  
  431.  
  432.  
  433.  
  434.           Data Mode             | Example Command
  435.        ===============================================
  436.        neither input nor output    data | test unit ready
  437.     no input data, output data   | inquiry,    read
  438.     input data, no output data   | mode select, write
  439.       input    data, output data    | mode sense
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.   8.  Inquiry Command Example
  447.  
  448.   One of the most basic    SCSI commands is the INQUIRY command, used to
  449.   identify the type and    make of    the device. Here is the    definition from
  450.   the SCSI-2 specification (for    details    refer to the SCSI-2 standard).
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.                   Table 44:    INQUIRY    Command
  464.   +=====-========-========-========-========-========-========-========-========+
  465.   |  Bit|   7     |   6      |   5       |   4    |    3    |     2    |      1    |   0    |
  466.   |Byte    |     |      |       |        |         |          |           |    |
  467.   |=====+=======================================================================|
  468.   | 0    |                Operation Code (12h)            |
  469.   |-----+-----------------------------------------------------------------------|
  470.   | 1    | Logical Unit Number       |              Reserved           |  EVPD    |
  471.   |-----+-----------------------------------------------------------------------|
  472.   | 2    |                Page Code                    |
  473.   |-----+-----------------------------------------------------------------------|
  474.   | 3    |                Reserved                    |
  475.   |-----+-----------------------------------------------------------------------|
  476.   | 4    |                Allocation Length                |
  477.   |-----+-----------------------------------------------------------------------|
  478.   | 5    |                Control                    |
  479.   +=============================================================================+
  480.  
  481.  
  482.  
  483.  
  484.   The output data are as follows:
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                Table 45: Standard INQUIRY Data Format
  530.   +=====-========-========-========-========-========-========-========-========+
  531.   |  Bit|   7     |   6      |   5       |   4    |    3    |     2    |      1    |   0    |
  532.   |Byte    |     |      |       |        |         |          |           |    |
  533.   |=====+==========================+============================================|
  534.   | 0    | Peripheral Qualifier       |           Peripheral Device Type        |
  535.   |-----+-----------------------------------------------------------------------|
  536.   | 1    |  RMB     |            Device-Type    Modifier            |
  537.   |-----+-----------------------------------------------------------------------|
  538.   | 2    |   ISO    Version      |      ECMA Version         |    ANSI-Approved Version    |
  539.   |-----+-----------------+-----------------------------------------------------|
  540.   | 3    |  AENC     | TrmIOP |    Reserved    |          Response Data Format    |
  541.   |-----+-----------------------------------------------------------------------|
  542.   | 4    |                Additional Length (n-4)            |
  543.   |-----+-----------------------------------------------------------------------|
  544.   | 5    |                Reserved                    |
  545.   |-----+-----------------------------------------------------------------------|
  546.   | 6    |                Reserved                    |
  547.   |-----+-----------------------------------------------------------------------|
  548.   | 7    | RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved|    CmdQue | SftRe    |
  549.   |-----+-----------------------------------------------------------------------|
  550.   | 8    | (MSB)                                    |
  551.   |- - -+---                Vendor Identification             ---|
  552.   | 15    |                                  (LSB)    |
  553.   |-----+-----------------------------------------------------------------------|
  554.   | 16    | (MSB)                                    |
  555.   |- - -+---                Product Identification             ---|
  556.   | 31    |                                  (LSB)    |
  557.   |-----+-----------------------------------------------------------------------|
  558.   | 32    | (MSB)                                    |
  559.   |- - -+---                Product Revision Level             ---|
  560.   | 35    |                                  (LSB)    |
  561.   |-----+-----------------------------------------------------------------------|
  562.   | 36    |                                    |
  563.   |- - -+---                Vendor Specific                 ---|
  564.   | 55    |                                    |
  565.   |-----+-----------------------------------------------------------------------|
  566.   | 56    |                                    |
  567.   |- - -+---                Reserved                     ---|
  568.   | 95    |                                    |
  569.   |=====+=======================================================================|
  570.   |    |            Vendor-Specific    Parameters            |
  571.   |=====+=======================================================================|
  572.   | 96    |                                    |
  573.   |- - -+---                Vendor Specific                 ---|
  574.   | n    |                                    |
  575.   +=============================================================================+
  576.  
  577.  
  578.  
  579.  
  580.  
  581.   The next example uses    the low-level function handle_SCSI_cmd to
  582.   perform the Inquiry SCSI command.
  583.  
  584.   We first append the command block to the generic header, then    call
  585.   handle_SCSI_cmd.  Note that the output buffer    size argument for the
  586.   handle_SCSI_cmd call excludes    the generic header size.  After    command
  587.   completion the output    buffer contains    the requested data, unless an
  588.   error    occurred.
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.   #define INQUIRY_CMD      0x12
  596.   #define INQUIRY_CMDLEN  6
  597.   #define INQUIRY_REPLY_LEN 96
  598.   #define INQUIRY_VENDOR  8      /* Offset in reply data to vendor name */
  599.  
  600.   /* request vendor brand and model */
  601.   static unsigned char *Inquiry    ( void )
  602.   {
  603.     unsigned char Inqbuffer[ SCSI_OFF +    INQUIRY_REPLY_LEN ];
  604.     unsigned char cmdblk [ INQUIRY_CMDLEN ] =
  605.     { INQUIRY_CMD,    /* command */
  606.             0,    /* lun/reserved    */
  607.             0,    /* page    code */
  608.             0,    /* reserved */
  609.     INQUIRY_REPLY_LEN,    /* allocation length */
  610.             0 };/* reserved/flag/link */
  611.  
  612.     memcpy( cmd    + SCSI_OFF, cmdblk, sizeof(cmdblk) );
  613.  
  614.     if (handle_SCSI_cmd(sizeof(cmdblk),    0, cmd,
  615.             sizeof(Inqbuffer) - SCSI_OFF, Inqbuffer    )) {
  616.     fprintf( stderr, "Inquiry failed\n" );
  617.     exit(2);
  618.     }
  619.     return (Inqbuffer +    SCSI_OFF);
  620.   }
  621.  
  622.  
  623.  
  624.  
  625.   The example above follows this structure. The    Inquiry    function copies
  626.   its command block behind the generic header (given by    SCSI_OFF). Input
  627.   data is not present for this command.     Handle_SCSI_cmd will define the
  628.   header structure. We can now implement the function main to complete
  629.   this working example program.
  630.  
  631.  
  632.  
  633.        void main( void )
  634.        {
  635.      fd = open(DEVICE, O_RDWR);
  636.      if (fd    < 0) {
  637.        fprintf( stderr, "No    access to "DEVICE".\n" );
  638.        exit(1);
  639.      }
  640.  
  641.      /* print the result of    Inquiry    */
  642.      printf( "%s\n", Inquiry() + INQUIRY_VENDOR );
  643.        }
  644.  
  645.  
  646.  
  647.  
  648.   We first open    the device, check for errors, and then call the    higher
  649.   level    subroutine. Then we print the results in human readable    format
  650.   including the    vendor,    product, and revision.
  651.  
  652.  
  653.   9.  The Sense    Buffer
  654.  
  655.  
  656.   Commands with    no output data can give    status information via the sense
  657.   buffer (which    is part    of the header structure).  Sense data is
  658.   available when the previous command has terminated with a CHECK
  659.   CONDITION status. In this case the kernel automatically retrieves the
  660.   sense    data via a REQUEST SENSE command. Its structure    is:
  661.        +=====-========-========-========-========-========-========-========-========+
  662.        |  Bit|     7    |      6    |   5    |   4     |   3      |   2       |   1    |    0    |
  663.        |Byte |          |           |    |     |      |       |        |         |
  664.        |=====+========+==============================================================|
  665.        | 0   | Valid  |             Error Code (70h or 71h)             |
  666.        |-----+-----------------------------------------------------------------------|
  667.        | 1   |                 Segment Number                     |
  668.        |-----+-----------------------------------------------------------------------|
  669.        | 2   |Filemark|     EOM   |  ILI    |Reserved|       Sense Key             |
  670.        |-----+-----------------------------------------------------------------------|
  671.        | 3   | (MSB)                                     |
  672.        |- - -+---             Information                  ---|
  673.        | 6   |                                       (LSB) |
  674.        |-----+-----------------------------------------------------------------------|
  675.        | 7   |                 Additional Sense Length (n-7)             |
  676.        |-----+-----------------------------------------------------------------------|
  677.        | 8   | (MSB)                                     |
  678.        |- - -+---             Command-Specific Information          ---|
  679.        | 11  |                                       (LSB) |
  680.        |-----+-----------------------------------------------------------------------|
  681.        | 12  |                 Additional Sense Code                 |
  682.        |-----+-----------------------------------------------------------------------|
  683.        | 13  |                 Additional Sense Code Qualifier         |
  684.        |-----+-----------------------------------------------------------------------|
  685.        | 14  |                 Field Replaceable Unit    Code             |
  686.        |-----+-----------------------------------------------------------------------|
  687.        | 15  |    SKSV  |                                     |
  688.        |- - -+------------         Sense-Key Specific              ---|
  689.        | 17  |                                         |
  690.        |-----+-----------------------------------------------------------------------|
  691.        | 18  |                                         |
  692.        |- - -+---             Additional Sense Bytes              ---|
  693.        | n   |                                         |
  694.        +=============================================================================+
  695.  
  696.  
  697.  
  698.  
  699.  
  700.   Note:    The most useful    fields are Sense Key (see section ``''),
  701.   Additional Sense Code    and Additional Sense Code Qualifier (see section
  702.   ``''). The latter two    are combined.
  703.  
  704.  
  705.  
  706.  
  707.   10.  Example Using Sense Buffer
  708.  
  709.   Here we will use the TEST UNIT READY command to check    whether    media is
  710.   loaded into our device. The header declarations and function
  711.   handle_SCSI_cmd from the inquiry example will    be needed as well.
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.               Table    73: TEST UNIT READY Command
  728.   +=====-========-========-========-========-========-========-========-========+
  729.   |  Bit|   7     |   6      |   5       |   4    |    3    |     2    |      1    |   0    |
  730.   |Byte    |     |      |       |        |         |          |           |    |
  731.   |=====+=======================================================================|
  732.   | 0    |                Operation Code (00h)            |
  733.   |-----+-----------------------------------------------------------------------|
  734.   | 1    | Logical Unit Number       |              Reserved            |
  735.   |-----+-----------------------------------------------------------------------|
  736.   | 2    |                Reserved                    |
  737.   |-----+-----------------------------------------------------------------------|
  738.   | 3    |                Reserved                    |
  739.   |-----+-----------------------------------------------------------------------|
  740.   | 4    |                Reserved                    |
  741.   |-----+-----------------------------------------------------------------------|
  742.   | 5    |                Control                    |
  743.   +=============================================================================+
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.   Here is the function which implements    it:
  751.  
  752.  
  753.  
  754.        #define TESTUNITREADY_CMD 0
  755.        #define TESTUNITREADY_CMDLEN 6
  756.  
  757.        #define ADD_SENSECODE 12
  758.        #define ADD_SC_QUALIFIER    13
  759.        #define NO_MEDIA_SC 0x3a
  760.        #define NO_MEDIA_SCQ 0x00
  761.  
  762.        int TestForMedium ( void    )
  763.        {
  764.      /* request READY status */
  765.      static    unsigned char cmdblk [TESTUNITREADY_CMDLEN] = {
  766.          TESTUNITREADY_CMD,    /* command */
  767.                  0,    /* reserved */
  768.                  0,    /* reserved */
  769.                  0,    /* reserved */
  770.                  0,    /* reserved */
  771.                  0};/* control */
  772.  
  773.      memcpy( cmd + SCSI_OFF, cmdblk, sizeof(cmdblk)    );
  774.  
  775.      if (handle_SCSI_cmd(sizeof(cmdblk), 0,    cmd,
  776.                    0, NULL)) {
  777.          fprintf (stderr, "Test unit ready failed\n");
  778.          exit(2);
  779.      }
  780.  
  781.      return
  782.       *(((struct sg_header*)cmd)->sense_buffer +ADD_SENSECODE) !=
  783.                                    NO_MEDIA_SC ||
  784.       *(((struct sg_header*)cmd)->sense_buffer +ADD_SC_QUALIFIER) !=
  785.                                    NO_MEDIA_SCQ;
  786.        }
  787.  
  788.  
  789.  
  790.  
  791.   Combined with    this main function we can do the check.
  792.  
  793.        void main( void )
  794.        {
  795.      fd = open(DEVICE, O_RDWR);
  796.      if (fd    < 0) {
  797.        fprintf( stderr, "No    access to "DEVICE".\n" );
  798.        exit(1);
  799.      }
  800.  
  801.      /* look if medium is loaded */
  802.  
  803.      if (!TestForMedium()) {
  804.        printf("device is unloaded\n");
  805.      } else    {
  806.        printf("device is loaded\n");
  807.      }
  808.        }
  809.  
  810.  
  811.  
  812.  
  813.  
  814.   The file generic_demo.c from this package contains both examples.
  815.  
  816.  
  817.   11.  Ioctl Functions
  818.  
  819.  
  820.   There    are two    ioctl functions    available:
  821.  
  822.   o  ioctl(fd, SG_SET_TIMEOUT, &Timeout); sets the timeout value to
  823.      Timeout * 10 milliseconds.    Timeout    has to be declared as int.
  824.  
  825.   o  ioctl(fd, SG_GET_TIMEOUT, &Timeout); gets the current timeout
  826.      value.  Timeout has to be declared    as int.
  827.  
  828.  
  829.   12.  Driver Defaults
  830.  
  831.  
  832.   12.1.     Transfer Lengths
  833.  
  834.  
  835.   Currently (at    least up to kernel version 1.1.68) input and output
  836.   sizes    have to    be less    than or    equal than 4096    bytes unless the kernel
  837.   has been compiled with SG_BIG_BUFF defined, if which case it is
  838.   limited to SG_BIG_BUFF (e.g. 32768) bytes.  These sizes include the
  839.   generic header as well as the    command    block on input.
  840.  
  841.  
  842.   12.2.     Timeout And Retry Values
  843.  
  844.   The default timeout value is set to one minute (Timeout = 6000).  It
  845.   can be changed through an ioctl call (see section ``'').  The    default
  846.   number of retries is one.
  847.  
  848.  
  849.   13.  Obtaining The Scsi Specifications
  850.  
  851.   There    are standards entitled SCSI-1 and SCSI-2 (and possibly soon
  852.   SCSI-3). The standards are mostly upward compatible.
  853.  
  854.   The SCSI-1 standard is (in the author's opinion) mostly obsolete, and
  855.   SCSI-2 is the    most widely used. SCSI-3 is very new and very expensive.
  856.   These    standardized command sets specify mandatory and    optional
  857.   commands for SCSI manufacturers and should be    preferred over the
  858.   vendor specific command extensions which are not standardized    and for
  859.   which    programming information    is seldom available.
  860.  
  861.  
  862.   Electronic copies are    available via anonymous    ftp from:
  863.  
  864.   o  ftp.cs.tulane.edu:pub/scsi
  865.  
  866.   o  ncrinfo.ncr.com:/pub/standards
  867.  
  868.   o  ftp.cs.uni-sb.de:/pub/misc/doc/scsi
  869.  
  870.   (I got my SCSI specification from the    Yggdrasil Linux    CD-ROM in the
  871.   directory /usr/doc/scsi-2 and    /usr/doc/scsi-1).
  872.  
  873.   The SCSI FAQ also lists the following    sources    of printed information:
  874.  
  875.   The SCSI specification: Available from:
  876.  
  877.  
  878.  
  879.          Global Engineering    Documents
  880.          15    Inverness Way East
  881.          Englewood Co  80112-5704
  882.          (800) 854-7179
  883.            SCSI-1: X3.131-1986
  884.            SCSI-2: X3.131-199x
  885.            SCSI-3 X3T9.2/91-010R4 Working Draft
  886.  
  887.        (Global Engineering Documentation in Irvine, CA (714)261-1455??)
  888.  
  889.        SCSI-1: Doc \# X3.131-1986 from ANSI, 1430 Broadway, NY,    NY 10018
  890.  
  891.        IN-DEPTH    EXPLORATION OF SCSI can    be obtained from
  892.        Solution    Technology, Attn: SCSI Publications, POB 104, Boulder Creek,
  893.        CA 95006, (408)338-4285,    FAX (408)338-4374
  894.  
  895.        THE SCSI    ENCYLOPEDIA and    the SCSI BENCH REFERENCE can be    obtained from
  896.        ENDL Publishing,    14426 Black Walnut Ct.,    Saratoga, CA 95090,
  897.        (408)867-6642, FAX (408)867-2115
  898.  
  899.        SCSI: UNDERSTANDING THE SMALL COMPUTER SYSTEM INTERFACE was published
  900.        by Prentice-Hall, ISBN 0-13-796855-8
  901.  
  902.  
  903.  
  904.  
  905.  
  906.   14.  Related Information Sources
  907.  
  908.   The Linux SCSI-HOWTO by Drew Eckhardt    covers all supported SCSI
  909.   controllers as well as device    specific questions. A lot of
  910.   troubleshooting hints    are given. It is available from    sunsite.unc.edu
  911.   in /pub/Linux/docs/LDP and its mirror    sites.
  912.  
  913.   General questions about SCSI are answered in the SCSI-FAQ from the
  914.   news group Comp.Periphs.Scsi (available on tsx-11 in
  915.   pub/linux/ALPHA/scsi and mirror sites).
  916.  
  917.   There    is a mailing list for bug reports and questions    regarding SCSI
  918.   development under Linux.  To join, send email    to
  919.   majordomo@vger.rutgers.edu with the line subscribe linux-scsi    in the
  920.   body of the message.    Messages should    be posted to linux-
  921.   scsi@vger.rutgers.edu.  Help text can    be requested by    sending    the
  922.   message line "help" to majordomo@vger.rutgers.edu.  There is another
  923.   mailing list server at niksula.hut.fi, but it    has been very busy (read
  924.   too busy) lately.
  925.   15.  Other SCSI Access Interfaces
  926.  
  927.   There    are some other similar interfaces in use in the    un*x world, but
  928.   not available    for Linux:
  929.  
  930.   1. CAM (Common Access    Method)    developed by Future Domain and other
  931.      SCSI vendors. This    was a response to the ASPI interface. Linux has
  932.      some support for a    SCSI CAM system    (mainly    for booting from hard
  933.      disk).  CAM even supports target mode, so one could disguise ones
  934.      computer as a peripheral hardware device (e.g. for    a small    SCSI
  935.      net).
  936.  
  937.   2. ASPI (Advanced SCSI Programming Interface)    developed by Adaptec.
  938.      This is the de facto standard for MS-DOS machines.
  939.  
  940.   There    are other application interfaces from SCO(TM), NeXT(TM), Silicon
  941.   Graphics(TM) and SUN(TM) as well.
  942.  
  943.  
  944.   16.  Final Comments
  945.  
  946.   The generic SCSI interface bridges the gap between user applications
  947.   and specific devices.    But rather than    bloating a lot of programs with
  948.   similar sets of low-level functions, it would    be more    desirable to
  949.   have a shared    library    with a generalized set of low-level functions
  950.   for a    particular purpose.  The main goal should be to    have independent
  951.   layers of interfaces.     A good    design would separate an application
  952.   into low-level and hardware independent routines. The    low-level
  953.   routines could be put    into a shared library and made available for all
  954.   applications.    Here, standardized interfaces should be    followed instead
  955.   of making new    ones.
  956.  
  957.   By now you should know more than I do    about the Linux    generic    SCSI
  958.   interface. So    you can    start developing powerful applications for the
  959.   benefit of the global    Linux community    now...
  960.  
  961.  
  962.   17.  Acknowledgments
  963.  
  964.   Special thanks go to Jeff Tranter for    proofreading and enhancing the
  965.   text considerably as well as to Carlos Puchol    for useful comments.
  966.   Drew Eckhardt's and Eric Youngdale's help on my first    (dumb) questions
  967.   about    the use    of this    interface has been appreciated.
  968.  
  969.  
  970.   R.  Appendix
  971.  
  972.  
  973.   S.  Error handling
  974.  
  975.  
  976.   The functions    open, ioctl, write and read can    report errors.    The
  977.   error    return values are defined in /usr/include/errno.h.  Possible
  978.   negative values are:
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.   Function | Error      | Description
  992.   =========|==============|=============================================
  993.   open       | -ENXIO      | not    a valid    device
  994.        | -EACCES      | access mode    is not read/write (O_RDWR)
  995.        | -EBUSY      | device was requested for nonblocking access,
  996.        |          | but    is busy    now.
  997.        | -ERESTARTSYS | this indicates an internal error. Try to
  998.        |          | make it reproducible and inform the    SCSI
  999.        |          | channel (for details on bug    reporting
  1000.        |          | see    Drew Eckhardts SCSI-HOWTO).
  1001.   ioctl       | -ENXIO      | not    a valid    device
  1002.   read       | -EWOULDBLOCK | the    device would block. Try    again later.
  1003.   write       | -EIO      | the    length is too small (smaller than the
  1004.        |          | generic header struct). Caution: Currently
  1005.        |          | there is checking for lengths being    too great
  1006.        | -EWOULDBLOCK | the    device would block. Try    again later.
  1007.        | -ERESTARTSYS | this indicates an internal error. Try to
  1008.        |          | make it reproducible and inform the    SCSI
  1009.        |          | channel (for details on bug    reporting
  1010.        |          | see    Drew Eckhardts SCSI-HOWTO).
  1011.        | -ENOMEM      | memory required for    this request could not be
  1012.        |          | allocated. Try later again unless you
  1013.        |          | exceeded the maximum transfer size (see above)
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.   Positive values indicate as usual the    amount of bytes    that have been
  1020.   successfully transferred, which should equal the amount you requested.
  1021.  
  1022.  
  1023.   S.1.    Error status decoding
  1024.  
  1025.  
  1026.   Furthermore a    detailed reporting is done via the kernels hd_status and
  1027.   the devices reports in the sense_buffer (see section ``'') from the
  1028.   header structure.
  1029.  
  1030.   The meaning of hd_status can be found    in drivers/scsi/scsi.h:    This
  1031.   unsigned int is composed out of different parts:
  1032.  
  1033.  
  1034.  
  1035.  
  1036.      lsb  |       ...      |    ...    |    msb
  1037.        =======|===========|===========|============
  1038.        status |    sense key | host code |    driver byte
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.   These    macros from drivers/scsi/scsi.h    can be used to separate    the
  1045.   fields:
  1046.  
  1047.  
  1048.  
  1049.            Macro       | Description
  1050.        ====================|================================================
  1051.        status_byte(result) | The SCSI device status. See above
  1052.        msg_byte(result)       | The devices sense key. See    above
  1053.        host_byte(result)   | The host code from    the kernel driver. See above
  1054.        driver_byte(result) | The first byte from the device
  1055.  
  1056.  
  1057.   S.2.    Status codes
  1058.  
  1059.  
  1060.   The following    status codes from the SCSI device (defined in
  1061.   drivers/scsi/scsi.h) should be used with the macro status_byte (see
  1062.   section ``''):
  1063.  
  1064.  
  1065.  
  1066.        Value | Symbol
  1067.        ======|=====================
  1068.        0x00  | GOOD
  1069.        0x01  | CHECK_CONDITION
  1070.        0x02  | CONDITION_GOOD
  1071.        0x04  | BUSY
  1072.        0x08  | INTERMEDIATE_GOOD
  1073.        0x0a  | INTERMEDIATE_C_GOOD
  1074.        0x0c  | RESERVATION_CONFLICT
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.   Note that these symbol values    have been shifted right    once.  From the
  1081.   SCSI-2 specification:
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.                  Table 27: Status Byte Code
  1124.   +=================================-==============================+
  1125.   |      Bits of Status Byte        |  Status               |
  1126.   |  7     6   5     4   3     2   1     0  |                   |
  1127.   |---------------------------------+------------------------------|
  1128.   |  R     R   0     0   0     0   0     R  |  GOOD               |
  1129.   |  R     R   0     0   0     0   1     R  |  CHECK CONDITION           |
  1130.   |  R     R   0     0   0     1   0     R  |  CONDITION MET           |
  1131.   |  R     R   0     0   1     0   0     R  |  BUSY               |
  1132.   |  R     R   0     1   0     0   0     R  |  INTERMEDIATE           |
  1133.   |  R     R   0     1   0     1   0     R  |  INTERMEDIATE-CONDITION MET  |
  1134.   |  R     R   0     1   1     0   0     R  |  RESERVATION CONFLICT       |
  1135.   |  R     R   1     0   0     0   1     R  |  COMMAND TERMINATED       |
  1136.   |  R     R   1     0   1     0   0     R  |  QUEUE FULL           |
  1137.   |                    |                   |
  1138.   |      All Other Codes        |  Reserved               |
  1139.   |----------------------------------------------------------------|
  1140.   |  Key: R = Reserved bit                       |
  1141.   +================================================================+
  1142.  
  1143.   A definition of the status byte codes    is given below.
  1144.  
  1145.   GOOD.     This status indicates that the    target has successfully    completed the
  1146.   command.
  1147.  
  1148.   CHECK    CONDITION.  This status    indicates that a contingent allegiance condition
  1149.   has occurred (see 6.6).
  1150.  
  1151.   CONDITION MET.  This status or INTERMEDIATE-CONDITION    MET is returned    whenever
  1152.   the requested    operation is satisfied (see the    SEARCH DATA and    PRE-FETCH
  1153.   commands).
  1154.  
  1155.   BUSY.     This status indicates that the    target is busy.     This status shall be
  1156.   returned whenever a target is    unable to accept a command from    an otherwise
  1157.   acceptable initiator (i.e., no reservation conflicts).  The recommended
  1158.   initiator recovery action is to issue    the command again at a later time.
  1159.  
  1160.   INTERMEDIATE.     This status or    INTERMEDIATE-CONDITION MET shall be returned for
  1161.   every    successfully completed command in a series of linked commands (except
  1162.   the last command), unless the    command    is terminated with CHECK CONDITION,
  1163.   RESERVATION CONFLICT,    or COMMAND TERMINATED status.  If INTERMEDIATE or
  1164.   INTERMEDIATE-CONDITION MET status is not returned, the series    of linked
  1165.   commands is terminated and the I/O process is    ended.
  1166.  
  1167.   INTERMEDIATE-CONDITION MET.  This status is the combination of the CONDITION
  1168.   MET and INTERMEDIATE statuses.
  1169.  
  1170.   RESERVATION CONFLICT.     This status shall be returned whenever    an initiator
  1171.   attempts to access a logical unit or an extent within    a logical unit that is
  1172.   reserved with    a conflicting reservation type for another SCSI    device (see the
  1173.   RESERVE and RESERVE UNIT commands).  The recommended initiator recovery action
  1174.   is to    issue the command again    at a later time.
  1175.  
  1176.   COMMAND TERMINATED.  This status shall be returned whenever the target
  1177.   terminates the current I/O process after receiving a TERMINATE I/O PROCESS
  1178.   message (see 5.6.22).     This status also indicates that a contingent allegiance
  1179.   condition has    occurred (see 6.6).
  1180.  
  1181.   QUEUE    FULL.  This status shall be implemented    if tagged queuing is
  1182.   implemented.    This status is returned    when a SIMPLE QUEUE TAG, ORDERED QUEUE
  1183.   TAG, or HEAD OF QUEUE    TAG message is received    and the    command    queue is full.
  1184.   The I/O process is not placed    in the command queue.
  1185.  
  1186.  
  1187.  
  1188.  
  1189.   S.3.    SCSI Sense Keys
  1190.  
  1191.  
  1192.   The sense key    from the result    should be retrieved with the macro
  1193.   msg_byte (see    section    ``'').    These kernel symbols (from
  1194.   drivers/scsi/scsi.h) are predefined:
  1195.  
  1196.  
  1197.  
  1198.        Value | Symbol
  1199.        ======|================
  1200.        0x00  | NO_SENSE
  1201.        0x01  | RECOVERED_ERROR
  1202.        0x02  | NOT_READY
  1203.        0x03  | MEDIUM_ERROR
  1204.        0x04  | HARDWARE_ERROR
  1205.        0x05  | ILLEGAL_REQUEST
  1206.        0x06  | UNIT_ATTENTION
  1207.        0x07  | DATA_PROTECT
  1208.        0x08  | BLANK_CHECK
  1209.        0x0a  | COPY_ABORTED
  1210.        0x0b  | ABORTED_COMMAND
  1211.        0x0d  | VOLUME_OVERFLOW
  1212.        0x0e  | MISCOMPARE
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.   A verbatim list from the SCSI-2 doc follows (from section 7.2.14.3):
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.               Table 69:    Sense Key (0h-7h) Descriptions
  1256.   +========-====================================================================+
  1257.   | Sense  |  Description                            |
  1258.   |  Key   |                                    |
  1259.   |--------+--------------------------------------------------------------------|
  1260.   |   0h   |  NO SENSE.     Indicates that    there is no specific sense key        |
  1261.   |       |  information to be    reported for the designated logical unit.  This    |
  1262.   |       |  would be the case    for a successful command or a command that    |
  1263.   |       |  received CHECK CONDITION or COMMAND TERMINATED status because one    |
  1264.   |       |  of the filemark, EOM, or ILI bits    is set to one.            |
  1265.   |--------+--------------------------------------------------------------------|
  1266.   |   1h   |  RECOVERED    ERROR.    Indicates that the last    command    completed    |
  1267.   |       |  successfully with    some recovery action performed by the target.    |
  1268.   |       |  Details may be determinable by examining the additional sense    |
  1269.   |       |  bytes and    the information    field.    When multiple recovered    errors    |
  1270.   |       |  occur during one command,    the choice of which error to report    |
  1271.   |       |  (first, last, most severe, etc.) is device specific.        |
  1272.   |--------+--------------------------------------------------------------------|
  1273.   |   2h   |  NOT READY.  Indicates that the logical unit addressed cannot be    |
  1274.   |       |  accessed.     Operator intervention may be required to correct this    |
  1275.   |       |  condition.                            |
  1276.   |--------+--------------------------------------------------------------------|
  1277.   |   3h   |  MEDIUM ERROR.  Indicates that the    command    terminated with    a non-    |
  1278.   |       |  recovered    error condition    that was probably caused by a flaw in    |
  1279.   |       |  the medium or an error in    the recorded data.  This sense key may    |
  1280.   |       |  also be returned if the target is    unable to distinguish between a    |
  1281.   |       |  flaw in the medium and a specific    hardware failure (sense    key 4h).|
  1282.   |--------+--------------------------------------------------------------------|
  1283.   |   4h   |  HARDWARE ERROR.  Indicates that the target detected a non-    |
  1284.   |       |  recoverable hardware failure (for    example, controller failure,    |
  1285.   |       |  device failure, parity error, etc.) while    performing the command    |
  1286.   |       |  or during    a self test.                        |
  1287.   |--------+--------------------------------------------------------------------|
  1288.   |   5h   |  ILLEGAL REQUEST.    Indicates that there was an illegal parameter in|
  1289.   |       |  the command descriptor block or in the additional    parameters    |
  1290.   |       |  supplied as data for some    commands (FORMAT UNIT, SEARCH DATA,    |
  1291.   |       |  etc.).  If the target detects an invalid parameter in the    command    |
  1292.   |       |  descriptor block,    then it    shall terminate    the command without    |
  1293.   |       |  altering the medium.  If the target detects an invalid parameter    |
  1294.   |       |  in the additional    parameters supplied as data, then the target may|
  1295.   |       |  have already altered the medium.    This sense key may also    indicate|
  1296.   |       |  that an invalid IDENTIFY message was received (5.6.7).        |
  1297.   |--------+--------------------------------------------------------------------|
  1298.   |   6h   |  UNIT ATTENTION.  Indicates that the removable medium may have been|
  1299.   |       |  changed or the target has    been reset.  See 6.9 for more detailed    |
  1300.   |       |  information about    the unit attention condition.            |
  1301.   |--------+--------------------------------------------------------------------|
  1302.   |   7h   |  DATA PROTECT.  Indicates that a command that reads or writes the    |
  1303.   |       |  medium was attempted on a    block that is protected    from this    |
  1304.   |       |  operation.  The read or write operation is not performed.        |
  1305.   +=============================================================================+
  1306.  
  1307.               Table 70:    Sense Key (8h-Fh) Descriptions
  1308.   +========-====================================================================+
  1309.   | Sense  |  Description                            |
  1310.   |  Key   |                                    |
  1311.   |--------+--------------------------------------------------------------------|
  1312.   |   8h   |  BLANK CHECK.  Indicates that a write-once    device or a sequential-    |
  1313.   |       |  access device encountered    blank medium or    format-defined end-of-    |
  1314.   |       |  data indication while reading or a write-once device encountered a|
  1315.   |       |  non-blank    medium while writing.                    |
  1316.   |--------+--------------------------------------------------------------------|
  1317.   |   9h   |  Vendor Specific.    This sense key is available for    reporting vendor|
  1318.   |       |  specific conditions.                        |
  1319.   |--------+--------------------------------------------------------------------|
  1320.   |   Ah   |  COPY ABORTED.  Indicates a COPY, COMPARE,    or COPY    AND VERIFY    |
  1321.   |       |  command was aborted due to an error condition on the source    |
  1322.   |       |  device, the destination device, or both.    (See 7.2.3.2 for    |
  1323.   |       |  additional information about this    sense key.)            |
  1324.   |--------+--------------------------------------------------------------------|
  1325.   |   Bh   |  ABORTED COMMAND.    Indicates that the target aborted the command.    |
  1326.   |       |  The initiator may    be able    to recover by trying the command again.    |
  1327.   |--------+--------------------------------------------------------------------|
  1328.   |   Ch   |  EQUAL.  Indicates    a SEARCH DATA command has satisfied an equal    |
  1329.   |       |  comparison.                            |
  1330.   |--------+--------------------------------------------------------------------|
  1331.   |   Dh   |  VOLUME OVERFLOW.    Indicates that a buffered peripheral device has    |
  1332.   |       |  reached the end-of-partition and data may    remain in the buffer    |
  1333.   |       |  that has not been    written    to the medium.    A RECOVER BUFFERED DATA    |
  1334.   |       |  command(s) may be    issued to read the unwritten data from the    |
  1335.   |       |  buffer.                                |
  1336.   |--------+--------------------------------------------------------------------|
  1337.   |   Eh   |  MISCOMPARE.  Indicates that the source data did not match    the data|
  1338.   |       |  read from    the medium.                        |
  1339.   |--------+--------------------------------------------------------------------|
  1340.   |   Fh   |  RESERVED.                                |
  1341.   +=============================================================================+
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.   S.4.    Hostcodes
  1349.  
  1350.  
  1351.   The following    host codes are defined in drivers/scsi/scsi.h. They are
  1352.   set by the kernel driver and should be used with the macro host_byte
  1353.   (see section ``''):
  1354.  
  1355.  
  1356.  
  1357.        Value | Symbol          |    Description
  1358.        ======|================|========================================
  1359.        0x00  | DID_OK          |    No error
  1360.        0x01  | DID_NO_CONNECT |    Couldn't connect before    timeout    period
  1361.        0x02  | DID_BUS_BUSY   |    BUS stayed busy    through    time out period
  1362.        0x03  | DID_TIME_OUT   |    TIMED OUT for other reason
  1363.        0x04  | DID_BAD_TARGET |    BAD target
  1364.        0x05  | DID_ABORT      |    Told to    abort for some other reason
  1365.        0x06  | DID_PARITY     |    Parity error
  1366.        0x07  | DID_ERROR      |    internal error
  1367.        0x08  | DID_RESET      |    Reset by somebody
  1368.        0x09  | DID_BAD_INTR   |    Got an interrupt we weren't expecting
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.   T.  Additional sense codes and additional sense code qualifiers
  1375.  
  1376.  
  1377.   From the SCSI-2 specification    I include two tables. The first    is in
  1378.   lexical, the second in numerical order.
  1379.  
  1380.  
  1381.   T.1.    ASC and    ASCQ in    lexical    order
  1382.  
  1383.   The following    table list gives a list    of descriptions    and device types
  1384.   they apply to.
  1385.  
  1386.  
  1387.        +=============================================================================+
  1388.        |       D - DIRECT ACCESS DEVICE                         |
  1389.        |       .T -    SEQUENTIAL ACCESS DEVICE                     |
  1390.        |       . L - PRINTER DEVICE                             |
  1391.        |       .  P    - PROCESSOR DEVICE                         |
  1392.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE                 |
  1393.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  1394.        |       .  .     S - SCANNER DEVICE                         |
  1395.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  1396.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  1397.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  1398.        |       .  .     .  .                                 |
  1399.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1400.        | --- ----           ----------------------------------------------------- |
  1401.        | 13h  00h  D   W  O    ADDRESS MARK NOT    FOUND FOR DATA FIELD             |
  1402.        | 12h  00h  D   W  O    ADDRESS MARK NOT    FOUND FOR ID FIELD             |
  1403.        | 00h  11h    R      AUDIO PLAY OPERATION IN PROGRESS                 |
  1404.        | 00h  12h    R      AUDIO PLAY OPERATION PAUSED                 |
  1405.        | 00h  14h    R      AUDIO PLAY OPERATION STOPPED DUE    TO ERROR         |
  1406.        | 00h  13h    R      AUDIO PLAY OPERATION SUCCESSFULLY COMPLETED         |
  1407.        | 00h  04h   T     S     BEGINNING-OF-PARTITION/MEDIUM DETECTED             |
  1408.        | 14h  04h   T           BLOCK SEQUENCE ERROR                     |
  1409.        | 30h  02h  DT  WR O    CANNOT READ MEDIUM - INCOMPATIBLE FORMAT             |
  1410.        | 30h  01h  DT  WR O    CANNOT READ MEDIUM - UNKNOWN FORMAT             |
  1411.        | 52h  00h   T           CARTRIDGE FAULT                         |
  1412.        | 3Fh  02h  DTLPWRSOMC  CHANGED OPERATING DEFINITION                 |
  1413.        | 11h  06h      WR O    CIRC UNRECOVERED    ERROR                     |
  1414.        | 30h  03h  DT           CLEANING    CARTRIDGE INSTALLED                 |
  1415.        | 4Ah  00h  DTLPWRSOMC  COMMAND PHASE ERROR                     |
  1416.        | 2Ch  00h  DTLPWRSOMC  COMMAND SEQUENCE    ERROR                     |
  1417.        | 2Fh  00h  DTLPWRSOMC  COMMANDS    CLEARED    BY ANOTHER INITIATOR             |
  1418.        | 2Bh  00h  DTLPWRSO C  COPY CANNOT EXECUTE SINCE HOST CANNOT DISCONNECT         |
  1419.        | 41h  00h  D           DATA PATH FAILURE (SHOULD USE 40    NN)             |
  1420.        | 4Bh  00h  DTLPWRSOMC  DATA PHASE ERROR                         |
  1421.        | 11h  07h      W  O    DATA RESYCHRONIZATION ERROR                 |
  1422.        | 16h  00h  D   W  O    DATA SYNCHRONIZATION MARK ERROR                 |
  1423.        | 19h  00h  D      O    DEFECT LIST ERROR                     |
  1424.        | 19h  03h  D      O    DEFECT LIST ERROR IN GROWN LIST                 |
  1425.        | 19h  02h  D      O    DEFECT LIST ERROR IN PRIMARY LIST             |
  1426.        | 19h  01h  D      O    DEFECT LIST NOT AVAILABLE                 |
  1427.        | 1Ch  00h  D      O    DEFECT LIST NOT FOUND                     |
  1428.        | 32h  01h  D   W  O    DEFECT LIST UPDATE FAILURE                 |
  1429.        | 40h  NNh  DTLPWRSOMC  DIAGNOSTIC FAILURE ON COMPONENT NN (80H-FFH)         |
  1430.        | 63h  00h    R      END OF USER AREA    ENCOUNTERED ON THIS TRACK         |
  1431.        | 00h  05h   T     S     END-OF-DATA DETECTED                     |
  1432.        | 14h  03h   T           END-OF-DATA NOT FOUND                     |
  1433.        | 00h  02h   T     S     END-OF-PARTITION/MEDIUM DETECTED                 |
  1434.        | 51h  00h   T      O    ERASE FAILURE                         |
  1435.        | 0Ah  00h  DTLPWRSOMC  ERROR LOG OVERFLOW                     |
  1436.        | 11h  02h  DT  W SO    ERROR TOO LONG TO CORRECT                 |
  1437.        | 03h  02h   T           EXCESSIVE WRITE ERRORS                     |
  1438.        | 3Bh  07h    L           FAILED TO SENSE BOTTOM-OF-FORM                 |
  1439.        | 3Bh  06h    L           FAILED TO SENSE TOP-OF-FORM                 |
  1440.        | 00h  01h   T           FILEMARK    DETECTED                     |
  1441.        | 14h  02h   T           FILEMARK    OR SETMARK NOT FOUND                 |
  1442.        | 09h  02h      WR O    FOCUS SERVO FAILURE                     |
  1443.        | 31h  01h  D L      O    FORMAT COMMAND FAILED                     |
  1444.        | 58h  00h      O    GENERATION DOES NOT EXIST                 |
  1445.        +=============================================================================+
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.   Table    71: (continued)
  1454.   +=============================================================================+
  1455.   | ASC    ASCQ  DTLPWRSOMC  DESCRIPTION                        |
  1456.   | ---    ----          -----------------------------------------------------    |
  1457.   | 1Ch     02h  D         O      GROWN    DEFECT LIST NOT    FOUND                |
  1458.   | 00h     06h  DTLPWRSOMC  I/O PROCESS TERMINATED                |
  1459.   | 10h     00h  D      W  O      ID CRC OR ECC    ERROR                    |
  1460.   | 22h     00h  D          ILLEGAL FUNCTION (SHOULD USE 20 00, 24 00, OR    26 00)    |
  1461.   | 64h     00h       R      ILLEGAL MODE FOR THIS    TRACK                |
  1462.   | 28h     01h          M      IMPORT OR EXPORT ELEMENT ACCESSED            |
  1463.   | 30h     00h  DT  WR OM      INCOMPATIBLE MEDIUM INSTALLED                |
  1464.   | 11h     08h   T      INCOMPLETE BLOCK READ                    |
  1465.   | 48h     00h  DTLPWRSOMC  INITIATOR DETECTED ERROR MESSAGE RECEIVED        |
  1466.   | 3Fh     03h  DTLPWRSOMC  INQUIRY DATA HAS CHANGED                |
  1467.   | 44h     00h  DTLPWRSOMC  INTERNAL TARGET FAILURE                |
  1468.   | 3Dh     00h  DTLPWRSOMC  INVALID BITS IN IDENTIFY MESSAGE            |
  1469.   | 2Ch     02h        S      INVALID COMBINATION OF WINDOWS SPECIFIED        |
  1470.   | 20h     00h  DTLPWRSOMC  INVALID COMMAND OPERATION CODE            |
  1471.   | 21h     01h          M      INVALID ELEMENT ADDRESS                |
  1472.   | 24h     00h  DTLPWRSOMC  INVALID FIELD    IN CDB                    |
  1473.   | 26h     00h  DTLPWRSOMC  INVALID FIELD    IN PARAMETER LIST            |
  1474.   | 49h     00h  DTLPWRSOMC  INVALID MESSAGE ERROR                    |
  1475.   | 11h     05h      WR O      L-EC UNCORRECTABLE ERROR                |
  1476.   | 60h     00h        S      LAMP FAILURE                        |
  1477.   | 5Bh     02h  DTLPWRSOM      LOG COUNTER AT MAXIMUM                |
  1478.   | 5Bh     00h  DTLPWRSOM      LOG EXCEPTION                        |
  1479.   | 5Bh     03h  DTLPWRSOM      LOG LIST CODES EXHAUSTED                |
  1480.   | 2Ah     02h  DTL WRSOMC  LOG PARAMETERS CHANGED                |
  1481.   | 21h     00h  DT  WR OM      LOGICAL BLOCK    ADDRESS    OUT OF RANGE            |
  1482.   | 08h     00h  DTL WRSOMC  LOGICAL UNIT COMMUNICATION FAILURE            |
  1483.   | 08h     02h  DTL WRSOMC  LOGICAL UNIT COMMUNICATION PARITY ERROR        |
  1484.   | 08h     01h  DTL WRSOMC  LOGICAL UNIT COMMUNICATION TIME-OUT            |
  1485.   | 4Ch     00h  DTLPWRSOMC  LOGICAL UNIT FAILED SELF-CONFIGURATION        |
  1486.   | 3Eh     00h  DTLPWRSOMC  LOGICAL UNIT HAS NOT SELF-CONFIGURED YET        |
  1487.   | 04h     01h  DTLPWRSOMC  LOGICAL UNIT IS IN PROCESS OF    BECOMING READY        |
  1488.   | 04h     00h  DTLPWRSOMC  LOGICAL UNIT NOT READY, CAUSE    NOT REPORTABLE        |
  1489.   | 04h     04h  DTL    O      LOGICAL UNIT NOT READY, FORMAT IN PROGRESS        |
  1490.   | 04h     02h  DTLPWRSOMC  LOGICAL UNIT NOT READY, INITIALIZING COMMAND REQUIRED    |
  1491.   | 04h     03h  DTLPWRSOMC  LOGICAL UNIT NOT READY, MANUAL INTERVENTION REQUIRED    |
  1492.   | 25h     00h  DTLPWRSOMC  LOGICAL UNIT NOT SUPPORTED                |
  1493.   | 15h     01h  DTL WRSOM      MECHANICAL POSITIONING ERROR                |
  1494.   | 53h     00h  DTL WRSOM      MEDIA    LOAD OR    EJECT FAILED                |
  1495.   | 3Bh     0Dh          M      MEDIUM DESTINATION ELEMENT FULL            |
  1496.   | 31h     00h  DT  W  O      MEDIUM FORMAT    CORRUPTED                |
  1497.   | 3Ah     00h  DTL WRSOM      MEDIUM NOT PRESENT                    |
  1498.   | 53h     02h  DT  WR OM      MEDIUM REMOVAL PREVENTED                |
  1499.   | 3Bh     0Eh          M      MEDIUM SOURCE    ELEMENT    EMPTY                |
  1500.   | 43h     00h  DTLPWRSOMC  MESSAGE ERROR                        |
  1501.   | 3Fh     01h  DTLPWRSOMC  MICROCODE HAS    BEEN CHANGED                |
  1502.   | 1Dh     00h  D      W  O      MISCOMPARE DURING VERIFY OPERATION            |
  1503.   | 11h     0Ah  DT     O      MISCORRECTED ERROR                    |
  1504.   | 2Ah     01h  DTL WRSOMC  MODE PARAMETERS CHANGED                |
  1505.   | 07h     00h  DTL WRSOM      MULTIPLE PERIPHERAL DEVICES SELECTED            |
  1506.   | 11h     03h  DT  W SO      MULTIPLE READ    ERRORS                    |
  1507.   | 00h     00h  DTLPWRSOMC  NO ADDITIONAL    SENSE INFORMATION            |
  1508.   | 00h     15h       R      NO CURRENT AUDIO STATUS TO RETURN            |
  1509.   | 32h     00h  D      W  O      NO DEFECT SPARE LOCATION AVAILABLE            |
  1510.   | 11h     09h   T      NO GAP FOUND                        |
  1511.   | 01h     00h  D      W  O      NO INDEX/SECTOR SIGNAL                |
  1512.   | 06h     00h  D      WR OM      NO REFERENCE POSITION    FOUND                |
  1513.   +=============================================================================+
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.        Table 71: (continued)
  1520.        +=============================================================================+
  1521.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1522.        | --- ----           ----------------------------------------------------- |
  1523.        | 02h  00h  D   WR OM   NO SEEK COMPLETE                         |
  1524.        | 03h  01h   T           NO WRITE    CURRENT                         |
  1525.        | 28h  00h  DTLPWRSOMC  NOT READY TO READY TRANSITION, MEDIUM MAY HAVE CHANGED|
  1526.        | 5Ah  01h  DT  WR OM   OPERATOR    MEDIUM REMOVAL REQUEST                 |
  1527.        | 5Ah  00h  DTLPWRSOM   OPERATOR    REQUEST    OR STATE CHANGE    INPUT (UNSPECIFIED)  |
  1528.        | 5Ah  03h  DT  W  O    OPERATOR    SELECTED WRITE PERMIT                 |
  1529.        | 5Ah  02h  DT  W  O    OPERATOR    SELECTED WRITE PROTECT                 |
  1530.        | 61h  02h     S     OUT OF FOCUS                         |
  1531.        | 4Eh  00h  DTLPWRSOMC  OVERLAPPED COMMANDS ATTEMPTED                 |
  1532.        | 2Dh  00h   T           OVERWRITE ERROR ON UPDATE IN PLACE             |
  1533.        | 3Bh  05h    L           PAPER JAM                         |
  1534.        | 1Ah  00h  DTLPWRSOMC  PARAMETER LIST LENGTH ERROR                 |
  1535.        | 26h  01h  DTLPWRSOMC  PARAMETER NOT SUPPORTED                     |
  1536.        | 26h  02h  DTLPWRSOMC  PARAMETER VALUE INVALID                     |
  1537.        | 2Ah  00h  DTL WRSOMC  PARAMETERS CHANGED                     |
  1538.        | 03h  00h  DTL W SO    PERIPHERAL DEVICE WRITE FAULT                 |
  1539.        | 50h  02h   T           POSITION    ERROR RELATED TO TIMING                 |
  1540.        | 3Bh  0Ch     S     POSITION    PAST BEGINNING OF MEDIUM             |
  1541.        | 3Bh  0Bh     S     POSITION    PAST END OF MEDIUM                 |
  1542.        | 15h  02h  DT  WR O    POSITIONING ERROR DETECTED BY READ OF MEDIUM         |
  1543.        | 29h  00h  DTLPWRSOMC  POWER ON, RESET,    OR BUS DEVICE RESET OCCURRED         |
  1544.        | 42h  00h  D           POWER-ON    OR SELF-TEST FAILURE (SHOULD USE 40 NN)         |
  1545.        | 1Ch  01h  D      O    PRIMARY DEFECT LIST NOT FOUND                 |
  1546.        | 40h  00h  D           RAM FAILURE (SHOULD USE 40 NN)                 |
  1547.        | 15h  00h  DTL WRSOM   RANDOM POSITIONING ERROR                     |
  1548.        | 3Bh  0Ah     S     READ PAST BEGINNING OF MEDIUM                 |
  1549.        | 3Bh  09h     S     READ PAST END OF    MEDIUM                     |
  1550.        | 11h  01h  DT  W SO    READ RETRIES EXHAUSTED                     |
  1551.        | 14h  01h  DT  WR O    RECORD NOT FOUND                         |
  1552.        | 14h  00h  DTL WRSO    RECORDED    ENTITY NOT FOUND                 |
  1553.        | 18h  02h  D   WR O    RECOVERED DATA -    DATA AUTO-REALLOCATED             |
  1554.        | 18h  05h  D   WR O    RECOVERED DATA -    RECOMMEND REASSIGNMENT             |
  1555.        | 18h  06h  D   WR O    RECOVERED DATA -    RECOMMEND REWRITE             |
  1556.        | 17h  05h  D   WR O    RECOVERED DATA USING PREVIOUS SECTOR ID             |
  1557.        | 18h  03h    R      RECOVERED DATA WITH CIRC                     |
  1558.        | 18h  01h  D   WR O    RECOVERED DATA WITH ERROR CORRECTION & RETRIES APPLIED|
  1559.        | 18h  00h  DT  WR O    RECOVERED DATA WITH ERROR CORRECTION APPLIED         |
  1560.        | 18h  04h    R      RECOVERED DATA WITH L-EC                     |
  1561.        | 17h  03h  DT  WR O    RECOVERED DATA WITH NEGATIVE HEAD OFFSET             |
  1562.        | 17h  00h  DT  WRSO    RECOVERED DATA WITH NO ERROR CORRECTION APPLIED         |
  1563.        | 17h  02h  DT  WR O    RECOVERED DATA WITH POSITIVE HEAD OFFSET             |
  1564.        | 17h  01h  DT  WRSO    RECOVERED DATA WITH RETRIES                 |
  1565.        | 17h  04h      WR O    RECOVERED DATA WITH RETRIES AND/OR CIRC APPLIED         |
  1566.        | 17h  06h  D   W  O    RECOVERED DATA WITHOUT ECC - DATA AUTO-REALLOCATED    |
  1567.        | 17h  07h  D   W  O    RECOVERED DATA WITHOUT ECC - RECOMMEND REASSIGNMENT   |
  1568.        | 17h  08h  D   W  O    RECOVERED DATA WITHOUT ECC - RECOMMEND REWRITE         |
  1569.        | 1Eh  00h  D   W  O    RECOVERED ID WITH ECC CORRECTION                 |
  1570.        | 3Bh  08h   T           REPOSITION ERROR                         |
  1571.        | 36h  00h    L           RIBBON, INK, OR TONER FAILURE                 |
  1572.        | 37h  00h  DTL WRSOMC  ROUNDED PARAMETER                     |
  1573.        | 5Ch  00h  D      O    RPL STATUS CHANGE                     |
  1574.        | 39h  00h  DTL WRSOMC  SAVING PARAMETERS NOT SUPPORTED                 |
  1575.        | 62h  00h     S     SCAN HEAD POSITIONING ERROR                 |
  1576.        | 47h  00h  DTLPWRSOMC  SCSI PARITY ERROR                     |
  1577.        | 54h  00h     P           SCSI TO HOST SYSTEM INTERFACE FAILURE             |
  1578.        | 45h  00h  DTLPWRSOMC  SELECT OR RESELECT FAILURE                 |
  1579.        +=============================================================================+
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.        Table 71: (concluded)
  1586.        +=============================================================================+
  1587.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1588.        | --- ----           ----------------------------------------------------- |
  1589.        | 3Bh  00h   TL           SEQUENTIAL POSITIONING ERROR                 |
  1590.        | 00h  03h   T           SETMARK DETECTED                         |
  1591.        | 3Bh  04h    L           SLEW FAILURE                         |
  1592.        | 09h  03h      WR O    SPINDLE SERVO FAILURE                     |
  1593.        | 5Ch  02h  D      O    SPINDLES    NOT SYNCHRONIZED                 |
  1594.        | 5Ch  01h  D      O    SPINDLES    SYNCHRONIZED                     |
  1595.        | 1Bh  00h  DTLPWRSOMC  SYNCHRONOUS DATA    TRANSFER ERROR                 |
  1596.        | 55h  00h     P           SYSTEM RESOURCE FAILURE                     |
  1597.        | 33h  00h   T           TAPE LENGTH ERROR                     |
  1598.        | 3Bh  03h    L           TAPE OR ELECTRONIC VERTICAL FORMS UNIT NOT READY         |
  1599.        | 3Bh  01h   T           TAPE POSITION ERROR AT BEGINNING-OF-MEDIUM         |
  1600.        | 3Bh  02h   T           TAPE POSITION ERROR AT END-OF-MEDIUM             |
  1601.        | 3Fh  00h  DTLPWRSOMC  TARGET OPERATING    CONDITIONS HAVE    CHANGED             |
  1602.        | 5Bh  01h  DTLPWRSOM   THRESHOLD CONDITION MET                     |
  1603.        | 26h  03h  DTLPWRSOMC  THRESHOLD PARAMETERS NOT    SUPPORTED             |
  1604.        | 2Ch  01h     S     TOO MANY    WINDOWS    SPECIFIED                 |
  1605.        | 09h  00h  DT  WR O    TRACK FOLLOWING ERROR                     |
  1606.        | 09h  01h      WR O    TRACKING    SERVO FAILURE                     |
  1607.        | 61h  01h     S     UNABLE TO ACQUIRE VIDEO                     |
  1608.        | 57h  00h    R      UNABLE TO RECOVER TABLE-OF-CONTENTS             |
  1609.        | 53h  01h   T           UNLOAD TAPE FAILURE                     |
  1610.        | 11h  00h  DT  WRSO    UNRECOVERED READ    ERROR                     |
  1611.        | 11h  04h  D   W  O    UNRECOVERED READ    ERROR -    AUTO REALLOCATE    FAILED         |
  1612.        | 11h  0Bh  D   W  O    UNRECOVERED READ    ERROR -    RECOMMEND REASSIGNMENT         |
  1613.        | 11h  0Ch  D   W  O    UNRECOVERED READ    ERROR -    RECOMMEND REWRITE THE DATA   |
  1614.        | 46h  00h  DTLPWRSOMC  UNSUCCESSFUL SOFT RESET                     |
  1615.        | 59h  00h      O    UPDATED BLOCK READ                     |
  1616.        | 61h  00h     S     VIDEO ACQUISITION ERROR                     |
  1617.        | 50h  00h   T           WRITE APPEND ERROR                     |
  1618.        | 50h  01h   T           WRITE APPEND POSITION ERROR                 |
  1619.        | 0Ch  00h   T     S     WRITE ERROR                         |
  1620.        | 0Ch  02h  D   W  O    WRITE ERROR - AUTO REALLOCATION FAILED             |
  1621.        | 0Ch  01h  D   W  O    WRITE ERROR RECOVERED WITH AUTO REALLOCATION         |
  1622.        | 27h  00h  DT  W  O    WRITE PROTECTED                         |
  1623.        |                                         |
  1624.        | 80h  XXh     \                                     |
  1625.        | THROUGH       >       VENDOR SPECIFIC.                         |
  1626.        | FFh  XX      /                                     |
  1627.        |                                         |
  1628.        | XXh  80h     \                                     |
  1629.        | THROUGH       >       VENDOR SPECIFIC QUALIFICATION OF    STANDARD ASC.         |
  1630.        | XXh  FFh     /                                     |
  1631.        |               ALL CODES NOT SHOWN ARE RESERVED.             |
  1632.        |-----------------------------------------------------------------------------|
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.   T.2.    ASC and    ASCQ in    numerical order
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.              Table 364: ASC    and ASCQ Assignments
  1652.  
  1653.   +=============================================================================+
  1654.   |          D    - DIRECT ACCESS    DEVICE                        |
  1655.   |          .T - SEQUENTIAL ACCESS DEVICE                    |
  1656.   |          .    L - PRINTER DEVICE                        |
  1657.   |          .     P - PROCESSOR DEVICE                        |
  1658.   |          .     .W - WRITE ONCE READ MULTIPLE DEVICE                |
  1659.   |          .     . R - READ ONLY (CD-ROM) DEVICE                |
  1660.   |          .     .  S -    SCANNER    DEVICE                        |
  1661.   |          .     .  .O - OPTICAL MEMORY    DEVICE                    |
  1662.   |          .     .  . M    - MEDIA    CHANGER    DEVICE                    |
  1663.   |          .     .  .  C - COMMUNICATION DEVICE                    |
  1664.   |          .     .  .  .                            |
  1665.   | ASC    ASCQ  DTLPWRSOMC  DESCRIPTION                        |
  1666.   | ---    ----          -----------------------------------------------------    |
  1667.   |  00     00   DTLPWRSOMC  NO ADDITIONAL    SENSE INFORMATION            |
  1668.   |  00     01    T      FILEMARK DETECTED                    |
  1669.   |  00     02    T    S      END-OF-PARTITION/MEDIUM DETECTED            |
  1670.   |  00     03    T      SETMARK DETECTED                    |
  1671.   |  00     04    T    S      BEGINNING-OF-PARTITION/MEDIUM    DETECTED        |
  1672.   |  00     05    T    S      END-OF-DATA DETECTED                    |
  1673.   |  00     06   DTLPWRSOMC  I/O PROCESS TERMINATED                |
  1674.   |  00     11   R          AUDIO    PLAY OPERATION IN PROGRESS            |
  1675.   |  00     12   R          AUDIO    PLAY OPERATION PAUSED                |
  1676.   |  00     13   R          AUDIO    PLAY OPERATION SUCCESSFULLY COMPLETED        |
  1677.   |  00     14   R          AUDIO    PLAY OPERATION STOPPED DUE TO ERROR        |
  1678.   |  00     15   R          NO CURRENT AUDIO STATUS TO RETURN            |
  1679.   |  01     00   DW  O      NO INDEX/SECTOR SIGNAL                |
  1680.   |  02     00   DWR OM      NO SEEK COMPLETE                    |
  1681.   |  03     00   DTL W SO      PERIPHERAL DEVICE WRITE FAULT                |
  1682.   |  03     01    T      NO WRITE CURRENT                    |
  1683.   |  03     02    T      EXCESSIVE WRITE ERRORS                |
  1684.   |  04     00   DTLPWRSOMC  LOGICAL UNIT NOT READY, CAUSE    NOT REPORTABLE        |
  1685.   |  04     01   DTLPWRSOMC  LOGICAL UNIT IS IN PROCESS OF    BECOMING READY        |
  1686.   |  04     02   DTLPWRSOMC  LOGICAL UNIT NOT READY, INITIALIZING COMMAND REQUIRED    |
  1687.   |  04     03   DTLPWRSOMC  LOGICAL UNIT NOT READY, MANUAL INTERVENTION REQUIRED    |
  1688.   |  04     04   DTL    O      LOGICAL UNIT NOT READY, FORMAT IN PROGRESS        |
  1689.   |  05     00   DTL WRSOMC  LOGICAL UNIT DOES NOT    RESPOND    TO SELECTION        |
  1690.   |  06     00   DWR OM  NO  REFERENCE POSITION FOUND                |
  1691.   |  07     00   DTL WRSOM      MULTIPLE PERIPHERAL DEVICES SELECTED            |
  1692.   |  08     00   DTL WRSOMC  LOGICAL UNIT COMMUNICATION FAILURE            |
  1693.   |  08     01   DTL WRSOMC  LOGICAL UNIT COMMUNICATION TIME-OUT            |
  1694.   |  08     02   DTL WRSOMC  LOGICAL UNIT COMMUNICATION PARITY ERROR        |
  1695.   |  09     00   DT  WR O      TRACK    FOLLOWING ERROR                    |
  1696.   |  09     01      WR O      TRA CKING SERVO FAILURE                |
  1697.   |  09     02      WR O      FOC US SERVO FAILURE                    |
  1698.   |  09     03      WR O      SPI NDLE SERVO FAILURE                |
  1699.   +=============================================================================+
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.   Table    364: (continued)
  1718.   +=============================================================================+
  1719.   |          D    - DIRECT ACCESS    DEVICE                        |
  1720.   |          .T - SEQUENTIAL ACCESS DEVICE                    |
  1721.   |          .    L - PRINTER DEVICE                        |
  1722.   |          .     P - PROCESSOR DEVICE                        |
  1723.   |          .     .W - WRITE ONCE READ MULTIPLE DEVICE                |
  1724.   |          .     . R - READ ONLY (CD-ROM) DEVICE                |
  1725.   |          .     .  S -    SCANNER    DEVICE                        |
  1726.   |          .     .  .O - OPTICAL MEMORY    DEVICE                    |
  1727.   |          .     .  . M    - MEDIA    CHANGER    DEVICE                    |
  1728.   |          .     .  .  C - COMMUNICATION DEVICE                    |
  1729.   |          .     .  .  .                            |
  1730.   | ASC    ASCQ  DTLPWRSOMC  DESCRIPTION                        |
  1731.   | ---    ----          -----------------------------------------------------    |
  1732.   |  0A     00   DTLPWRSOMC  ERROR    LOG OVERFLOW                    |
  1733.   |  0B     00                                    |
  1734.   |  0C     00    T     S      WRITE    ERROR                        |
  1735.   |  0C     01   D      W  O      WRITE    ERROR RECOVERED    WITH AUTO REALLOCATION        |
  1736.   |  0C     02   D      W  O      WRITE    ERROR -    AUTO REALLOCATION FAILED        |
  1737.   |  0D     00                                    |
  1738.   |  0E     00                                    |
  1739.   |  0F     00                                    |
  1740.   |  10     00   D      W  O      ID CRC OR ECC    ERROR                    |
  1741.   |  11     00   DT  WRSO      UNRECOVERED READ ERROR                |
  1742.   |  11     01   DT  W SO      READ RETRIES EXHAUSTED                |
  1743.   |  11     02   DT  W SO      ERROR    TOO LONG TO CORRECT                |
  1744.   |  11     03   DT  W SO      MULTIPLE READ    ERRORS                    |
  1745.   |  11     04   D      W  O      UNRECOVERED READ ERROR - AUTO    REALLOCATE FAILED    |
  1746.   |  11     05      WR O      L-EC UNCORRECTABLE ERROR                |
  1747.   |  11     06      WR O      CIRC UNRECOVERED ERROR                |
  1748.   |  11     07      W  O      DATA RESYCHRONIZATION    ERROR                |
  1749.   |  11     08    T      INCOMPLETE BLOCK READ                    |
  1750.   |  11     09    T      NO GAP FOUND                        |
  1751.   |  11     0A   DT     O      MISCORRECTED ERROR                    |
  1752.   |  11     0B   D      W  O      UNRECOVERED READ ERROR - RECOMMEND REASSIGNMENT    |
  1753.   |  11     0C   D      W  O      UNRECOVERED READ ERROR - RECOMMEND REWRITE THE DATA    |
  1754.   |  12     00   D      W  O      ADDRESS MARK NOT FOUND FOR ID    FIELD            |
  1755.   |  13     00   D      W  O      ADDRESS MARK NOT FOUND FOR DATA FIELD            |
  1756.   |  14     00   DTL WRSO      RECORDED ENTITY NOT FOUND                |
  1757.   |  14     01   DT  WR O      RECORD NOT FOUND                    |
  1758.   |  14     02    T      FILEMARK OR SETMARK NOT FOUND                |
  1759.   |  14     03    T      END-OF-DATA NOT FOUND                    |
  1760.   |  14     04    T      BLOCK    SEQUENCE ERROR                    |
  1761.   |  15     00   DTL WRSOM      RANDOM POSITIONING ERROR                |
  1762.   |  15     01   DTL WRSOM      MECHANICAL POSITIONING ERROR                |
  1763.   |  15     02   DT  WR O      POSITIONING ERROR DETECTED BY    READ OF    MEDIUM        |
  1764.   |  16     00   DW     O      DATA SYNCHRONIZATION MARK ERROR            |
  1765.   |  17     00   DT  WRSO      RECOVERED DATA WITH NO ERROR CORRECTION APPLIED    |
  1766.   |  17     01   DT  WRSO      RECOVERED DATA WITH RETRIES                |
  1767.   |  17     02   DT  WR O      RECOVERED DATA WITH POSITIVE HEAD OFFSET        |
  1768.   |  17     03   DT  WR O      RECOVERED DATA WITH NEGATIVE HEAD OFFSET        |
  1769.   |  17     04      WR O      RECOVERED DATA WITH RETRIES AND/OR CIRC APPLIED    |
  1770.   |  17     05   D      WR O      RECOVERED DATA USING PREVIOUS    SECTOR ID        |
  1771.   |  17     06   D      W  O      RECOVERED DATA WITHOUT ECC - DATA AUTO-REALLOCATED    |
  1772.   |  17     07   D      W  O      RECOVERED DATA WITHOUT ECC - RECOMMEND REASSIGNMENT    |
  1773.   |  17     08   D      W  O      RECOVERED DATA WITHOUT ECC - RECOMMEND REWRITE    |
  1774.   |  18     00   DT  WR O      RECOVERED DATA WITH ERROR CORRECTION APPLIED        |
  1775.   |  18     01   D      WR O      RECOVERED DATA WITH ERROR CORRECTION & RETRIES APPLIED|
  1776.   |  18     02   D      WR O      RECOVERED DATA - DATA    AUTO-REALLOCATED        |
  1777.   |  18     03       R      RECOVERED DATA WITH CIRC                |
  1778.   |  18     04       R      RECOVERED DATA WITH LEC                |
  1779.   |  18     05   D      WR O      RECOVERED DATA - RECOMMEND REASSIGNMENT        |
  1780.   |  18     06   D      WR O      RECOVERED DATA - RECOMMEND REWRITE            |
  1781.   +=============================================================================+
  1782.  
  1783.        Table 364: (continued)
  1784.        +=============================================================================+
  1785.        |       D - DIRECT ACCESS DEVICE                         |
  1786.        |       .T -    SEQUENTIAL ACCESS DEVICE                     |
  1787.        |       . L - PRINTER DEVICE                             |
  1788.        |       .  P    - PROCESSOR DEVICE                         |
  1789.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE                 |
  1790.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  1791.        |       .  .     S - SCANNER DEVICE                         |
  1792.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  1793.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  1794.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  1795.        |       .  .     .  .                                 |
  1796.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1797.        | --- ----           ----------------------------------------------------- |
  1798.        |  19  00   D      O    DEFECT LIST ERROR                     |
  1799.        |  19  01   D      O    DEFECT LIST NOT AVAILABLE                 |
  1800.        |  19  02   D      O    DEFECT LIST ERROR IN PRIMARY LIST             |
  1801.        |  19  03   D      O    DEFECT LIST ERROR IN GROWN LIST                 |
  1802.        |  1A  00   DTLPWRSOMC  PARAMETER LIST LENGTH ERROR                 |
  1803.        |  1B  00   DTLPWRSOMC  SYNCHRONOUS DATA    TRANSFER ERROR                 |
  1804.        |  1C  00   D      O    DEFECT LIST NOT FOUND                     |
  1805.        |  1C  01   D      O    PRIMARY DEFECT LIST NOT FOUND                 |
  1806.        |  1C  02   D      O    GROWN DEFECT LIST NOT FOUND                 |
  1807.        |  1D  00   D   W  O    MISCOMPARE DURING VERIFY    OPERATION             |
  1808.        |  1E  00   D   W  O    RECOVERED ID WITH ECC                     |
  1809.        |  1F  00                                     |
  1810.        |  20  00   DTLPWRSOMC  INVALID COMMAND OPERATION CODE                 |
  1811.        |  21  00   DT  WR OM   LOGICAL BLOCK ADDRESS OUT OF RANGE             |
  1812.        |  21  01       M   INVALID ELEMENT ADDRESS                     |
  1813.        |  22  00   D           ILLEGAL FUNCTION    (SHOULD    USE 20 00, 24 00, OR 26    00)  |
  1814.        |  23  00                                     |
  1815.        |  24  00   DTLPWRSOMC  INVALID FIELD IN    CDB                     |
  1816.        |  25  00   DTLPWRSOMC  LOGICAL UNIT NOT    SUPPORTED                 |
  1817.        |  26  00   DTLPWRSOMC  INVALID FIELD IN    PARAMETER LIST                 |
  1818.        |  26  01   DTLPWRSOMC  PARAMETER NOT SUPPORTED                     |
  1819.        |  26  02   DTLPWRSOMC  PARAMETER VALUE INVALID                     |
  1820.        |  26  03   DTLPWRSOMC  THRESHOLD PARAMETERS NOT    SUPPORTED             |
  1821.        |  27  00   DT  W  O    WRITE PROTECTED                         |
  1822.        |  28  00   DTLPWRSOMC  NOT READY TO READY TRANSITION(MEDIUM MAY    HAVE CHANGED)|
  1823.        |  28  01       M   IMPORT OR EXPORT    ELEMENT    ACCESSED             |
  1824.        |  29  00   DTLPWRSOMC  POWER ON, RESET,    OR BUS DEVICE RESET OCCURRED         |
  1825.        |  2A  00   DTL WRSOMC  PARAMETERS CHANGED                     |
  1826.        |  2A  01   DTL WRSOMC  MODE PARAMETERS CHANGED                     |
  1827.        |  2A  02   DTL WRSOMC  LOG PARAMETERS CHANGED                     |
  1828.        |  2B  00   DTLPWRSO C  COPY CANNOT EXECUTE SINCE HOST CANNOT DISCONNECT         |
  1829.        |  2C  00   DTLPWRSOMC  COMMAND SEQUENCE    ERROR                     |
  1830.        |  2C  01     S     TOO MANY    WINDOWS    SPECIFIED                 |
  1831.        |  2C  02     S     INVALID COMBINATION OF WINDOWS SPECIFIED             |
  1832.        |  2D  00    T           OVERWRITE ERROR ON UPDATE IN PLACE             |
  1833.        |  2E  00                                     |
  1834.        |  2F  00   DTLPWRSOMC  COMMANDS    CLEARED    BY ANOTHER INITIATOR             |
  1835.        |  30  00   DT  WR OM   INCOMPATIBLE MEDIUM INSTALLED                 |
  1836.        |  30  01   DT  WR O    CANNOT READ MEDIUM - UNKNOWN FORMAT             |
  1837.        |  30  02   DT  WR O    CANNOT READ MEDIUM - INCOMPATIBLE FORMAT             |
  1838.        |  30  03   DT           CLEANING    CARTRIDGE INSTALLED                 |
  1839.        |  31  00   DT  W  O    MEDIUM FORMAT CORRUPTED                     |
  1840.        |  31  01   D L      O    FORMAT COMMAND FAILED                     |
  1841.        |  32  00   D   W  O    NO DEFECT SPARE LOCATION    AVAILABLE             |
  1842.        |  32  01   D   W  O    DEFECT LIST UPDATE FAILURE                 |
  1843.        |  33  00    T           TAPE LENGTH ERROR                     |
  1844.        |  34  00                                     |
  1845.        |  35  00                                     |
  1846.        |  36  00     L           RIBBON, INK, OR TONER FAILURE                 |
  1847.        +=============================================================================+
  1848.  
  1849.        Table 364: (continued)
  1850.        +=============================================================================+
  1851.        |       D - DIRECT ACCESS DEVICE                         |
  1852.        |       .T -    SEQUENTIAL ACCESS DEVICE                     |
  1853.        |       . L - PRINTER DEVICE                             |
  1854.        |       .  P    - PROCESSOR DEVICE                         |
  1855.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE                 |
  1856.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  1857.        |       .  .     S - SCANNER DEVICE                         |
  1858.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  1859.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  1860.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  1861.        |       .  .     .  .                                 |
  1862.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1863.        | --- ----           ----------------------------------------------------- |
  1864.        |  37  00   DTL WRSOMC  ROUNDED PARAMETER                     |
  1865.        |  38  00                                     |
  1866.        |  39  00   DTL WRSOMC  SAVING PARAMETERS NOT SUPPORTED                 |
  1867.        |  3A  00   DTL WRSOM   MEDIUM NOT PRESENT                     |
  1868.        |  3B  00    TL           SEQUENTIAL POSITIONING ERROR                 |
  1869.        |  3B  01    T           TAPE POSITION ERROR AT BEGINNING-OF-MEDIUM         |
  1870.        |  3B  02    T           TAPE POSITION ERROR AT END-OF-MEDIUM             |
  1871.        |  3B  03     L           TAPE OR ELECTRONIC VERTICAL FORMS UNIT NOT READY         |
  1872.        |  3B  04     L           SLEW FAILURE                         |
  1873.        |  3B  05     L           PAPER JAM                         |
  1874.        |  3B  06     L           FAILED TO SENSE TOP-OF-FORM                 |
  1875.        |  3B  07     L           FAILED TO SENSE BOTTOM-OF-FORM                 |
  1876.        |  3B  08    T           REPOSITION ERROR                         |
  1877.        |  3B  09     S     READ PAST END OF    MEDIUM                     |
  1878.        |  3B  0A     S     READ PAST BEGINNING OF MEDIUM                 |
  1879.        |  3B  0B     S     POSITION    PAST END OF MEDIUM                 |
  1880.        |  3B  0C     S     POSITION    PAST BEGINNING OF MEDIUM             |
  1881.        |  3B  0D       M   MEDIUM DESTINATION ELEMENT FULL                 |
  1882.        |  3B  0E       M   MEDIUM SOURCE ELEMENT EMPTY                 |
  1883.        |  3C  00                                     |
  1884.        |  3D  00   DTLPWRSOMC  INVALID BITS IN IDENTIFY    MESSAGE                 |
  1885.        |  3E  00   DTLPWRSOMC  LOGICAL UNIT HAS    NOT SELF-CONFIGURED YET             |
  1886.        |  3F  00   DTLPWRSOMC  TARGET OPERATING    CONDITIONS HAVE    CHANGED             |
  1887.        |  3F  01   DTLPWRSOMC  MICROCODE HAS BEEN CHANGED                 |
  1888.        |  3F  02   DTLPWRSOMC  CHANGED OPERATING DEFINITION                 |
  1889.        |  3F  03   DTLPWRSOMC  INQUIRY DATA HAS    CHANGED                     |
  1890.        |  40  00   D           RAM FAILURE (SHOULD USE 40 NN)                 |
  1891.        |  40  NN   DTLPWRSOMC  DIAGNOSTIC FAILURE ON COMPONENT NN (80H-FFH)         |
  1892.        |  41  00   D           DATA PATH FAILURE (SHOULD USE 40    NN)             |
  1893.        |  42  00   D           POWER-ON    OR SELF-TEST FAILURE (SHOULD USE 40 NN)         |
  1894.        |  43  00   DTLPWRSOMC  MESSAGE ERROR                         |
  1895.        |  44  00   DTLPWRSOMC  INTERNAL    TARGET FAILURE                     |
  1896.        |  45  00   DTLPWRSOMC  SELECT OR RESELECT FAILURE                 |
  1897.        |  46  00   DTLPWRSOMC  UNSUCCESSFUL SOFT RESET                     |
  1898.        |  47  00   DTLPWRSOMC  SCSI PARITY ERROR                     |
  1899.        |  48  00   DTLPWRSOMC  INITIATOR DETECTED ERROR    MESSAGE    RECEIVED         |
  1900.        |  49  00   DTLPWRSOMC  INVALID MESSAGE ERROR                     |
  1901.        |  4A  00   DTLPWRSOMC  COMMAND PHASE ERROR                     |
  1902.        |  4B  00   DTLPWRSOMC  DATA PHASE ERROR                         |
  1903.        |  4C  00   DTLPWRSOMC  LOGICAL UNIT FAILED SELF-CONFIGURATION             |
  1904.        |  4D  00                                     |
  1905.        |  4E  00   DTLPWRSOMC  OVERLAPPED COMMANDS ATTEMPTED                 |
  1906.        |  4F  00                                     |
  1907.        |  50  00    T           WRITE APPEND ERROR                     |
  1908.        |  50  01    T           WRITE APPEND POSITION ERROR                 |
  1909.        |  50  02    T           POSITION    ERROR RELATED TO TIMING                 |
  1910.        |  51  00    T      O    ERASE FAILURE                         |
  1911.        |  52  00    T           CARTRIDGE FAULT                         |
  1912.        +=============================================================================+
  1913.  
  1914.  
  1915.        Table 364: (continued)
  1916.        +=============================================================================+
  1917.        |       D - DIRECT ACCESS DEVICE                         |
  1918.        |       .T -    SEQUENTIAL ACCESS DEVICE                     |
  1919.        |       . L - PRINTER DEVICE                             |
  1920.        |       .  P    - PROCESSOR DEVICE                         |
  1921.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE                 |
  1922.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  1923.        |       .  .     S - SCANNER DEVICE                         |
  1924.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  1925.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  1926.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  1927.        |       .  .     .  .                                 |
  1928.        | ASC ASCQ  DTLPWRSOMC  DESCRIPTION                         |
  1929.        | --- ----           ----------------------------------------------------- |
  1930.        |  53  00   DTL WRSOM   MEDIA LOAD OR EJECT FAILED                 |
  1931.        |  53  01    T           UNLOAD TAPE FAILURE                     |
  1932.        |  53  02   DT  WR OM   MEDIUM REMOVAL PREVENTED                     |
  1933.        |  54  00      P           SCSI TO HOST SYSTEM INTERFACE FAILURE             |
  1934.        |  55  00      P           SYSTEM RESOURCE FAILURE                     |
  1935.        |  56  00                                     |
  1936.        |  57  00    R      UNABLE TO RECOVER TABLE-OF-CONTENTS             |
  1937.        |  58  00     O           GENERATION DOES NOT EXIST                 |
  1938.        |  59  00     O           UPDATED BLOCK READ                     |
  1939.        |  5A  00   DTLPWRSOM   OPERATOR    REQUEST    OR STATE CHANGE    INPUT (UNSPECIFIED)  |
  1940.        |  5A  01   DT  WR OM   OPERATOR    MEDIUM REMOVAL REQUEST                 |
  1941.        |  5A  02   DT  W  O    OPERATOR    SELECTED WRITE PROTECT                 |
  1942.        |  5A  03   DT  W  O    OPERATOR    SELECTED WRITE PERMIT                 |
  1943.        |  5B  00   DTLPWRSOM   LOG EXCEPTION                         |
  1944.        |  5B  01   DTLPWRSOM   THRESHOLD CONDITION MET                     |
  1945.        |  5B  02   DTLPWRSOM   LOG COUNTER AT MAXIMUM                     |
  1946.        |  5B  03   DTLPWRSOM   LOG LIST    CODES EXHAUSTED                     |
  1947.        |  5C  00   D   O       RPL STATUS CHANGE                     |
  1948.        |  5C  01   D   O       SPINDLES    SYNCHRONIZED                     |
  1949.        |  5C  02   D   O       SPINDLES    NOT SYNCHRONIZED                 |
  1950.        |  5D  00                                     |
  1951.        |  5E  00                                     |
  1952.        |  5F  00                                     |
  1953.        |  60  00     S     LAMP FAILURE                         |
  1954.        |  61  00     S     VIDEO ACQUISITION ERROR                     |
  1955.        |  61  01     S     UNABLE TO ACQUIRE VIDEO                     |
  1956.        |  61  02     S     OUT OF FOCUS                         |
  1957.        |  62  00     S     SCAN HEAD POSITIONING ERROR                 |
  1958.        |  63  00    R      END OF USER AREA    ENCOUNTERED ON THIS TRACK         |
  1959.        |  64  00    R      ILLEGAL MODE FOR    THIS TRACK                 |
  1960.        |  65  00                                     |
  1961.        |  66  00                                     |
  1962.        |  67  00                                     |
  1963.        |  68  00                                     |
  1964.        |  69  00                                     |
  1965.        |  6A  00                                     |
  1966.        |  6B  00                                     |
  1967.        |  6C  00                                     |
  1968.        |  6D  00                                     |
  1969.        |  6E  00                                     |
  1970.        |  6F  00                                     |
  1971.        +=============================================================================+
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.   Table    364: (concluded)
  1982.   +=============================================================================+
  1983.   |          D    - DIRECT ACCESS    DEVICE                        |
  1984.   |          .T - SEQUENTIAL ACCESS DEVICE                    |
  1985.   |          .    L - PRINTER DEVICE                        |
  1986.   |          .     P - PROCESSOR DEVICE                        |
  1987.   |          .     .W - WRITE ONCE READ MULTIPLE DEVICE                |
  1988.   |          .     . R - READ ONLY (CD-ROM) DEVICE                |
  1989.   |          .     .  S -    SCANNER    DEVICE                        |
  1990.   |          .     .  .O - OPTICAL MEMORY    DEVICE                    |
  1991.   |          .     .  . M    - MEDIA    CHANGER    DEVICE                    |
  1992.   |          .     .  .  C - COMMUNICATION DEVICE                    |
  1993.   |          .     .  .  .                            |
  1994.   | ASC    ASCQ  DTLPWRSOMC  DESCRIPTION                        |
  1995.   | ---    ----          -----------------------------------------------------    |
  1996.   |  70     00                                    |
  1997.   |  71     00                                    |
  1998.   |  72     00                                    |
  1999.   |  73     00                                    |
  2000.   |  74     00                                    |
  2001.   |  75     00                                    |
  2002.   |  76     00                                    |
  2003.   |  77     00                                    |
  2004.   |  78     00                                    |
  2005.   |  79     00                                    |
  2006.   |  7A     00                                    |
  2007.   |  7B     00                                    |
  2008.   |  7C     00                                    |
  2009.   |  7D     00                                    |
  2010.   |  7E     00                                    |
  2011.   |  7F     00                                    |
  2012.   |                                        |
  2013.   |  80     xxh \                                    |
  2014.   |   THROUGH >     VENDOR    SPECIFIC.                        |
  2015.   |  FF     xxh /                                    |
  2016.   |                                        |
  2017.   |  xxh 80 \                                    |
  2018.   |  THROUGH >    VENDOR SPECIFIC    QUALIFICATION OF STANDARD ASC.            |
  2019.   |  xxh FF /                                    |
  2020.   |          ALL CODES NOT    SHOWN OR BLANK ARE RESERVED.            |
  2021.   +=============================================================================+
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.   U.  A    SCSI command code quick    reference
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.   Table    365 is a numerical order listing of the    command    operation codes.
  2048.  
  2049.               Table    365: SCSI-2 Operation Codes
  2050.  
  2051.   +=============================================================================+
  2052.   |          D    - DIRECT ACCESS    DEVICE                 Device Column Key    |
  2053.   |          .T - SEQUENTIAL ACCESS DEVICE             M = Mandatory    |
  2054.   |          .    L - PRINTER DEVICE                 O = Optional    |
  2055.   |          .     P - PROCESSOR DEVICE                 V = Vendor    Specific|
  2056.   |          .     .W - WRITE ONCE READ MULTIPLE DEVICE         R = Reserved    |
  2057.   |          .     . R - READ ONLY (CD-ROM) DEVICE                |
  2058.   |          .     .  S -    SCANNER    DEVICE                        |
  2059.   |          .     .  .O - OPTICAL MEMORY    DEVICE                    |
  2060.   |          .     .  . M    - MEDIA    CHANGER    DEVICE                    |
  2061.   |          .     .  .  C - COMMUNICATION DEVICE                    |
  2062.   |          .     .  .  .                            |
  2063.   |       OP DTLPWRSOMC Description                        |
  2064.   |----------+----------+-------------------------------------------------------|
  2065.   |       00 MMMMMMMMMM TEST UNIT READY                    |
  2066.   |       01  M     REWIND                            |
  2067.   |       01 O    V OO OO     REZERO    UNIT                        |
  2068.   |       02 VVVVVV  V                                |
  2069.   |       03 MMMMMMMMMM REQUEST SENSE                        |
  2070.   |       04    O     FORMAT                            |
  2071.   |       04 M         O     FORMAT    UNIT                        |
  2072.   |       05 VMVVVV  V     READ BLOCK LIMITS                    |
  2073.   |       06 VVVVVV  V                                |
  2074.   |       07          O     INITIALIZE ELEMENT STATUS                |
  2075.   |       07 OVV O  OV     REASSIGN BLOCKS                    |
  2076.   |       08           M GET MESSAGE(06)                    |
  2077.   |       08 OMV OO OV     READ(06)                        |
  2078.   |       08     O     RECEIVE                        |
  2079.   |       09 VVVVVV  V                                |
  2080.   |       0A    M     PRINT                            |
  2081.   |       0A           M SEND MESSAGE(06)                    |
  2082.   |       0A     M     SEND(06)                        |
  2083.   |       0A OM  O  OV     WRITE(06)                        |
  2084.   |       0B O      OO OV     SEEK(06)                        |
  2085.   |       0B    O     SLEW AND PRINT                        |
  2086.   |       0C VVVVVV  V                                |
  2087.   |       0D VVVVVV  V                                |
  2088.   |       0E VVVVVV  V                                |
  2089.   |       0F VOVVVV  V     READ REVERSE                        |
  2090.   |       10    O O     SYNCHRONIZE BUFFER                    |
  2091.   |       10 VM VVV     WRITE FILEMARKS                    |
  2092.   |       11 VMVVVV     SPACE                            |
  2093.   |       12 MMMMMMMMMM INQUIRY                        |
  2094.   |       13 VOVVVV     VERIFY(06)                        |
  2095.   |       14 VOOVVV     RECOVER BUFFERED DATA                    |
  2096.   |       15 OMO OOOOOO MODE SELECT(06)                    |
  2097.   |       16 M      MM MO     RESERVE                        |
  2098.   |       16  MM   M     RESERVE UNIT                        |
  2099.   |       17 M      MM MO     RELEASE                        |
  2100.   |       17  MM   M     RELEASE UNIT                        |
  2101.   |       18 OOOOOOOO     COPY                            |
  2102.   |       19 VMVVVV     ERASE                            |
  2103.   |       1A OMO OOOOOO MODE SENSE(06)                        |
  2104.   |       1B  O     LOAD UNLOAD                        |
  2105.   |       1B        O     SCAN                            |
  2106.   |       1B    O     STOP PRINT                        |
  2107.   |       1B O      OO O     STOP START UNIT                    |
  2108.   +=============================================================================+
  2109.  
  2110.  
  2111.  
  2112.  
  2113.        Table 365: (continued)
  2114.        +=============================================================================+
  2115.        |       D - DIRECT ACCESS DEVICE              Device Column    Key  |
  2116.        |       .T -    SEQUENTIAL ACCESS DEVICE          M = Mandatory         |
  2117.        |       . L - PRINTER DEVICE                  O = Optional         |
  2118.        |       .  P    - PROCESSOR DEVICE              V = Vendor Specific|
  2119.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE      R = Reserved         |
  2120.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  2121.        |       .  .     S - SCANNER DEVICE                         |
  2122.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  2123.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  2124.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  2125.        |       .  .     .  .                                 |
  2126.        |    OP DTLPWRSOMC Description                         |
  2127.        |----------+----------+-------------------------------------------------------|
  2128.        |    1C OOOOOOOOOO RECEIVE DIAGNOSTIC RESULTS                 |
  2129.        |    1D MMMMMMMMMM SEND DIAGNOSTIC                         |
  2130.        |    1E OO  OO OO  PREVENT ALLOW MEDIUM REMOVAL                 |
  2131.        |    1F                                     |
  2132.        |    20 V   VV V                                 |
  2133.        |    21 V   VV V                                 |
  2134.        |    22 V   VV V                                 |
  2135.        |    23 V   VV V                                 |
  2136.        |    24 V   VVM    SET WINDOW                         |
  2137.        |    25     O    GET WINDOW                         |
  2138.        |    25 M   M  M   READ CAPACITY                         |
  2139.        |    25    M     READ CD-ROM CAPACITY                     |
  2140.        |    26 V   VV                                 |
  2141.        |    27 V   VV                                 |
  2142.        |    28        O GET MESSAGE(10)                         |
  2143.        |    28 M   MMMM   READ(10)                             |
  2144.        |    29 V   VV O   READ GENERATION                         |
  2145.        |    2A        O SEND MESSAGE(10)                         |
  2146.        |    2A     O    SEND(10)                             |
  2147.        |    2A M   M  M   WRITE(10)                             |
  2148.        |    2B  O          LOCATE                             |
  2149.        |    2B       O  POSITION TO ELEMENT                     |
  2150.        |    2B O   OO O   SEEK(10)                             |
  2151.        |    2C V      O   ERASE(10)                             |
  2152.        |    2D V   O  O   READ UPDATED BLOCK                     |
  2153.        |    2E O   O  O   WRITE AND    VERIFY(10)                     |
  2154.        |    2F O   OO O   VERIFY(10)                         |
  2155.        |    30 O   OO O   SEARCH DATA HIGH(10)                     |
  2156.        |    31     O    OBJECT POSITION                         |
  2157.        |    31 O   OO O   SEARCH DATA EQUAL(10)                     |
  2158.        |    32 O   OO O   SEARCH DATA LOW(10)                     |
  2159.        |    33 O   OO O   SET LIMITS(10)                         |
  2160.        |    34     O    GET DATA BUFFER STATUS                     |
  2161.        |    34 O   OO O   PRE-FETCH                             |
  2162.        |    34  O          READ POSITION                         |
  2163.        |    35 O   OO O   SYNCHRONIZE CACHE                         |
  2164.        |    36 O   OO O   LOCK UNLOCK CACHE                         |
  2165.        |    37 O      O   READ DEFECT DATA(10)                     |
  2166.        |    38     O  O   MEDIUM SCAN                         |
  2167.        |    39 OOOOOOOO   COMPARE                             |
  2168.        |    3A OOOOOOOO   COPY AND VERIFY                         |
  2169.        |    3B OOOOOOOOOO WRITE BUFFER                         |
  2170.        |    3C OOOOOOOOOO READ BUFFER                         |
  2171.        |    3D     O  O   UPDATE BLOCK                         |
  2172.        |    3E O   OO O   READ LONG                             |
  2173.        |    3F O   O  O   WRITE LONG                         |
  2174.        +=============================================================================+
  2175.  
  2176.  
  2177.  
  2178.  
  2179.        Table 365: (continued)
  2180.        +=============================================================================+
  2181.        |       D - DIRECT ACCESS DEVICE              Device Column    Key  |
  2182.        |       .T -    SEQUENTIAL ACCESS DEVICE          M = Mandatory         |
  2183.        |       . L - PRINTER DEVICE                  O = Optional         |
  2184.        |       .  P    - PROCESSOR DEVICE              V = Vendor Specific|
  2185.        |       .  .W - WRITE ONCE READ MULTIPLE DEVICE      R = Reserved         |
  2186.        |       .  .    R - READ ONLY (CD-ROM) DEVICE                     |
  2187.        |       .  .     S - SCANNER DEVICE                         |
  2188.        |       .  .     .O - OPTICAL MEMORY DEVICE                     |
  2189.        |       .  .     . M - MEDIA CHANGER DEVICE                     |
  2190.        |       .  .     .  C -    COMMUNICATION DEVICE                     |
  2191.        |       .  .     .  .                                 |
  2192.        |    OP DTLPWRSOMC Description                         |
  2193.        |----------+----------+-------------------------------------------------------|
  2194.        |    40 OOOOOOOOOO CHANGE DEFINITION                         |
  2195.        |    41 O          WRITE SAME                         |
  2196.        |    42    O     READ SUB-CHANNEL                         |
  2197.        |    43    O     READ TOC                             |
  2198.        |    44    O     READ HEADER                         |
  2199.        |    45    O     PLAY AUDIO(10)                         |
  2200.        |    46                                     |
  2201.        |    47    O     PLAY AUDIO MSF                         |
  2202.        |    48    O     PLAY AUDIO TRACK INDEX                     |
  2203.        |    49    O     PLAY TRACK RELATIVE(10)                     |
  2204.        |    4A                                     |
  2205.        |    4B    O     PAUSE RESUME                         |
  2206.        |    4C OOOOOOOOOO LOG SELECT                         |
  2207.        |    4D OOOOOOOOOO LOG SENSE                             |
  2208.        |    4E                                     |
  2209.        |    4F                                     |
  2210.        |    50                                     |
  2211.        |    51                                     |
  2212.        |    52                                     |
  2213.        |    53                                     |
  2214.        |    54                                     |
  2215.        |    55 OOO OOOOOO MODE SELECT(10)                         |
  2216.        |    56                                     |
  2217.        |    57                                     |
  2218.        |    58                                     |
  2219.        |    59                                     |
  2220.        |    5A OOO OOOOOO MODE SENSE(10)                         |
  2221.        |    5B                                     |
  2222.        |    5C                                     |
  2223.        |    5D                                     |
  2224.        |    5E                                     |
  2225.        |    5F                                     |
  2226.        +=============================================================================+
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.   Table    365: (concluded)
  2246.   +=============================================================================+
  2247.   |          D    - DIRECT ACCESS    DEVICE                 Device Column Key    |
  2248.   |          .T - SEQUENTIAL ACCESS DEVICE             M = Mandatory    |
  2249.   |          .    L - PRINTER DEVICE                 O = Optional    |
  2250.   |          .     P - PROCESSOR DEVICE                 V = Vendor    Specific|
  2251.   |          .     .W - WRITE ONCE READ MULTIPLE DEVICE         R = Reserved    |
  2252.   |          .     . R - READ ONLY (CD-ROM) DEVICE                |
  2253.   |          .     .  S -    SCANNER    DEVICE                        |
  2254.   |          .     .  .O - OPTICAL MEMORY    DEVICE                    |
  2255.   |          .     .  . M    - MEDIA    CHANGER    DEVICE                    |
  2256.   |          .     .  .  C - COMMUNICATION DEVICE                    |
  2257.   |          .     .  .  .                            |
  2258.   |       OP DTLPWRSOMC Description                        |
  2259.   |----------+----------+-------------------------------------------------------|
  2260.   |       A0                                    |
  2261.   |       A1                                    |
  2262.   |       A2                                    |
  2263.   |       A3                                    |
  2264.   |       A4                                    |
  2265.   |       A5          M     MOVE MEDIUM                        |
  2266.   |       A5       O     PLAY AUDIO(12)                        |
  2267.   |       A6          O     EXCHANGE MEDIUM                    |
  2268.   |       A7                                    |
  2269.   |       A8           O GET MESSAGE(12)                    |
  2270.   |       A8      OO O     READ(12)                        |
  2271.   |       A9       O     PLAY TRACK RELATIVE(12)                |
  2272.   |       AA           O SEND MESSAGE(12)                    |
  2273.   |       AA      O  O     WRITE(12)                        |
  2274.   |       AB                                    |
  2275.   |       AC         O     ERASE(12)                        |
  2276.   |       AD                                    |
  2277.   |       AE      O  O     WRITE AND VERIFY(12)                    |
  2278.   |       AF      OO O     VERIFY(12)                        |
  2279.   |       B0      OO O     SEARCH    DATA HIGH(12)                    |
  2280.   |       B1      OO O     SEARCH    DATA EQUAL(12)                    |
  2281.   |       B2      OO O     SEARCH    DATA LOW(12)                    |
  2282.   |       B3      OO O     SET LIMITS(12)                        |
  2283.   |       B4                                    |
  2284.   |       B5                                    |
  2285.   |       B5          O     REQUEST VOLUME    ELEMENT    ADDRESS                |
  2286.   |       B6                                    |
  2287.   |       B6          O     SEND VOLUME TAG                    |
  2288.   |       B7         O     READ DEFECT DATA(12)                    |
  2289.   |       B8                                    |
  2290.   |       B8          O     READ ELEMENT STATUS                    |
  2291.   |       B9                                    |
  2292.   |       BA                                    |
  2293.   |       BB                                    |
  2294.   |       BC                                    |
  2295.   |       BD                                    |
  2296.   |       BE                                    |
  2297.   |       BF                                    |
  2298.   +=============================================================================+
  2299.