15 #include <linux/errno.h>
16 #include <linux/sched.h>
17 #include <linux/tty.h>
20 #include <linux/fcntl.h>
23 #include <linux/slab.h>
24 #include <linux/capability.h>
28 #include <linux/module.h>
29 #include <linux/serial.h>
37 #undef SIMSERIAL_DEBUG
39 #define KEYBOARD_INTR 3
56 static void receive_chars(
struct tty_struct *tty)
59 static unsigned char seen_esc = 0;
62 if (ch == 27 && seen_esc == 0) {
65 }
else if (seen_esc == 1 && ch ==
'O') {
68 }
else if (seen_esc == 2) {
71 #ifdef CONFIG_MAGIC_SYSRQ
84 if (tty_insert_flip_char(tty, ch,
TTY_NORMAL) == 0)
117 static int rs_put_char(
struct tty_struct *tty,
unsigned char ch)
130 info->
xmit.buf[info->
xmit.head] = ch;
147 console->
write(console, &c, 1);
156 #ifdef SIMSERIAL_DEBUG
157 printk(
"transmit_chars: head=%d, tail=%d, stopped=%d\n",
172 console->
write(console, info->
xmit.buf+info->
xmit.tail, count);
181 console->
write(console, info->
xmit.buf, count);
188 static void rs_flush_chars(
struct tty_struct *tty)
196 transmit_chars(tty, info,
NULL);
200 const unsigned char *
buf,
int count)
218 info->
xmit.head = ((info->
xmit.head +
c) &
230 transmit_chars(tty, info,
NULL);
235 static int rs_write_room(
struct tty_struct *tty)
242 static int rs_chars_in_buffer(
struct tty_struct *tty)
249 static void rs_flush_buffer(
struct tty_struct *tty)
255 info->
xmit.head = info->
xmit.tail = 0;
265 static void rs_send_xchar(
struct tty_struct *tty,
char ch)
275 transmit_chars(tty, info,
NULL);
287 static void rs_throttle(
struct tty_struct * tty)
295 static void rs_unthrottle(
struct tty_struct * tty)
308 static int rs_ioctl(
struct tty_struct *tty,
unsigned int cmd,
unsigned long arg)
335 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
341 !(tty->termios.c_cflag &
CRTSCTS)) {
359 if (info->
xmit.buf) {
377 rs_flush_buffer(tty);
397 state->
xmit.buf = (
unsigned char *) page;
406 state->
xmit.head = state->
xmit.tail = 0;
446 console = console->
next;
456 static int rs_proc_show(
struct seq_file *
m,
void *
v)
462 seq_printf(m,
"%d: uart:16550 port:3F8 irq:%d\n",
474 .open = rs_proc_open,
484 .put_char = rs_put_char,
485 .flush_chars = rs_flush_chars,
486 .write_room = rs_write_room,
487 .chars_in_buffer = rs_chars_in_buffer,
488 .flush_buffer = rs_flush_buffer,
490 .throttle = rs_throttle,
491 .unthrottle = rs_unthrottle,
492 .send_xchar = rs_send_xchar,
493 .set_termios = rs_set_termios,
495 .proc_fops = &rs_proc_fops,
503 static int __init simrs_init(
void)
511 hp_simserial_driver = alloc_tty_driver(NR_PORTS);
512 if (!hp_simserial_driver)
520 hp_simserial_driver->
name =
"ttyS";
533 state->
port.ops = &hp_port_ops;
534 state->
port.close_delay = 0;