diff --git a/src/idt/idt.S b/src/idt/idt.S index de819e6..52eb314 100644 --- a/src/idt/idt.S +++ b/src/idt/idt.S @@ -151,12 +151,13 @@ vector_7_handler: align 16 vector_8_handler: ; No error code, we only push vector number - push qword 1 + push qword 8 jmp interrupt_stub ; Coprocessor Segment Overrun align 16 vector_9_handler: + push qword 0 push qword 9 jmp interrupt_stub diff --git a/src/idt/idt.c b/src/idt/idt.c index 34efe6b..13195d8 100644 --- a/src/idt/idt.c +++ b/src/idt/idt.c @@ -54,7 +54,7 @@ void idt_init() { // We set 256 entries, but we have only the first few stubs. // Undefined behavior? - for (size_t i=0; i<256; i++) + for (size_t i=0; i<=33; i++) { // Each vector handler is 16-byte aligned, so *16 = address of that handler idt_set_entry(i, vector_0_handler + (i*16), 0); @@ -210,6 +210,7 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context) case 33: DEBUG("Keyboard Interrupt"); keyboard_handler(); + outb(0x20, 0x20); break; default: diff --git a/src/io/kbd/ps2.c b/src/io/kbd/ps2.c index 65b1585..872d88e 100644 --- a/src/io/kbd/ps2.c +++ b/src/io/kbd/ps2.c @@ -176,9 +176,6 @@ void keyboard_handler() key_status &= ~ALT_PRESSED_BIT; break; } - - // Send EOI - outb(0x20, 0x20); return; } else @@ -200,20 +197,21 @@ void keyboard_handler() default: { - // Should we get a SHIFTED char or a regular one? - unsigned char c = (key_status & SHIFT_PRESSED_BIT) ? keymap_shifted[scancode] : keymap[scancode]; - - if (c) + // Avoiding buffer overflow from extended keys lol + if (scancode < 128) { - // Should probably have a keyboard buffer here... instead of this - _putchar(c); + // Should we get a SHIFTED char or a regular one? + unsigned char c = (key_status & SHIFT_PRESSED_BIT) ? keymap_shifted[scancode] : keymap[scancode]; + + if (c) + { + // Should probably have a keyboard buffer here... instead of this + _putchar(c); + } } } } } - - // End of Interrupt (to master PIC) - outb(0x20, 0x20); } void keyboard_init(unsigned char layout) @@ -233,10 +231,16 @@ void keyboard_init(unsigned char layout) break; default: - skputs("Unsupported layout."); + panic(NULL, "Unsupported keyboard layout"); return; } + // Flush keyboard buffer + while (inb(0x64) & 1) + { + inb(0x60); + } + // Unmask IRQ1 uint8_t mask = inb(0x21); mask &= ~(1 << 1); diff --git a/src/io/serial/serial.c b/src/io/serial/serial.c index e2b9c57..469501b 100644 --- a/src/io/serial/serial.c +++ b/src/io/serial/serial.c @@ -54,6 +54,7 @@ static int is_transmit_empty() // Serial kernel putchar void skputc(char c) { + // TODO: Spinlock here (serial access) while (!is_transmit_empty()); // wait for free spot outb(PORT, c); } diff --git a/src/io/term/term.c b/src/io/term/term.c index 6d7b709..b44c086 100644 --- a/src/io/term/term.c +++ b/src/io/term/term.c @@ -22,6 +22,7 @@ extern struct flanterm_context* ft_ctx; // Overhead that could be avoided, right? (for printf) void _putchar(char character) { + // TODO: Spinlock here (terminal access) flanterm_write(ft_ctx, &character, 1); }