summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/cserial.h
blob: a05ff4b181babd7b6d807113d7be2b478d7f9a79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/*-
 * Ioctl interface to Cronyx serial drivers.
 *
 * Copyright (C) 1997-2002 Cronyx Engineering.
 * Author: Serge Vakulenko, <vak@cronyx.ru>
 *
 * Copyright (C) 2001-2003 Cronyx Engineering.
 * Author: Roman Kurakin, <rik@cronyx.ru>
 *
 * This software is distributed with NO WARRANTIES, not even the implied
 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Authors grant any other persons or organisations permission to use
 * or modify this software as long as this message is kept with the software,
 * all derivative works or modified versions.
 *
 * Cronyx Id: cserial.h,v 1.1.2.4 2003/11/12 17:11:08 rik Exp $
 * $FreeBSD$
 */

/*
 * General channel statistics.
 */
struct serial_statistics {
	unsigned long rintr;		/* receive interrupts */
	unsigned long tintr;		/* transmit interrupts */
	unsigned long mintr;		/* modem interrupts */
	unsigned long ibytes;		/* input bytes */
	unsigned long ipkts;		/* input packets */
	unsigned long ierrs;		/* input errors */
	unsigned long obytes;		/* output bytes */
	unsigned long opkts;		/* output packets */
	unsigned long oerrs;		/* output errors */
};

/*
 * Statistics for E1/G703 channels.
 */
struct e1_counters {
	unsigned long bpv;		/* bipolar violations */
	unsigned long fse;		/* frame sync errors */
	unsigned long crce;		/* CRC errors */
	unsigned long rcrce;		/* remote CRC errors (E-bit) */
	unsigned long uas;		/* unavailable seconds */
	unsigned long les;		/* line errored seconds */
	unsigned long es;		/* errored seconds */
	unsigned long bes;		/* bursty errored seconds */
	unsigned long ses;		/* severely errored seconds */
	unsigned long oofs;		/* out of frame seconds */
	unsigned long css;		/* controlled slip seconds */
	unsigned long dm;		/* degraded minutes */
};

struct e1_statistics {
	unsigned long status;		/* line status bit mask */
	unsigned long cursec;		/* seconds in current interval */
	unsigned long totsec;		/* total seconds elapsed */
	struct e1_counters currnt;	/* current 15-min interval data */
	struct e1_counters total;	/* total statistics data */
	struct e1_counters interval [48]; /* 12 hour period data */
};

struct e3_statistics {
	unsigned long status;
	unsigned long cursec;
	unsigned long totsec;
	unsigned long ccv;
	unsigned long tcv;
	unsigned long icv[48];
};

#define M_ASYNC         0		/* asynchronous mode */
#define M_HDLC          1		/* bit-sync mode (HDLC) */
#define M_G703          2
#define M_E1            3

/*
 * Receive error codes.
 */
#define ER_FRAMING	1		/* framing error */
#define ER_CHECKSUM	2		/* parity/CRC error */
#define ER_BREAK	3		/* break state */
#define ER_OVERFLOW	4		/* receive buffer overflow */
#define ER_OVERRUN	5		/* receive fifo overrun */
#define ER_UNDERRUN	6		/* transmit fifo underrun */
#define ER_SCC_FRAMING	7		/* subchannel framing error */
#define ER_SCC_OVERFLOW	8		/* subchannel receive buffer overflow */
#define ER_SCC_OVERRUN	9		/* subchannel receiver overrun */

/*
 * E1 channel status.
 */
#define E1_NOALARM	0x0001          /* no alarm present */
#define E1_FARLOF	0x0002          /* receiving far loss of framing */
#define E1_AIS		0x0008          /* receiving all ones */
#define E1_LOF		0x0020          /* loss of framing */
#define E1_LOS		0x0040          /* loss of signal */
#define E1_AIS16	0x0100          /* receiving all ones in timeslot 16 */
#define E1_FARLOMF	0x0200          /* receiving alarm in timeslot 16 */
#define E1_LOMF		0x0400          /* loss of multiframe sync */
#define E1_TSTREQ	0x0800          /* test code detected */
#define E1_TSTERR	0x1000          /* test error */

