kernel/uart: fix GetChar for PL011

Check RX buffer status when GetChar is called in no-wait mode.
This fixes an 'infinite keypress' issue that used to occur
after 16 keypresses.

Change-Id: I47762de387b07c4fed46cc192cd3b81fdabfb270
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4732
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
David Karoly
2021-11-24 13:38:14 +00:00
committed by Adrien Destugues
parent 750ed8dd41
commit 191fa37376
@@ -289,10 +289,14 @@ int
ArchUARTPL011::GetChar(bool wait)
{
if (Enabled() == true) {
// Wait until a character is received?
if (wait) {
// Wait until a character is received
while ((In32(PL01x_FR) & PL01x_FR_RXFE) != 0)
Barrier();
} else {
// Check if there is any data available in RX fifo
if ((In32(PL01x_FR) & PL01x_FR_RXFE) != 0)
return -1;
}
return In32(PL01x_DR);
}