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