man(1) Manual page archive


     SCSI(4)                                                   SCSI(4)

     NAME
          scsi - SCSI interface

     SYNOPSIS
          #include <scsi.h>

     DESCRIPTION
          The special file provides a low level interface to a SCSI
          bus.  Commands are transmitted to the bus by write; the
          response to each command is received with read(2). The for-
          mat of a command is

               unsigned long tran_id;     /* transaction id */
               unsigned char target;      /* SCSI id of target device */
               unsigned char flags;       /* flags for this transaction */
               unsigned long nreturn;     /* number of bytes to be read back */
               char cmd[10];              /* SCSI command */
               char data[];               /* optional data */

          Thus, to send n bytes of data, the byte count for write
          should be n+20. Possible flags are SCSI_WR (data goes from
          host to SCSI), SCSI_RD (data goes from SCSI to host),
          SCSI_BRESET (reset the SCSI bus), SCSI_RESET (reset the con-
          troller), and SCSI_SENSE (return extended sense data on
          error).  For most controllers, SCSI_BRESET implies
          SCSI_RESET.  Flags are OR'ed together, and there must be
          exactly one of SCSI_WR and SCSI_RD.  The SCSI command should
          terminate within a small time (currently 10 seconds); a
          longer limit (300 seconds) can be specified by using
          SCSI_LTMOUT.

          The data read is structured as

               unsigned long tran_id;     /* transaction id */
               unsigned char status;      /* scsi status byte */
               unsigned char message;     /* scsi message byte */
               unsigned char flags;       /* flags for this transaction */
               unsigned char c_type;      /* 1=td 2=us */
               unsigned short c_reg1;     /* td=sa, us=csr */
               unsigned short c_reg2;     /* td=mscp, us=per */
               unsigned char sense[22];   /* extended sense data */
               char pad[2];
               char data[];               /* any data */

          Thus, to read n bytes of data. the byte count to read should
          be n+36. If flags has the SCSI_CERR bit set, there was a
          controller error, which is described by the c_ fields.  The
          values of csr (or sa) and per (or mscp) are documented in
          the interface manual for the U.S. Design 1158 Unibus con-
          troller (or T.D. Systems Viking controller).  If the

     SCSI(4)                                                   SCSI(4)

          SCSI_SENSE bit was set in the write, and the status byte
          shows a check condition, an attempt is made to get extended
          sense information.  If the attempt succeeds the SCSI_SENSE
          is set in flags. Otherwise, the status and message bytes for
          the failed attempt are placed in sense[0] and sense[1]
          respectively.

          The transaction id identifies which write caused the results
          for this read. This will become more important when multiple
          simultaneous transactions are allowed.

     FILES
     SEE ALSO
          scsish(8)