This is my first post on this forum, and that might be a stupid question, but a cannot find the bug.
I am trying to developp a very small kernel.
I want to have at least the keyboard working, but i cannot make it work correctly.
It seems there is 2 problems in 1:
The irq event triggered depend of the text written on screen (wtf ?)
Which i think is the cause why keyboard 'pressed' event is sent twice while clicking once.
Here is my the code of my main:
Code: Select all
void k_main(void)
{
terminal_initialize();
init_gdt();
init_idt();
//terminal_writestr("42\n");
asm volatile ("sti");
init_kbd();
terminal_writestr("a");
for(;;) {
asm("hlt");
}
}
Code: Select all
terminal_writestr("a");
One letter -> Irq 1, 2 letters irq 2, etc...
I am thinking of the way of handling irqs, but i cannot find my mistake
Here is the asm code for irqs:
Code: Select all
%macro IRQ 2 ; We need 2 parameters for our macro
global irq%1 ; First declare the name (irq0, irq1 etc...) as global
irq%1: ; Declare our function with the name (irq0, irq1 etc...)
cli ; Disable interrupts
push byte 0 ; push 0 on the stack
push byte %2 ; Push irqcode into the stack (second parameter)
jmp irq_common_stub ; call irq_common_stub function
%endmacro
IRQ 0, 32
IRQ 1, 33
IRQ 2, 34
IRQ 3, 35
IRQ 4, 36
IRQ 5, 37
IRQ 6, 38
IRQ 7, 39
IRQ 8, 40
IRQ 9, 41
IRQ 10,42
IRQ 11,43
IRQ 12,44
IRQ 13,45
IRQ 14,46
IRQ 15,47
irq_common_stub:
pusha ; push everything on the stack
push ds
push es
push fs
push gs
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, irq_handler
call eax
pop eax
pop gs
pop fs
pop es
pop ds
popa
add esp, 8
iret
https://github.com/lubenard/kfs-1
Thanks !