mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
Only write UART if transmitter-hold register empty
The line-status register has two relevant status bits - transmitter-hold register empty and data-hold register empty - from which only the THR is relevant as it signals new character can be written to the device. Fixes #281
This commit is contained in:
parent
b2478aec76
commit
abd09e419f
@ -53,7 +53,10 @@ enum {
|
||||
COMPORT_2_BASE = 0x3e8,
|
||||
COMPORT_3_BASE = 0x2e8,
|
||||
COMPORT_DATA_OFFSET = 0,
|
||||
COMPORT_STATUS_OFFSET = 5
|
||||
COMPORT_STATUS_OFFSET = 5,
|
||||
|
||||
STATUS_THR_EMPTY = 0x20, /* transmitter hold register empty */
|
||||
STATUS_DHR_EMPTY = 0x40, /* data hold register empty - data completely sent */
|
||||
};
|
||||
|
||||
|
||||
@ -101,7 +104,8 @@ inline void serial_out_char(Comport comport, uint8_t c)
|
||||
COMPORT_2_BASE, COMPORT_3_BASE };
|
||||
|
||||
/* wait until serial port is ready */
|
||||
while (!(inb(io_port[comport] + COMPORT_STATUS_OFFSET) & 0x60));
|
||||
uint8_t ready = STATUS_THR_EMPTY;
|
||||
while ((inb(io_port[comport] + COMPORT_STATUS_OFFSET) & ready) != ready);
|
||||
|
||||
/* output character */
|
||||
outb(io_port[comport] + COMPORT_DATA_OFFSET, c);
|
||||
|
Loading…
Reference in New Issue
Block a user