From 45283c43460900d080478973c873339b5db3013e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 27 Mar 2022 14:47:50 +0200 Subject: kernel/tty: poll only on IRQs, don't burn cycles --- src/kernel/arch/i386/tty/serial.c | 4 +--- src/kernel/arch/i386/tty/tty.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/kernel/arch/i386/tty') 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"); } } } -- cgit v1.2.3