voron

experimental ARM OS
git clone git://git.2f30.org/voron.git
Log | Files | Refs | LICENSE

commit 633f6a73abb4d28ed14bd182e267d1866d99d515
parent 0d4188028ef7ba4662e033a674b23d9ffce84637
Author: oblique <psyberbits@gmail.com>
Date:   Wed Jan  9 06:03:11 +0200

rs232.c: check if TX FIFO is full before waiting to get empty.

Diffstat:
include/uart.h | 1+
kernel/rs232.c | 13+++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/include/uart.h b/include/uart.h @@ -4,6 +4,7 @@ #include <inttypes.h> /* TRM p.4459 */ +#define TX_FIFO_FULL (1<<0) #define TX_FIFO_E (1<<5) #define RX_FIFO_E (1<<0) #define RHR_IT (1<<0) diff --git a/kernel/rs232.c b/kernel/rs232.c @@ -24,13 +24,18 @@ int rs232_putchar(int c) { if (c == '\n') { + if (readl(&uart->ssr) & TX_FIFO_FULL) { + while ((readl(&uart->lsr) & TX_FIFO_E) == 0) + ; + } + writel('\r', &uart->thr); + } + /* if UART TX FIFO is full */ + if (readl(&uart->ssr) & TX_FIFO_FULL) { + /* while UART TX FIFO is not empty */ while ((readl(&uart->lsr) & TX_FIFO_E) == 0) ; - writel('\r', &uart->thr); } - /* while UART TX FIFO is not empty */ - while ((readl(&uart->lsr) & TX_FIFO_E) == 0) - ; /* write the character */ writel(c, &uart->thr); return c;