From: Thomas Veerman Date: Wed, 17 Oct 2012 14:57:08 +0000 (+0000) Subject: Kernel: busy wait until serial out has finished X-Git-Tag: v3.2.1~253 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/%7B%24global.css%7D?a=commitdiff_plain;h=87de14114114a7446b179d5441ddeec8d76d2b76;p=minix.git Kernel: busy wait until serial out has finished --- diff --git a/kernel/arch/arm/omap_serial.c b/kernel/arch/arm/omap_serial.c index 30e744e99..5a598c796 100644 --- a/kernel/arch/arm/omap_serial.c +++ b/kernel/arch/arm/omap_serial.c @@ -9,9 +9,14 @@ void omap3_ser_putc(char c) /* Wait until FIFO's empty */ for (i = 0; i < 100000; i++) - if (mmio_read(OMAP3_UART3_LSR) & OMAP3_LSR_TX_FIFO_E) + if (mmio_read(OMAP3_UART3_LSR) & OMAP3_LSR_THRE) break; /* Write character */ mmio_write(OMAP3_UART3_THR, c); + + /* And wait again until FIFO's empty to prevent TTY from overwriting */ + for (i = 0; i < 100000; i++) + if (mmio_read(OMAP3_UART3_LSR) & (OMAP3_LSR_THRE | OMAP3_LSR_TEMT)) + break; } diff --git a/kernel/arch/arm/omap_serial.h b/kernel/arch/arm/omap_serial.h index 278d02883..f3b0626ef 100644 --- a/kernel/arch/arm/omap_serial.h +++ b/kernel/arch/arm/omap_serial.h @@ -12,7 +12,8 @@ #define OMAP3_SSR 0x044 /* Supplementary status register */ /* Line status register fields */ -#define OMAP3_LSR_TX_FIFO_E (1 << 5) /* Transmit FIFO empty */ +#define OMAP3_LSR_TEMT 0x40 /* Transmitter empty */ +#define OMAP3_LSR_THRE 0x20 /* Transmit-hold-register empty */ /* Supplementary status register fields */ #define OMAP3_SSR_TX_FIFO_FULL (1 << 0) /* Transmit FIFO full */