diff options
Diffstat (limited to 'kernel/source/interrupts.asm')
-rw-r--r-- | kernel/source/interrupts.asm | 102 |
1 files changed, 89 insertions, 13 deletions
diff --git a/kernel/source/interrupts.asm b/kernel/source/interrupts.asm index babc020..e0c3cdb 100644 --- a/kernel/source/interrupts.asm +++ b/kernel/source/interrupts.asm @@ -227,14 +227,6 @@ section .bss section .text -write_keyboard_byte: - in al, 0x64 - test al, 0x02 - jnz write_keyboard_byte - mov al, dil - out 0x60, al - ret - extern on_keyboard_interrupt keyboard_isr: @@ -249,6 +241,7 @@ keyboard_isr: push rcx push rax + call wait_read_ps2 in al, 0x60 mov dil, al @@ -269,6 +262,54 @@ keyboard_isr: iretq +extern on_mouse_interrupt + +mouse_isr: + + push r11 + push r10 + push r9 + push r8 + push rsi + push rdi + push rdx + push rcx + push rax + + call wait_read_ps2 + in al, 0x60 + mov dil, al + + call on_mouse_interrupt + + mov al, 0x20 + out 0x20, al + out 0xa0, al + + pop rax + pop rcx + pop rdx + pop rdi + pop rsi + pop r8 + pop r9 + pop r10 + pop r11 + + iretq + +wait_send_ps2: + in al, 0x64 + test al, 0x02 + jnz wait_send_ps2 + ret + +wait_read_ps2: + in al, 0x64 + test al, 0x01 + jz wait_send_ps2 + ret + load_gdt_and_idt: ;fill exception entries in idt @@ -294,7 +335,7 @@ load_gdt_and_idt: out 0x21, al mov al, 0x01 out 0x21, al - mov al, 0xfd ;mask all but irq 1 + mov al, 0xf9 ;mask all but irq 1 and 2 out 0x21, al mov al, 0x11 @@ -305,19 +346,54 @@ load_gdt_and_idt: out 0xa1, al mov al, 0x01 out 0xa1, al - mov al, 0xff ;mask all + mov al, 0xef ;mask all but irq 12 out 0xa1, al + ;register keyboard and mouse interrupts + mov rdi, 0x21 mov rsi, keyboard_isr call set_isr - ;set keyboard config + mov rdi, 0x2c + mov rsi, mouse_isr + call set_isr + + ;set ps2 config + call wait_send_ps2 mov al, 0x60 out 0x64, al - mov dil, 0x01 - call write_keyboard_byte + + call wait_send_ps2 + mov al, 0x03 + out 0x60, al + + ;set mouse defaults + + call wait_send_ps2 + mov al, 0xd4 + out 0x64, al + + call wait_send_ps2 + mov al, 0xf6 + out 0x60, al + + call wait_read_ps2 + in al, 0x60 + + ;enable mouse reporting + + call wait_send_ps2 + mov al, 0xd4 + out 0x64, al + + call wait_send_ps2 + mov al, 0xf4 + out 0x60, al + + call wait_read_ps2 + in al, 0x60 ;make tss entry in gdt |