diff options
author | dzwdz | 2022-03-27 14:47:50 +0200 |
---|---|---|
committer | dzwdz | 2022-03-27 14:47:50 +0200 |
commit | 45283c43460900d080478973c873339b5db3013e (patch) | |
tree | cde5d7afdf54fa57b07c8aa5f2a61cc663261445 /src/kernel/arch/i386/tty | |
parent | cc16c5d9847da67b3ff369c13712fcae4bebe2ae (diff) |
kernel/tty: poll only on IRQs, don't burn cycles
Diffstat (limited to 'src/kernel/arch/i386/tty')
-rw-r--r-- | src/kernel/arch/i386/tty/serial.c | 4 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/tty.c | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/kernel/arch/i386/tty/serial.c b/src/kernel/arch/i386/tty/serial.c index e77ff5c..054f956 100644 --- a/src/kernel/arch/i386/tty/serial.c +++ b/src/kernel/arch/i386/tty/serial.c @@ -14,15 +14,13 @@ static void serial_selftest(void) { void serial_init(void) { // see https://www.sci.muni.cz/docs/pc/serport.txt - - port_out8(COM1 + 1, 0x00); // disable interrupts, we won't be using them - // set baud rate divisor port_out8(COM1 + 3, 0b10000000); // enable DLAB port_out8(COM1 + 0, 0x01); // divisor = 1 (low byte) port_out8(COM1 + 1, 0x00); // (high byte) port_out8(COM1 + 3, 0b00000011); // 8 bits, no parity, one stop bit + port_out8(COM1 + 1, 0x01); // enable the Data Ready IRQ port_out8(COM1 + 2, 0b11000111); // enable FIFO with 14-bit trigger level (???) serial_selftest(); diff --git a/src/kernel/arch/i386/tty/tty.c b/src/kernel/arch/i386/tty/tty.c index f3fecf3..a63c16a 100644 --- a/src/kernel/arch/i386/tty/tty.c +++ b/src/kernel/arch/i386/tty/tty.c @@ -19,6 +19,7 @@ void tty_read(char *buf, size_t len) { for (;;) { if (serial_poll_read(&buf[i])) break; if (keyboard_poll_read(&buf[i])) break; + asm("hlt" ::: "memory"); } } } |