Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / i386 / include / cronyx.h
1 /*
2  * Defines for Cronyx-Sigma adapter driver.
3  *
4  * Copyright (C) 1994 Cronyx Ltd.
5  * Author: Serge Vakulenko, <vak@zebub.msk.su>
6  *
7  * This software is distributed with NO WARRANTIES, not even the implied
8  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  *
10  * Authors grant any other persons or organizations permission to use
11  * or modify this software as long as this message is kept with the software,
12  * all derivative works or modified versions.
13  *
14  * Version 1.9, Wed Oct  4 18:58:15 MSK 1995
15  *
16  * $FreeBSD: src/sys/i386/include/cronyx.h,v 1.9 1999/12/29 04:33:00 peter Exp $
17  * $DragonFly: src/sys/i386/include/Attic/cronyx.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
18  */
19 /*
20  * Asynchronous channel mode -------------------------------------------------
21  */
22
23 /* Parity */
24 #define PAR_EVEN        0       /* even parity */
25 #define PAR_ODD         1       /* odd parity */
26
27 /* Parity mode */
28 #define PARM_NOPAR      0       /* no parity */
29 #define PARM_FORCE      1       /* force parity (odd = force 1, even = 0) */
30 #define PARM_NORMAL     2       /* normal parity */
31
32 /* Flow control transparency mode */
33 #define FLOWCC_PASS     0       /* pass flow ctl chars as exceptions */
34 #define FLOWCC_NOTPASS  1       /* don't pass flow ctl chars to the host */
35
36 /* Stop bit length */
37 #define STOPB_1         2       /* 1 stop bit */
38 #define STOPB_15        3       /* 1.5 stop bits */
39 #define STOPB_2         4       /* 2 stop bits */
40
41 /* Action on break condition */
42 #define BRK_INTR        0       /* generate an exception interrupt */
43 #define BRK_NULL        1       /* translate to a NULL character */
44 #define BRK_RESERVED    2       /* reserved */
45 #define BRK_DISCARD     3       /* discard character */
46
47 /* Parity/framing error actions */
48 #define PERR_INTR       0       /* generate an exception interrupt */
49 #define PERR_NULL       1       /* translate to a NULL character */
50 #define PERR_IGNORE     2       /* ignore error; char passed as good data */
51 #define PERR_DISCARD    3       /* discard error character */
52 #define PERR_FFNULL     5       /* translate to FF NULL char */
53
54 typedef struct {                /* async channel option register 1 */
55         unsigned charlen : 4;   /* character length, 5..8 */
56         unsigned ignpar : 1;    /* ignore parity */
57         unsigned parmode : 2;   /* parity mode */
58         unsigned parity : 1;    /* parity */
59 } cx_cor1_async_t;
60
61 typedef struct {                /* async channel option register 2 */
62         unsigned dsrae : 1;     /* DSR automatic enable */
63         unsigned ctsae : 1;     /* CTS automatic enable */
64         unsigned rtsao : 1;     /* RTS automatic output enable */
65         unsigned rlm : 1;       /* remote loopback mode enable */
66         unsigned zero : 1;
67         unsigned etc : 1;       /* embedded transmitter cmd enable */
68         unsigned ixon : 1;      /* in-band XON/XOFF enable */
69         unsigned ixany : 1;     /* XON on any character */
70 } cx_cor2_async_t;
71
72 typedef struct {                /* async channel option register 3 */
73         unsigned stopb : 3;     /* stop bit length */
74         unsigned zero : 1;
75         unsigned scde : 1;      /* special char detection enable */
76         unsigned flowct : 1;    /* flow control transparency mode */
77         unsigned rngde : 1;     /* range detect enable */
78         unsigned escde : 1;     /* extended spec. char detect enable */
79 } cx_cor3_async_t;
80
81 typedef struct {                /* async channel option register 6 */
82         unsigned parerr : 3;    /* parity/framing error actions */
83         unsigned brk : 2;       /* action on break condition */
84         unsigned inlcr : 1;     /* translate NL to CR on input */
85         unsigned icrnl : 1;     /* translate CR to NL on input */
86         unsigned igncr : 1;     /* discard CR on input */
87 } cx_cor6_async_t;
88
89 typedef struct {                /* async channel option register 7 */
90         unsigned ocrnl : 1;     /* translate CR to NL on output */
91         unsigned onlcr : 1;     /* translate NL to CR on output */
92         unsigned zero : 3;
93         unsigned fcerr : 1;     /* process flow ctl err chars enable */
94         unsigned lnext : 1;     /* LNext option enable */
95         unsigned istrip : 1;    /* strip 8-bit on input */
96 } cx_cor7_async_t;
97
98 typedef struct {                /* async channel options */
99         cx_cor1_async_t cor1;   /* channel option register 1 */
100         cx_cor2_async_t cor2;   /* channel option register 2 */
101         cx_cor3_async_t cor3;   /* option register 3 */
102         cx_cor6_async_t cor6;   /* channel option register 6 */
103         cx_cor7_async_t cor7;   /* channel option register 7 */
104         unsigned char schr1;    /* special character register 1 (XON) */
105         unsigned char schr2;    /* special character register 2 (XOFF) */
106         unsigned char schr3;    /* special character register 3 */
107         unsigned char schr4;    /* special character register 4 */
108         unsigned char scrl;     /* special character range low */
109         unsigned char scrh;     /* special character range high */
110         unsigned char lnxt;     /* LNext character */
111 } cx_opt_async_t;
112
113 /*
114  * HDLC channel mode ---------------------------------------------------------
115  */
116 /* Address field length option */
117 #define AFLO_1OCT       0       /* address field is 1 octet in length */
118 #define AFLO_2OCT       1       /* address field is 2 octet in length */
119
120 /* Clear detect for X.21 data transfer phase */
121 #define CLRDET_DISABLE  0       /* clear detect disabled */
122 #define CLRDET_ENABLE   1       /* clear detect enabled */
123
124 /* Addressing mode */
125 #define ADMODE_NOADDR   0       /* no address */
126 #define ADMODE_4_1      1       /* 4 * 1 byte */
127 #define ADMODE_2_2      2       /* 2 * 2 byte */
128
129 /* FCS append */
130 #define FCS_NOTPASS     0       /* receive CRC is not passed to the host */
131 #define FCS_PASS        1       /* receive CRC is passed to the host */
132
133 /* CRC modes */
134 #define CRC_INVERT      0       /* CRC is transmitted inverted (CRC V.41) */
135 #define CRC_DONT_INVERT 1       /* CRC is not transmitted inverted (CRC-16) */
136
137 /* Send sync pattern */
138 #define SYNC_00         0       /* send 00h as pad char (NRZI encoding) */
139 #define SYNC_AA         1       /* send AAh (Manchester/NRZ encoding) */
140
141 /* FCS preset */
142 #define FCSP_ONES       0       /* FCS is preset to all ones (CRC V.41) */
143 #define FCSP_ZEROS      1       /* FCS is preset to all zeros (CRC-16) */
144
145 /* idle mode */
146 #define IDLE_FLAG       0       /* idle in flag */
147 #define IDLE_MARK       1       /* idle in mark */
148
149 /* CRC polynomial select */
150 #define POLY_V41        0       /* x^16+x^12+x^5+1 (HDLC, preset to 1) */
151 #define POLY_16         1       /* x^16+x^15+x^2+1 (bisync, preset to 0) */
152
153 typedef struct {                /* hdlc channel option register 1 */
154         unsigned ifflags : 4;   /* number of inter-frame flags sent */
155         unsigned admode : 2;    /* addressing mode */
156         unsigned clrdet : 1;    /* clear detect for X.21 data transfer phase */
157         unsigned aflo : 1;      /* address field length option */
158 } cx_cor1_hdlc_t;
159
160 typedef struct {                /* hdlc channel option register 2 */
161         unsigned dsrae : 1;     /* DSR automatic enable */
162         unsigned ctsae : 1;     /* CTS automatic enable */
163         unsigned rtsao : 1;     /* RTS automatic output enable */
164         unsigned zero1 : 1;
165         unsigned crcninv : 1;   /* CRC inversion option */
166         unsigned zero2 : 1;
167         unsigned fcsapd : 1;    /* FCS append */
168         unsigned zero3 : 1;
169 } cx_cor2_hdlc_t;
170
171 typedef struct {                /* hdlc channel option register 3 */
172         unsigned padcnt : 3;    /* pad character count */
173         unsigned idle : 1;      /* idle mode */
174         unsigned nofcs : 1;     /* FCS disable */
175         unsigned fcspre : 1;    /* FCS preset */
176         unsigned syncpat : 1;   /* send sync pattern */
177         unsigned sndpad : 1;    /* send pad characters before flag enable */
178 } cx_cor3_hdlc_t;
179
180 typedef struct {                /* hdlc channel options */
181         cx_cor1_hdlc_t cor1;    /* hdlc channel option register 1 */
182         cx_cor2_hdlc_t cor2;    /* hdlc channel option register 2 */
183         cx_cor3_hdlc_t cor3;    /* hdlc channel option register 3 */
184         unsigned char rfar1;    /* receive frame address register 1 */
185         unsigned char rfar2;    /* receive frame address register 2 */
186         unsigned char rfar3;    /* receive frame address register 3 */
187         unsigned char rfar4;    /* receive frame address register 4 */
188         unsigned char cpsr;     /* CRC polynomial select */
189 } cx_opt_hdlc_t;
190
191 /*
192  * BISYNC channel mode -------------------------------------------------------
193  */
194
195 /* Longitudinal redundancy check */
196 #define BCC_CRC16       0       /* CRC16 is used for BCC */
197 #define BCC_LRC         1       /* LRC is used for BCC */
198
199 /* Send pad pattern */
200 #define PAD_AA          0       /* send AAh as pad character */
201 #define PAD_55          1       /* send 55h as pad character */
202
203 typedef struct {                /* channel option register 1 */
204         unsigned charlen : 4;   /* character length, 5..8 */
205         unsigned ignpar : 1;    /* ignore parity */
206         unsigned parmode : 2;   /* parity mode */
207         unsigned parity : 1;    /* parity */
208 } cx_cor1_bisync_t;
209
210 typedef struct {                /* channel option register 2 */
211         unsigned syns : 4;      /* number of extra SYN chars before a frame */
212         unsigned crcninv : 1;   /* CRC inversion option */
213         unsigned ebcdic : 1;    /* use EBCDIC as char set (instead of ASCII) */
214         unsigned bcc : 1;       /* BCC append enable */
215         unsigned lrc : 1;       /* longitudinal redundancy check */
216 } cx_cor2_bisync_t;
217
218 typedef struct {                /* channel option register 3 */
219         unsigned padcnt : 3;    /* pad character count */
220         unsigned idle : 1;      /* idle mode */
221         unsigned nofcs : 1;     /* FCS disable */
222         unsigned fcspre : 1;    /* FCS preset */
223         unsigned padpat : 1;    /* send pad pattern */
224         unsigned sndpad : 1;    /* send pad characters before SYN enable */
225 } cx_cor3_bisync_t;
226
227 typedef struct {                /* channel option register 6 */
228         unsigned char specterm; /* special termination character */
229 } cx_cor6_bisync_t;
230
231 typedef struct {                /* bisync channel options */
232         cx_cor1_bisync_t cor1;  /* channel option register 1 */
233         cx_cor2_bisync_t cor2;  /* channel option register 2 */
234         cx_cor3_bisync_t cor3;  /* channel option register 3 */
235         cx_cor6_bisync_t cor6;  /* channel option register 6 */
236         unsigned char cpsr;     /* CRC polynomial select */
237 } cx_opt_bisync_t;
238
239 /*
240  * X.21 channel mode ---------------------------------------------------------
241  */
242
243 /* The number of SYN chars on receive */
244 #define X21SYN_2        0       /* two SYN characters are required */
245 #define X21SYN_1        1       /* one SYN character is required */
246
247 typedef struct {                /* channel option register 1 */
248         unsigned charlen : 4;   /* character length, 5..8 */
249         unsigned ignpar : 1;    /* ignore parity */
250         unsigned parmode : 2;   /* parity mode */
251         unsigned parity : 1;    /* parity */
252 } cx_cor1_x21_t;
253
254 typedef struct {                /* channel option register 2 */
255         unsigned zero1 : 5;
256         unsigned etc : 1;       /* embedded transmitter command enable */
257         unsigned zero2 : 2;
258 } cx_cor2_x21_t;
259
260 typedef struct {                /* channel option register 3 */
261         unsigned zero : 4;
262         unsigned scde : 1;      /* special character detect enable */
263         unsigned stripsyn : 1;  /* treat SYN chars as special condition */
264         unsigned ssde : 1;      /* steady state detect enable */
265         unsigned syn : 1;       /* the number of SYN chars on receive */
266 } cx_cor3_x21_t;
267
268 typedef struct {                /* channel option register 6 */
269         unsigned char synchar;  /* syn character */
270 } cx_cor6_x21_t;
271
272 typedef struct {                /* x21 channel options */
273         cx_cor1_x21_t cor1;     /* channel option register 1 */
274         cx_cor2_x21_t cor2;     /* channel option register 2 */
275         cx_cor3_x21_t cor3;     /* channel option register 3 */
276         cx_cor6_x21_t cor6;     /* channel option register 6 */
277         unsigned char schr1;    /* special character register 1 */
278         unsigned char schr2;    /* special character register 2 */
279         unsigned char schr3;    /* special character register 3 */
280 } cx_opt_x21_t;
281
282 /*
283  * CD2400 channel state structure --------------------------------------------
284  */
285
286 /* Signal encoding */
287 #define ENCOD_NRZ        0      /* NRZ mode */
288 #define ENCOD_NRZI       1      /* NRZI mode */
289 #define ENCOD_MANCHESTER 2      /* Manchester mode */
290
291 /* Clock source */
292 #define CLK_0           0      /* clock 0 */
293 #define CLK_1           1      /* clock 1 */
294 #define CLK_2           2      /* clock 2 */
295 #define CLK_3           3      /* clock 3 */
296 #define CLK_4           4      /* clock 4 */
297 #define CLK_EXT         6      /* external clock */
298 #define CLK_RCV         7      /* receive clock */
299
300 /* Channel type */
301 #define T_NONE          0       /* no channel */
302 #define T_ASYNC         1       /* pure asynchronous RS-232 channel */
303 #define T_SYNC_RS232    2       /* pure synchronous RS-232 channel */
304 #define T_SYNC_V35      3       /* pure synchronous V.35 channel */
305 #define T_SYNC_RS449    4       /* pure synchronous RS-449 channel */
306 #define T_UNIV_RS232    5       /* sync/async RS-232 channel */
307 #define T_UNIV_RS449    6       /* sync/async RS-232/RS-449 channel */
308 #define T_UNIV_V35      7       /* sync/async RS-232/V.35 channel */
309
310 typedef enum {                  /* channel mode */
311         M_ASYNC,                /* asynchronous mode */
312         M_HDLC,                 /* HDLC mode */
313         M_BISYNC,               /* BISYNC mode */
314         M_X21                   /* X.21 mode */
315 } cx_chan_mode_t;
316
317 typedef struct {                /* channel option register 4 */
318         unsigned thr : 4;       /* FIFO threshold */
319         unsigned zero : 1;
320         unsigned cts_zd : 1;    /* detect 1 to 0 transition on the CTS */
321         unsigned cd_zd : 1;     /* detect 1 to 0 transition on the CD */
322         unsigned dsr_zd : 1;    /* detect 1 to 0 transition on the DSR */
323 } cx_cor4_t;
324
325 typedef struct {                /* channel option register 5 */
326         unsigned rx_thr : 4;    /* receive flow control FIFO threshold */
327         unsigned zero : 1;
328         unsigned cts_od : 1;    /* detect 0 to 1 transition on the CTS */
329         unsigned cd_od : 1;     /* detect 0 to 1 transition on the CD */
330         unsigned dsr_od : 1;    /* detect 0 to 1 transition on the DSR */
331 } cx_cor5_t;
332
333 typedef struct {                /* receive clock option register */
334         unsigned clk : 3;       /* receive clock source */
335         unsigned encod : 2;     /* signal encoding NRZ/NRZI/Manchester */
336         unsigned dpll : 1;      /* DPLL enable */
337         unsigned zero : 1;
338         unsigned tlval : 1;     /* transmit line value */
339 } cx_rcor_t;
340
341 typedef struct {                /* transmit clock option register */
342         unsigned zero1 : 1;
343         unsigned llm : 1;       /* local loopback mode */
344         unsigned zero2 : 1;
345         unsigned ext1x : 1;     /* external 1x clock mode */
346         unsigned zero3 : 1;
347         unsigned clk : 3;       /* transmit clock source */
348 } cx_tcor_t;
349
350 typedef struct {
351         cx_cor4_t cor4;         /* channel option register 4 */
352         cx_cor5_t cor5;         /* channel option register 5 */
353         cx_rcor_t rcor;         /* receive clock option register */
354         cx_tcor_t tcor;         /* transmit clock option register */
355 } cx_chan_opt_t;
356
357 typedef enum {                  /* line break mode */
358         BRK_IDLE,               /* normal line mode */
359         BRK_SEND,               /* start sending break */
360         BRK_STOP                /* stop sending break */
361 } cx_break_t;
362
363 typedef struct {
364         unsigned cisco : 1;     /* cisco mode */
365         unsigned keepalive : 1; /* keepalive enable */
366         unsigned ext : 1;       /* use external ppp implementation */
367         unsigned lock : 1;      /* channel locked for use by driver */
368         unsigned norts : 1;     /* disable automatic RTS control */
369 } cx_soft_opt_t;
370
371 #define NCHIP    4              /* the number of controllers per board */
372 #define NCHAN    16             /* the number of channels on the board */
373
374 typedef struct {
375         unsigned char board;            /* adapter number, 0..2 */
376         unsigned char channel;          /* channel number, 0..15 */
377         unsigned char type;             /* channel type (read only) */
378         unsigned char iftype;           /* chan0 interface RS-232/RS-449/V.35 */
379         unsigned long rxbaud;           /* receiver speed */
380         unsigned long txbaud;           /* transmitter speed */
381         cx_chan_mode_t mode;            /* channel mode */
382         cx_chan_opt_t opt;              /* common channel options */
383         cx_opt_async_t aopt;            /* async mode options */
384         cx_opt_hdlc_t hopt;             /* hdlc mode options */
385         cx_opt_bisync_t bopt;           /* bisync mode options */
386         cx_opt_x21_t xopt;              /* x.21 mode options */
387         cx_soft_opt_t sopt;             /* software options and state flags */
388         char master[16];                /* master interface name or \0 */
389 } cx_options_t;                         /* user settable options */
390
391 typedef struct _chan_t {
392         unsigned char type;             /* channel type */
393         unsigned char num;              /* channel number, 0..15 */
394         struct _board_t *board;         /* board pointer */
395         struct _chip_t *chip;           /* controller pointer */
396         struct _stat_t *stat;           /* statistics */
397         unsigned long rxbaud;           /* receiver speed */
398         unsigned long txbaud;           /* transmitter speed */
399         cx_chan_mode_t mode;            /* channel mode */
400         cx_chan_opt_t opt;              /* common channel options */
401         cx_opt_async_t aopt;            /* async mode options */
402         cx_opt_hdlc_t hopt;             /* hdlc mode options */
403         cx_opt_bisync_t bopt;           /* bisync mode options */
404         cx_opt_x21_t xopt;              /* x.21 mode options */
405         unsigned char *arbuf;           /* receiver A dma buffer */
406         unsigned char *brbuf;           /* receiver B dma buffer */
407         unsigned char *atbuf;           /* transmitter A dma buffer */
408         unsigned char *btbuf;           /* transmitter B dma buffer */
409         unsigned long arphys;           /* receiver A phys address */
410         unsigned long brphys;           /* receiver B phys address */
411         unsigned long atphys;           /* transmitter A phys address */
412         unsigned long btphys;           /* transmitter B phys address */
413         unsigned char dtr;              /* DTR signal value */
414         unsigned char rts;              /* RTS signal value */
415 #ifdef _KERNEL
416         struct tty *ttyp;               /* tty structure pointer */
417         struct ifnet *ifp;              /* network interface data */
418         struct ifnet *master;           /* master interface, or ==ifp */
419         struct _chan_t *slaveq;         /* slave queue pointer, or NULL */
420         cx_soft_opt_t sopt;             /* software options and state flags */
421         cx_break_t brk;                 /* line break mode */
422 #ifdef __bsdi__
423         struct ttydevice_tmp *ttydev;   /* tty statistics structure */
424 #endif
425 #endif
426 } cx_chan_t;
427
428 typedef struct _chip_t {
429         unsigned short port;            /* base port address, or 0 if no chip */
430         unsigned char num;              /* controller number, 0..3 */
431         struct _board_t *board;         /* board pointer */
432         unsigned long oscfreq;          /* oscillator frequency in Hz */
433 } cx_chip_t;
434
435 typedef struct _stat_t {
436         unsigned char board;            /* adapter number, 0..2 */
437         unsigned char channel;          /* channel number, 0..15 */
438         unsigned long rintr;            /* receive interrupts */
439         unsigned long tintr;            /* transmit interrupts */
440         unsigned long mintr;            /* modem interrupts */
441         unsigned long ibytes;           /* input bytes */
442         unsigned long ipkts;            /* input packets */
443         unsigned long ierrs;            /* input errors */
444         unsigned long obytes;           /* output bytes */
445         unsigned long opkts;            /* output packets */
446         unsigned long oerrs;            /* output errors */
447 } cx_stat_t;
448
449 typedef struct _board_t {
450         unsigned short port;    /* base board port, 0..3f0 */
451         unsigned short num;     /* board number, 0..2 */
452         unsigned char irq;      /* interrupt request {3 5 7 10 11 12 15} */
453         unsigned char dma;      /* DMA request {5 6 7} */
454         unsigned char if0type;  /* chan0 interface RS-232/RS-449/V.35 */
455         unsigned char if8type;  /* chan8 interface RS-232/RS-449/V.35 */
456         unsigned short bcr0;    /* BCR0 image */
457         unsigned short bcr0b;   /* BCR0b image */
458         unsigned short bcr1;    /* BCR1 image */
459         unsigned short bcr1b;   /* BCR1b image */
460         cx_chip_t chip[NCHIP];  /* controller structures */
461         cx_chan_t chan[NCHAN];  /* channel structures */
462         cx_stat_t stat[NCHAN];  /* channel statistics */
463         char name[16];          /* board version name */
464         unsigned char nuniv;    /* number of universal channels */
465         unsigned char nsync;    /* number of sync. channels */
466         unsigned char nasync;   /* number of async. channels */
467 } cx_board_t;
468
469 #define CX_SPEED_DFLT   9600
470
471 #ifdef _KERNEL
472 int cx_probe_board (int port);
473 void cx_init (cx_board_t *b, int num, int port, int irq, int dma);
474 void cx_setup_board (cx_board_t *b);
475 void cx_setup_chan (cx_chan_t *c);
476 void cx_chan_dtr (cx_chan_t *c, int on);
477 void cx_chan_rts (cx_chan_t *c, int on);
478 void cx_cmd (int base, int cmd);
479 int cx_chan_cd (cx_chan_t *c);
480 void cx_clock (long hz, long ba, int *clk, int *div);
481 #endif
482
483 #define CXIOCGETMODE _IOWR('x', 1, cx_options_t)   /* get channel options */
484 #define CXIOCSETMODE _IOW('x', 2, cx_options_t)    /* set channel options */
485 #define CXIOCGETSTAT _IOWR('x', 3, cx_stat_t)      /* get channel stats */