summaryrefslogtreecommitdiff
path: root/src/interrupt_stub.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/interrupt_stub.s')
-rw-r--r--src/interrupt_stub.s54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/interrupt_stub.s b/src/interrupt_stub.s
new file mode 100644
index 0000000..618c982
--- /dev/null
+++ b/src/interrupt_stub.s
@@ -0,0 +1,54 @@
+
+.set IRQ_BASE, 0x20
+
+.section .text
+
+.extern handle_int
+.global int_ignore
+
+
+.macro handle_exception num
+.global handle_irq\num
+handle_irq\num:
+ movb $\num, (int_number)
+ jmp int_bottom
+.endm
+
+.macro handle_irq num
+.global handle_irq\num
+handle_irq\num:
+ movb $\num + IRQ_BASE, (int_number)
+ jmp int_bottom
+.endm
+
+handle_irq 0x00
+handle_irq 0x01
+handle_exception 0x0D
+
+int_bottom:
+ pop %eax
+ push int_bottom
+ pusha
+ pushl %ds
+ pushl %es
+ pushl %fs
+ pushl %gs
+
+ pushl %esp
+ pushl %eax
+ push (int_number)
+ call handle_int
+ movl %eax, %esp // Set the stack pointer to the return value of handle_int
+
+ popl %gs
+ popl %fs
+ popl %es
+ popl %ds
+ popa
+
+int_ignore:
+
+ iret
+
+.data
+ int_number: .byte 0