summaryrefslogtreecommitdiff
path: root/kernel/source/interrupts.asm
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-05-19 13:27:11 -0400
committerBenji Dial <benji@benjidial.net>2024-05-19 13:27:11 -0400
commit649ff9636fe7289749c91141bbf32b2dcbe6dde4 (patch)
tree5da6e8ddfd449b012d8936040e292fa4de534cc0 /kernel/source/interrupts.asm
parentf8ff95f19289a88706935abebd71e317355641d4 (diff)
downloadhilbert-os-649ff9636fe7289749c91141bbf32b2dcbe6dde4.tar.gz
add serial logging for exceptions, fix virtualbox issue
Diffstat (limited to 'kernel/source/interrupts.asm')
-rw-r--r--kernel/source/interrupts.asm80
1 files changed, 44 insertions, 36 deletions
diff --git a/kernel/source/interrupts.asm b/kernel/source/interrupts.asm
index e0c3cdb..e4912ee 100644
--- a/kernel/source/interrupts.asm
+++ b/kernel/source/interrupts.asm
@@ -227,19 +227,51 @@ section .bss
section .text
+isr_start:
+
+ push rcx
+ mov rcx, qword [rsp + 8]
+ mov qword [rsp + 8], rax
+ push rdx
+ push rdi
+ push rsi
+ push r8
+ push r9
+ push r10
+ push r11
+ push rcx
+
+ ;this is a complete hack but it works
+ mov rdi, qword [rsp + 10 * 8 + 4 * 8]
+ cmp rdi, 0x38
+ je .fix_ss
+ ret
+
+.fix_ss:
+ mov qword [rsp + 10 * 8 + 4 * 8], 0x3b
+ ret
+
+isr_end:
+
+ pop rcx
+ pop r11
+ pop r10
+ pop r9
+ pop r8
+ pop rsi
+ pop rdi
+ pop rdx
+ mov rax, qword [rsp + 8]
+ mov qword [rsp + 8], rcx
+ pop rcx
+
+ 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
+ call isr_start
call wait_read_ps2
in al, 0x60
@@ -250,15 +282,7 @@ keyboard_isr:
mov al, 0x20
out 0x20, al
- pop rax
- pop rcx
- pop rdx
- pop rdi
- pop rsi
- pop r8
- pop r9
- pop r10
- pop r11
+ call isr_end
iretq
@@ -266,15 +290,7 @@ 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 isr_start
call wait_read_ps2
in al, 0x60
@@ -286,15 +302,7 @@ mouse_isr:
out 0x20, al
out 0xa0, al
- pop rax
- pop rcx
- pop rdx
- pop rdi
- pop rsi
- pop r8
- pop r9
- pop r10
- pop r11
+ call isr_end
iretq