xref: /csrg-svn/sys/tahoe/vba/mpreg.h (revision 34506)
1*34506Skarels /*
2*34506Skarels  *	@(#)mpreg.h	1.3 (Berkeley) 05/26/88
3*34506Skarels  */
432632Ssam 
532632Ssam /*
632632Ssam  * MPCC Asynchronous Communications Interface.
732632Ssam  */
832632Ssam #define MPINTRBASE	0xa0		/* base vector for interupts */
932632Ssam #define MPMAGIC		1969		/* magic number for mblok */
1032632Ssam #define MPMAXPORT	32		/* maximum number of ports on an MPCC */
1132632Ssam 
1232632Ssam /*
1332632Ssam  * MPCC's are capable of supporting one of a
1432632Ssam  * the protocols listed below.  This driver
1532632Ssam  * supports only the async terminal protocol.
1632632Ssam  */
1732632Ssam #define MPPROTO_UNUSED	0	/* port not in use */
1832632Ssam #define MPPROTO_ASYNC	1	/* async protocol */
1932632Ssam #define MPPROTO_X25	2	/* x25 protocol (unsupported) */
2032632Ssam #define MPPROTO_BISYNC	3	/* bisync protocol (unsupported) */
2132632Ssam #define MPPROTO_SNA  	4	/* sna protocol (unsupported) */
2232632Ssam 
2332632Ssam #define NMPPROTO	5	/* max protocols supported by MPCC */
2432632Ssam 
2532632Ssam #define MPINSET        8
2632632Ssam #define MPOUTSET       8
2732632Ssam 
2832632Ssam /*
2932632Ssam  * Host Interface Structure
3032632Ssam  */
3132632Ssam struct his {
3232632Ssam 	u_char	semaphore;
3332632Ssam #define MPSEMA_AVAILABLE	1
3432632Ssam #define MPSEMA_WORK		4
3532632Ssam 	u_char	imok;
3632632Ssam #define MPIMOK_ALIVE	0x01
3732632Ssam #define MPIMOK_DEAD	0x80
3832632Ssam 	u_char	brdnum;		/* Virtual brd number for protocol */
3932632Ssam 	u_char	unused;
4032632Ssam 	struct {
41*34506Skarels 		u_char	inbdone[MPMAXPORT];	/* Ports w/ inbound completed */
42*34506Skarels 		u_char	outbdone[MPMAXPORT];	/* Ports w/outbound available */
4332632Ssam 		u_int	fill[2];
4432632Ssam 	} proto[NMPPROTO];
4532632Ssam };
4632632Ssam 
47*34506Skarels #define MPPORT_EOL	0xff		/* end of port list */
4832632Ssam 
4932632Ssam /*
5032632Ssam  * Async host transmit list structure.
5132632Ssam  */
5232632Ssam #define MPXMIT	4	/* # of transmit ptrs/MP_WRITE event */
5332632Ssam 
5432632Ssam struct	hxmtl {
5532632Ssam 	caddr_t	dblock[MPXMIT];	/* ptrs to data blocks */
5632632Ssam 	u_short	size[MPXMIT];	/* size of each block */
5732632Ssam };
5832632Ssam 
5932632Ssam /*
6032632Ssam  * MPCC asynchronous protocol events.
6132632Ssam  */
6232632Ssam struct mpevent {
6332632Ssam 	u_char	ev_status;	/* Go Status */
6432632Ssam 	u_char	ev_cmd;		/* Optional Op-code */
6532632Ssam 	u_short	ev_opts;	/* Optional flags */
6632632Ssam 	u_short	ev_error;	/* error status returned */
6732632Ssam 	u_short	ev_flags;	/* optional event flags field */
6832632Ssam 	caddr_t	ev_params;	/* pointer to event parameters */
6932632Ssam 	union {
7032632Ssam 		struct	hxmtl *hxl;	/* pointer to host xmit list */
7132632Ssam 		u_char	*rcvblk;	/* pointer to receive block */
7232632Ssam 	} ev_un;
7332632Ssam 	u_short	ev_count;	/* # ptrs in xmit list/# receive chars  */
7432632Ssam 	u_short	ev_unused;	/* round to longword */
7532632Ssam 	u_int	ev_unused2;	/* round to size of BSC struct. GROT!! */
7632632Ssam };
7732632Ssam 
7832632Ssam /* defines for ev_status */
7932632Ssam #define EVSTATUS_FREE	0
8032632Ssam #define EVSTATUS_GO	1
8132632Ssam #define EVSTATUS_BUSY	2
8232632Ssam #define EVSTATUS_DONE	4
8332632Ssam 
8432632Ssam /* defines for ev_cmd */
8532632Ssam #define EVCMD_OPEN	1
8632632Ssam #define EVCMD_CLOSE	2
8732632Ssam #define EVCMD_RESET	3
8832632Ssam #define EVCMD_IOCTL	4
8932632Ssam #define EVCMD_WRITE	5
9032632Ssam #define EVCMD_READ	6
9132632Ssam #define EVCMD_STATUS	7
9232632Ssam #define EVCMD_EVENT	8
9332632Ssam 
9432632Ssam /*
9532632Ssam  * Host-MPCC interface block.
9632632Ssam  */
9732632Ssam struct	mblok {
9832632Ssam 	u_char	mb_status;		/* mpcc status */
9932632Ssam 	u_char	mb_ivec;		/* host interrupt vector */
10032632Ssam 	u_short	mb_magic;
10132632Ssam 	u_char	mb_diagswitch[2];	/* run diagnostics/application */
10232632Ssam 	u_char	mb_softerr;		/* soft error code */
10332632Ssam 	u_char	mb_harderr;		/* hard error code */
10432632Ssam 	struct mpdl {		/* download/config area */
10532632Ssam 		u_char	mpdl_status;	/* control/status */
10632632Ssam 		u_char	mpdl_cmd;	/* request type */
10732632Ssam 		u_short	mpdl_count;	/* size of parameter block */
10832632Ssam 		caddr_t	mpdl_data;	/* command parameters */
10932632Ssam 	} mb_dl;
11032632Ssam 	u_char	mb_hiport, mb_loport;	/* high-low mpcc port numbers */
11132632Ssam 	u_char	mb_unit;		/* mpcc unit number */
11232632Ssam 	u_char	mb_hndshk;		/* handshaking timer */
11332632Ssam 	caddr_t	mb_imokclk;		/* handshaking clock */
11432632Ssam 	u_char	mb_nointcnt;		/* no interrupt from handshake */
11532632Ssam 	u_char	mb_mpintcnt;		/* # outstanding interupts to MPCC */
11632632Ssam 	short	mb_unused;
11732632Ssam 	caddr_t	mb_mpintclk;		/* MPCC interrupt clock */
11832632Ssam 	struct	his mb_hostint;		/* To Talk with Host */
11932632Ssam 	u_char	mb_proto[MPMAXPORT];	/* per-port protocols */
12032632Ssam 	u_char	mb_intr[MPMAXPORT];	/* per-port host->mpcc int flags */
12132632Ssam 	struct	mpport {	/* per-port structure */
12232632Ssam 		u_short	mp_proto;	/* protocol of port */
12332632Ssam 		u_char	mp_on;		/* Next available entry on Host */
12432632Ssam 		u_char	mp_off;		/* Next expected 'DONE' entry on Host */
12532632Ssam 		struct	mpevent mp_recvq[MPINSET]; /* queue of events to host */
12632632Ssam 		struct	mpevent mp_sendq[MPOUTSET];/* queue of events to mpcc */
12732632Ssam 		u_char	mp_nextrcv;	/* next expected 'DONE' entry on Host */
12832632Ssam 		u_char	mp_flags;	/* host flags */
12932632Ssam 		short	mp_unused;
13032632Ssam 		caddr_t	mp_data;	/* pointer to data for port */
13132632Ssam 	} mb_port[MPMAXPORT];
13232632Ssam };
13332632Ssam 
13432632Ssam /* status defines for mblok.status */
13532632Ssam #define MP_DLPEND	1
13632632Ssam #define MP_DLOPEN	2
13732632Ssam #define MP_DLDONE	3
13832632Ssam #define MP_OPCLOSE	4
13932632Ssam #define MP_OPOPEN	5
14032632Ssam #define MP_DLTIME	6
14132632Ssam #define MP_DLERROR	(-1)
14232632Ssam 
14332632Ssam /* hard error status values loaded into mblock.herr */
14432632Ssam #define NOHERR		0	/* no error */
14532632Ssam #define MPBUSERR	1	/* bus error */
14632632Ssam #define ADDRERR		2	/* address error */
14732632Ssam #define UNDECC		3	/* undefined ecc interrupt */
14832632Ssam #define UNDINT		4	/* undefined interrupt */
14932632Ssam #define PWRFL		5	/* power fail occurred */
15032632Ssam #define NOXENTRY	6	/* xdone was enterred w/o xmit entry on queue */
15132632Ssam #define TWOFTMRS	7	/* tried to start two fast timers on one port */
15232632Ssam #define INTQFULL	8	/* interupt queue full */
15332632Ssam #define INTQERR		9	/* interupt queue ack error */
15432632Ssam #define CBPERR		10	/* uncorrectable DMA parity error */
15532632Ssam #define ACPDEAD		11	/* acap has died */
15632632Ssam /* additional panic codes not listed */
15732632Ssam 
15832632Ssam /* soft error status values loaded into mblock.serr */
15932632Ssam #define NOSERR	0		/* no error */
16032632Ssam #define DMAPERR	1		/* dma parity error */
16132632Ssam #define ECCERR	2		/* local memory ecc error */
16232632Ssam 
16332632Ssam /* Defines for flags */
16432632Ssam #define MP_PROGRESS	1	/* Open or Close is in progress */
16532632Ssam #define MP_PORTUP	2	/* link is up for port */
16632632Ssam #define MP_REMBSY	4	/* remote station busy */
16732632Ssam 
16832632Ssam /*
16932632Ssam  * Asynchronous Terminal Protocol Definitions.
17032632Ssam  */
17132632Ssam #define A_RCVTIM	2	/* default max tix for receive event (~20ms) */
17232632Ssam #define ACPTMR		300	/* approx. 5 secs to wait for acap     */
17332632Ssam #define A_MAXEVTP	3	/* maximum # of L1 or Host Events to    */
17432632Ssam 				/* process per port at one time	 */
17532632Ssam #define A_MAXRCV	128	/* max # of chars in rcv event - enough */
17632632Ssam 				/* to hold 20ms of chars at 19.2KB      */
17732632Ssam #define A_NUMRCV	32	/* number of rcv buffers per port       */
17832632Ssam #define A_NUMXMT	2	/* max number of concurrent xmits/port  */
17932632Ssam #define A_NUMEVT	32	/* number of evt bufs for status evts   */
18032632Ssam 				/* and L2 to L1 transmit evts	   */
18132632Ssam #define WR5	5		/* SCC Write Reg 5		      */
18232632Ssam #define TXENBL	0x08		/* mask to enable transmitter in WR 5   */
18332632Ssam #define RTSON	0x02		/* mask to turn on RTS in wreg 5	*/
18432632Ssam #define CHR5MSK	0x1F		/* mask for 5-bit transmit data	 */
18532632Ssam 
18632632Ssam /*
18732632Ssam  * macro to adjust a circular buffer ptr
18832632Ssam  *      x  = pointer or index
18932632Ssam  *      sz = size of circular buffer
19032632Ssam  */
19132632Ssam #define adjptr(x,sz)	((x) = ((++(x) == (sz)) ? 0 : (x)))
19232632Ssam #define adjptrbk(x,sz)	((x) = ((x) == 0) ? (sz) : --(x))
19332632Ssam 
19432632Ssam /*
19532632Ssam  * Events from ASYNC Level 1 to Level 2
19632632Ssam  */
19732632Ssam #define RCVDTA	10	/* normal receive data available */
19832632Ssam #define PARERR	11	/* receive data with parity error */
19932632Ssam #define OVRNERR	12	/* receive data with overrun error */
20032632Ssam #define OVFERR	13	/* receive data with overflow error */
20132632Ssam #define FRAMERR	14	/* receive data with framing error */
20232632Ssam #define ACKXMT	15	/* successful completion of transmit */
20332632Ssam #define NORBUF	16	/* No Receive Buffers available	 */
20432632Ssam #define NOEBUF	17	/* No Event Buffers available */
20532632Ssam #define BRKASRT	18	/* Break condition detected */
20632632Ssam 
20732632Ssam /* defines for error conditions */
20832632Ssam #define A_OK		0	/* No Errors */
20932632Ssam #define A_INVEVT	1	/* Invalid Event Error */
21032632Ssam #define A_IOCERR	2	/* Error while configuring port */
21132632Ssam #define A_SIZERR	3	/* Error in count of data chars to xmt */
21232632Ssam #define A_NXBERR	4	/* Transmit Incomplete due to lack of bufs */
21332632Ssam 
21432632Ssam /*
21532632Ssam  * Modem control signal control structure.
21632632Ssam  */
21732632Ssam struct mdmctl {
21832632Ssam         u_char	mc_rngdsr;	/* ring or dsr */
21932632Ssam         u_char	mc_rts;		/* request to send */
22032632Ssam         u_char	mc_rate;
22132632Ssam         u_char	mc_dcd;		/* data carrier detect */
22232632Ssam         u_char	mc_sectx;	/* secondary transmit */
22332632Ssam         u_char	mc_cts;		/* clear to send */
22432632Ssam         u_char	mc_secrx;	/* secondary receive */
22532632Ssam         u_char	mc_dtr;		/* data terminal ready */
22632632Ssam };
22732632Ssam 
22832632Ssam /* defines for modem control lines */
22932632Ssam #define ASSERT	1		/* line asserted */
23032632Ssam #define DROP	2		/* line dropped */
23132632Ssam #define AUTO	3		/* auto mode enabled, rts only */
23232632Ssam 
23332632Ssam /*
23432632Ssam  * Async parameter structure.
23532632Ssam  */
23632632Ssam struct asyncparam {
23732632Ssam 	u_char	ap_xon, ap_xoff;	/* xon-xoff characters */
23832632Ssam 	u_char	ap_xena;		/* xon/xoff enabled */
23932632Ssam 	u_char	ap_xany;		/* any received char enables xmitter */
24032632Ssam 	struct	mdmctl ap_modem;	/* port modem control lines */
24132632Ssam 	struct	mdmctl ap_intena;	/* modem signals which generate */
24232632Ssam 					/* status change events */
24332632Ssam 	u_char	ap_data;		/* number of data bits */
24432632Ssam 	u_char	ap_stop;		/* number of stop bits */
24532632Ssam 	u_char	ap_baud;		/* baud rate */
24632632Ssam 	u_char	ap_parity;		/* even/odd/no parity */
24732632Ssam 	u_char	ap_loop;		/* enable for local loopback */
24832632Ssam 	u_char	ap_rtimer;		/* receive timer value (msec) */
24932632Ssam 	short	ap_fill;		/* round to longword */
25032632Ssam };
25132632Ssam 
25232632Ssam /* enable/disable signal codes */
25332632Ssam #define MPA_ENA	1		/* condition enabled */
25432632Ssam #define MPA_DIS	2		/* condition disabled */
25532632Ssam 
25632632Ssam /* defines for ap_data */
25732632Ssam #define MPCHAR_5	0	/* 5 bits per character */
25832632Ssam #define MPCHAR_6	2	/* 6 bits per character */
25932632Ssam #define MPCHAR_7	1	/* 7 bits per character */
26032632Ssam #define MPCHAR_8 	3	/* 8 bits per character */
26132632Ssam 
26232632Ssam /* defines for ap_stop */
26332632Ssam #define MPSTOP_1	1	/* 1 stop bit per character */
26432632Ssam #define MPSTOP_1_5	2	/* 1 1/2 stop bits per character */
26532632Ssam #define MPSTOP_2	3	/* 2 stop bits per character */
26632632Ssam 
26732632Ssam /* defines for ap_baud */
26832632Ssam #define MODEM	0
26932632Ssam #define M0	0		/* baud rate = 0 */
27032632Ssam #define M50	1		/* baud rate = 50 */
27132632Ssam #define M75	2		/* baud rate = 75 */
27232632Ssam #define M110	3		/* baud rate = 110 */
27332632Ssam #define M134_5	4		/* baud rate = 134.5 */
27432632Ssam #define M150	5		/* baud rate = 150 */
27532632Ssam #define M200	6		/* baud rate = 200 */
27632632Ssam #define M300	7		/* baud rate = 300 */
27732632Ssam #define M600	8		/* baud rate = 600 */
27832632Ssam #define M1200	9		/* baud rate = 1200 */
27932632Ssam #define M1800	10		/* baud rate = 1800 */
28032632Ssam #define M2400	11		/* baud rate = 2400 */
28132632Ssam #define M4800	12		/* baud rate = 4800 */
28232632Ssam #define M9600	13		/* baud rate = 9600 */
28332632Ssam #define MEXTA	14		/* baud rate = Ext A */
28432632Ssam #define MEXTB	15		/* baud rate = Ext B */
28532632Ssam #define M2000	16		/* baud rate = 2000 */
28632632Ssam #define M3600	17		/* baud rate = 3600 */
28732632Ssam #define M7200	18		/* baud rate = 7200 */
28832632Ssam #define M19200	19		/* baud rate = 19,200 */
28932632Ssam #define M24000	20		/* baud rate = 24,000 */
29032632Ssam #define M28400	21		/* baud rate = 28,400 */
29132632Ssam #define M37800	22		/* baud rate = 37,800 */
29232632Ssam #define M40300	23		/* baud rate = 40,300 */
29332632Ssam #define M48000	24		/* baud rate = 48,000 */
29432632Ssam #define M52000	25		/* baud rate = 52,000 */
29532632Ssam #define M56800	26		/* baud rate = 56,800 */
29632632Ssam 
29732632Ssam /* defines for ap_parity */
29832632Ssam #define MPPAR_NONE	0	/* no parity */
29932632Ssam #define MPPAR_ODD	1	/* odd parity */
30032632Ssam #define MPPAR_EVEN	3	/* even parity */
30132632Ssam 
30232632Ssam /* possible flags for Host MP_IOCTL Events */
30332632Ssam #define A_CHGX		1	/* IOCTL is only chging xonxoff params */
30432632Ssam #define A_MDMCHG	2	/* change modem control lines */
30532632Ssam #define A_MDMGET	3	/* get current state of modem ctl lines */
30632632Ssam #define A_CHGL1P	4	/* IOCTL is changing changing L1 params */
30732632Ssam #define A_BRKON		5	/* set port break bit */
30832632Ssam #define A_BRKOFF	6	/* clear port break bit */
30932632Ssam #define A_CHGALL	7	/* IOCTL is changing xonxoff params, */
31032632Ssam 				/* pcnfg struct, & modem ctl structs */
31132632Ssam #define A_DISABX	8	/* disable port transmitter (ctl-s) */
31232632Ssam #define A_ENABLX	9	/* enable port transmitter (ctl-q) */
31332632Ssam 
31432632Ssam /* possible flags for Host MP_WRITE Events */
31532632Ssam #define A_FLUSH		1	/* flush any queued transmit events */
31632632Ssam #define A_SSTOP		2	/* transmit a port stop (xoff) char */
31732632Ssam 				/* before sending rest of event xmts */
31832632Ssam #define A_SSTART	3	/* transmit a port start (xon) char */
31932632Ssam 				/* before sending rest of event xmts */
32032632Ssam 
32132632Ssam /* possible flags for Outbound MP_READ Events */
32232632Ssam #define A_XOFF		1	/* transmitter stopped from by xoff char */
32332632Ssam 
32432632Ssam /* Perpos flags for modem control fields */
32532632Ssam #define A_RNGDSR	00001
32632632Ssam #define A_RTS		00002
32732632Ssam #define A_RATE		00004
32832632Ssam #define A_DCD		00010
32932632Ssam #define A_SECTX		00020
33032632Ssam #define A_CTS		00040
33132632Ssam #define A_SECRX		00100
33232632Ssam #define A_DTR		00200
33332632Ssam 
33432632Ssam /* error messages printed at console , board & port # filled in later */
33532632Ssam #define A_INVSTS	"\n#### Invalid Status Event "
33632632Ssam #define A_INVCMD	"\n#### Invalid Event From the MPCC "
33732632Ssam #define A_NORBUF	"\n#### No More Available Receive Buffers "
33832632Ssam #define A_NOEBUF	"\n#### No More Available Event Buffers "
33932632Ssam #define A_OVRN		"\n#### Overrun Error Detected "
34032632Ssam #define A_OVRF		"\n#### Overflow Error Detected "
34132632Ssam #define A_NOXBUF	"\n#### No More Available Transmit Event Buffers "
34232632Ssam #define A_XSIZE		"\n#### Transmit Data Block Size Exceeds Event Data Buffer Size "
34332632Ssam #define A_NOFREIN	"\n#### No Available Inbound Entries to Send Close Event "
34432632Ssam 
34532632Ssam #define DCDASRT		100	/* data carrier detect asserted */
34632632Ssam #define DTRASRT		101	/* data terminal ready asserted */
34732632Ssam #define RNGASRT		102	/* ring indicator asserted */
34832632Ssam #define DSRASRT		102	/* data set ready asserted */
34932632Ssam #define CTSASRT		103	/* clear to send asserted */
35032632Ssam #define RTSASRT		104	/* ready to send asserted */
35132632Ssam #define STXASRT		105	/* secondary transmit asserted */
35232632Ssam #define SRXASRT		106	/* secondary recieve asserted */
35332632Ssam #define RATEASRT	107	/* rate signal asserted */
35432632Ssam #define DCDDROP		108	/* data carrier detect dropped */
35532632Ssam #define DTRDROP		109	/* data terminal ready dropped */
35632632Ssam #define RNGDROP		110	/* ring indicator dropped */
35732632Ssam #define MPDSRDROP	110	/* data set ready dropped */
35832632Ssam #define CTSDROP		111	/* clear to send dropped */
35932632Ssam #define RTSDROP		112	/* ready to send dropped */
36032632Ssam #define STXDROP		113	/* secondary transmit dropped */
36132632Ssam #define SRXDROP		114	/* secondary recieve dropped */
36232632Ssam #define RATEDROP	115	/* rate signal dropped */
36332632Ssam 
36432632Ssam /* Defines for filters and intena in portstat */
36532632Ssam #define MDM_OFF	0
36632632Ssam #define MDM_ON	1
36732632Ssam 
36832632Ssam /* Modem on/off flags */
36932632Ssam #define MMOD_OFF 0
37032632Ssam #define MMOD_ON 1
37132632Ssam 
37232632Ssam /* defintions for DL interface */
37332632Ssam 
37432632Ssam #define MPDLBUFSIZE       1024
37532632Ssam 
37632632Ssam 
37732632Ssam /*      mpdlioctl command defines       */
37832632Ssam 
37932632Ssam struct protports {
38032632Ssam 	char protoport[MPMAXPORT];
38132632Ssam } ;
38232632Ssam 
38332632Ssam struct abdcf {
38432632Ssam         short   xmtbsz;         /* transmit buffer size - should */
38532632Ssam                                 /* equal # of chars in a cblock  */
38632632Ssam };
38732632Ssam 
38832632Ssam struct bdcf {
38932632Ssam 	char    loadname[NMPPROTO+1];
39032632Ssam 	char    protoports[MPMAXPORT];
39132632Ssam 	char    fccstimer;      /* powerfail timer */
39232632Ssam 	char    fccsports;      /* ports to affect */
39332632Ssam 	char    fccssoc;        /* ports which will 'switch on close' */
39432632Ssam };
39532632Ssam 
39632632Ssam 
39732632Ssam /* These ioctls are for the dlmpcc command */
39833092Sbostic #define MPIOPORTMAP         _IOW('m',1, struct protports)
39933092Sbostic #define MPIOHILO            _IOW('m',3, short)
40033092Sbostic #define MPIOENDCODE         _IO('m',4)
40133092Sbostic #define MPIOASYNCNF         _IOW('m',7, struct abdcf)
40233092Sbostic #define MPIOENDDL           _IO('m',10)
40333092Sbostic #define MPIOSTARTDL         _IO('m',11)
40433092Sbostic #define MPIORESETBOARD      _IO('m',12)
40532632Ssam 
40632632Ssam /*      mpdlwrite opcode defines        */
40732632Ssam 
40832632Ssam #define MPDLCMD_NORMAL          1
40932632Ssam 
410