summaryrefslogtreecommitdiff
path: root/Kernel/Arch/i386/Interrupts.h
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Arch/i386/Interrupts.h')
-rw-r--r--Kernel/Arch/i386/Interrupts.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/Kernel/Arch/i386/Interrupts.h b/Kernel/Arch/i386/Interrupts.h
new file mode 100644
index 0000000000..b45483b1b3
--- /dev/null
+++ b/Kernel/Arch/i386/Interrupts.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <AK/Types.h>
+
+extern "C" void interrupt_common_asm_entry();
+
+#define GENERATE_GENERIC_INTERRUPT_HANDLER_ASM_ENTRY(interrupt_vector, isr_number) \
+ extern "C" void interrupt_##interrupt_vector##_asm_entry(); \
+ asm(".globl interrupt_" #interrupt_vector "_asm_entry\n" \
+ "interrupt_" #interrupt_vector "_asm_entry:\n" \
+ " pushw $" #isr_number "\n" \
+ " pushw $0\n" \
+ " jmp interrupt_common_asm_entry\n");
+
+asm(
+ ".globl interrupt_common_asm_entry\n"
+ "interrupt_common_asm_entry: \n"
+ " pusha\n"
+ " pushl %ds\n"
+ " pushl %es\n"
+ " pushl %fs\n"
+ " pushl %gs\n"
+ " pushl %ss\n"
+ " mov $0x10, %ax\n"
+ " mov %ax, %ds\n"
+ " mov %ax, %es\n"
+ " cld\n"
+ " call handle_interrupt\n"
+ " add $0x4, %esp\n" // "popl %ss"
+ " popl %gs\n"
+ " popl %fs\n"
+ " popl %es\n"
+ " popl %ds\n"
+ " popa\n"
+ " add $0x4, %esp\n"
+ " iret\n");