arch_debug_serial_[try_]getchar(): Look at the line status we read a bit closer

before assuming we have data. If the I/O port isn't valid (e.g. because there
is no serial port) 0xff seems to be a typical value to read. In that case fail.
Fixes KDL input on machines without serial port -- kgetc() would always think
it read something from the serial port, never trying any other input.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2011-06-13 18:25:08 +00:00
parent 224d969b1d
commit 0a187107e7

View File

@ -324,7 +324,14 @@ arch_debug_blue_screen_getchar(void)
int
arch_debug_serial_try_getchar(void)
{
if ((in8(sSerialBasePort + SERIAL_LINE_STATUS) & 0x1) == 0)
uint8 lineStatus = in8(sSerialBasePort + SERIAL_LINE_STATUS);
if (lineStatus == 0xff) {
// The "data available" bit is set, but also all error bits. Likely we
// don't have a valid I/O port.
return -1;
}
if ((lineStatus & 0x1) == 0)
return -1;
return in8(sSerialBasePort + SERIAL_RECEIVE_BUFFER);
@ -334,8 +341,19 @@ arch_debug_serial_try_getchar(void)
char
arch_debug_serial_getchar(void)
{
while ((in8(sSerialBasePort + SERIAL_LINE_STATUS) & 0x1) == 0)
asm volatile ("pause;");
while (true) {
uint8 lineStatus = in8(sSerialBasePort + SERIAL_LINE_STATUS);
if (lineStatus == 0xff) {
// The "data available" bit is set, but also all error bits. Likely
// we don't have a valid I/O port.
return 0;
}
if ((lineStatus & 0x1) != 0)
break;
PAUSE();
}
return in8(sSerialBasePort + SERIAL_RECEIVE_BUFFER);
}