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