diff options
Diffstat (limited to 'kernel/interrupts.asm')
-rw-r--r-- | kernel/interrupts.asm | 96 |
1 files changed, 91 insertions, 5 deletions
diff --git a/kernel/interrupts.asm b/kernel/interrupts.asm index 4827cfd..c096ddb 100644 --- a/kernel/interrupts.asm +++ b/kernel/interrupts.asm @@ -220,27 +220,111 @@ gdt: .tss: dq 0x0000e90000000067 dq 0;tss is 2 qwords wide - dq 0x00209b0000000000 - dq 0x00009b0000000000 - dq 0x0000fb0000000000 - dq 0x0020fb0000000000 + dq 0x002f98000000ffff + dq 0x002f92000000ffff + dq 0x002ff2000000ffff + dq 0x002ff8000000ffff + +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: + + push r11 + push r10 + push r9 + push r8 + push rsi + push rdi + push rdx + push rcx + push rax + + in al, 0x60 + mov dil, al + + call on_keyboard_interrupt + + mov al, 0x20 + out 0x20, al + + pop rax + pop rcx + pop rdx + pop rdi + pop rsi + pop r8 + pop r9 + pop r10 + pop r11 + + iretq + load_gdt_and_idt: + ;fill exception entries in idt + mov rcx, 16 .loop: mov rdi, rcx dec rdi - mov sil, 0 + mov sil, 1 mov rdx, qword [exception_isrs + rdi * 8] call set_isr loop .loop + ;reset pic and map irqs to 0x20 - 0x2f + + mov al, 0x11 + out 0x20, al + mov al, 0x20 + out 0x21, al + mov al, 0x04 + out 0x21, al + mov al, 0x01 + out 0x21, al + mov al, 0xfd ;mask all but irq 1 + out 0x21, al + + mov al, 0x11 + out 0xa0, al + mov al, 0x28 + out 0xa1, al + mov al, 0x02 + out 0xa1, al + mov al, 0x01 + out 0xa1, al + mov al, 0xff ;mask all + out 0xa1, al + + mov rdi, 0x21 + xor sil, sil + mov rdx, keyboard_isr + call set_isr + + ;set keyboard config + + mov al, 0x60 + out 0x64, al + mov dil, 0x01 + call write_keyboard_byte + + ;make tss entry in gdt + mov rax, tss mov word [gdt.tss + 2], ax @@ -250,6 +334,8 @@ load_gdt_and_idt: shr rax, 16 mov dword [gdt.tss + 8], eax + ;load gdt, idt, tss + lgdt [gdtr] lidt [idtr] mov ax, 0x18 |