diff --git a/minix/drivers/tty/tty/arch/earm/pl011.c b/minix/drivers/tty/tty/arch/earm/pl011.c index 52e5781a7..758c061a0 100644 --- a/minix/drivers/tty/tty/arch/earm/pl011.c +++ b/minix/drivers/tty/tty/arch/earm/pl011.c @@ -281,7 +281,7 @@ static void rs_config(rs232_t *rs) * XXX: Disable FIFO otherwise only half of every received character * will trigger an interrupt. */ - serial_out(rs, PL011_LCR_H, serial_in(rs, PL011_LCR_H) & (~PL011_LCR_FEN)); + serial_out(rs, PL011_LCR_H, serial_in(rs, PL011_LCR_H) | PL011_LCR_FEN); /* Set interrupt levels */ serial_out(rs, PL011_IFLS, 0x0); @@ -398,14 +398,29 @@ rs_interrupt(message *m) int line; rs232_t *rs; - irq_set = m->m_notify.interrupts; - for (line = 0, rs = rs_lines; line < NR_RS_LINES; line++, rs++) { - if ((irq_set & (1 << rs->irq_hook_id)) && (rs->phys_base != 0)) { - rs232_handler(rs); - if (sys_irqenable(&rs->irq_hook_kernel_id) != OK) - panic("unable to enable interrupts"); - } - } + switch (_ENDPOINT_P(m->m_source)) { + case CLOCK: + for (line = 0, rs = rs_lines; line < NR_RS_LINES; line++, rs++) { + if (rs->phys_base != 0) { + if ((serial_in(rs, PL011_FR) & PL011_RXFE) == 0) { + read_chars(rs); + } + if (sys_irqenable(&rs->irq_hook_kernel_id) != OK) + panic("unable to enable interrupts"); + } + } + break; + case HARDWARE: + irq_set = m->m_notify.interrupts; + for (line = 0, rs = rs_lines; line < NR_RS_LINES; line++, rs++) { + if ((irq_set & (1 << rs->irq_hook_id)) && (rs->phys_base != 0)) { + rs232_handler(rs); + if (sys_irqenable(&rs->irq_hook_kernel_id) != OK) + panic("unable to enable interrupts"); + } + } + break; + } } static int diff --git a/minix/drivers/tty/tty/tty.c b/minix/drivers/tty/tty/tty.c index d017af6eb..613e4cd2e 100644 --- a/minix/drivers/tty/tty/tty.c +++ b/minix/drivers/tty/tty/tty.c @@ -140,6 +140,7 @@ static void sef_local_startup(void); static int sef_cb_init_fresh(int type, sef_init_info_t *info); static void sef_cb_signal_handler(int signo); +#define SANE_TIMEOUT 100000 /* 100 ms */ /*===========================================================================* * tty_task * *===========================================================================*/ @@ -155,7 +156,13 @@ int main(void) /* SEF local startup. */ sef_local_startup(); + int ticks = SANE_TIMEOUT * sys_hz() / 1000000; + + if (ticks <= 0) + ticks = 1; + while (TRUE) { + sys_setalarm(ticks, 0); /* Check for and handle any events on any of the ttys. */ for (tp = FIRST_TTY; tp < END_TTY; tp++) { if (tp->tty_events) handle_events(tp); @@ -178,26 +185,27 @@ int main(void) if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(tty_mess.m_source)) { - case CLOCK: - /* run watchdogs of expired timers */ - expire_timers(tty_mess.m_notify.timestamp); - break; - case HARDWARE: - /* hardware interrupt notification */ + case CLOCK: + /* run watchdogs of expired timers */ + rs_interrupt(&tty_mess); + expire_timers(tty_mess.m_notify.timestamp); + break; + case HARDWARE: + /* hardware interrupt notification */ #if NR_RS_LINES > 0 - /* serial I/O */ - if (tty_mess.m_notify.interrupts & rs_irq_set) - rs_interrupt(&tty_mess); + /* serial I/O */ + if (tty_mess.m_notify.interrupts & rs_irq_set) + rs_interrupt(&tty_mess); #endif - /* run watchdogs of expired timers */ - expire_timers(tty_mess.m_notify.timestamp); - break; - default: - /* do nothing */ - break; + /* run watchdogs of expired timers */ + expire_timers(tty_mess.m_notify.timestamp); + break; + default: + /* do nothing */ + break; } - + sys_setalarm(0, 0); /* done, get new message */ continue; }