home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / linux / atari / source / source.lzh / atari-linux-0.01pl3 / drivers / scsi / atari_scsi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  6.6 KB  |  189 lines

  1. /*
  2.  * atari_scsi.h -- Header file for the Atari native SCSI driver
  3.  *
  4.  * Copyright 1994 Roman Hodek
  5.  *   EMail: rnhodek@cip.informatik.uni-erlangen.de (Internet)
  6.  *      or: Roman_Hodek@n.maus.de (MausNet, NO mail > 16 KB!)
  7.  *
  8.  * (Loosely based on the work of Robert De Vries' team)
  9.  *
  10.  * This file is subject to the terms and conditions of the GNU General Public
  11.  * License.  See the file README.legal in the main directory of this archive
  12.  * for more details.
  13.  *
  14.  */
  15.  
  16.  
  17. #ifndef ATARI_SCSI_H
  18. #define ATARI_SCSI_H
  19.  
  20. /* IMPORTANT NOTE:
  21.  * ===============
  22.  *
  23.  * The NCR5380 is said to have a nasty characteristic when
  24.  * re-programming the DMA while a command is ongoing (see comment in
  25.  * atari_NCR5380.c in function NCR5380_transfer_dma()). The author of
  26.  * the generic 5380 driver, Drew Eckhardt, provided a trick to
  27.  * compensate that. It is activated by defining the symbol
  28.  * 'READ_OVERRUNS'. The problem in short: If the end of DMA doesn't
  29.  * happen at the same time as a SCSI phase change, the 5380 may loose
  30.  * one byte. This is compensated by programming the DMA for 2 bytes
  31.  * less than wanted and transfer these last two bytes by hand. This
  32.  * also implies that the READ_OVERRUNS trick cannot work on the
  33.  * Falcon, since the ST-DMA can only process 512 byte blocks and hence
  34.  * not two bytes less. This in turns implies that no scatter-gather
  35.  * operations are possible, which causes a drastic loss of performance :-(
  36.  *
  37.  * While testing the SCSI driver, I wondered that such overruns
  38.  * never occured. After the driver worked reliably, I tried without
  39.  * READ_OVERRUNS and that works fine, too. But -- I can't be sure that
  40.  * this is the case with all machines. Maybe may TT is a exception and
  41.  * has a (maybe newer) 5380 that doesn't have the problem. So I
  42.  * decided to make the overrun fix user-definable by the symbol
  43.  * 'I_HAVE_OVERRUNS', defined below. It can have the values 0 to 3:
  44.  *
  45.  *   - 0:
  46.  *     This means, you also never have seen overruns like me and have no
  47.  *     problems with read faults or the like. The READ_OVERRUNS trick
  48.  *     is turned off (i.e. the whole transfer is done by DMA, no two
  49.  *     polled bytes). If this value is choosen, scatter-gather is
  50.  *     enabled (on both TT and Falcon).
  51.  *
  52.  *   - 1:
  53.  *     You don't know if you have overruns or not. For TT's, the
  54.  *     READ_OVERRUNS trick is used and scatter-gather remains
  55.  *     enabled. If overruns should occur, you get kernel messages or
  56.  *     other effects (see below). THIS MODE MUST NOT BE SELECTED ON
  57.  *     THE FALCON! Defining READ_OVERRUNS is not possible there.
  58.  *        Every time a overrun really occurs you receive a kernel
  59.  *       message: "overrun handled (dont't worry)". If you see this
  60.  *       message, you have overruns for sure and it'd be better to
  61.  *       define I_HAVE_OVERRUNS to 2. Another symptom of read overruns
  62.  *       may be suprious -- but not explicitly reported -- read faults,
  63.  *       causing programs of all sorts to get SIGSEGV's, bad kernel
  64.  *       traps and more abnormalities.  Characteristic is that this
  65.  *       doesn`t happen always on the same binaries.
  66.  *        If you see such symptoms and have to turn on the
  67.  *     overrun trick and the symptoms go away by that, please report
  68.  *     this to
  69.  *        rnhodek@cip.informatik.uni-erlangen.de
  70.  *     or
  71.  *        Roman_Hodek@n.maus.de
  72.  *     If many people have such overruns, the overrun trick may become
  73.  *     the default.
  74.  *
  75.  *   - 2:
  76.  *     You have a TT and surely know that you have overruns and need
  77.  *     the overrun trick for proper operation. THIS MODE MUST NOT BE
  78.  *     SELECTED ON THE FALCON!
  79.  *
  80.  *   - 3:
  81.  *     This mode should be selected by Falcon users that have
  82.  *     overruns. Overruns are not handled (this is not possible on the
  83.  *     Falcon), but their deeper reason is eleminated by disabling
  84.  *     scatter-gather operations. This means a performance loss of up
  85.  *     to 90% (sorry!).
  86.  *
  87.  *                                                               Roman
  88.  *
  89.  */
  90.  
  91. /* Select here whether you have overruns:
  92.  *  0 = no (TT and Falcon)
  93.  *  1 = don't know (TT)
  94.  *  2 = yes (TT)
  95.  *  3 = yes (Falcon)
  96.  */
  97. #define    I_HAVE_OVERRUNS    0
  98.  
  99. #ifndef ASM
  100. int atari_scsi_abort (Scsi_Cmnd *, int);
  101. int atari_scsi_detect (int);
  102. const char *atari_scsi_info (void);
  103. int atari_scsi_queue_command (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
  104. int atari_scsi_reset (Scsi_Cmnd *);
  105.  
  106. /* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher
  107.  * values may work, too; try it! (but it costs memory!) */
  108.  
  109. #ifndef CMD_PER_LUN
  110. #define CMD_PER_LUN 16
  111. #endif
  112.  
  113. #ifndef CAN_QUEUE
  114. #define CAN_QUEUE 16
  115. #endif
  116.  
  117. #ifndef I_HAVE_OVERRUNS
  118. #error I_HAVE_OVERRUNS is not defined. See comment at start of atari_scsi.h
  119. #endif
  120.  
  121.  
  122. #ifdef HOSTS_C
  123.  
  124. #if I_HAVE_OVERRUNS > 2
  125.  
  126. #define ATARI_SCSI {                            \
  127.   "Atari native SCSI",                            \
  128.   atari_scsi_detect,                            \
  129.   atari_scsi_info,                                \
  130.   /* command */ NULL,                            \
  131.   atari_scsi_queue_command,                        \
  132.   atari_scsi_abort,                                \
  133.   atari_scsi_reset,                                \
  134.   /* slave_attach */ NULL,                        \
  135.   /* bios_param */ NULL,                        \
  136.   /* can queue */             CAN_QUEUE,            \
  137.   /* host_id */                7,                    \
  138.   /* scatter gather */         SG_NONE,            \
  139.   /* cmd per lun */         CMD_PER_LUN,        \
  140.   /* present */             0,                    \
  141.   /* unchecked ISA DMA */    0 }
  142.  
  143. #else
  144.  
  145. #define ATARI_SCSI {                            \
  146.   "Atari native SCSI",                            \
  147.   atari_scsi_detect,                            \
  148.   atari_scsi_info,                                \
  149.   /* command */ NULL,                            \
  150.   atari_scsi_queue_command,                        \
  151.   atari_scsi_abort,                                \
  152.   atari_scsi_reset,                                \
  153.   /* slave_attach */ NULL,                        \
  154.   /* bios_param */ NULL,                        \
  155.   /* can queue */             CAN_QUEUE,            \
  156.   /* host_id */                7,                    \
  157.   /* scatter gather */         SG_ALL,                \
  158.   /* cmd per lun */         CMD_PER_LUN,        \
  159.   /* present */             0,                    \
  160.   /* unchecked ISA DMA */    0 }
  161.  
  162. #endif
  163.  
  164. #else
  165.  
  166. #define NCR5380_implementation_fields        /* none */
  167. #define NCR5380_local_declare() int __none /* bad design */
  168. #define NCR5380_setup(instance) __none = 0 /* to avoid warning */
  169.  
  170. #define NCR5380_read(reg)          atari_scsi_reg_read( reg )
  171. #define NCR5380_write(reg, value) atari_scsi_reg_write( reg, value )
  172.  
  173. #define NCR5380_intr atari_scsi_intr
  174. #define NCR5380_queue_command atari_scsi_queue_command
  175. #define NCR5380_abort atari_scsi_abort
  176. /* #define NCR5380_reset atari_scsi_reset */
  177. #define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0)
  178. #define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1)
  179. #define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst )
  180. /* #define NCR5380_pread(instance, d, c) atari_scsi_pread (instance, d, c) */
  181. /* #define NCR5380_pwrite(instance, d, c) atari_scsi_pwrite (instance, d, c) */
  182. #define    NCR5380_dma_xfer_len(i,cmd) atari_dma_xfer_len(cmd->SCp.this_residual)
  183.  
  184. #endif /* else def HOSTS_C */
  185. #endif /* ndef ASM */
  186. #endif /* ATARI_SCSI_H */
  187.  
  188.  
  189.