1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

before writing to UART, check if the fifo is free

This commit is contained in:
Stefan Lankes 2017-06-02 20:13:09 +02:00
parent ab6dee0db7
commit 8ce912ef03
2 changed files with 20 additions and 0 deletions

View file

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

View file

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