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