kbd_fix #12

Merged
xamidev merged 3 commits from kbd_fix into main 2026-03-09 09:30:42 +01:00
5 changed files with 23 additions and 15 deletions
Showing only changes of commit 5e9c582833 - Show all commits

View File

@@ -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

View File

@@ -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 <vector_no>*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:

View File

@@ -176,9 +176,6 @@ void keyboard_handler()
key_status &= ~ALT_PRESSED_BIT;
break;
}
// Send EOI
outb(0x20, 0x20);
return;
}
else
@@ -199,6 +196,9 @@ void keyboard_handler()
break;
default:
{
// Avoiding buffer overflow from extended keys lol
if (scancode < 128)
{
// Should we get a SHIFTED char or a regular one?
unsigned char c = (key_status & SHIFT_PRESSED_BIT) ? keymap_shifted[scancode] : keymap[scancode];
@@ -211,9 +211,7 @@ void keyboard_handler()
}
}
}
// 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);

View File

@@ -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);
}

View File

@@ -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);
}