Home | History | Annotate | Line # | Download | only in ic
ncr5380.doc revision 1.1
      1 MI 5380 driver
      2 ==============
      3 
      4 (What?  Documentation?  Is this guy nuts? :-)
      5 
      6 Reselection
      7 -----------
      8 
      9 This driver will permit reselection on non-polled commands if
     10 sc->sc_flags & NCR5380_PERMIT_RESELECT is 1.  This permits enabling of
     11 reselection on a per-device basis.
     12 
     13 Disconnect/reselect is never permitted for polled commands.
     14 
     15 
     16 
     17 Interfacing the driver to MD code
     18 ---------------------------------
     19 
     20 /sys/dev/ic/ncr5380.c is now stand-alone.  DON'T include it after your
     21 MD stuff!
     22 
     23 This allows for more than one 5380-based SCSI board in your system.  This is
     24 a real possibility for Amiga generic kernels.
     25 
     26 Your driver's softc structure must have an instance of struct ncr5380_softc
     27 as the first thing in the structure.  The MD code must initialize the
     28 following:
     29 
     30 sci_*: pointers to the 5380 registers.  All accesses are done through
     31   these pointers.  This indirection allows the driver to work with
     32   boards that map the 5380 on even addresses only or do other
     33   wierdnesses.
     34 
     35 int (*sc_pio_out)(sc, phase, datalen, data)
     36 int (*sc_pio_in)(sc, phase, datalen, data)
     37   These point to functions that do programmed I/O transfers to the bus and
     38   from the bus, respectively.  Arguments:
     39 
     40   sc            points to the softc
     41   phase         the current SCSI bus phase
     42   datalen       length of data to transfer
     43   data          pointer to the buffer
     44 
     45   Both functions must return the number of bytes successfully transferred.
     46   A transfer operation must be aborted if the target requests a different
     47   phase before the transfer completes.
     48 
     49   If you have no special requirements, you can point these to
     50   ncr5380_pio_out() and ncr5380_pio_in() respectively.  If your board
     51   can do pseudo-DMA, then you might want to point these to functions
     52   that use this feature.
     53 
     54 void (*sc_dma_alloc)(sc)
     55   This function is called to set up a DMA transfer.  You must create and
     56   return a "DMA handle" in sc->sc_dma_hand which identifies the DMA transfer.
     57   The driver will pass you your DMA handle in sc->sc_dma_hand for future
     58   operations.  The contents of the DMA handle are immaterial to the MI
     59   code - the DMA handle is for your bookkeeping only.  Usually, you
     60   create a structure and point to it here.
     61 
     62   For example, you can record the mapped and unmapped addresses of the
     63   buffer.  The Sun driver places an Am9516 UDC control block in the DMA
     64   handle.
     65 
     66   If for some reason you decide not to do DMA for the transfer, make
     67   sc->sc_dma_hand NULL.  This might happen if the proposed transfer is
     68   misaligned, or in the wrong type of memory, or...
     69 
     70 void (*sc_dma_start)(sc)
     71   This function starts the transfer.
     72 
     73 void (*sc_dma_stop)(sc)
     74   This function stops a transfer.  sc->sc_datalen and sc->sc_dataptr must
     75   be updated to reflect the portion of the DMA already done.
     76 
     77 void (*sc_dma_eop)(sc)
     78   This function is called when the 5380 signals EOP.  Either continue
     79   the DMA or stop the DMA.
     80 
     81 void (*sc_dma_free)(sc)
     82   This function frees the current DMA handle.
     83 
     84 u_char *sc_dataptr;
     85 int sc_datalen;
     86   These variables form the active SCSI data pointer.  DMA code must start
     87   DMA at the location given, and update the pointer/length in response to
     88   DMA operations.
     89 
     90 u_short sc_dma_flags;
     91   See ncr5380var.h
     92 
     93 
     94 
     95 Writing your DMA code
     96 ---------------------
     97 
     98 DMA on a system with protected or virtual memory is always a problem.  Even
     99 though a disk transfer may be logically contiguous, the physical pages backing
    100 the transfer may not be.  There are two common solutions to this problem:
    101 
    102 DMA chains: the DMA is broken up into a list of contiguous segments.  The first
    103 segment is submitted to the DMA controller, and when it completes, the second
    104 segment is submitted, without stopping the 5380.  This is what the sc_dma_eop()
    105 function can do efficiently - if you have a DMA chain, it can quickly load up
    106 the next link in the chain.  The sc_dma_alloc() function builds the chain and
    107 sc_dma_free() releases any resources you used to build it.
    108 
    109 DVMA: Direct Virtual Memory Access.  In this scheme, DMA requests go through
    110 the MMU.  Although you can't page fault, you can program the MMU to remap
    111 things so the DMA controller sees contiguous data.  In this mode, sc_dma_alloc()
    112 is used to map the transfer into the address space reserved for DVMA and
    113 sc_dma_free() is used to unmap it.
    114 
    115 
    116 Interrupts
    117 ----------
    118 
    119 ncr5380_sbc_intr() must be called when the 5380 interrupts the host.
    120 
    121 You must write an interrupt routine pretty much from scratch to check for
    122 things generated by MD hardware.
    123 
    124 
    125 Known problems
    126 --------------
    127 
    128 I'm getting this out now so that other ports can hack on it and integrate it.
    129 
    130 The sun3, DMA/Interrupt appears to be working now, but needs testing.
    131 
    132 Polled commands submitted while non-polled commands are in progress are not
    133 handled correctly.  This can happen if reselection is enabled and a new disk
    134 is mounted while an I/O is in progress on another disk. 
    135 
    136 The problem is: what to do if you get reselected while doing the selection
    137 for the polled command?  Currently, the driver busy waits for the non-polled
    138 command to complete, but this is bogus.  I need to complete the non-polled
    139 command in polled mode, then do the polled command.
    140 
    141 
    142 Timeouts in the driver are EXTREMELY sensitive to the characteristics of the
    143 local implementation of delay().  The Sun3 version delays for a minimum of 5us.
    144 However, the driver must assume that delay(1) will delay only 1us.  For this
    145 reason, performance on the Sun3 sucks in some places.
    146 
    147