#define E3_LOS		0x00000002	/* Lost of synchronization */
#define E3_TXE		0x00000004	/* Transmit error */

/*
 * Query the mask of all registered channels, max 128.
 */
#define SERIAL_GETREGISTERED	_IOR ('x', 0, char[16])

/*
 * Attach/detach the protocol to the channel.
 * The protocol is given by it's name, char[8].
 * For example "async", "hdlc", "cisco", "fr", "ppp".
 */
#define SERIAL_GETPROTO		_IOR ('x', 1, char [8])
#define SERIAL_SETPROTO		_IOW ('x', 1, char [8])

/*
 * Query/set the hardware mode for the channel.
 */
#define SERIAL_GETMODE		_IOR ('x', 2, int)
#define SERIAL_SETMODE		_IOW ('x', 2, int)

#define SERIAL_ASYNC		1
#define SERIAL_HDLC		2

/*
 * Get/clear the channel statistics.
 */
#define SERIAL_GETSTAT		_IOR ('x', 3, struct serial_statistics)
#define SERIAL_GETESTAT		_IOR ('x', 3, struct e1_statistics)
#define SERIAL_GETE3STAT	_IOR ('x', 3, struct e3_statistics)
#define SERIAL_CLRSTAT		_IO  ('x', 3)

/*
 * Query/set the synchronization mode and baud rate.
 * If baud==0 then the external clock is used.
 */
#define SERIAL_GETBAUD		_IOR ('x', 4, long)
#define SERIAL_SETBAUD		_IOW ('x', 4, long)

/*
 * Query/set the internal loopback mode,
 * useful for debugging purposes.
 */
#define SERIAL_GETLOOP		_IOR ('x', 5, int)
#define SERIAL_SETLOOP		_IOW ('x', 5, int)

/*
 * Query/set the DPLL mode, commonly used with NRZI
 * for channels lacking synchro signals.
 */
#define SERIAL_GETDPLL		_IOR ('x', 6, int)
#define SERIAL_SETDPLL		_IOW ('x', 6, int)

/*
 * Query/set the NRZI encoding (default is NRZ).
 */
#define SERIAL_GETNRZI		_IOR ('x', 7, int)
#define SERIAL_SETNRZI		_IOW ('x', 7, int)

/*
 * Invert receive and transmit clock.
 */
#define SERIAL_GETINVCLK	_IOR ('x', 8, int)
#define SERIAL_SETINVCLK	_IOW ('x', 8, int)

/*
 * Query/set the E1/G703 synchronization mode.
 */
#define SERIAL_GETCLK		_IOR ('x', 9, int)
#define SERIAL_SETCLK		_IOW ('x', 9, int)

#define E1CLK_INTERNAL		0
#define E1CLK_RECEIVE		1
#define E1CLK_RECEIVE_CHAN0	2
#define E1CLK_RECEIVE_CHAN1	3
#define E1CLK_RECEIVE_CHAN2	4
#define E1CLK_RECEIVE_CHAN3	5

/*
 * Query/set the E1 timeslot mask.
 */
#define SERIAL_GETTIMESLOTS	_IOR ('x', 10, long)
#define SERIAL_SETTIMESLOTS	_IOW ('x', 10, long)

/*
 * Query/set the E1 subchannel timeslot mask.
 */
#define SERIAL_GETSUBCHAN	_IOR ('x', 11, long)
#define SERIAL_SETSUBCHAN	_IOW ('x', 11, long)

/*
 * Query/set the high input sensitivity mode (E1).
 */
#define SERIAL_GETHIGAIN	_IOR ('x', 12, int)
#define SERIAL_SETHIGAIN	_IOW ('x', 12, int)

/*
 * Query the input signal level in santibells.
 */
#define SERIAL_GETLEVEL		_IOR ('x', 13, int)

/*
 * Get the channel name.
 */
