FreeBSD/Linux Kernel Cross Reference
sys/i386/include/si.h
1 /*
2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors.
3 * 'C' definitions for Specialix serial multiplex driver.
4 *
5 * Copyright (C) 1990, 1992, 1998 Specialix International,
6 * Copyright (C) 1993, Andy Rutter <andy@acronym.co.uk>
7 * Copyright (C) 1995, Peter Wemm <peter@netplex.com.au>
8 *
9 * Derived from: SunOS 4.x version
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notices, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notices, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Andy Rutter of
22 * Advanced Methods and Tools Ltd. based on original information
23 * from Specialix International.
24 * 4. Neither the name of Advanced Methods and Tools, nor Specialix
25 * International may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
31 * NO EVENT SHALL THE AUTHORS BE LIABLE.
32 *
33 * $FreeBSD$
34 */
35
36 #include <sys/callout.h>
37
38 /*
39 * Macro to turn a device number into various parameters, and test for
40 * CONTROL device.
41 * max of 4 controllers with up to 32 ports per controller.
42 * minor device allocation is:
43 * adapter port
44 * 0 0-31
45 * 1 32-63
46 * 2 64-95
47 * 3 96-127
48 */
49 #define SI_MAXPORTPERCARD 32
50 #define SI_MAXCONTROLLER 4
51
52
53 /*
54 * breakup of minor device number:
55 * lowest 5 bits: port number on card 0x1f
56 * next 2 bits: card number 0x60
57 * top bit: callout 0x80
58 * next 8 bits is the major number
59 * next 2 bits select initial/lock states
60 * next 1 bit selects the master control device
61 */
62
63 #define SI_PORT_MASK 0x1f
64 #define SI_CARD_MASK 0x60
65 #define SI_TTY_MASK 0x7f
66 #define SI_CALLOUT_MASK 0x80
67 #define SI_INIT_STATE_MASK 0x10000
68 #define SI_LOCK_STATE_MASK 0x20000
69 #define SI_STATE_MASK 0x30000
70 #define SI_CONTROLDEV_MASK 0x40000
71 #define SI_SPECIAL_MASK 0x70000
72
73 #define SI_CARDSHIFT 5
74 #define SI_PORT(m) (m & SI_PORT_MASK)
75 #define SI_CARD(m) ((m & SI_CARD_MASK) >> SI_CARDSHIFT)
76 #define SI_TTY(m) (m & SI_TTY_MASK)
77
78 #define IS_CALLOUT(m) (m & SI_CALLOUT_MASK)
79 #define IS_STATE(m) (m & SI_STATE_MASK)
80 #define IS_CONTROLDEV(m) (m & SI_CONTROLDEV_MASK)
81 #define IS_SPECIAL(m) (m & SI_SPECIAL_MASK)
82
83 #define MINOR2SC(m) (&si_softc[SI_CARD(m)])
84 #define MINOR2PP(m) (MINOR2SC((m))->sc_ports + SI_PORT((m)))
85 #define MINOR2TP(m) (MINOR2PP((m))->sp_tty)
86 #define TP2PP(tp) (MINOR2PP(SI_TTY(minor((tp)->t_dev))))
87
88 /* Adapter types */
89 #define SIEMPTY 0
90 #define SIHOST 1
91 #define SIMCA 2
92 #define SIHOST2 3
93 #define SIEISA 4
94 #define SIPCI 5
95 #define SIJETPCI 6
96 #define SIJETISA 7
97
98 #define SI_ISJET(x) (((x) == SIJETPCI) || ((x) == SIJETISA))
99
100 /* Buffer parameters */
101 #define SI_BUFFERSIZE 256
102
103 typedef unsigned char BYTE; /* Type cast for unsigned 8 bit */
104 typedef unsigned short WORD; /* Type cast for unsigned 16 bit */
105
106
107 /*
108 * Hardware `registers', stored in the shared memory.
109 * These are related to the firmware running on the Z280.
110 */
111
112 struct si_reg {
113 BYTE initstat;
114 BYTE memsize;
115 WORD int_count;
116 WORD revision;
117 BYTE rx_int_count; /* isr_count on Jet */
118 BYTE main_count; /* spare on Z-280 */
119 WORD int_pending;
120 WORD int_counter;
121 BYTE int_scounter;
122 BYTE res[0x80 - 13];
123 };
124
125 /*
126 * Per module control structure, stored in shared memory.
127 */
128 struct si_module {
129 WORD sm_next; /* Next module */
130 BYTE sm_type; /* Number of channels */
131 BYTE sm_number; /* Module number on cable */
132 BYTE sm_dsr; /* Private dsr copy */
133 BYTE sm_res[0x80 - 5]; /* Reserve space to 128 bytes */
134 };
135
136 /*
137 * The 'next' pointer & with 0x7fff + SI base addres give
138 * the address of the next module block if fitted. (else 0)
139 * Note that next points to the TX buffer so 0x60 must be
140 * subtracted to find the true base.
141 */
142 #define TA4 0x00
143 #define TA8 0x08
144 #define TA4_ASIC 0x0A
145 #define TA8_ASIC 0x0B
146 #define MTA 0x28
147 #define SXDC 0x48
148
149 /*
150 * Per channel(port) control structure, stored in shared memory.
151 */
152 struct si_channel {
153 /*
154 * Generic stuff
155 */
156 WORD next; /* Next Channel */
157 WORD addr_uart; /* Uart address */
158 WORD module; /* address of module struct */
159 BYTE type; /* Uart type */
160 BYTE fill;
161 /*
162 * Uart type specific stuff
163 */
164 BYTE x_status; /* XON / XOFF status */
165 BYTE c_status; /* cooking status */
166 BYTE hi_rxipos; /* stuff into rx buff */
167 BYTE hi_rxopos; /* stuff out of rx buffer */
168 BYTE hi_txopos; /* Stuff into tx ptr */
169 BYTE hi_txipos; /* ditto out */
170 BYTE hi_stat; /* Command register */
171 BYTE dsr_bit; /* Magic bit for DSR */
172 BYTE txon; /* TX XON char */
173 BYTE txoff; /* ditto XOFF */
174 BYTE rxon; /* RX XON char */
175 BYTE rxoff; /* ditto XOFF */
176 BYTE hi_mr1; /* mode 1 image */
177 BYTE hi_mr2; /* mode 2 image */
178 BYTE hi_csr; /* clock register */
179 BYTE hi_op; /* Op control */
180 BYTE hi_ip; /* Input pins */
181 BYTE hi_state; /* status */
182 BYTE hi_prtcl; /* Protocol */
183 BYTE hi_txon; /* host copy tx xon stuff */
184 BYTE hi_txoff;
185 BYTE hi_rxon;
186 BYTE hi_rxoff;
187 BYTE close_prev; /* Was channel previously closed */
188 BYTE hi_break; /* host copy break process */
189 BYTE break_state; /* local copy ditto */
190 BYTE hi_mask; /* Mask for CS7 etc. */
191 BYTE mask_z280; /* Z280's copy */
192 BYTE res[0x60 - 36];
193 BYTE hi_txbuf[SI_BUFFERSIZE];
194 BYTE hi_rxbuf[SI_BUFFERSIZE];
195 BYTE res1[0xA0];
196 };
197
198 /*
199 * Register definitions
200 */
201
202 /*
203 * Break input control register definitions
204 */
205 #define BR_IGN 0x01 /* Ignore any received breaks */
206 #define BR_INT 0x02 /* Interrupt on received break */
207 #define BR_PARMRK 0x04 /* Enable parmrk parity error processing */
208 #define BR_PARIGN 0x08 /* Ignore chars with parity errors */
209
210 /*
211 * Protocol register provided by host for XON/XOFF and cooking
212 */
213 #define SP_TANY 0x01 /* Tx XON any char */
214 #define SP_TXEN 0x02 /* Tx XON/XOFF enabled */
215 #define SP_CEN 0x04 /* Cooking enabled */
216 #define SP_RXEN 0x08 /* Rx XON/XOFF enabled */
217 #define SP_DCEN 0x20 /* DCD / DTR check */
218 #define SP_PAEN 0x80 /* Parity checking enabled */
219
220 /*
221 * HOST STATUS / COMMAND REGISTER
222 */
223 #define IDLE_OPEN 0x00 /* Default mode, TX and RX polled
224 buffer updated etc */
225 #define LOPEN 0x02 /* Local open command (no modem ctl */
226 #define MOPEN 0x04 /* Open and monitor modem lines (blocks
227 for DCD */
228 #define MPEND 0x06 /* Wating for DCD */
229 #define CONFIG 0x08 /* Channel config has changed */
230 #define CLOSE 0x0A /* Close channel */
231 #define SBREAK 0x0C /* Start break */
232 #define EBREAK 0x0E /* End break */
233 #define IDLE_CLOSE 0x10 /* Closed channel */
234 #define IDLE_BREAK 0x12 /* In a break */
235 #define FCLOSE 0x14 /* Force a close */
236 #define RESUME 0x16 /* Clear a pending xoff */
237 #define WFLUSH 0x18 /* Flush output buffer */
238 #define RFLUSH 0x1A /* Flush input buffer */
239
240 /*
241 * Host status register
242 */
243 #define ST_BREAK 0x01 /* Break received (clear with config) */
244
245 /*
246 * OUTPUT PORT REGISTER
247 */
248 #define OP_CTS 0x01 /* Enable CTS */
249 #define OP_DSR 0x02 /* Enable DSR */
250 /*
251 * INPUT PORT REGISTER
252 */
253 #define IP_DCD 0x04 /* DCD High */
254 #define IP_DTR 0x20 /* DTR High */
255 #define IP_RTS 0x02 /* RTS High */
256 #define IP_RI 0x40 /* RI High */
257
258 /*
259 * Mode register and uart specific stuff
260 */
261 /*
262 * MODE REGISTER 1
263 */
264 #define MR1_5_BITS 0x00
265 #define MR1_6_BITS 0x01
266 #define MR1_7_BITS 0x02
267 #define MR1_8_BITS 0x03
268 /*
269 * Parity
270 */
271 #define MR1_ODD 0x04
272 #define MR1_EVEN 0x00
273 /*
274 * Parity mode
275 */
276 #define MR1_WITH 0x00
277 #define MR1_FORCE 0x08
278 #define MR1_NONE 0x10
279 #define MR1_SPECIAL 0x18
280 /*
281 * Error mode
282 */
283 #define MR1_CHAR 0x00
284 #define MR1_BLOCK 0x20
285 /*
286 * Request to send line automatic control
287 */
288 #define MR1_CTSCONT 0x80
289
290 /*
291 * MODE REGISTER 2
292 */
293 /*
294 * Number of stop bits
295 */
296 #define MR2_1_STOP 0x07
297 #define MR2_2_STOP 0x0F
298 /*
299 * Clear to send automatic testing before character sent
300 */
301 #define MR2_RTSCONT 0x10
302 /*
303 * Reset RTS automatically after sending character?
304 */
305 #define MR2_CTSCONT 0x20
306 /*
307 * Channel mode
308 */
309 #define MR2_NORMAL 0x00
310 #define MR2_AUTO 0x40
311 #define MR2_LOCAL 0x80
312 #define MR2_REMOTE 0xC0
313
314 /*
315 * CLOCK SELECT REGISTER - this and the code assumes ispeed == ospeed
316 */
317 /*
318 * Clocking rates are in lower and upper nibbles.. R = upper, T = lower
319 */
320 #define CLK75 0x0
321 #define CLK110 0x1 /* 110 on XIO!! */
322 #define CLK38400 0x2 /* out of sequence */
323 #define CLK150 0x3
324 #define CLK300 0x4
325 #define CLK600 0x5
326 #define CLK1200 0x6
327 #define CLK2000 0x7
328 #define CLK2400 0x8
329 #define CLK4800 0x9
330 #define CLK7200 0xa /* unchecked */
331 #define CLK9600 0xb
332 #define CLK19200 0xc
333 #define CLK57600 0xd
334
335 /*
336 * Per-port (channel) soft information structure, stored in the driver.
337 * This is visible via ioctl()'s.
338 */
339 struct si_port {
340 volatile struct si_channel *sp_ccb;
341 struct tty *sp_tty;
342 int sp_pend; /* pending command */
343 int sp_last_hi_ip; /* cached DCD */
344 int sp_state;
345 int sp_active_out; /* callout is open */
346 int sp_dtr_wait; /* DTR holddown in hz */
347 int sp_delta_overflows;
348 u_int sp_wopeners; /* # procs waiting DCD */
349 u_char sp_hotchar; /* ldisc specific ASAP char */
350 /* Initial state. */
351 struct termios sp_iin;
352 struct termios sp_iout;
353 /* Lock state. */
354 struct termios sp_lin;
355 struct termios sp_lout;
356 struct callout_handle lstart_ch;/* For canceling our timeout */
357 #ifdef SI_DEBUG
358 int sp_debug; /* debug mask */
359 #endif
360 };
361
362 /* sp_state */
363 #define SS_CLOSED 0x0000
364 #define SS_OPEN 0x0001 /* Port is active */
365 /* 0x0002 -- */
366 /* 0x0004 -- */
367 /* 0x0008 -- */
368 /* 0x0010 -- */
369 /* 0x0020 -- */
370 /* 0x0040 -- */
371 /* 0x0080 -- */
372 #define SS_LSTART 0x0100 /* lstart timeout pending */
373 #define SS_INLSTART 0x0200 /* running an lstart induced t_oproc */
374 #define SS_CLOSING 0x0400 /* in the middle of a siclose() */
375 /* 0x0800 -- */
376 #define SS_WAITWRITE 0x1000
377 #define SS_BLOCKWRITE 0x2000
378 #define SS_DTR_OFF 0x4000 /* DTR held off */
379
380 /*
381 * Command post flags
382 */
383 #define SI_NOWAIT 0x00 /* Don't wait for command */
384 #define SI_WAIT 0x01 /* Wait for complete */
385
386 /*
387 * Extensive debugging stuff - manipulated using siconfig(8)
388 */
389 #define DBG_ENTRY 0x00000001
390 #define DBG_DRAIN 0x00000002
391 #define DBG_OPEN 0x00000004
392 #define DBG_CLOSE 0x00000008
393 #define DBG_READ 0x00000010
394 #define DBG_WRITE 0x00000020
395 #define DBG_PARAM 0x00000040
396 #define DBG_INTR 0x00000080
397 #define DBG_IOCTL 0x00000100
398 /* 0x00000200 */
399 #define DBG_SELECT 0x00000400
400 #define DBG_OPTIM 0x00000800
401 #define DBG_START 0x00001000
402 #define DBG_EXIT 0x00002000
403 #define DBG_FAIL 0x00004000
404 #define DBG_STOP 0x00008000
405 #define DBG_AUTOBOOT 0x00010000
406 #define DBG_MODEM 0x00020000
407 #define DBG_DOWNLOAD 0x00040000
408 #define DBG_LSTART 0x00080000
409 #define DBG_POLL 0x00100000
410 #define DBG_ALL 0xffffffff
411
412 /*
413 * SI ioctls
414 */
415 /*
416 * struct for use by Specialix ioctls - used by siconfig(8)
417 */
418 typedef struct {
419 unsigned char
420 sid_port:5, /* 0 - 31 ports per card */
421 sid_card:2, /* 0 - 3 cards */
422 sid_control:1; /* controlling device (all cards) */
423 } sidev_t;
424 struct si_tcsi {
425 sidev_t tc_dev;
426 union {
427 int x_int;
428 int x_dbglvl;
429 } tc_action;
430 #define tc_card tc_dev.sid_card
431 #define tc_port tc_dev.sid_port
432 #define tc_int tc_action.x_int
433 #define tc_dbglvl tc_action.x_dbglvl
434 };
435
436 struct si_pstat {
437 sidev_t tc_dev;
438 union {
439 struct si_port x_siport;
440 struct si_channel x_ccb;
441 struct tty x_tty;
442 } tc_action;
443 #define tc_siport tc_action.x_siport
444 #define tc_ccb tc_action.x_ccb
445 #define tc_tty tc_action.x_tty
446 };
447
448 #define IOCTL_MIN 96
449 #define TCSIDEBUG _IOW('S', 96, struct si_tcsi) /* Toggle debug */
450 #define TCSIRXIT _IOW('S', 97, struct si_tcsi) /* RX int throttle */
451 #define TCSIIT _IOW('S', 98, struct si_tcsi) /* TX int throttle */
452 /* 99 defunct */
453 /* 100 defunct */
454 /* 101 defunct */
455 /* 102 defunct */
456 /* 103 defunct */
457 /* 104 defunct */
458 #define TCSISTATE _IOWR('S', 105, struct si_tcsi) /* get current state of RTS
459 DCD and DTR pins */
460 /* 106 defunct */
461 #define TCSIPORTS _IOR('S', 107, int) /* Number of ports found */
462 #define TCSISDBG_LEVEL _IOW('S', 108, struct si_tcsi) /* equivalent of TCSIDEBUG which sets a
463 * particular debug level (DBG_??? bit
464 * mask), default is 0xffff */
465 #define TCSIGDBG_LEVEL _IOWR('S', 109, struct si_tcsi)
466 #define TCSIGRXIT _IOWR('S', 110, struct si_tcsi)
467 #define TCSIGIT _IOWR('S', 111, struct si_tcsi)
468 /* 112 defunct */
469 /* 113 defunct */
470 /* 114 defunct */
471 /* 115 defunct */
472 /* 116 defunct */
473 /* 117 defunct */
474
475 #define TCSISDBG_ALL _IOW('S', 118, int) /* set global debug level */
476 #define TCSIGDBG_ALL _IOR('S', 119, int) /* get global debug level */
477
478 /* 120 defunct */
479 /* 121 defunct */
480 /* 122 defunct */
481 /* 123 defunct */
482 #define TCSIMODULES _IOR('S', 124, int) /* Number of modules found */
483
484 /* Various stats and monitoring hooks per tty device */
485 #define TCSI_PORT _IOWR('S', 125, struct si_pstat) /* get si_port */
486 #define TCSI_CCB _IOWR('S', 126, struct si_pstat) /* get si_ccb */
487 #define TCSI_TTY _IOWR('S', 127, struct si_pstat) /* get tty struct */
488
489 #define IOCTL_MAX 127
490
491 #define IS_SI_IOCTL(cmd) ((u_int)((cmd)&0xff00) == ('S'<<8) && \
492 (u_int)((cmd)&0xff) >= IOCTL_MIN && \
493 (u_int)((cmd)&0xff) <= IOCTL_MAX)
494
495 #define CONTROLDEV "/dev/si_control"
Cache object: 188c0474ae5a1856f5a17be89e4a8a69
|