*#ident "$Revision: 1.15 $"
*
* jag - Interphase Jaguar scsi disk driver
*
*FLAG	PREFIX	SOFT	#DEV	DEPENDENCIES
ns	jag	-	-	io,scsi

$$$
/* disk driver variable tables */
#if defined(IP5) || defined(IP17) || defined(EVEREST)
#include "sys/dmamap.h"
#endif
#include "sys/scsi.h"
#include "sys/jag.h"

#ifdef NOPROBE
#define JCC		 JAG_CTLRS 
#else
#define JCC		 ##C
#endif
struct jagunitinfo	 jagunitinfo[JCC][JAG_UPC];
struct jagctlrinfo	 jagctlrinfo[JCC];
struct jagmemcqe	 jagcqe[JCC][JAG_NCQE];
uint			 jagcqenext[JCC];
struct jag_cib		 jag_cib[JCC];
struct jag_crb		*jag_crb[JCC];
uint			 jag_numctlr = JCC;

#if defined(IP5) || defined(IP17) || defined(EVEREST)
int			jagblock = 1;
#else
int			jagblock = 0;
#endif

/*
 * To workaround a bug in 01J firmware, transfer count exceptions can
 * be ignored on controllers with that firmware revision.
 * This means that the count returned from the low level driver to the
 * upper level driver will not be correct.  For disk devices, this will
 * cause no harm.  For tape devices, this means that incorrect counts
 * will be returned if the 'SILI' bit is set in a 'read', i.e., 'mt sili'
 * will not work correctly if the requested block size does not match
 * the block size on tape.
 *
 * The bug is stepped over when SCSI devices disconnect without sending
 * a Save Data Pointers message after having transferred some data.  If
 * the devices on a system do not do this, this variable should be clear.
 * If not, this variable must be set for those devices to be usable.
 */
int			jag_01J_ignore_xfercount_exceptions = 0;

/*
 * The following variable sets the host adapter id for both of the SCSI
 * buses on the 4210 controller.  For maximum throughput, set the host
 * adapter id to 7.  For maximum fairness, set it to 0.
 *
 * SCSI devices that have bus id numbers lower than the host adapter,
 * and have two other devices with higher numbers on the bus, may not
 * get the SCSI bus for extended periods of time when the two higher
 * numbered devices are busy.
 *
 * For example, if the host adapter id number is 5, and there are devices
 * at 6 and 4, devices numbered 3 and lower may not get the SCSI bus when
 * they need it.
 *
 * If there is a device with the same address as the host adapter, nothing
 * on that SCSI bus will work.
 */
uint			jag_hostid = 7;

/*
 * jag_nmap is used to allocate IO3 mapper registers to commands.  It
 * controls the maximum number of pages that can be transferred in a
 * single I/O request.  For the disk driver, if a request is bigger, it
 * will get split up into multiple maximum size requests followed by a
 * remainder.  Other drivers must call
 * 	jagxfersizemax(struct jagctlrinfo *, struct jagunitinfo *)
 * to find out what the maximum transfer size is.  If a request sent
 * to jagspecial() is too large, it will be rejected with EINVAL.
 *
 * The numbers represent the maximum number of 4k pages that can be part
 * of a single request.  It is assumed that requests will not be page
 * aligned; thus, you can expect to transfer 64k with 17 pages and
 * 256k with 65 pages.  Recall that there are a limited number of mapper
 * registers on the IO3 (only about 5400 are available for use by drivers)
 * and some are used by other drivers, so do not allocate too many for
 * your devices.
 *
 * The rows correspond to controller number, and the columns correspond
 * to unit number.  The first eight columns are for the possible devices
 * on the first bus; the second eight are on the second bus.
 */
ushort	jag_nmap[JAG_CTLRS][JAG_LUPC] =
{
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
	{17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},
};
