2 * linux/drivers/char/pcxx.c
4 * Written by Troy De Jongh, November, 1994
6 * Copyright (C) 1994,1995 Troy De Jongh
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License.
10 * This driver is for the DigiBoard PC/Xe and PC/Xi line of products.
12 * This driver does NOT support DigiBoard's fastcook FEP option and
13 * does not support the transparent print (i.e. digiprint) option.
15 * This Driver is currently maintained by Christoph Lameter (christoph@lameter.com)
17 * Please contact digi for support issues at digilnux@dgii.com.
18 * Some more information can be found at
19 * http://lameter.com/digi.
21 * 1.5.2 Fall 1995 Bug fixes by David Nugent
22 * 1.5.3 March 9, 1996 Christoph Lameter: Fixed 115.2K Support. Memory
23 * allocation harmonized with 1.3.X Series.
24 * 1.5.4 March 30, 1996 Christoph Lameter: Fixup for 1.3.81. Use init_bh
25 * instead of direct assignment to kernel arrays.
26 * 1.5.5 April 5, 1996 Major device numbers corrected.
27 * Mike McLagan<mike.mclagan@linux.org>: Add setup
28 * variable handling, instead of using the old pcxxconfig.h
29 * 1.5.6 April 16, 1996 Christoph Lameter: Pointer cleanup, macro cleanup.
30 * Call out devices changed to /dev/cudxx.
31 * 1.5.7 July 22, 1996 Martin Mares: CLOCAL fix, pcxe_table clearing.
32 * David Nugent: Bug in pcxe_open.
33 * Brian J. Murrell: Modem Control fixes, Majors correctly assigned
34 * 1.6.1 April 6, 1997 Bernhard Kaindl: fixed virtual memory access for 2.1
35 * i386-kernels and use on other archtitectures, Allowing use
36 * as module, added module parameters, added switch to enable
37 * verbose messages to assist user during card configuration.
38 * Currently only tested on a PC/Xi card, but should work on Xe
40 * 1.6.2 August, 7, 2000: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
41 * get rid of panics, release previously allocated resources
42 * 1.6.3 August, 23, 2000: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
43 * cleaned up wrt verify_area.
44 * Christoph Lameter: Update documentation, email addresses
45 * and URLs. Remove some obsolete code.
49 #include <linux/module.h>
51 #include <linux/ioport.h>
52 #include <linux/errno.h>
53 #include <linux/signal.h>
54 #include <linux/sched.h>
55 #include <linux/timer.h>
56 #include <linux/interrupt.h>
57 #include <linux/tty.h>
58 #include <linux/tty_flip.h>
59 #include <linux/major.h>
60 #include <linux/string.h>
61 #include <linux/fcntl.h>
62 #include <linux/ptrace.h>
63 #include <linux/delay.h>
64 #include <linux/serial.h>
65 #include <linux/tty_driver.h>
66 #include <linux/slab.h>
67 #include <linux/init.h>
68 #include <linux/bitops.h>
71 #include <linux/ctype.h> /* We only need it for parsing the "digi="-line */
74 #include <asm/system.h>
76 #include <asm/uaccess.h>
77 #include <asm/semaphore.h>
79 #define VERSION "1.6.3"
85 #include "digi_bios.h"
88 * Define one default setting if no digi= config line is used.
89 * Default is altpin = disabled, 16 ports, I/O 200h, Memory 0D0000h
91 static struct board_info boards[MAX_DIGI_BOARDS] = { {
92 /* Board is enabled */ ENABLED,
93 /* Type is auto-detected */ 0,
94 /* altping is disabled */ DISABLED,
95 /* number of ports = 16 */ 16,
96 /* io address is 0x200 */ 0x200,
97 /* card memory at 0xd0000 */ 0xd0000,
98 /* first minor device no. */ 0
101 static int verbose = 0;
102 static int debug = 0;
105 /* Variables for insmod */
106 static int io[] = {0, 0, 0, 0};
107 static int membase[] = {0, 0, 0, 0};
108 static int memsize[] = {0, 0, 0, 0};
109 static int altpin[] = {0, 0, 0, 0};
110 static int numports[] = {0, 0, 0, 0};
112 MODULE_AUTHOR("Bernhard Kaindl");
113 MODULE_DESCRIPTION("Digiboard PC/X{i,e,eve} driver");
114 MODULE_LICENSE("GPL");
115 module_param(verbose, bool, 0644);
116 module_param(debug, bool, 0644);
117 module_param_array(io, int, NULL, 0);
118 module_param_array(membase, int, NULL, 0);
119 module_param_array(memsize, int, NULL, 0);
120 module_param_array(altpin, int, NULL, 0);
121 module_param_array(numports, int, NULL, 0);
125 static int numcards = 1;
126 static int nbdevs = 0;
128 static struct channel *digi_channels;
130 int pcxx_ncook=sizeof(pcxx_cook);
131 int pcxx_nbios=sizeof(pcxx_bios);
133 #define pcxxassert(x, msg) if(!(x)) pcxx_error(__LINE__, msg)
135 #define FEPTIMEOUT 200000
136 #define SERIAL_TYPE_NORMAL 1
137 #define PCXE_EVENT_HANGUP 1
139 static struct tty_driver *pcxe_driver;
141 static struct timer_list pcxx_timer;
143 static void pcxxpoll(unsigned long dummy);
144 static void fepcmd(struct channel *, int, int, int, int, int);
145 static void pcxe_put_char(struct tty_struct *, unsigned char);
146 static void pcxe_flush_chars(struct tty_struct *);
147 static void pcxx_error(int, char *);
148 static void pcxe_close(struct tty_struct *, struct file *);
149 static int pcxe_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long);
150 static void pcxe_set_termios(struct tty_struct *, struct termios *);
151 static int pcxe_write(struct tty_struct *, const unsigned char *, int);
152 static int pcxe_write_room(struct tty_struct *);
153 static int pcxe_chars_in_buffer(struct tty_struct *);
154 static void pcxe_flush_buffer(struct tty_struct *);
155 static void doevent(int);
156 static void receive_data(struct channel *);
157 static void pcxxparam(struct tty_struct *, struct channel *ch);
158 static void do_softint(void *);
159 static inline void pcxe_sched_event(struct channel *, int);
160 static void pcxe_start(struct tty_struct *);
161 static void pcxe_stop(struct tty_struct *);
162 static void pcxe_throttle(struct tty_struct *);
163 static void pcxe_unthrottle(struct tty_struct *);
164 static void digi_send_break(struct channel *ch, int msec);
165 static void shutdown(struct channel *);
166 static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
167 static inline void memwinon(struct board_info *b, unsigned int win);
168 static inline void memwinoff(struct board_info *b, unsigned int win);
169 static inline void globalwinon(struct channel *ch);
170 static inline void rxwinon(struct channel *ch);
171 static inline void txwinon(struct channel *ch);
172 static inline void memoff(struct channel *ch);
173 static inline void assertgwinon(struct channel *ch);
174 static inline void assertmemoff(struct channel *ch);
175 static int pcxe_tiocmget(struct tty_struct *tty, struct file *file);
176 static int pcxe_tiocmset(struct tty_struct *tty, struct file *file,
177 unsigned int set, unsigned int clear);
179 #define TZ_BUFSZ 4096
181 /* function definitions */
183 /*****************************************************************************/
185 static void cleanup_board_resources(void)
188 struct board_info *bd;
191 for(crd = 0; crd < numcards; crd++) {
193 ch = digi_channels + bd->first_minor;
196 release_region(bd->port, 4);
198 for(i = 0; i < bd->numports; i++, ch++)
204 static void __exit pcxe_cleanup(void)
210 printk(KERN_NOTICE "Unloading PC/Xx version %s\n", VERSION);
214 del_timer_sync(&pcxx_timer);
216 if ((e1 = tty_unregister_driver(pcxe_driver)))
217 printk("SERIAL: failed to unregister serial driver (%d)\n", e1);
219 put_tty_driver(pcxe_driver);
220 cleanup_board_resources();
221 kfree(digi_channels);
222 restore_flags(flags);
225 static inline struct channel *chan(register struct tty_struct *tty)
228 register struct channel *ch=(struct channel *)tty->driver_data;
229 if (ch >= digi_channels && ch < digi_channels+nbdevs) {
230 if (ch->magic==PCXX_MAGIC)
237 /* These inline routines are to turn board memory on and off */
238 static inline void memwinon(struct board_info *b, unsigned int win)
240 if(b->type == PCXEVE)
241 outb_p(FEPWIN|win, b->port+1);
243 outb_p(inb(b->port)|FEPMEM, b->port);
246 static inline void memwinoff(struct board_info *b, unsigned int win)
248 outb_p(inb(b->port)&~FEPMEM, b->port);
249 if(b->type == PCXEVE)
250 outb_p(0, b->port + 1);
253 static inline void globalwinon(struct channel *ch)
255 if(ch->board->type == PCXEVE)
256 outb_p(FEPWIN, ch->board->port+1);
258 outb_p(FEPMEM, ch->board->port);
261 static inline void rxwinon(struct channel *ch)
264 outb_p(FEPMEM, ch->board->port);
266 outb_p(ch->rxwin, ch->board->port+1);
269 static inline void txwinon(struct channel *ch)
272 outb_p(FEPMEM, ch->board->port);
274 outb_p(ch->txwin, ch->board->port+1);
277 static inline void memoff(struct channel *ch)
279 outb_p(0, ch->board->port);
280 if(ch->board->type == PCXEVE)
281 outb_p(0, ch->board->port+1);
284 static inline void assertgwinon(struct channel *ch)
286 if(ch->board->type != PCXEVE)
287 pcxxassert(inb(ch->board->port) & FEPMEM, "Global memory off");
290 static inline void assertmemoff(struct channel *ch)
292 if(ch->board->type != PCXEVE)
293 pcxxassert(!(inb(ch->board->port) & FEPMEM), "Memory on");
296 static inline void pcxe_sched_event(struct channel *info, int event)
298 info->event |= 1 << event;
299 schedule_work(&info->tqueue);
302 static void pcxx_error(int line, char *msg)
304 printk("pcxx_error (DigiBoard): line=%d %s\n", line, msg);
307 static int pcxx_waitcarrier(struct tty_struct *tty,struct file *filp,struct channel *info)
309 DECLARE_WAITQUEUE(wait, current);
313 if (tty->termios->c_cflag & CLOCAL)
317 * Block waiting for the carrier detect and the line to become free
321 add_wait_queue(&info->open_wait, &wait);
323 info->blocked_open++;
328 info->omodem |= DTR|RTS;
329 fepcmd(info, SETMODEM, DTR|RTS, 0, 10, 1);
332 set_current_state(TASK_INTERRUPTIBLE);
333 if(tty_hung_up_p(filp) || (info->asyncflags & ASYNC_INITIALIZED) == 0) {
334 if(info->asyncflags & ASYNC_HUP_NOTIFY)
337 retval = -ERESTARTSYS;
340 if ((info->asyncflags & ASYNC_CLOSING) == 0 &&
341 (do_clocal || (info->imodem & info->dcd)))
343 if(signal_pending(current)) {
344 retval = -ERESTARTSYS;
349 current->state = TASK_RUNNING;
350 remove_wait_queue(&info->open_wait, &wait);
352 if(!tty_hung_up_p(filp))
354 info->blocked_open--;
360 int pcxe_open(struct tty_struct *tty, struct file * filp)
362 volatile struct board_chan *bc;
371 if(line < 0 || line >= nbdevs) {
372 printk("line out of range in pcxe_open\n");
373 tty->driver_data = NULL;
377 for(boardnum=0;boardnum<numcards;boardnum++)
378 if ((line >= boards[boardnum].first_minor) &&
379 (line < boards[boardnum].first_minor + boards[boardnum].numports))
382 if(boardnum >= numcards || boards[boardnum].status == DISABLED ||
383 (line - boards[boardnum].first_minor) >= boards[boardnum].numports) {
384 tty->driver_data = NULL; /* Mark this device as 'down' */
388 ch = digi_channels+line;
390 if(ch->brdchan == 0) {
391 tty->driver_data = NULL;
396 * If the device is in the middle of being closed, then block
397 * until it's done, and then try again.
399 if(ch->asyncflags & ASYNC_CLOSING) {
400 interruptible_sleep_on(&ch->close_wait);
401 if(ch->asyncflags & ASYNC_HUP_NOTIFY)
410 tty->driver_data = ch;
413 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) {
419 ch->imodem = bc->mstat;
424 ch->imodem = bc->mstat;
426 ch->omodem = DTR|RTS;
427 fepcmd(ch, SETMODEM, DTR|RTS, 0, 10, 1);
429 ch->asyncflags |= ASYNC_INITIALIZED;
431 restore_flags(flags);
433 if(ch->asyncflags & ASYNC_CLOSING) {
434 interruptible_sleep_on(&ch->close_wait);
435 if(ch->asyncflags & ASYNC_HUP_NOTIFY)
441 if (!(filp->f_flags & O_NONBLOCK)) {
442 /* this has to be set in order for the "block until
443 * CD" code to work correctly. i'm not sure under
444 * what circumstances asyncflags should be set to
445 * ASYNC_NORMAL_ACTIVE though
448 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
449 if ((retval = pcxx_waitcarrier(tty, filp, ch)) != 0)
452 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
457 static void shutdown(struct channel *info)
460 volatile struct board_chan *bc;
461 struct tty_struct *tty;
463 if (!(info->asyncflags & ASYNC_INITIALIZED))
477 * If we're a modem control device and HUPCL is on, drop RTS & DTR.
479 if(tty->termios->c_cflag & HUPCL) {
480 info->omodem &= ~(RTS|DTR);
481 fepcmd(info, SETMODEM, 0, DTR|RTS, 10, 1);
485 info->asyncflags &= ~ASYNC_INITIALIZED;
486 restore_flags(flags);
490 static void pcxe_close(struct tty_struct * tty, struct file * filp)
492 struct channel *info;
494 if ((info=chan(tty))!=NULL) {
499 if(tty_hung_up_p(filp)) {
500 /* flag that somebody is done with this module */
501 restore_flags(flags);
504 /* this check is in serial.c, it won't hurt to do it here too */
505 if ((tty->count == 1) && (info->count != 1)) {
507 * Uh, oh. tty->count is 1, which means that the tty
508 * structure will be freed. Info->count should always
509 * be one in these conditions. If it's greater than
510 * one, we've got real problems, since it means the
511 * serial port won't be shutdown.
513 printk("pcxe_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count);
516 if (info->count-- > 1) {
517 restore_flags(flags);
520 if (info->count < 0) {
524 info->asyncflags |= ASYNC_CLOSING;
527 if(info->asyncflags & ASYNC_INITIALIZED) {
528 setup_empty_event(tty,info);
529 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
532 if(tty->driver->flush_buffer)
533 tty->driver->flush_buffer(tty);
534 tty_ldisc_flush(tty);
539 if(info->blocked_open) {
540 if(info->close_delay) {
541 msleep_interruptible(jiffies_to_msecs(info->close_delay));
543 wake_up_interruptible(&info->open_wait);
545 info->asyncflags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
546 wake_up_interruptible(&info->close_wait);
547 restore_flags(flags);
552 void pcxe_hangup(struct tty_struct *tty)
556 if ((ch=chan(tty))!=NULL) {
565 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
566 wake_up_interruptible(&ch->open_wait);
567 restore_flags(flags);
573 static int pcxe_write(struct tty_struct * tty, const unsigned char *buf, int count)
576 volatile struct board_chan *bc;
577 int total, remain, size, stlen;
578 unsigned int head, tail;
580 /* printk("Entering pcxe_write()\n"); */
582 if ((ch=chan(tty))==NULL)
586 size = ch->txbufsize;
589 * All data is now local
596 head = bc->tin & (size - 1);
598 if (tail != bc->tout)
602 remain = size - (head - tail) - 1;
606 remain = tail - head - 1;
609 count = min(remain, count);
613 stlen = min(count, stlen);
614 memcpy(ch->txptr + head, buf, stlen);
624 ch->statusflags |= TXBUSY;
627 if ((ch->statusflags & LOWWAIT) == 0) {
628 ch->statusflags |= LOWWAIT;
632 restore_flags(flags);
638 static void pcxe_put_char(struct tty_struct *tty, unsigned char c)
640 pcxe_write(tty, &c, 1);
645 static int pcxe_write_room(struct tty_struct *tty)
651 if ((ch=chan(tty))!=NULL) {
652 volatile struct board_chan *bc;
653 unsigned int head, tail;
661 head = bc->tin & (ch->txbufsize - 1);
663 if (tail != bc->tout)
665 tail &= (ch->txbufsize - 1);
667 if((remain = tail - head - 1) < 0 )
668 remain += ch->txbufsize;
670 if (remain && (ch->statusflags & LOWWAIT) == 0) {
671 ch->statusflags |= LOWWAIT;
675 restore_flags(flags);
682 static int pcxe_chars_in_buffer(struct tty_struct *tty)
685 unsigned int ctail, head, tail;
689 volatile struct board_chan *bc;
691 if ((ch=chan(tty))==NULL)
701 ctail = ch->mailbox->cout;
702 if(tail == head && ch->mailbox->cin == ctail && bc->tbusy == 0)
705 head = bc->tin & (ch->txbufsize - 1);
706 tail &= (ch->txbufsize - 1);
707 if((remain = tail - head - 1) < 0 )
708 remain += ch->txbufsize;
710 chars = (int)(ch->txbufsize - remain);
713 * Make it possible to wakeup anything waiting for output
714 * in tty_ioctl.c, etc.
716 if(!(ch->statusflags & EMPTYWAIT))
717 setup_empty_event(tty,ch);
721 restore_flags(flags);
727 static void pcxe_flush_buffer(struct tty_struct *tty)
730 volatile struct board_chan *bc;
734 if ((ch=chan(tty))==NULL)
743 fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
746 restore_flags(flags);
751 static void pcxe_flush_chars(struct tty_struct *tty)
755 if ((ch=chan(tty))!=NULL) {
760 if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT))
761 setup_empty_event(tty,ch);
762 restore_flags(flags);
769 * Driver setup function when linked into the kernel to optionally parse multible
770 * "digi="-lines and initialize the driver at boot time. No probing.
772 void __init pcxx_setup(char *str, int *ints)
775 struct board_info board;
782 memset(&board, 0, sizeof(board));
784 for(last=0,i=1;i<=ints[0];i++)
788 board.status = ints[i];
793 board.type = ints[i];
798 board.altpin = ints[i];
803 board.numports = ints[i];
808 board.port = ints[i];
813 board.membase = ints[i];
818 printk("PC/Xx: Too many integer parms\n");
824 /* find the next comma or terminator */
826 while (*temp && (*temp != ','))
840 if (strncmp("Disable", str, len) == 0)
843 if (strncmp("Enable", str, len) == 0)
847 printk("PC/Xx: Invalid status %s\n", str);
854 for(j=0;j<PCXX_NUM_TYPES;j++)
855 if (strcmp(board_desc[j], str) == 0)
858 if (i<PCXX_NUM_TYPES)
862 printk("PC/Xx: Invalid board name: %s\n", str);
870 if (strncmp("Disable", str, len) == 0)
873 if (strncmp("Enable", str, len) == 0)
877 printk("PC/Xx: Invalid altpin %s\n", str);
890 printk("PC/Xx: Invalid port count %s\n", str);
894 board.numports = simple_strtoul(str, NULL, 0);
900 while (isxdigit(*t2))
905 printk("PC/Xx: Invalid io port address %s\n", str);
909 board.port = simple_strtoul(str, NULL, 16);
915 while (isxdigit(*t2))
920 printk("PC/Xx: Invalid memory base %s\n", str);
924 board.membase = simple_strtoul(str, NULL, 16);
929 printk("PC/Xx: Too many string parms\n");
937 printk("PC/Xx: Insufficient parms specified\n");
941 /* I should REALLY validate the stuff here */
943 memcpy(&boards[numcards],&board, sizeof(board));
944 printk("PC/Xx: Added board %i, %s %s %i ports at 0x%4.4X base 0x%6.6X\n",
945 numcards, board_desc[board.type], board_mem[board.type],
946 board.numports, board.port, (unsigned int) board.membase);
948 /* keep track of my initial minor number */
950 boards[numcards].first_minor = boards[numcards-1].first_minor + boards[numcards-1].numports;
952 boards[numcards].first_minor = 0;
954 /* yeha! string parameter was successful! */
959 static struct tty_operations pcxe_ops = {
963 .put_char = pcxe_put_char,
964 .flush_chars = pcxe_flush_chars,
965 .write_room = pcxe_write_room,
966 .chars_in_buffer = pcxe_chars_in_buffer,
967 .flush_buffer = pcxe_flush_buffer,
969 .throttle = pcxe_throttle,
970 .unthrottle = pcxe_unthrottle,
971 .set_termios = pcxe_set_termios,
974 .hangup = pcxe_hangup,
975 .tiocmget = pcxe_tiocmget,
976 .tiocmset = pcxe_tiocmset,
980 * function to initialize the driver with the given parameters, which are either
981 * the default values from this file or the parameters given at boot.
983 static int __init pcxe_init(void)
985 ulong memory_seg=0, memory_size=0;
986 int lowwater, enabled_cards=0, i, crd, shrinkmem=0, topwin = 0xff00L, botwin=0x100L;
988 unchar *fepos, *memaddr, *bios, v;
989 volatile struct global_data *gd;
990 volatile struct board_chan *bc;
991 struct board_info *bd;
994 printk(KERN_NOTICE "Digiboard PC/X{i,e,eve} driver v%s\n", VERSION);
997 for (i = 0; i < MAX_DIGI_BOARDS; i++) {
1003 if (numcards == 0) {
1004 int first_minor = 0;
1006 for (i = 0; i < MAX_DIGI_BOARDS; i++) {
1009 boards[i].status = DISABLED;
1012 boards[i].port = (ushort)io[i];
1013 boards[i].status = ENABLED;
1014 boards[i].first_minor = first_minor;
1018 boards[i].membase = (ulong)membase[i];
1020 boards[i].membase = 0xD0000;
1023 boards[i].memsize = (ulong)(memsize[i] * 1024);
1025 boards[i].memsize = 0;
1028 boards[i].altpin = ON;
1030 boards[i].altpin = OFF;
1033 boards[i].numports = (ushort)numports[i];
1035 boards[i].numports = 16;
1037 boards[i].region = NULL;
1038 first_minor += boards[i].numports;
1045 printk("PC/Xx: No cards configured, driver not active.\n");
1050 for (i = 0; i < numcards; i++) {
1051 printk("Card %d:status=%d, port=0x%x, membase=0x%lx, memsize=0x%lx, altpin=%d, numports=%d, first_minor=%d\n",
1059 boards[i].first_minor);
1063 for (i=0;i<numcards;i++)
1064 nbdevs += boards[i].numports;
1068 printk("PC/Xx: No devices activated, driver not active.\n");
1072 pcxe_driver = alloc_tty_driver(nbdevs);
1077 * this turns out to be more memory efficient, as there are no
1080 digi_channels = kmalloc(sizeof(struct channel) * nbdevs, GFP_KERNEL);
1081 if (!digi_channels) {
1082 printk(KERN_ERR "Unable to allocate digi_channel struct\n");
1083 put_tty_driver(pcxe_driver);
1086 memset(digi_channels, 0, sizeof(struct channel) * nbdevs);
1088 init_timer(&pcxx_timer);
1089 pcxx_timer.function = pcxxpoll;
1091 pcxe_driver->owner = THIS_MODULE;
1092 pcxe_driver->name = "ttyD";
1093 pcxe_driver->devfs_name = "pcxe/";
1094 pcxe_driver->major = DIGI_MAJOR;
1095 pcxe_driver->minor_start = 0;
1096 pcxe_driver->type = TTY_DRIVER_TYPE_SERIAL;
1097 pcxe_driver->subtype = SERIAL_TYPE_NORMAL;
1098 pcxe_driver->init_termios = tty_std_termios;
1099 pcxe_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
1100 pcxe_driver->flags = TTY_DRIVER_REAL_RAW;
1101 tty_set_operations(pcxe_driver, &pcxe_ops);
1103 for(crd=0; crd < numcards; crd++) {
1105 outb(FEPRST, bd->port);
1108 for(i=0; (inb(bd->port) & FEPMASK) != FEPRST; i++) {
1110 printk("PC/Xx: Board not found at port 0x%x! Check switch settings.\n",
1112 bd->status = DISABLED;
1120 if(bd->status == DISABLED)
1125 if((v & 0x1) == 0x1) {
1126 if((v & 0x30) == 0) { /* PC/Xi 64K card */
1127 memory_seg = 0xf000;
1128 memory_size = 0x10000;
1131 if((v & 0x30) == 0x10) { /* PC/Xi 128K card */
1132 memory_seg = 0xe000;
1133 memory_size = 0x20000;
1136 if((v & 0x30) == 0x20) { /* PC/Xi 256K card */
1137 memory_seg = 0xc000;
1138 memory_size = 0x40000;
1141 if((v & 0x30) == 0x30) { /* PC/Xi 512K card */
1142 memory_seg = 0x8000;
1143 memory_size = 0x80000;
1147 if((v & 0x1) == 0x1) {
1148 bd->status = DISABLED; /* PC/Xm unsupported card */
1149 printk("PC/Xx: PC/Xm at 0x%x not supported!!\n", bd->port);
1154 outb((((ulong)bd->membase>>8) & 0xe0) | 0x10, bd->port+2);
1155 outb(((ulong)bd->membase>>16) & 0xff, bd->port+3);
1156 bd->type = PCXEVE; /* PC/Xe 8K card */
1158 bd->type = PCXE; /* PC/Xe 64K card */
1161 memory_seg = 0xf000;
1162 memory_size = 0x10000;
1166 printk("Configuring card %d as a %s %ldK card. io=0x%x, mem=%lx-%lx\n",
1167 crd+1, board_desc[bd->type], memory_size/1024,
1168 bd->port,bd->membase,bd->membase+memory_size-1);
1170 if (boards[crd].memsize == 0)
1171 boards[crd].memsize = memory_size;
1173 if (boards[crd].memsize != memory_size) {
1174 printk("PC/Xx: memory size mismatch:supplied=%lx(%ldK) probed=%ld(%ldK)\n",
1175 boards[crd].memsize, boards[crd].memsize / 1024,
1176 memory_size, memory_size / 1024);
1180 memaddr = (unchar *)phys_to_virt(bd->membase);
1183 printk("Resetting board and testing memory access:");
1185 outb(FEPRST|FEPMEM, bd->port);
1187 for(i=0; (inb(bd->port) & FEPMASK) != (FEPRST|FEPMEM); i++) {
1189 printk("\nPC/Xx: %s not resetting at port 0x%x! Check switch settings.\n",
1190 board_desc[bd->type], bd->port);
1191 bd->status = DISABLED;
1199 if(bd->status == DISABLED)
1203 *(ulong *)(memaddr + botwin) = 0xa55a3cc3;
1204 *(ulong *)(memaddr + topwin) = 0x5aa5c33c;
1206 if(*(ulong *)(memaddr + botwin) != 0xa55a3cc3 ||
1207 *(ulong *)(memaddr + topwin) != 0x5aa5c33c) {
1208 printk("PC/Xx: Failed memory test at %lx for %s at port %x, check switch settings.\n",
1209 bd->membase, board_desc[bd->type], bd->port);
1210 bd->status = DISABLED;
1216 for(i=0; i < 16; i++) {
1217 memaddr[MISCGLOBAL+i] = 0;
1220 if(bd->type == PCXI || bd->type == PCXE) {
1221 bios = memaddr + BIOSCODE + ((0xf000 - memory_seg) << 4);
1224 printk("Downloading BIOS to 0x%lx:", virt_to_phys(bios));
1226 memcpy(bios, pcxx_bios, pcxx_nbios);
1231 outb(FEPMEM, bd->port);
1234 printk("Waiting for BIOS to become ready");
1236 for(i=1; i <= 30; i++) {
1237 if(*(ushort *)((ulong)memaddr + MISCGLOBAL) == *(ushort *)"GD" ) {
1251 printk("\nPC/Xx: BIOS download failed for board at 0x%x(addr=%lx-%lx)!\n",
1252 bd->port, bd->membase, bd->membase+bd->memsize);
1253 bd->status = DISABLED;
1257 if(bd->type == PCXEVE) {
1258 bios = memaddr + (BIOSCODE & 0x1fff);
1261 memcpy(bios, pcxx_bios, pcxx_nbios);
1263 outb(FEPCLR, bd->port);
1266 for(i=0; i <= 1000; i++) {
1267 if(*(ushort *)((ulong)memaddr + MISCGLOBAL) == *(ushort *)"GD" ) {
1281 printk("\nPC/Xx: BIOS download failed on the %s at 0x%x!\n",
1282 board_desc[bd->type], bd->port);
1283 bd->status = DISABLED;
1288 fepos = memaddr + FEPCODE;
1289 if(bd->type == PCXEVE)
1290 fepos = memaddr + (FEPCODE & 0x1fff);
1293 printk(" ok.\nDownloading FEP/OS to 0x%lx:", virt_to_phys(fepos));
1295 memwinon(bd, (FEPCODE >> 13));
1296 memcpy(fepos, pcxx_cook, pcxx_ncook);
1302 *(ushort *)((ulong)memaddr + MBOX + 0) = 2;
1303 *(ushort *)((ulong)memaddr + MBOX + 2) = memory_seg + FEPCODESEG;
1304 *(ushort *)((ulong)memaddr + MBOX + 4) = 0;
1305 *(ushort *)((ulong)memaddr + MBOX + 6) = FEPCODESEG;
1306 *(ushort *)((ulong)memaddr + MBOX + 8) = 0;
1307 *(ushort *)((ulong)memaddr + MBOX + 10) = pcxx_ncook;
1309 outb(FEPMEM|FEPINT, bd->port);
1310 outb(FEPMEM, bd->port);
1312 for(i=0; *(ushort *)((ulong)memaddr + MBOX); i++) {
1314 printk("PC/Xx: Command failed for the %s at 0x%x!\n",
1315 board_desc[bd->type], bd->port);
1316 bd->status = DISABLED;
1325 if(bd->status == DISABLED)
1329 printk("Waiting for FEP/OS to become ready");
1331 *(ushort *)(memaddr + FEPSTAT) = 0;
1332 *(ushort *)(memaddr + MBOX + 0) = 1;
1333 *(ushort *)(memaddr + MBOX + 2) = FEPCODESEG;
1334 *(ushort *)(memaddr + MBOX + 4) = 0x4L;
1336 outb(FEPINT, bd->port);
1337 outb(FEPCLR, bd->port);
1340 for(i=1; *(ushort *)((ulong)memaddr + FEPSTAT) != *(ushort *)"OS"; i++) {
1342 printk("\nPC/Xx: FEP/OS download failed on the %s at 0x%x!\n",
1343 board_desc[bd->type], bd->port);
1344 bd->status = DISABLED;
1350 printk("\n%5d",i/50);
1357 if(bd->status == DISABLED)
1363 ch = digi_channels+bd->first_minor;
1364 pcxxassert(ch < digi_channels+nbdevs, "ch out of range");
1366 bc = (volatile struct board_chan *)((ulong)memaddr + CHANSTRUCT);
1367 gd = (volatile struct global_data *)((ulong)memaddr + GLOBAL);
1369 if((bd->type == PCXEVE) && (*(ushort *)((ulong)memaddr+NPORT) < 3))
1372 bd->region = request_region(bd->port, 4, "PC/Xx");
1375 printk(KERN_ERR "I/O port 0x%x is already used\n", bd->port);
1377 goto cleanup_boards;
1380 for(i=0; i < bd->numports; i++, ch++, bc++) {
1381 if(((ushort *)((ulong)memaddr + PORTBASE))[i] == 0) {
1387 INIT_WORK(&ch->tqueue, do_softint, ch);
1388 ch->board = &boards[crd];
1389 #ifdef DEFAULT_HW_FLOW
1390 ch->digiext.digi_flags = RTSPACE|CTSPACE;
1392 if(boards[crd].altpin) {
1395 ch->digiext.digi_flags |= DIGI_ALTPIN;
1401 ch->magic = PCXX_MAGIC;
1405 ch->dev = bd->first_minor + i;
1409 fepcmd(ch, SETBUFFER, 32, 0, 0, 0);
1413 if(bd->type != PCXEVE) {
1414 ch->txptr = memaddr+((bc->tseg-memory_seg) << 4);
1415 ch->rxptr = memaddr+((bc->rseg-memory_seg) << 4);
1416 ch->txwin = ch->rxwin = 0;
1418 ch->txptr = memaddr+(((bc->tseg-memory_seg) << 4) & 0x1fff);
1419 ch->txwin = FEPWIN | ((bc->tseg-memory_seg) >> 9);
1420 ch->rxptr = memaddr+(((bc->rseg-memory_seg) << 4) & 0x1fff);
1421 ch->rxwin = FEPWIN | ((bc->rseg-memory_seg) >>9 );
1424 ch->txbufsize = bc->tmax + 1;
1425 ch->rxbufsize = bc->rmax + 1;
1426 ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL);
1427 init_MUTEX(&ch->tmp_buf_sem);
1430 printk(KERN_ERR "Unable to allocate memory for temp buffers\n");
1431 goto cleanup_boards;
1434 lowwater = ch->txbufsize >= 2000 ? 1024 : ch->txbufsize/2;
1435 fepcmd(ch, STXLWATER, lowwater, 0, 10, 0);
1436 fepcmd(ch, SRXLWATER, ch->rxbufsize/4, 0, 10, 0);
1437 fepcmd(ch, SRXHWATER, 3 * ch->rxbufsize/4, 0, 10, 0);
1442 ch->startc = bc->startc;
1443 ch->stopc = bc->stopc;
1444 ch->startca = bc->startca;
1445 ch->stopca = bc->stopca;
1455 ch->close_delay = 50;
1457 ch->blocked_open = 0;
1458 init_waitqueue_head(&ch->open_wait);
1459 init_waitqueue_head(&ch->close_wait);
1464 printk("Card No. %d ready: %s (%s) I/O=0x%x Mem=0x%lx Ports=%d\n",
1465 crd+1, board_desc[bd->type], board_mem[bd->type], bd->port,
1466 bd->membase, bd->numports);
1468 printk("PC/Xx: %s (%s) I/O=0x%x Mem=0x%lx Ports=%d\n",
1469 board_desc[bd->type], board_mem[bd->type], bd->port,
1470 bd->membase, bd->numports);
1476 if (enabled_cards <= 0) {
1477 printk(KERN_NOTICE "PC/Xx: No cards enabled, no driver.\n");
1479 goto cleanup_boards;
1482 ret = tty_register_driver(pcxe_driver);
1484 printk(KERN_ERR "Couldn't register PC/Xe driver\n");
1485 goto cleanup_boards;
1489 * Start up the poller to check for events on all enabled boards
1491 mod_timer(&pcxx_timer, HZ/25);
1494 printk(KERN_NOTICE "PC/Xx: Driver with %d card(s) ready.\n", enabled_cards);
1498 cleanup_board_resources();
1499 kfree(digi_channels);
1500 put_tty_driver(pcxe_driver);
1504 module_init(pcxe_init)
1505 module_exit(pcxe_cleanup)
1507 static void pcxxpoll(unsigned long dummy)
1509 unsigned long flags;
1511 volatile unsigned int head, tail;
1513 struct board_info *bd;
1518 for(crd=0; crd < numcards; crd++) {
1521 ch = digi_channels+bd->first_minor;
1523 if(bd->status == DISABLED)
1529 head = ch->mailbox->ein;
1530 tail = ch->mailbox->eout;
1538 mod_timer(&pcxx_timer, jiffies + HZ/25);
1539 restore_flags(flags);
1542 static void doevent(int crd)
1544 volatile struct board_info *bd;
1545 static struct tty_struct *tty;
1546 volatile struct board_chan *bc;
1547 volatile unchar *eventbuf;
1548 volatile unsigned int head;
1549 volatile unsigned int tail;
1551 struct channel *chan0;
1552 int channel, event, mstat, lstat;
1556 chan0 = digi_channels+bd->first_minor;
1557 pcxxassert(chan0 < digi_channels+nbdevs, "ch out of range");
1560 assertgwinon(chan0);
1562 while ((tail = chan0->mailbox->eout) != (head = chan0->mailbox->ein)) {
1563 assertgwinon(chan0);
1564 eventbuf = (volatile unchar *)phys_to_virt(bd->membase + tail + ISTART);
1565 channel = eventbuf[0];
1566 event = eventbuf[1];
1567 mstat = eventbuf[2];
1568 lstat = eventbuf[3];
1572 if ((unsigned)channel >= bd->numports || !ch) {
1573 printk("physmem=%lx, tail=%x, head=%x\n", bd->membase, tail, head);
1574 printk("doevent(%x) channel %x, event %x, mstat %x, lstat %x\n",
1575 crd, (unsigned)channel, event, (unsigned)mstat, lstat);
1576 if(channel >= bd->numports)
1581 if ((bc = ch->brdchan) == NULL)
1584 if (event & DATA_IND) {
1589 if (event & MODEMCHG_IND) {
1591 if (ch->asyncflags & ASYNC_NORMAL_ACTIVE) {
1592 if (ch->asyncflags & ASYNC_CHECK_CD) {
1593 if (mstat & ch->dcd) {
1594 wake_up_interruptible(&ch->open_wait);
1596 pcxe_sched_event(ch, PCXE_EVENT_HANGUP);
1606 if (event & BREAK_IND) {
1608 *tty->flip.flag_buf_ptr++ = TTY_BREAK;
1609 *tty->flip.char_buf_ptr++ = 0;
1611 if (ch->asyncflags & ASYNC_SAK)
1614 tty_schedule_flip(tty);
1617 if (event & LOWTX_IND) {
1618 if (ch->statusflags & LOWWAIT) {
1619 ch->statusflags &= ~LOWWAIT;
1624 if (event & EMPTYTX_IND) {
1625 ch->statusflags &= ~TXBUSY;
1626 if (ch->statusflags & EMPTYWAIT) {
1627 ch->statusflags &= ~EMPTYWAIT;
1635 if(!bc) printk("bc == NULL in doevent!\n");
1638 chan0->mailbox->eout = (tail+4) & (IMAX-ISTART-4);
1646 fepcmd(struct channel *ch, int cmd, int word_or_byte, int byte2, int ncmds,
1650 unsigned int head, tail;
1654 if(ch->board->status == DISABLED)
1659 memaddr = (unchar *)phys_to_virt(ch->board->membase);
1660 head = ch->mailbox->cin;
1662 if(head >= (CMAX-CSTART) || (head & 03)) {
1663 printk("line %d: Out of range, cmd=%x, head=%x\n", __LINE__, cmd, head);
1668 *(unchar *)(memaddr+head+CSTART+0) = cmd;
1670 *(unchar *)(memaddr+head+CSTART+1) = ch->dev - ch->board->first_minor;
1672 *(unchar *)(memaddr+head+CSTART+2) = word_or_byte;
1673 *(unchar *)(memaddr+head+CSTART+3) = byte2;
1675 *(unchar *)(memaddr+head+CSTART+0) = cmd;
1677 *(unchar *)(memaddr+head+CSTART+1) = ch->dev - ch->board->first_minor;
1678 *(ushort*)(memaddr+head+CSTART+2) = word_or_byte;
1681 head = (head+4) & (CMAX-CSTART-4);
1682 ch->mailbox->cin = head;
1689 printk("Fep not responding in fepcmd()\n");
1693 head = ch->mailbox->cin;
1694 tail = ch->mailbox->cout;
1696 n = (head-tail) & (CMAX-CSTART-4);
1698 if(n <= ncmds * (sizeof(short)*4))
1700 /* Seems not to be good here: schedule(); */
1705 static unsigned termios2digi_c(struct channel *ch, unsigned cflag)
1708 if (cflag & CBAUDEX)
1710 ch->digiext.digi_flags |= DIGI_FAST;
1712 /* This gets strange but if we don't do this we will get 78600
1713 * instead of 115200. 57600 is mapped to 50 baud yielding 57600 in
1714 * FAST mode. 115200 is mapped to 75. We need to map it to 110 to
1717 if (cflag & B115200) res|=1;
1719 else ch->digiext.digi_flags &= ~DIGI_FAST;
1720 res |= cflag & (CBAUD | PARODD | PARENB | CSTOPB | CSIZE | CLOCAL);
1724 static unsigned termios2digi_i(struct channel *ch, unsigned iflag)
1726 unsigned res = iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|IXON|IXANY|IXOFF);
1728 if(ch->digiext.digi_flags & DIGI_AIXON)
1733 static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
1737 if(cflag & CRTSCTS) {
1738 ch->digiext.digi_flags |= (RTSPACE|CTSPACE);
1741 if(ch->digiext.digi_flags & RTSPACE)
1743 if(ch->digiext.digi_flags & DTRPACE)
1745 if(ch->digiext.digi_flags & CTSPACE)
1747 if(ch->digiext.digi_flags & DSRPACE)
1749 if(ch->digiext.digi_flags & DCDPACE)
1753 ch->digiext.digi_flags |= RTSPACE;
1755 ch->digiext.digi_flags |= CTSPACE;
1760 static void pcxxparam(struct tty_struct *tty, struct channel *ch)
1762 volatile struct board_chan *bc;
1764 unsigned mval, hflow, cflag, iflag;
1771 if((ts->c_cflag & CBAUD) == 0) {
1775 fepcmd(ch, STOUT, (unsigned) head, 0, 0, 0);
1779 cflag = termios2digi_c(ch, ts->c_cflag);
1781 if(cflag != ch->fepcflag) {
1782 ch->fepcflag = cflag;
1783 fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0);
1787 ch->asyncflags &= ~ASYNC_CHECK_CD;
1789 ch->asyncflags |= ASYNC_CHECK_CD;
1795 iflag = termios2digi_i(ch, ts->c_iflag);
1797 if(iflag != ch->fepiflag) {
1798 ch->fepiflag = iflag;
1799 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0);
1803 if((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD))
1804 if(ch->digiext.digi_flags & DIGI_FORCEDCD)
1807 ch->imodem = bc->mstat;
1809 hflow = termios2digi_h(ch, ts->c_cflag);
1811 if(hflow != ch->hflow) {
1813 fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1);
1816 /* mval ^= ch->modemfake & (mval ^ ch->modem); */
1818 if(ch->omodem != mval) {
1820 fepcmd(ch, SETMODEM, mval, RTS|DTR, 0, 1);
1823 if(ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) {
1824 ch->fepstartc = ch->startc;
1825 ch->fepstopc = ch->stopc;
1826 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1);
1829 if(ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) {
1830 ch->fepstartca = ch->startca;
1831 ch->fepstopca = ch->stopca;
1832 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
1837 static void receive_data(struct channel *ch)
1839 volatile struct board_chan *bc;
1840 struct tty_struct *tty;
1841 unsigned int tail, head, wrapmask;
1844 struct termios *ts=0;
1851 if (ch->statusflags & RXSTOPPED)
1861 printk("bc is NULL in receive_data!\n");
1865 wrapmask = ch->rxbufsize - 1;
1869 tail = bc->rout & wrapmask;
1871 n = (head-tail) & wrapmask;
1877 * If CREAD bit is off or device not open, set TX tail to head
1879 if(!tty || !ts || !(ts->c_cflag & CREAD)) {
1884 if(tty->flip.count == TTY_FLIPBUF_SIZE) {
1885 /* printk("tty->flip.count = TTY_FLIPBUF_SIZE\n"); */
1891 printk("overrun! DigiBoard device %s\n", tty->name);
1895 rptr = tty->flip.char_buf_ptr;
1896 rc = tty->flip.count;
1898 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;
1899 piece = (wrapgap < n) ? wrapgap : n;
1902 * Make sure we don't overflow the buffer
1905 if ((rc + piece) > TTY_FLIPBUF_SIZE)
1906 piece = TTY_FLIPBUF_SIZE - rc;
1911 memcpy(rptr, ch->rxptr + tail, piece);
1914 tail = (tail + piece) & wrapmask;
1917 tty->flip.count = rc;
1918 tty->flip.char_buf_ptr = rptr;
1922 /* Must be called with global data */
1923 tty_schedule_flip(ch->tty);
1928 static int pcxe_tiocmget(struct tty_struct *tty, struct file *file)
1930 struct channel *ch = (struct channel *) tty->driver_data;
1931 volatile struct board_chan *bc;
1932 unsigned long flags;
1939 printk("ch is NULL in %s!\n", __FUNCTION__);
1948 restore_flags(flags);
1967 static int pcxe_tiocmset(struct tty_struct *tty, struct file *file,
1968 unsigned int set, unsigned int clear)
1970 struct channel *ch = (struct channel *) tty->driver_data;
1971 volatile struct board_chan *bc;
1972 unsigned long flags;
1977 printk("ch is NULL in %s!\n", __FUNCTION__);
1984 * I think this modemfake stuff is broken. It doesn't
1985 * correctly reflect the behaviour desired by the TIOCM*
1986 * ioctls. Therefore this is probably broken.
1988 if (set & TIOCM_DTR) {
1989 ch->modemfake |= DTR;
1992 if (set & TIOCM_RTS) {
1993 ch->modemfake |= RTS;
1997 if (clear & TIOCM_DTR) {
1998 ch->modemfake |= DTR;
2001 if (clear & TIOCM_RTS) {
2002 ch->modemfake |= RTS;
2008 restore_flags(flags);
2013 static int pcxe_ioctl(struct tty_struct *tty, struct file * file,
2014 unsigned int cmd, unsigned long arg)
2016 struct channel *ch = (struct channel *) tty->driver_data;
2017 volatile struct board_chan *bc;
2019 unsigned int mflag, mstat;
2020 unsigned char startc, stopc;
2021 unsigned long flags;
2027 printk("ch is NULL in pcxe_ioctl!\n");
2034 case TCSBRK: /* SVID version: non-zero arg --> no break */
2035 retval = tty_check_change(tty);
2038 setup_empty_event(tty,ch);
2039 tty_wait_until_sent(tty, 0);
2041 digi_send_break(ch, HZ/4); /* 1/4 second */
2044 case TCSBRKP: /* support for POSIX tcsendbreak() */
2045 retval = tty_check_change(tty);
2048 setup_empty_event(tty,ch);
2049 tty_wait_until_sent(tty, 0);
2050 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
2054 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned int *)arg);
2059 if (get_user(value, (unsigned int *) arg))
2061 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (value ? CLOCAL : 0));
2066 mflag = pcxe_tiocmget(tty, file);
2067 if (put_user(mflag, (unsigned int *) arg))
2072 if (get_user(mstat, (unsigned int *) arg))
2074 return pcxe_tiocmset(tty, file, mstat, ~mstat);
2080 fepcmd(ch, SETMODEM, DTR, 0, 10, 1);
2082 restore_flags(flags);
2089 fepcmd(ch, SETMODEM, 0, DTR, 10, 1);
2091 restore_flags(flags);
2095 if (copy_to_user((char*)arg, &ch->digiext, sizeof(digi_t)))
2101 if(cmd == DIGI_SETAW) {
2102 setup_empty_event(tty,ch);
2103 tty_wait_until_sent(tty, 0);
2106 tty_ldisc_flush(tty);
2112 if (copy_from_user(&ch->digiext, (char*)arg, sizeof(digi_t)))
2115 printk("ioctl(DIGI_SETA): flags = %x\n", ch->digiext.digi_flags);
2118 if(ch->digiext.digi_flags & DIGI_ALTPIN) {
2130 restore_flags(flags);
2137 if(cmd == DIGI_GETFLOW) {
2138 dflow.startc = bc->startc;
2139 dflow.stopc = bc->stopc;
2141 dflow.startc = bc->startca;
2142 dflow.stopc = bc->stopca;
2145 restore_flags(flags);
2147 if (copy_to_user((char*)arg, &dflow, sizeof(dflow)))
2153 if(cmd == DIGI_SETFLOW) {
2154 startc = ch->startc;
2157 startc = ch->startca;
2161 if (copy_from_user(&dflow, (char*)arg, sizeof(dflow)))
2164 if(dflow.startc != startc || dflow.stopc != stopc) {
2168 if(cmd == DIGI_SETFLOW) {
2169 ch->fepstartc = ch->startc = dflow.startc;
2170 ch->fepstopc = ch->stopc = dflow.stopc;
2171 fepcmd(ch,SONOFFC,ch->fepstartc,ch->fepstopc,0, 1);
2173 ch->fepstartca = ch->startca = dflow.startc;
2174 ch->fepstopca = ch->stopca = dflow.stopc;
2175 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
2178 if(ch->statusflags & TXSTOPPED)
2182 restore_flags(flags);
2187 return -ENOIOCTLCMD;
2193 static void pcxe_set_termios(struct tty_struct *tty, struct termios *old_termios)
2195 struct channel *info;
2197 if ((info=chan(tty))!=NULL) {
2198 unsigned long flags;
2202 pcxxparam(tty,info);
2205 if ((old_termios->c_cflag & CRTSCTS) &&
2206 ((tty->termios->c_cflag & CRTSCTS) == 0))
2207 tty->hw_stopped = 0;
2208 if(!(old_termios->c_cflag & CLOCAL) &&
2209 (tty->termios->c_cflag & CLOCAL))
2210 wake_up_interruptible(&info->open_wait);
2211 restore_flags(flags);
2217 static void do_softint(void *private_)
2219 struct channel *info = (struct channel *) private_;
2221 if(info && info->magic == PCXX_MAGIC) {
2222 struct tty_struct *tty = info->tty;
2223 if (tty && tty->driver_data) {
2224 if(test_and_clear_bit(PCXE_EVENT_HANGUP, &info->event)) {
2226 wake_up_interruptible(&info->open_wait);
2227 info->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
2234 static void pcxe_stop(struct tty_struct *tty)
2236 struct channel *info;
2238 if ((info=chan(tty))!=NULL) {
2239 unsigned long flags;
2242 if ((info->statusflags & TXSTOPPED) == 0) {
2244 fepcmd(info, PAUSETX, 0, 0, 0, 0);
2245 info->statusflags |= TXSTOPPED;
2248 restore_flags(flags);
2252 static void pcxe_throttle(struct tty_struct * tty)
2254 struct channel *info;
2256 if ((info=chan(tty))!=NULL) {
2257 unsigned long flags;
2260 if ((info->statusflags & RXSTOPPED) == 0) {
2262 fepcmd(info, PAUSERX, 0, 0, 0, 0);
2263 info->statusflags |= RXSTOPPED;
2266 restore_flags(flags);
2270 static void pcxe_unthrottle(struct tty_struct *tty)
2272 struct channel *info;
2274 if ((info=chan(tty)) != NULL) {
2275 unsigned long flags;
2277 /* Just in case output was resumed because of a change in Digi-flow */
2280 if(info->statusflags & RXSTOPPED) {
2281 volatile struct board_chan *bc;
2284 fepcmd(info, RESUMERX, 0, 0, 0, 0);
2285 info->statusflags &= ~RXSTOPPED;
2288 restore_flags(flags);
2293 static void pcxe_start(struct tty_struct *tty)
2295 struct channel *info;
2297 if ((info=chan(tty))!=NULL) {
2298 unsigned long flags;
2302 /* Just in case output was resumed because of a change in Digi-flow */
2303 if(info->statusflags & TXSTOPPED) {
2304 volatile struct board_chan *bc;
2307 if(info->statusflags & LOWWAIT)
2309 fepcmd(info, RESUMETX, 0, 0, 0, 0);
2310 info->statusflags &= ~TXSTOPPED;
2313 restore_flags(flags);
2318 void digi_send_break(struct channel *ch, int msec)
2320 unsigned long flags;
2327 * Maybe I should send an infinite break here, schedule() for
2328 * msec amount of time, and then stop the break. This way,
2329 * the user can't screw up the FEP by causing digi_send_break()
2330 * to be called (i.e. via an ioctl()) more than once in msec amount
2331 * of time. Try this for now...
2334 fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
2337 restore_flags(flags);
2340 static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
2342 volatile struct board_chan *bc;
2343 unsigned long flags;
2348 ch->statusflags |= EMPTYWAIT;
2352 restore_flags(flags);