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