diff --git a/arch/x86/kernel/uart.c b/arch/x86/kernel/uart.c index 1962b885d..7631dc88e 100644 --- a/arch/x86/kernel/uart.c +++ b/arch/x86/kernel/uart.c @@ -111,8 +111,18 @@ static inline unsigned char read_from_uart(uint32_t off) return c; } +static inline int is_transmit_empty(void) +{ + if (uartport) + return inportb(uartport + UART_LSR) & 0x20; + + return 1; +} + static inline void write_to_uart(uint32_t off, unsigned char c) { + while (is_transmit_empty() == 0) { PAUSE; } + if (uartport) outportb(uartport + off, c); } diff --git a/arch/x86/loader/uart.c b/arch/x86/loader/uart.c index 3130260ba..8141a61a6 100644 --- a/arch/x86/loader/uart.c +++ b/arch/x86/loader/uart.c @@ -104,8 +104,18 @@ static inline unsigned char read_from_uart(uint32_t off) return c; } +static inline int is_transmit_empty(void) +{ + if (uartport) + return inportb(uartport + UART_LSR) & 0x20; + + return 1; +} + static void write_to_uart(uint32_t off, unsigned char c) { + while (is_transmit_empty() == 0) ; + if (uartport) outportb(uartport + off, c); }