diff options
author | Martin Aberg <maberg@gaisler.com> | 2017-03-14 17:27:57 +0100 |
---|---|---|
committer | Daniel Hellstrom <daniel@gaisler.com> | 2017-05-02 12:34:46 +0200 |
commit | 6860ddb6e86cb78a8d02bac4121f63097b5104e7 (patch) | |
tree | e3425e79b395a2b15b593e914efafc8c7b3bc68a | |
parent | leon, apbuart: support termios task driven mode (diff) | |
download | rtems-6860ddb6e86cb78a8d02bac4121f63097b5104e7.tar.bz2 |
leon, apbuart: Optimized RX processing in ISR
Limit the number of calls to termios rtems_termios_enqueue_raw_characters() by
reading out the RX FIFO on stack and then call termios only once.
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c index 6591cd88fd..a52c360f21 100644 --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c @@ -806,7 +806,7 @@ static void apbuart_cons_isr(void *arg) struct apbuart_priv *uart = condev_get_priv(condev); struct apbuart_regs *regs = uart->regs; unsigned int status; - char data; + char buf[33]; int cnt; if (uart->mode == TERMIOS_TASK_DRIVEN) { @@ -824,13 +824,22 @@ static void apbuart_cons_isr(void *arg) rtems_termios_rxirq_occured(tty); } } else { - /* Get all received characters */ - while ((status=regs->status) & APBUART_STATUS_DR) { - /* Data has arrived, get new data */ - data = regs->data; - - /* Tell termios layer about new character */ - rtems_termios_enqueue_raw_characters(tty, &data, 1); + /* + * Get all new characters from APBUART RX (FIFO) and store them + * on the stack. Then tell termios about the new characters. + * Maximum APBUART RX FIFO size is 32 characters. + */ + cnt = 0; + while ( + ((status=regs->status) & APBUART_STATUS_DR) && + (cnt < sizeof(buf)) + ) { + buf[cnt] = regs->data; + cnt++; + } + if (0 < cnt) { + /* Tell termios layer about new characters */ + rtems_termios_enqueue_raw_characters(tty, &buf[0], cnt); } } |