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