1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the University of California, Berkeley. The name of the 14 * University may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * 20 * @(#)mpreg.h 7.3 (Berkeley) 10/19/88 21 */ 22 23 /* 24 * MPCC Asynchronous Communications Interface. 25 */ 26 #define MPINTRBASE 0xa0 /* base vector for interupts */ 27 #define MPMAGIC 1969 /* magic number for mblok */ 28 #define MPMAXPORT 32 /* maximum number of ports on an MPCC */ 29 30 /* 31 * MPCC's are capable of supporting one of a 32 * the protocols listed below. This driver 33 * supports only the async terminal protocol. 34 */ 35 #define MPPROTO_UNUSED 0 /* port not in use */ 36 #define MPPROTO_ASYNC 1 /* async protocol */ 37 #define MPPROTO_X25 2 /* x25 protocol (unsupported) */ 38 #define MPPROTO_BISYNC 3 /* bisync protocol (unsupported) */ 39 #define MPPROTO_SNA 4 /* sna protocol (unsupported) */ 40 41 #define NMPPROTO 5 /* max protocols supported by MPCC */ 42 43 #define MPINSET 8 44 #define MPOUTSET 8 45 46 /* 47 * Host Interface semaphores 48 */ 49 #define MPSEMA_AVAILABLE 1 50 #define MPSEMA_WORK 4 51 52 /* 53 * Host Interface imok values 54 */ 55 #define MPIMOK_ALIVE 0x01 56 #define MPIMOK_DEAD 0x80 57 58 /* 59 * Host Interface Structure 60 */ 61 struct his { 62 u_char semaphore; 63 u_char imok; 64 u_char brdnum; /* Virtual brd number for protocol */ 65 u_char unused; 66 struct { 67 u_char inbdone[MPMAXPORT]; /* Ports w/ inbound completed */ 68 u_char outbdone[MPMAXPORT]; /* Ports w/outbound available */ 69 u_int fill[2]; 70 } proto[NMPPROTO]; 71 }; 72 73 #define MPPORT_EOL 0xff /* end of port list */ 74 75 /* 76 * Async host transmit list structure. 77 */ 78 #define MPXMIT 4 /* # of transmit ptrs/MP_WRITE event */ 79 80 struct hxmtl { 81 caddr_t dblock[MPXMIT]; /* ptrs to data blocks */ 82 u_short size[MPXMIT]; /* size of each block */ 83 }; 84 85 /* 86 * MPCC asynchronous protocol events. 87 */ 88 struct mpevent { 89 u_char ev_status; /* Go Status */ 90 u_char ev_cmd; /* Optional Op-code */ 91 u_short ev_opts; /* Optional flags */ 92 u_short ev_error; /* error status returned */ 93 u_short ev_flags; /* optional event flags field */ 94 caddr_t ev_params; /* pointer to event parameters */ 95 union { 96 struct hxmtl *hxl; /* pointer to host xmit list */ 97 u_char *rcvblk; /* pointer to receive block */ 98 } ev_un; 99 u_short ev_count; /* # ptrs in xmit list/# receive chars */ 100 u_short ev_unused; /* round to longword */ 101 u_int ev_unused2; /* round to size of BSC struct. GROT!! */ 102 }; 103 104 /* defines for ev_status */ 105 #define EVSTATUS_FREE 0 106 #define EVSTATUS_GO 1 107 #define EVSTATUS_BUSY 2 108 #define EVSTATUS_DONE 4 109 110 /* defines for ev_cmd */ 111 #define EVCMD_OPEN 1 112 #define EVCMD_CLOSE 2 113 #define EVCMD_RESET 3 114 #define EVCMD_IOCTL 4 115 #define EVCMD_WRITE 5 116 #define EVCMD_READ 6 117 #define EVCMD_STATUS 7 118 #define EVCMD_EVENT 8 119 120 /* 121 * Host-MPCC interface block. 122 */ 123 struct mblok { 124 u_char mb_status; /* mpcc status */ 125 u_char mb_ivec; /* host interrupt vector */ 126 u_short mb_magic; 127 u_char mb_diagswitch[2]; /* run diagnostics/application */ 128 u_char mb_softerr; /* soft error code */ 129 u_char mb_harderr; /* hard error code */ 130 struct mpdl { /* download/config area */ 131 u_char mpdl_status; /* control/status */ 132 u_char mpdl_cmd; /* request type */ 133 u_short mpdl_count; /* size of parameter block */ 134 caddr_t mpdl_data; /* command parameters */ 135 } mb_dl; 136 u_char mb_hiport, mb_loport; /* high-low mpcc port numbers */ 137 u_char mb_unit; /* mpcc unit number */ 138 u_char mb_hndshk; /* handshaking timer */ 139 caddr_t mb_imokclk; /* handshaking clock */ 140 u_char mb_nointcnt; /* no interrupt from handshake */ 141 u_char mb_mpintcnt; /* # outstanding interupts to MPCC */ 142 short mb_unused; 143 caddr_t mb_mpintclk; /* MPCC interrupt clock */ 144 struct his mb_hostint; /* To Talk with Host */ 145 u_char mb_proto[MPMAXPORT]; /* per-port protocols */ 146 u_char mb_intr[MPMAXPORT]; /* per-port host->mpcc int flags */ 147 struct mpport { /* per-port structure */ 148 u_short mp_proto; /* protocol of port */ 149 u_char mp_on; /* Next available entry on Host */ 150 u_char mp_off; /* Next expected 'DONE' entry on Host */ 151 struct mpevent mp_recvq[MPINSET]; /* queue of events to host */ 152 struct mpevent mp_sendq[MPOUTSET];/* queue of events to mpcc */ 153 u_char mp_nextrcv; /* next expected 'DONE' entry on Host */ 154 u_char mp_flags; /* host flags */ 155 short mp_unused; 156 caddr_t mp_data; /* pointer to data for port */ 157 } mb_port[MPMAXPORT]; 158 }; 159 160 /* status defines for mblok.status */ 161 #define MP_DLPEND 1 162 #define MP_DLOPEN 2 163 #define MP_DLDONE 3 164 #define MP_OPCLOSE 4 165 #define MP_OPOPEN 5 166 #define MP_DLTIME 6 167 #define MP_DLERROR (-1) 168 169 /* hard error status values loaded into mblock.herr */ 170 #define NOHERR 0 /* no error */ 171 #define MPBUSERR 1 /* bus error */ 172 #define ADDRERR 2 /* address error */ 173 #define UNDECC 3 /* undefined ecc interrupt */ 174 #define UNDINT 4 /* undefined interrupt */ 175 #define PWRFL 5 /* power fail occurred */ 176 #define NOXENTRY 6 /* xdone was enterred w/o xmit entry on queue */ 177 #define TWOFTMRS 7 /* tried to start two fast timers on one port */ 178 #define INTQFULL 8 /* interupt queue full */ 179 #define INTQERR 9 /* interupt queue ack error */ 180 #define CBPERR 10 /* uncorrectable DMA parity error */ 181 #define ACPDEAD 11 /* acap has died */ 182 /* additional panic codes not listed */ 183 184 /* soft error status values loaded into mblock.serr */ 185 #define NOSERR 0 /* no error */ 186 #define DMAPERR 1 /* dma parity error */ 187 #define ECCERR 2 /* local memory ecc error */ 188 189 /* Defines for flags */ 190 #define MP_PROGRESS 1 /* Open or Close is in progress */ 191 #define MP_IOCTL 2 /* IOCTL is in progress */ 192 #define MP_REMBSY 4 /* remote station busy */ 193 194 /* 195 * Asynchronous Terminal Protocol Definitions. 196 */ 197 #define A_RCVTIM 2 /* default max tix for receive event (~20ms) */ 198 #define ACPTMR 300 /* approx. 5 secs to wait for acap */ 199 #define A_MAXEVTP 3 /* maximum # of L1 or Host Events to */ 200 /* process per port at one time */ 201 #define A_MAXRCV 128 /* max # of chars in rcv event - enough */ 202 /* to hold 20ms of chars at 19.2KB */ 203 #define A_NUMRCV 32 /* number of rcv buffers per port */ 204 #define A_NUMXMT 2 /* max number of concurrent xmits/port */ 205 #define A_NUMEVT 32 /* number of evt bufs for status evts */ 206 /* and L2 to L1 transmit evts */ 207 #define WR5 5 /* SCC Write Reg 5 */ 208 #define TXENBL 0x08 /* mask to enable transmitter in WR 5 */ 209 #define RTSON 0x02 /* mask to turn on RTS in wreg 5 */ 210 #define CHR5MSK 0x1F /* mask for 5-bit transmit data */ 211 212 /* 213 * macro to adjust a circular buffer ptr 214 * x = pointer or index 215 * sz = size of circular buffer 216 */ 217 #define adjptr(x,sz) ((x) = ((++(x) == (sz)) ? 0 : (x))) 218 #define adjptrbk(x,sz) ((x) = ((x) == 0) ? (sz) : --(x)) 219 220 /* 221 * Events from ASYNC Level 1 to Level 2 222 */ 223 #define RCVDTA 10 /* normal receive data available */ 224 #define PARERR 11 /* receive data with parity error */ 225 #define OVRNERR 12 /* receive data with overrun error */ 226 #define OVFERR 13 /* receive data with overflow error */ 227 #define FRAMERR 14 /* receive data with framing error */ 228 #define ACKXMT 15 /* successful completion of transmit */ 229 #define NORBUF 16 /* No Receive Buffers available */ 230 #define NOEBUF 17 /* No Event Buffers available */ 231 #define BRKASRT 18 /* Break condition detected */ 232 233 /* defines for error conditions */ 234 #define A_OK 0 /* No Errors */ 235 #define A_INVEVT 1 /* Invalid Event Error */ 236 #define A_IOCERR 2 /* Error while configuring port */ 237 #define A_SIZERR 3 /* Error in count of data chars to xmt */ 238 #define A_NXBERR 4 /* Transmit Incomplete due to lack of bufs */ 239 240 /* 241 * Modem control signal control structure. 242 */ 243 struct mdmctl { 244 u_char mc_rngdsr; /* ring or dsr */ 245 u_char mc_rts; /* request to send */ 246 u_char mc_rate; 247 u_char mc_dcd; /* data carrier detect */ 248 u_char mc_sectx; /* secondary transmit */ 249 u_char mc_cts; /* clear to send */ 250 u_char mc_secrx; /* secondary receive */ 251 u_char mc_dtr; /* data terminal ready */ 252 }; 253 254 /* defines for modem control lines */ 255 #define ASSERT 1 /* line asserted */ 256 #define DROP 2 /* line dropped */ 257 #define AUTO 3 /* auto mode enabled, rts only */ 258 259 /* 260 * Async parameter structure. 261 */ 262 struct asyncparam { 263 u_char ap_xon, ap_xoff; /* xon-xoff characters */ 264 u_char ap_xena; /* xon/xoff enabled */ 265 u_char ap_xany; /* any received char enables xmitter */ 266 struct mdmctl ap_modem; /* port modem control lines */ 267 struct mdmctl ap_intena; /* modem signals which generate */ 268 /* status change events */ 269 u_char ap_data; /* number of data bits */ 270 u_char ap_stop; /* number of stop bits */ 271 u_char ap_baud; /* baud rate */ 272 u_char ap_parity; /* even/odd/no parity */ 273 u_char ap_loop; /* enable for local loopback */ 274 u_char ap_rtimer; /* receive timer value (msec) */ 275 short ap_fill; /* round to longword */ 276 }; 277 278 /* enable/disable signal codes */ 279 #define MPA_ENA 1 /* condition enabled */ 280 #define MPA_DIS 2 /* condition disabled */ 281 282 /* defines for ap_data */ 283 #define MPCHAR_5 0 /* 5 bits per character */ 284 #define MPCHAR_6 2 /* 6 bits per character */ 285 #define MPCHAR_7 1 /* 7 bits per character */ 286 #define MPCHAR_8 3 /* 8 bits per character */ 287 288 /* defines for ap_stop */ 289 #define MPSTOP_1 1 /* 1 stop bit per character */ 290 #define MPSTOP_1_5 2 /* 1 1/2 stop bits per character */ 291 #define MPSTOP_2 3 /* 2 stop bits per character */ 292 293 /* defines for ap_baud */ 294 #define MODEM 0 295 #define M0 0 /* baud rate = 0 */ 296 #define M50 1 /* baud rate = 50 */ 297 #define M75 2 /* baud rate = 75 */ 298 #define M110 3 /* baud rate = 110 */ 299 #define M134_5 4 /* baud rate = 134.5 */ 300 #define M150 5 /* baud rate = 150 */ 301 #define M200 6 /* baud rate = 200 */ 302 #define M300 7 /* baud rate = 300 */ 303 #define M600 8 /* baud rate = 600 */ 304 #define M1200 9 /* baud rate = 1200 */ 305 #define M1800 10 /* baud rate = 1800 */ 306 #define M2400 11 /* baud rate = 2400 */ 307 #define M4800 12 /* baud rate = 4800 */ 308 #define M9600 13 /* baud rate = 9600 */ 309 #define MEXTA 14 /* baud rate = Ext A */ 310 #define MEXTB 15 /* baud rate = Ext B */ 311 #define M2000 16 /* baud rate = 2000 */ 312 #define M3600 17 /* baud rate = 3600 */ 313 #define M7200 18 /* baud rate = 7200 */ 314 #define M19200 19 /* baud rate = 19,200 */ 315 #define M24000 20 /* baud rate = 24,000 */ 316 #define M28400 21 /* baud rate = 28,400 */ 317 #define M37800 22 /* baud rate = 37,800 */ 318 #define M40300 23 /* baud rate = 40,300 */ 319 #define M48000 24 /* baud rate = 48,000 */ 320 #define M52000 25 /* baud rate = 52,000 */ 321 #define M56800 26 /* baud rate = 56,800 */ 322 323 /* defines for ap_parity */ 324 #define MPPAR_NONE 0 /* no parity */ 325 #define MPPAR_ODD 1 /* odd parity */ 326 #define MPPAR_EVEN 3 /* even parity */ 327 328 /* possible flags for Host MP_IOCTL Events */ 329 #define A_CHGX 1 /* IOCTL is only chging xonxoff params */ 330 #define A_MDMCHG 2 /* change modem control lines */ 331 #define A_MDMGET 3 /* get current state of modem ctl lines */ 332 #define A_CHGL1P 4 /* IOCTL is changing changing L1 params */ 333 #define A_BRKON 5 /* set port break bit */ 334 #define A_BRKOFF 6 /* clear port break bit */ 335 #define A_CHGALL 7 /* IOCTL is changing xonxoff params, */ 336 /* pcnfg struct, & modem ctl structs */ 337 #define A_DISABX 8 /* disable port transmitter (ctl-s) */ 338 #define A_ENABLX 9 /* enable port transmitter (ctl-q) */ 339 340 /* possible flags for Host MP_WRITE Events */ 341 #define A_FLUSH 1 /* flush any queued transmit events */ 342 #define A_SSTOP 2 /* transmit a port stop (xoff) char */ 343 /* before sending rest of event xmts */ 344 #define A_SSTART 3 /* transmit a port start (xon) char */ 345 /* before sending rest of event xmts */ 346 347 /* possible flags for Outbound MP_READ Events */ 348 #define A_XOFF 1 /* transmitter stopped from by xoff char */ 349 350 /* Perpos flags for modem control fields */ 351 #define A_RNGDSR 00001 352 #define A_RTS 00002 353 #define A_RATE 00004 354 #define A_DCD 00010 355 #define A_SECTX 00020 356 #define A_CTS 00040 357 #define A_SECRX 00100 358 #define A_DTR 00200 359 360 #define DCDASRT 100 /* data carrier detect asserted */ 361 #define DTRASRT 101 /* data terminal ready asserted */ 362 #define RNGASRT 102 /* ring indicator asserted */ 363 #define DSRASRT 102 /* data set ready asserted */ 364 #define CTSASRT 103 /* clear to send asserted */ 365 #define RTSASRT 104 /* ready to send asserted */ 366 #define STXASRT 105 /* secondary transmit asserted */ 367 #define SRXASRT 106 /* secondary recieve asserted */ 368 #define RATEASRT 107 /* rate signal asserted */ 369 #define DCDDROP 108 /* data carrier detect dropped */ 370 #define DTRDROP 109 /* data terminal ready dropped */ 371 #define RNGDROP 110 /* ring indicator dropped */ 372 #define MPDSRDROP 110 /* data set ready dropped */ 373 #define CTSDROP 111 /* clear to send dropped */ 374 #define RTSDROP 112 /* ready to send dropped */ 375 #define STXDROP 113 /* secondary transmit dropped */ 376 #define SRXDROP 114 /* secondary recieve dropped */ 377 #define RATEDROP 115 /* rate signal dropped */ 378 379 /* Defines for filters and intena in portstat */ 380 #define MDM_OFF 0 381 #define MDM_ON 1 382 383 /* Modem on/off flags */ 384 #define MMOD_OFF 0 385 #define MMOD_ON 1 386 387 /* defintions for DL interface */ 388 389 #define MPDLBUFSIZE 1024 390 391 /* mpdlioctl command defines */ 392 393 struct protports { 394 char protoport[MPMAXPORT]; 395 }; 396 397 struct abdcf { 398 short xmtbsz; /* transmit buffer size - should */ 399 /* equal # of chars in a cblock */ 400 }; 401 402 struct bdcf { 403 char loadname[NMPPROTO+1]; 404 char protoports[MPMAXPORT]; 405 char fccstimer; /* powerfail timer */ 406 char fccsports; /* ports to affect */ 407 char fccssoc; /* ports which will 'switch on close' */ 408 }; 409 410 411 /* These ioctls are for the dlmpcc command */ 412 #define MPIOPORTMAP _IOW('m',1, struct protports) 413 #define MPIOHILO _IOW('m',3, short) 414 #define MPIOENDCODE _IO('m',4) 415 #define MPIOASYNCNF _IOW('m',7, struct abdcf) 416 #define MPIOENDDL _IO('m',10) 417 #define MPIOSTARTDL _IO('m',11) 418 #define MPIORESETBOARD _IO('m',12) 419 420 /* mpdlwrite opcode defines */ 421 422 #define MPDLCMD_NORMAL 1 423 424 /* error messages printed at console , board & port # filled in later */ 425 426 #define A_INVSTS "Invalid Status Event " 427 #define A_INVCMD "Invalid Event From the MPCC " 428 #define A_NORBUF "No More Available Receive Buffers " 429 #define A_NOEBUF "No More Available Event Buffers " 430 #define A_OVRN "Overrun Error Detected " 431 #define A_OVRF "Overflow Error Detected " 432 #define A_NOXBUF "No More Available Transmit Event Buffers " 433 #define A_XSIZE "Transmit Data Block Size Exceeds Event Data Buffer Size " 434 #define A_NOFREIN "No Available Inbound Entries to Send Close Event " 435