OutsideApe3019
OutsideApe3019

Reputation: 25

Keyboard irq not properly returning

I am trying to create a keyboard driver for a kernel i am developing. I am using qemu-x86

main

[bits 32]
[org 0x1000]

_start:
    call idt_init
    jmp $

%include "include\vga.s"
%include "include\memory.s"
%include "include\interrupts.s"
%include "kernel\drivers\keyboard.s"

idt init

    mov eax, isr_0
    shr eax, 16
    mov [idt_start + 6 + (8 * 0)], ax
    ; ...
    mov eax, keyboard_handler
    shr eax, 16
    mov [idt_start + 6 + (8 * 32)], ax
    lidt [idt_descriptor]
    ; PIC remapping
    mov al, 0x11
    out 0x20, al
    out 0xA0, al
    mov al, 32
    out 0x21, al
    mov al, 38
    out 0xA1, al
    mov al, 4
    out 0x21, al
    mov al, 2
    out 0xA1, al
    mov al, 1
    out 0x21, al
    out 0xA1, al
    mov al, 0
    out 0x21, al
    out 0xA1, al
    sti
    ret

idt (only keyboard entry)

    dw keyboard_handler
    dw 8
    db 0
    db 10001110b
    dw 0

keyboard handler

    pusha
    in al, 0x60
    call kprint_char ; kprint_char takes al as the character. I am trying to write the scancode to understand the problem better
    mov al, 0x20
    out 0x20, al
    popa
    iret

It continuosly prints the scancode: when it press e key in prints the new scancode. It is like that the handler does not return properly and the PIC is sending the interrupt thinking it wasn't received. And when I press a key it makes a General Protection Fault, but only the first time a press I key

Upvotes: -3

Views: 44

Answers (0)

Related Questions