#define SERIAL_GETNAME		_IOR ('x', 14, char [32])

/*
 * Get version string.
 */
#define SERIAL_GETVERSIONSTRING _IOR ('x', 15, char [256])

/*
 * Query/set master channel.
 */
#define SERIAL_GETMASTER	_IOR ('x', 16, char [16])
#define SERIAL_SETMASTER 	_IOW ('x', 16, char [16])

/*
 * Query/set keepalive.
 */
#define SERIAL_GETKEEPALIVE 	_IOR ('x', 17, int)
#define SERIAL_SETKEEPALIVE 	_IOW ('x', 17, int)

/*
 * Query/set E1 configuration.
 */
#define SERIAL_GETCFG		_IOR ('x', 18, char)
#define SERIAL_SETCFG		_IOW ('x', 18, char)

/*
 * Query/set debug.
 */
#define SERIAL_GETDEBUG		_IOR ('x', 19, int)
#define SERIAL_SETDEBUG		_IOW ('x', 19, int)

/*
 * Query/set phony mode (E1).
 */
#define SERIAL_GETPHONY		_IOR ('x', 20, int)
#define SERIAL_SETPHONY		_IOW ('x', 20, int)

/*
 * Query/set timeslot 16 usage mode (E1).
 */
#define SERIAL_GETUSE16		_IOR ('x', 21, int)
#define SERIAL_SETUSE16		_IOW ('x', 21, int)

/*
 * Query/set crc4 mode (E1).
 */
#define SERIAL_GETCRC4		_IOR ('x', 22, int)
#define SERIAL_SETCRC4		_IOW ('x', 22, int)

/*
 * Query/set the timeout to recover after transmit interrupt loss.
 * If timo==0 recover will be disabled.
 */
#define SERIAL_GETTIMO		_IOR ('x', 23, long)
#define SERIAL_SETTIMO		_IOW ('x', 23, long)

/*
 * Query/set port type for old models of Sigma
 * -1 Fixed or cable select
 * 0  RS-232
 * 1  V35
 * 2  RS-449
 * 3  E1	(only for Windows 2000)
 * 4  G.703	(only for Windows 2000)
 * 5  DATA	(only for Windows 2000)
 * 6  E3	(only for Windows 2000)
 * 7  T3	(only for Windows 2000)
 * 8  STS1	(only for Windows 2000)
 */
#define SERIAL_GETPORT		_IOR ('x', 25, int)
#define SERIAL_SETPORT		_IOW ('x', 25, int)

/*
 * Add the virtual channel DLCI (Frame Relay).
 */
#define SERIAL_ADDDLCI		_IOW ('x', 26, int)

/*
 * Invert receive clock.
 */
#define SERIAL_GETINVRCLK	_IOR ('x', 27, int)
#define SERIAL_SETINVRCLK	_IOW ('x', 27, int)

/*
 * Invert transmit clock.
 */
#define SERIAL_GETINVTCLK	_IOR ('x', 28, int)
#define SERIAL_SETINVTCLK	_IOW ('x', 28, int)

/*
 * Unframed E1 mode.
 */
#define SERIAL_GETUNFRAM	_IOR ('x', 29, int)
#define SERIAL_SETUNFRAM	_IOW ('x', 29, int)

/*
 * E1 monitoring mode.
 */
#define SERIAL_GETMONITOR	_IOR ('x', 30, int)
#define SERIAL_SETMONITOR	_IOW ('x', 30, int)

/*
 * Interrupt number.
 */
#define SERIAL_GETIRQ		_IOR ('x', 31, int)

/*
 * Reset.
 */
#define SERIAL_RESET		_IO ('x', 32)

/*
 * Hard reset.
 */
#define SERIAL_HARDRESET	_IO ('x', 33)

/*
 * Query cable type.
 */
#define SERIAL_GETCABLE		_IOR ('x', 34, int)

/*
 * Assignment of HDLC ports to E1 channels.
 */
#define SERIAL_GETDIR		_IOR ('x', 35, int)
#define SERIAL_SETDIR		_IOW ('x', 35, int)

