xref: /csrg-svn/sys/tahoe/vba/drreg.h (revision 44534)
134406Skarels /*
235514Sbostic  * Copyright (c) 1988 The Regents of the University of California.
335514Sbostic  * All rights reserved.
435514Sbostic  *
535514Sbostic  * This code is derived from software contributed to Berkeley by
635514Sbostic  * Computer Consoles Inc.
735514Sbostic  *
8*44534Sbostic  * %sccs.include.redist.c%
935514Sbostic  *
10*44534Sbostic  *	@(#)drreg.h	7.3 (Berkeley) 06/28/90
1134406Skarels  */
1229650Ssam 
1329650Ssam /*
1429650Ssam     ------------------------------------------
1529650Ssam     Must include <h/types.h> and <h/buf.h>
1629650Ssam     ------------------------------------------
1729650Ssam */
1829650Ssam 
1929650Ssam #define	DRINTV	0x9c		/* Has to match with ml/scb.s */
2029650Ssam #define DRADDMOD 0x01		/* Addr modifier used to access TAHOE memory */
2129650Ssam #define DR_ZERO 0
2229650Ssam #define DRPRI	(PZERO+1)
2329650Ssam 
2429650Ssam #define DR_TICK 600		/* Default # of clock ticks between call
2529650Ssam 				   to local timer watchdog routine */
2629650Ssam #define	DR_TOCK	2		/* default # of calls to local watch dog
2729650Ssam 				   before an IO or wait is determined to
2829650Ssam 				   have timeout */
2929650Ssam 
3029650Ssam 
3129650Ssam struct rsdevice {
3229650Ssam     ushort dr_cstat;		/* Control & status registers */
3329650Ssam     ushort dr_data;		/* Input/Ouptut data registers */
3429650Ssam     char dr_addmod;		/* Address modifier for DMA */
3529650Ssam     char dr_intvect;		/* Interrupt vector */
3629650Ssam     ushort dr_pulse;		/* Pulse command register */
3729650Ssam     ushort dr_xx08;		/* Not used */
3829650Ssam     ushort dr_xx0A;		/* Not used */
3929650Ssam     ushort dr_xx0C;		/* Not used */
4029650Ssam     ushort dr_xx0E;		/* Not used */
4129650Ssam     ushort dr_xx10;		/* Not used */
4229650Ssam     ushort dr_walo;		/* Low DMA address register --when written-- */
4329650Ssam     ushort dr_range;		/* DMA range counter */
4429650Ssam     ushort dr_ralo;		/* Low DMA address register --when read-- */
4529650Ssam     ushort dr_xx18;		/* Not used */
4629650Ssam     ushort dr_wahi;		/* High DMA address register --when written-- */
4729650Ssam     ushort dr_xx1C;		/* Not used */
4829650Ssam     ushort dr_rahi;		/* High DMA address register --when read-- */
4929650Ssam };
5029650Ssam 
5129650Ssam 
5229650Ssam struct dr_aux {
5329650Ssam 	struct rsdevice *dr_addr; /* Physical addr of currently active DR11 */
5429650Ssam 	struct buf *dr_actf;	/* Pointers to DR11's active buffers list */
5529650Ssam 	unsigned int dr_flags;	/* State: Hold open, active,... */
5629650Ssam 	ushort dr_cmd;		/* Hold cmd placed here by ioctl
5729650Ssam 				   for later execution by rsstrategy() */
5829650Ssam 	ushort dr_op;		/* Current operation: DR_READ/DR_WRITE */
5929650Ssam 	long   dr_bycnt;	/* Total byte cnt of current operation */
6029650Ssam 				/* decremented by completion interrupt */
6129650Ssam 	caddr_t dr_oba;		/* original xfer addr, count */
6229650Ssam 	long   dr_obc;
6329650Ssam 	unsigned long
6429650Ssam 		rtimoticks,	/* No of ticks before timing out on no stall
6529650Ssam 				   read */
6629650Ssam 		wtimoticks,	/* No of ticks before timing out on no stall
6729650Ssam 				   write */
6829650Ssam 		currenttimo;	/* the number of current timeout call to
6929650Ssam 				   omrwtimo() */
7029650Ssam    	ushort dr_istat;	/* Latest interrupt status */
7129650Ssam 	struct buf dr_buf;
7229650Ssam 
7329650Ssam 	/*ushort dr_time;		/* # of ticks until timeout */
7429650Ssam 	/*ushort dr_tock;		/* # of ticks accumulated */
7529650Ssam 	/*ushort dr_cseq;		/* Current sequence number */
7629650Ssam 	/*ushort dr_lseq;		/* Last sequence number */
7729650Ssam };
7829650Ssam 
7929650Ssam /*	Command used by drioctl()
8029650Ssam */
8129650Ssam struct dr11io {
8229650Ssam 	ushort arg[8];
8329650Ssam };
8429650Ssam 
8529650Ssam #define RSADDR(unit)    ((struct rsdevice *)drinfo[unit]->ui_addr)
8629650Ssam 
8729650Ssam /*	Control register bits */
8829650Ssam #define	RDMA	0x8000		/* reset DMA end-of-range flag */
8929650Ssam #define	RATN	0x4000		/* reset attention flag */
9029650Ssam #define RPER	0x2000		/* reset device parity error flag */
9129650Ssam #define MCLR	0x1000		/* master clear board and INT device */
9229650Ssam #define CYCL	0x0100		/* forces DMA cycle if DMA enabled */
9329650Ssam #define IENB	0x0040		/* enables interrupt */
9429650Ssam #define FCN3	0x0008		/* func. bit 3 to device (FNCT3 H) */
9529650Ssam #define FCN2	0x0004		/* func. bit 2 to device (FNCT2 H) */
9629650Ssam 				/* also asserts ACLO FCNT2 H to device */
9729650Ssam #define FCN1	0x0002		/* func. bit 1 to device (FNCT1 H) */
9829650Ssam #define GO	0x0001		/* enable DMA and pulse GO to device */
9929650Ssam 
10029650Ssam /*	Status register bits */
10129650Ssam #define	DMAF	0x8000		/* indicates DMA end-of-range */
10229650Ssam #define	ATTF	0x4000		/* indicates attention false-to-true */
10329650Ssam #define ATTN	0x2000		/* current state of ATTENTION H input */
10429650Ssam #define PERR	0x1000		/* Set by external parity error */
10529650Ssam #define STTA	0x0800		/* STATUS A H input state */
10629650Ssam #define STTB	0x0400		/* STATUS B H input state */
10729650Ssam #define STTC	0x0200		/* STATUS C H input state */
10829650Ssam #define REDY	0x0080		/* board ready for cmd (dma not on) */
10929650Ssam #define IENF	0x0040		/* Interrupt enabled if on */
11029650Ssam #define BERR	0x0020		/* Set if bus error during DMA */
11129650Ssam #define TERR	0x0010		/* Set if bus timeout during DMA */
11229650Ssam #define FC3S	0x0008		/* State of FCN3 latch */
11329650Ssam #define FC2S	0x0004		/* State of FCN2 latch */
11429650Ssam #define FC1S	0x0002		/* State of FCN1 latch */
11529650Ssam #define DLFG	0x0001		/* 0 -> IKON-10083 *** 1 -> IKON-10077 */
11629650Ssam 
11729650Ssam /*	Pulse command register bits */
11829650Ssam #define SMSK	0x0040		/* pulse interrupt mask on:  Set IENB */
11929650Ssam #define RMSK	0x0020		/* pulse interrupt mask off: Reset IENB */
12029650Ssam 
12129650Ssam 
12229650Ssam /*
12329650Ssam  * 	DR11 driver's internal flags -- to be stored in dr_flags
12429650Ssam */
12529650Ssam #define DR_FMSK		0x0000E	/* function bits mask */
12629650Ssam #define	DR_OPEN		0x00001	/* This dr11 has been opened */
12729650Ssam #define DR_PRES		0x00002	/* This dr11 is present */
12829650Ssam #define DR_ACTV		0x00004	/* waiting for end-of-range */
12929650Ssam #define DR_ATWT 	0x00008	/* waiting for attention interrupt */
13029650Ssam #define DR_ATRX 	0x00010	/* attn received-resets when read */
13129650Ssam #define DR_TMDM		0x00020	/* timeout waiting for end-of-range */
13229650Ssam #define DR_TMAT		0x00040	/* timeout waiting for attention */
13329650Ssam #define DR_DMAX		0x00080	/* end-of-range interrupt received */
13429650Ssam #define DR_PCYL		0x00100	/* set cycle with next go */
13529650Ssam #define DR_DFCN 	0x00200	/* donot update function bits until next  go */
13629650Ssam #define DR_DACL		0x00400	/* defer alco pulse until go */
13729650Ssam #define DR_LOOPTST 	0x02000	/* This dr11 is in loopback test mode */
13829650Ssam #define DR_LNKMODE 	0x04000	/* This dr11 is in link mode */
13929650Ssam #define	DR_NORSTALL	0x10000	/* Device is set to no stall mode for reads. */
14029650Ssam #define	DR_NOWSTALL	0x20000	/* Device is set to no stall mode for writes. */
14129650Ssam #define	DR_TIMEDOUT	0x40000	/* The device timed out on a stall mode R/W */
14229650Ssam 
14329650Ssam /*
14429650Ssam  * 	DR11 driver's internal flags -- to be stored in dr_op
14529650Ssam */
14629650Ssam #define	DR_READ		FCN1
14729650Ssam #define DR_WRITE	0
14829650Ssam 
14929650Ssam /*
15029650Ssam  *	Ioctl commands
15129650Ssam */
15233093Sbostic #define DRWAIT		_IOWR('d',1,long)
15333093Sbostic #define	DRPIOW		_IOWR('d',2,long)
15433093Sbostic #define DRPACL		_IOWR('d',3,long)
15533093Sbostic #define DRDACL		_IOWR('d',4,long)
15633093Sbostic #define DRPCYL		_IOWR('d',5,long)
15733093Sbostic #define DRDFCN 		_IOWR('d',6,long)
15833093Sbostic #define DRRPER 		_IOWR('d',7,long)
15933093Sbostic #define DRRATN		_IOWR('d',8,long)
16033093Sbostic #define DRRDMA 		_IOWR('d',9,long)
16133093Sbostic #define DRSFCN 		_IOWR('d',10,long)
16229650Ssam 
16333093Sbostic #define	DRSETRSTALL	_IOWR('d',13,long)
16433093Sbostic #define	DRSETNORSTALL	_IOWR('d',14,long)
16533093Sbostic #define	DRGETRSTALL	_IOWR('d',15,long)
16633093Sbostic #define	DRSETRTIMEOUT	_IOWR('d',16,long)
16733093Sbostic #define	DRGETRTIMEOUT	_IOWR('d',17,long)
16833093Sbostic #define	DRSETWSTALL	_IOWR('d',18,long)
16933093Sbostic #define	DRSETNOWSTALL	_IOWR('d',19,long)
17033093Sbostic #define	DRGETWSTALL	_IOWR('d',20,long)
17133093Sbostic #define	DRSETWTIMEOUT	_IOWR('d',21,long)
17233093Sbostic #define	DRGETWTIMEOUT	_IOWR('d',22,long)
17333093Sbostic #define	DRWRITEREADY	_IOWR('d',23,long)
17433093Sbostic #define	DRREADREADY	_IOWR('d',24,long)
17533093Sbostic #define	DRBUSY		_IOWR('d',25,long)
17633093Sbostic #define	DRRESET		_IOWR('d',26,long)
17729650Ssam 
17829650Ssam /* The block size for buffering and DMA transfers. */
17929650Ssam /* OM_BLOCKSIZE must be even and <= 32768. Multiples of 512 are prefered. */
18029650Ssam #define	OM_BLOCKSIZE	32768
18129650Ssam 
18229650Ssam 
18329650Ssam /* --- Define ioctl call used by dr11 utility device --  */
18429650Ssam 
18533093Sbostic #define DR11STAT	_IOWR('d',30,struct dr11io)   /* Get status dr11, unit
18629650Ssam 						   number is dr11io.arg[0] */
18733093Sbostic #define DR11LOOP	_IOR('d',31,struct dr11io)   /* Perform loopback test */
18829650Ssam 
18929650Ssam /* ---------------------------------------------------- */
19029650Ssam 
191