summaryrefslogtreecommitdiffstats
path: root/src/kernel/chr_drv/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/chr_drv/serial.c')
-rw-r--r--src/kernel/chr_drv/serial.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/kernel/chr_drv/serial.c b/src/kernel/chr_drv/serial.c
new file mode 100644
index 0000000..aba25df
--- /dev/null
+++ b/src/kernel/chr_drv/serial.c
@@ -0,0 +1,59 @@
1/*
2 * linux/kernel/serial.c
3 *
4 * (C) 1991 Linus Torvalds
5 */
6
7/*
8 * serial.c
9 *
10 * This module implements the rs232 io functions
11 * void rs_write(struct tty_struct * queue);
12 * void rs_init(void);
13 * and all interrupts pertaining to serial IO.
14 */
15
16#include <linux/tty.h>
17#include <linux/sched.h>
18#include <asm/system.h>
19#include <asm/io.h>
20
21#define WAKEUP_CHARS (TTY_BUF_SIZE/4)
22
23extern void rs1_interrupt(void);
24extern void rs2_interrupt(void);
25
26static void init(int port)
27{
28 outb_p(0x80,port+3); /* set DLAB of line control reg */
29 outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */
30 outb_p(0x00,port+1); /* MS of divisor */
31 outb_p(0x03,port+3); /* reset DLAB */
32 outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */
33 outb_p(0x0d,port+1); /* enable all intrs but writes */
34 (void)inb(port); /* read data port to reset things (?) */
35}
36
37void rs_init(void)
38{
39 set_intr_gate(0x24,rs1_interrupt);
40 set_intr_gate(0x23,rs2_interrupt);
41 init(tty_table[1].read_q.data);
42 init(tty_table[2].read_q.data);
43 outb(inb_p(0x21)&0xE7,0x21);
44}
45
46/*
47 * This routine gets called when tty_write has put something into
48 * the write_queue. It must check wheter the queue is empty, and
49 * set the interrupt register accordingly
50 *
51 * void _rs_write(struct tty_struct * tty);
52 */
53void rs_write(struct tty_struct * tty)
54{
55 cli();
56 if (!EMPTY(tty->write_q))
57 outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1);
58 sti();
59}