struct dxc_table {			/* cross-connector parameters */
	unsigned char ts [32];		/* timeslot number */
	unsigned char link [32];	/* E1 link number */
};

/*
 * DXC cross-connector settings for E1 channels.
 */
#define SERIAL_GETDXC		_IOR ('x', 36, struct dxc_table)
#define SERIAL_SETDXC		_IOW ('x', 36, struct dxc_table)

/*
 * Scrambler for G.703.
 */
#define SERIAL_GETSCRAMBLER	_IOR ('x', 37, int)
#define SERIAL_SETSCRAMBLER	_IOW ('x', 37, int)

/*
 * Length of cable for T3 and STS-1.
 */
#define SERIAL_GETCABLEN	_IOR ('x', 38, int)
#define SERIAL_SETCABLEN	_IOW ('x', 38, int)

/*
 * Remote loopback for E3, T3 and STS-1.
 */
#define SERIAL_GETRLOOP		_IOR ('x', 39, int)
#define SERIAL_SETRLOOP		_IOW ('x', 39, int)

/*
 * Dynamic binder interface.
 */
#ifdef __KERNEL__
typedef struct _chan_t chan_t;
typedef struct _proto_t proto_t;

void binder_register_protocol (proto_t *p);
void binder_unregister_protocol (proto_t *p);

int binder_register_channel (chan_t *h, char *prefix, int minor);
void binder_unregister_channel (chan_t *h);

/*
 * Hardware channel driver structure.
 */
struct sk_buff;

struct _chan_t {
	char name [16];
	int mtu;			/* max packet size */
	int fifosz;			/* total hardware i/o buffer size */
	int port;			/* hardware base i/o port */
	int irq;			/* hardware interrupt line */
	int minor;			/* minor number 0..127, assigned by binder */
	int debug;			/* debug level, 0..2 */
	int running;			/* running, 0..1 */
	struct _proto_t *proto;		/* protocol interface data */
	void *sw;			/* protocol private data */
	void *hw;			/* hardware layer private data */

	/* Interface to protocol */
	int (*up) (chan_t *h);
	void (*down) (chan_t *h);
	int (*transmit) (chan_t *h, struct sk_buff *skb);
	void (*set_dtr) (chan_t *h, int val);
	void (*set_rts) (chan_t *h, int val);
	int (*query_dtr) (chan_t *h);
	int (*query_rts) (chan_t *h);
	int (*query_dsr) (chan_t *h);
	int (*query_cts) (chan_t *h);
	int (*query_dcd) (chan_t *h);

	/* Interface to async protocol */
	void (*set_async_param) (chan_t *h, int baud, int bits, int parity,
		int stop2, int ignpar, int rtscts,
		int ixon, int ixany, int symstart, int symstop);
	void (*send_break) (chan_t *h, int msec);
	void (*send_xon) (chan_t *h);
	void (*send_xoff) (chan_t *h);
	void (*start_transmitter) (chan_t *h);
	void (*stop_transmitter) (chan_t *h);
	void (*flush_transmit_buffer) (chan_t *h);

	/* Control interface */
	int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
};

/*
 * Protocol driver structure.
 */
struct _proto_t {
	char *name;
	struct _proto_t *next;

	/* Interface to channel */
	void (*receive) (chan_t *h, struct sk_buff *skb);
	void (*receive_error) (chan_t *h, int errcode);
	void (*transmit) (chan_t *h);
	void (*modem_event) (chan_t *h);

	/* Interface to binder */
	int (*open) (chan_t *h);
	void (*close) (chan_t *h);
	int (*read) (chan_t *h, unsigned short flg, char *buf, int len);
	int (*write) (chan_t *h, unsigned short flg, const char *buf, int len);
	int (*select) (chan_t *h, int type, void *st, struct file *filp);
	struct fasync_struct *fasync;

	/* Control interface */
	int (*attach) (chan_t *h);
	int (*detach) (chan_t *h);
	int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
};
#endif /* KERNEL */
OpenPOWER on IntegriCloud