| Commit | Line | Data |
|---|---|---|
| 984263bc MD |
1 | /*- |
| 2 | * $FreeBSD: src/sys/dev/dgb/dgmreg.h,v 1.4.2.1 2001/09/23 19:54:54 brian Exp $ | |
| e3869ec7 | 3 | * $DragonFly: src/sys/dev/serial/dgb/dgmreg.h,v 1.3 2006/12/22 23:26:24 swildner Exp $ |
| 984263bc MD |
4 | * |
| 5 | * Digiboard driver. | |
| 6 | * | |
| 7 | * Stage 1. "Better than nothing". | |
| 8 | * Stage 2. "Gee, it works!". | |
| 9 | * | |
| 10 | * Redistribution and use in source and binary forms, with or without | |
| 11 | * modification, are permitted provided that the following conditions | |
| 12 | * are met: | |
| 13 | * 1. Redistributions of source code must retain the above copyright | |
| 14 | * notice, this list of conditions, and the following disclaimer, | |
| 15 | * without modification, immediately at the beginning of the file. | |
| 16 | * 2. Redistributions of binary code must retain the above copyright | |
| 17 | * notice, this list of conditions, and the following disclaimer, | |
| 18 | * without modification, in the accompanying documentation. | |
| 19 | * 3. The name of the author may not be used to endorse or promote products | |
| 20 | * derived from this software without specific prior written permission. | |
| 21 | * | |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR | |
| 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 32 | * SUCH DAMAGE. | |
| 33 | * | |
| 34 | * Written by Sergey Babkin, | |
| 35 | * Joint Stock Commercial Bank "Chelindbank" | |
| 36 | * (Chelyabinsk, Russia) | |
| 37 | * babkin@freebsd.org | |
| 38 | */ | |
| 39 | ||
| 40 | #define MAX_DGM_PORTS 64 | |
| 41 | ||
| 42 | /* digi.h */ | |
| 43 | /* Definitions for DigiBoard ditty(1) command. */ | |
| 44 | ||
| 45 | #if !defined(TIOCMODG) | |
| 46 | #define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ | |
| 47 | #define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ | |
| 48 | #endif | |
| 49 | ||
| 50 | #if !defined(TIOCMSET) | |
| 51 | #define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ | |
| 52 | #define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ | |
| 53 | #endif | |
| 54 | ||
| 55 | #if !defined(TIOCMBIC) | |
| 56 | #define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ | |
| 57 | #define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ | |
| 58 | #endif | |
| 59 | ||
| 60 | #if !defined(TIOCSDTR) | |
| 61 | #define TIOCSDTR ('e'<<8) | 0 /* set DTR */ | |
| 62 | #define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ | |
| 63 | #endif | |
| 64 | ||
| 65 | /************************************************************************ | |
| 66 | * Ioctl command arguments for DIGI parameters. | |
| 67 | ************************************************************************/ | |
| 68 | #define DIGI_GETA ('e'<<8) | 94 /* Read params */ | |
| 69 | ||
| 70 | #define DIGI_SETA ('e'<<8) | 95 /* Set params */ | |
| 71 | #define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ | |
| 72 | #define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ | |
| 73 | ||
| 74 | #define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ | |
| 75 | /* control characters */ | |
| 76 | #define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ | |
| 77 | /* control characters */ | |
| 78 | #define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ | |
| 79 | /* flow control chars */ | |
| 80 | #define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ | |
| 81 | /* flow control chars */ | |
| 82 | ||
| 83 | struct digiflow_struct { | |
| 84 | unsigned char startc; /* flow cntl start char */ | |
| 85 | unsigned char stopc; /* flow cntl stop char */ | |
| 86 | }; | |
| 87 | ||
| 88 | typedef struct digiflow_struct digiflow_t; | |
| 89 | ||
| 90 | ||
| 91 | /************************************************************************ | |
| 92 | * Values for digi_flags | |
| 93 | ************************************************************************/ | |
| 94 | #define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ | |
| 95 | #define DIGI_FAST 0x0002 /* Fast baud rates */ | |
| 96 | #define RTSPACE 0x0004 /* RTS input flow control */ | |
| 97 | #define CTSPACE 0x0008 /* CTS output flow control */ | |
| 98 | #define DSRPACE 0x0010 /* DSR output flow control */ | |
| 99 | #define DCDPACE 0x0020 /* DCD output flow control */ | |
| 100 | #define DTRPACE 0x0040 /* DTR input flow control */ | |
| 101 | #define DIGI_FORCEDCD 0x0100 /* Force carrier */ | |
| 102 | #define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */ | |
| 103 | #define DIGI_AIXON 0x0400 /* Aux flow control in fep */ | |
| 104 | ||
| 105 | ||
| 106 | /************************************************************************ | |
| 107 | * Structure used with ioctl commands for DIGI parameters. | |
| 108 | ************************************************************************/ | |
| 109 | struct digi_struct { | |
| 110 | unsigned short digi_flags; /* Flags (see above) */ | |
| 111 | }; | |
| 112 | ||
| 113 | typedef struct digi_struct digi_t; | |
| 114 | ||
| 115 | /* fep.h */ | |
| 116 | ||
| 117 | #define FEP_CSTART 0x400L | |
| 118 | #define FEP_CMAX 0x800L | |
| 119 | #define FEP_ISTART 0x800L | |
| 120 | #define FEP_IMAX 0xC00L | |
| 121 | #define FEP_CIN 0xD10L | |
| 122 | #define FEP_GLOBAL 0xD10L | |
| 123 | #define FEP_EIN 0xD18L | |
| 124 | #define FEPSTAT 0xD20L | |
| 125 | #define CHANSTRUCT 0x1000L | |
| 126 | #define RXTXBUF 0x4000L | |
| 127 | ||
| 128 | ||
| 129 | struct global_data { | |
| 130 | volatile ushort cin; | |
| 131 | volatile ushort cout; | |
| 132 | volatile ushort cstart; | |
| 133 | volatile ushort cmax; | |
| 134 | volatile ushort ein; | |
| 135 | volatile ushort eout; | |
| 136 | volatile ushort istart; | |
| 137 | volatile ushort imax; | |
| 138 | }; | |
| 139 | ||
| 140 | ||
| 141 | struct board_chan { | |
| 142 | int filler1; | |
| 143 | int filler2; | |
| 144 | volatile ushort tseg; | |
| 145 | volatile ushort tin; | |
| 146 | volatile ushort tout; | |
| 147 | volatile ushort tmax; | |
| 148 | ||
| 149 | volatile ushort rseg; | |
| 150 | volatile ushort rin; | |
| 151 | volatile ushort rout; | |
| 152 | volatile ushort rmax; | |
| 153 | ||
| 154 | volatile ushort tlow; | |
| 155 | volatile ushort rlow; | |
| 156 | volatile ushort rhigh; | |
| 157 | volatile ushort incr; | |
| 158 | ||
| 159 | volatile ushort etime; | |
| 160 | volatile ushort edelay; | |
| 161 | volatile u_char *dev; | |
| 162 | ||
| 163 | volatile ushort iflag; | |
| 164 | volatile ushort oflag; | |
| 165 | volatile ushort cflag; | |
| 166 | volatile ushort gmask; | |
| 167 | ||
| 168 | volatile ushort col; | |
| 169 | volatile ushort delay; | |
| 170 | volatile ushort imask; | |
| 171 | volatile ushort tflush; | |
| 172 | ||
| 173 | int filler3; | |
| 174 | int filler4; | |
| 175 | int filler5; | |
| 176 | int filler6; | |
| 177 | ||
| 178 | volatile u_char num; | |
| 179 | volatile u_char ract; | |
| 180 | volatile u_char bstat; | |
| 181 | volatile u_char tbusy; | |
| 182 | volatile u_char iempty; | |
| 183 | volatile u_char ilow; | |
| 184 | volatile u_char idata; | |
| 185 | volatile u_char eflag; | |
| 186 | ||
| 187 | volatile u_char tflag; | |
| 188 | volatile u_char rflag; | |
| 189 | volatile u_char xmask; | |
| 190 | volatile u_char xval; | |
| 191 | volatile u_char mstat; | |
| 192 | volatile u_char mchange; | |
| 193 | volatile u_char mint; | |
| 194 | volatile u_char lstat; | |
| 195 | ||
| 196 | volatile u_char mtran; | |
| 197 | volatile u_char orun; | |
| 198 | volatile u_char startca; | |
| 199 | volatile u_char stopca; | |
| 200 | volatile u_char startc; | |
| 201 | volatile u_char stopc; | |
| 202 | volatile u_char vnext; | |
| 203 | volatile u_char hflow; | |
| 204 | ||
| 205 | volatile u_char fillc; | |
| 206 | volatile u_char ochar; | |
| 207 | volatile u_char omask; | |
| 208 | ||
| 209 | u_char filler7; | |
| 210 | u_char filler8[28]; | |
| 211 | }; | |
| 212 | ||
| 213 | ||
| 214 | #define SRXLWATER 0xE0 | |
| 215 | #define SRXHWATER 0xE1 | |
| 216 | #define STOUT 0xE2 | |
| 217 | #define PAUSETX 0xE3 | |
| 218 | #define RESUMETX 0xE4 | |
| 219 | #define SAUXONOFFC 0xE6 | |
| 220 | #define SENDBREAK 0xE8 | |
| 221 | #define SETMODEM 0xE9 | |
| 222 | #define SETIFLAGS 0xEA | |
| 223 | #define SONOFFC 0xEB | |
| 224 | #define STXLWATER 0xEC | |
| 225 | #define PAUSERX 0xEE | |
| 226 | #define RESUMERX 0xEF | |
| 227 | #define SETBUFFER 0xF2 | |
| 228 | #define SETCOOKED 0xF3 | |
| 229 | #define SETHFLOW 0xF4 | |
| 230 | #define SETCTRLFLAGS 0xF5 | |
| 231 | #define SETVNEXT 0xF6 | |
| 232 | ||
| 233 | ||
| 234 | ||
| 235 | #define BREAK_IND 0x01 | |
| 236 | #define LOWTX_IND 0x02 | |
| 237 | #define EMPTYTX_IND 0x04 | |
| 238 | #define DATA_IND 0x08 | |
| 239 | #define MODEMCHG_IND 0x20 | |
| 240 | ||
| 241 | #define ALL_IND (BREAK_IND|LOWTX_IND|EMPTYTX_IND|DATA_IND|MODEMCHG_IND) | |
| 242 | ||
| 243 | #define CD 0x80 | |
| 244 | #define DSR 0x20 | |
| 245 | #define CTS 0x10 | |
| 246 | #define DTR 0x01 | |
| 247 | #define RTS 0x02 | |
| 248 | #define RI 0x40 | |
| 249 | ||
| 250 | #define FEPCODESEG 0x0200L | |
| 251 | #define FEPCODE 0x2000L | |
| 252 | #define BIOSCODE 0xf800L | |
| 253 | #define BIOSOFFSET 0x1000L | |
| 254 | ||
| 255 | #define MISCGLOBAL 0x0C00L | |
| 256 | #define NPORT 0x0C02L | |
| 257 | #define MBOX 0x0C40L | |
| 258 | #define BOTWIN 0x100L | |
| 259 | #define TOPWIN 0xFF00L | |
| 260 | ||
| 261 | #define FEPCLR 0x00 | |
| 262 | #define FEPMEM 0x02 | |
| 263 | #define FEPRST 0x04 | |
| 264 | #define FEPINT 0x08 | |
| 265 | #define FEPMASK 0x0e | |
| 266 | #define FEPWIN 0x80 | |
| 267 | ||
| 268 | #define PCXI 0 | |
| 269 | #define PCXE 1 | |
| 270 | #define PCXEVE 2 | |
| 271 | #define PCXEM 3 | |
| 272 | ||
| 273 | static char * const board_desc[] = { | |
| 274 | "PC/Xi (64K)", | |
| 275 | "PC/Xe (64K)", | |
| 276 | "PC/Xe (8K) ", | |
| 277 | "PC/Xem ", | |
| 278 | }; | |
| 279 | ||
| 280 | #define STARTC 021 | |
| 281 | #define STOPC 023 | |
| 282 | #define IAIXON 0x2000 | |
| 283 | ||
| 284 | ||
| 285 | struct board_info { | |
| 286 | u_char status; | |
| 287 | u_char type; | |
| 288 | u_char altpin; | |
| 289 | ushort numports; | |
| 290 | ushort port; | |
| 291 | u_long membase; | |
| 292 | }; | |
| 293 | ||
| 294 | ||
| 295 | #define TXSTOPPED 0x1 | |
| 296 | #define LOWWAIT 0x2 | |
| 297 | #define EMPTYWAIT 0x4 | |
| 298 | ||
| 299 | #define DISABLED 0 | |
| 300 | #define ENABLED 1 | |
| 301 | #define OFF 0 | |
| 302 | #define ON 1 | |
| 303 | ||
| 304 | #define FEPTIMEOUT 200000 | |
| 305 | #define SERIAL_TYPE_NORMAL 1 | |
| 306 | #define SERIAL_TYPE_CALLOUT 2 | |
| 307 | #define PCXE_EVENT_HANGUP 1 | |
| 308 | ||
| 309 | struct channel { | |
| 310 | u_char unit; /* board unit number */ | |
| 311 | u_char omodem; /* FEP output modem status */ | |
| 312 | u_char imodem; /* FEP input modem status */ | |
| 313 | u_char modemfake; /* Modem values to be forced */ | |
| 314 | u_char modem; /* Force values */ | |
| 315 | u_char hflow; | |
| 316 | u_char dsr; | |
| 317 | u_char dcd; | |
| 318 | u_char stopc; | |
| 319 | u_char startc; | |
| 320 | u_char stopca; | |
| 321 | u_char startca; | |
| 322 | u_char fepstopc; | |
| 323 | u_char fepstartc; | |
| 324 | u_char fepstopca; | |
| 325 | u_char fepstartca; | |
| 326 | u_char txwin; | |
| 327 | u_char rxwin; | |
| 328 | ushort fepiflag; | |
| 329 | ushort fepcflag; | |
| 330 | ushort fepoflag; | |
| 331 | ushort txbufhead; | |
| 332 | ushort txbufsize; | |
| 333 | ushort rxbufhead; | |
| 334 | ushort rxbufsize; | |
| 335 | int close_delay; | |
| 336 | int count; | |
| 337 | int blocked_open; | |
| 338 | int event; | |
| 339 | int asyncflags; | |
| 340 | uint dev; | |
| 341 | long session; | |
| 342 | long pgrp; | |
| 343 | u_long statusflags; | |
| 344 | u_long c_iflag; | |
| 345 | u_long c_cflag; | |
| 346 | u_long c_lflag; | |
| 347 | u_long c_oflag; | |
| 348 | u_char *txptr; | |
| 349 | u_char *rxptr; | |
| 350 | struct board_info *board; | |
| 351 | struct board_chan *brdchan; | |
| 352 | struct digi_struct digiext; | |
| 353 | struct tty *tty; | |
| 354 | struct termios normal_termios; | |
| 355 | struct termios callout_termios; | |
| 356 | volatile struct global_data *mailbox; | |
| 357 | }; | |
| 358 | ||
| 359 | /* flags for configuring */ | |
| 360 | ||
| 361 | #define DGBFLAG_ALTPIN 0x0001 /* chande DCD and DCD */ | |
| 362 | #define DGBFLAG_NOWIN 0x0002 /* use windowed PC/Xe as non-windowed */ | |
| 363 | ||
| 364 | #define DB_RD 0x0001 | |
| 365 | #define DB_WR 0x0002 | |
| 366 | #define DB_WIN 0x0004 | |
| 367 | #define DB_INFO 0x0008 | |
| 368 | #define DB_EXCEPT 0x0010 | |
| 369 | #define DB_OPEN 0x0100 | |
| 370 | #define DB_CLOSE 0x0200 | |
| 371 | #define DB_DATA 0x0400 | |
| 372 | #define DB_RXDATA 0x0401 | |
| 373 | #define DB_TXDATA 0x0402 | |
| 374 | #define DB_EVENT 0x0800 | |
| 375 | #define DB_MODEM 0x1000 | |
| 376 | #define DB_BREAK 0x2000 | |
| 377 | #define DB_PARAM 0x4000 | |
| 378 | #define DB_FEP 0x8000 | |
| 379 | ||
| 380 | /* debugging printout */ | |
| 381 | ||
| 382 | #ifdef DEBUG | |
| e3869ec7 SW |
383 | #define DPRINT1(l,a1) (dgmdebug&l ? kprintf(a1) : 0) |
| 384 | #define DPRINT2(l,a1,a2) (dgmdebug&l ? kprintf(a1,a2) : 0) | |
| 385 | #define DPRINT3(l,a1,a2,a3) (dgmdebug&l ? kprintf(a1,a2,a3) : 0) | |
| 386 | #define DPRINT4(l,a1,a2,a3,a4) (dgmdebug&l ? kprintf(a1,a2,a3,a4) : 0) | |
| 387 | #define DPRINT5(l,a1,a2,a3,a4,a5) (dgmdebug&l ? kprintf(a1,a2,a3,a4,a5) : 0) | |
| 388 | #define DPRINT6(l,a1,a2,a3,a4,a5,a6) (dgmdebug&l ? kprintf(a1,a2,a3,a4,a5,a6) : 0) | |
| 389 | #define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7) (dgmdebug&l ? kprintf(a1,a2,a3,a4,a5,a6,a7) : 0) | |
| 984263bc MD |
390 | #else |
| 391 | #define DPRINT1(l,a1) | |
| 392 | #define DPRINT2(l,a1,a2) | |
| 393 | #define DPRINT3(l,a1,a2,a3) | |
| 394 | #define DPRINT4(l,a1,a2,a3,a4) | |
| 395 | #define DPRINT5(l,a1,a2,a3,a4,a5) | |
| 396 | #define DPRINT6(l,a1,a2,a3,a4,a5,a6) | |
| 397 | #define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7) | |
| 398 | #endif | |
| 399 | ||
| 400 | ||
| 401 | /* These are termios bits as the FEP understands them */ | |
| 402 | ||
| 403 | /* c_cflag bits */ | |
| 404 | #define FEP_CBAUD 0x00000f | |
| 405 | #define FEP_B0 0x000000 /* hang up */ | |
| 406 | #define FEP_B50 0x000001 | |
| 407 | #define FEP_B75 0x000002 | |
| 408 | #define FEP_B110 0x000003 | |
| 409 | #define FEP_B134 0x000004 | |
| 410 | #define FEP_B150 0x000005 | |
| 411 | #define FEP_B200 0x000006 | |
| 412 | #define FEP_B300 0x000007 | |
| 413 | #define FEP_B600 0x000008 | |
| 414 | #define FEP_B1200 0x000009 | |
| 415 | #define FEP_B1800 0x00000a | |
| 416 | #define FEP_B2400 0x00000b | |
| 417 | #define FEP_B4800 0x00000c | |
| 418 | #define FEP_B9600 0x00000d | |
| 419 | #define FEP_B19200 0x00000e | |
| 420 | #define FEP_B38400 0x00000f | |
| 421 | #define FEP_EXTA FEP_B19200 | |
| 422 | #define FEP_EXTB FEP_B38400 | |
| 423 | #define FEP_CSIZE 0x000030 | |
| 424 | #define FEP_CS5 0x000000 | |
| 425 | #define FEP_CS6 0x000010 | |
| 426 | #define FEP_CS7 0x000020 | |
| 427 | #define FEP_CS8 0x000030 | |
| 428 | #define FEP_CSTOPB 0x000040 | |
| 429 | #define FEP_CREAD 0x000080 | |
| 430 | #define FEP_PARENB 0x000100 | |
| 431 | #define FEP_PARODD 0x000200 | |
| 432 | #define FEP_CLOCAL 0x000800 | |
| 433 | #define FEP_FASTBAUD 0x000400 | |
| 434 | /* c_iflag bits */ | |
| 435 | #define FEP_IGNBRK 0000001 | |
| 436 | #define FEP_BRKINT 0000002 | |
| 437 | #define FEP_IGNPAR 0000004 | |
| 438 | #define FEP_PARMRK 0000010 | |
| 439 | #define FEP_INPCK 0000020 | |
| 440 | #define FEP_ISTRIP 0000040 | |
| 441 | #define FEP_IXON 0002000 | |
| 442 | #define FEP_IXANY 0004000 | |
| 443 | #define FEP_IXOFF 0010000 |