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