[MAJOR] FIFO UART is enabled

Added support of FIFO, timeout and fifo-size may be not optimal, but
basic functional is free.
Copy-paste issue fixed by this hack.
This commit is contained in:
Korobov Nikita
2017-07-11 18:34:29 +03:00
parent fc93b4db26
commit dab346e282
2 changed files with 48 additions and 25 deletions

View File

@@ -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

View File

@@ -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;
}