aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/idt.s
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2017-03-06 02:52:05 +0100
committerRobin Krahl <robin.krahl@ireas.org>2017-03-06 02:52:05 +0100
commit05b9ca73793047e795e46a2ae13db02c34b8a7c3 (patch)
tree5ab672db87c57cbe01662547e7733e71aa748743 /arch/x86_64/idt.s
parent28301499381cb541eec4eb99f61e3d1a193c5a2d (diff)
downloadgarmos-05b9ca73793047e795e46a2ae13db02c34b8a7c3.tar.gz
garmos-05b9ca73793047e795e46a2ae13db02c34b8a7c3.tar.bz2
idt: add interruption handling
The Interruption Descriptor Table (IDT) is implemented in idt.{c,h} as part of the core, but the setup and activation of the IDT and the registration of specific interruption request handlers is part of arch.{c,h}. The request handlers are implemented in idt.s and delegate to kernel_handle_interrupt.
Diffstat (limited to 'arch/x86_64/idt.s')
-rw-r--r--arch/x86_64/idt.s47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/x86_64/idt.s b/arch/x86_64/idt.s
new file mode 100644
index 0000000..ead5b20
--- /dev/null
+++ b/arch/x86_64/idt.s
@@ -0,0 +1,47 @@
+.set IRQ_BASE, 0x20
+
+.section .text
+.extern handle_interrput
+.global irqign
+
+.macro gen_irq_handler num
+.global irqhdl\num\()
+irqhdl\num\():
+movb $\num + IRQ_BASE, (intrptno)
+jmp _bot
+.endm
+
+gen_irq_handler 0x00
+gen_irq_handler 0x01
+
+_bot:
+/* store current data */
+push %ebp
+push %edi
+push %esi
+push %edx
+push %ecx
+push %ebx
+push %eax
+
+/* call interrupt handler */
+push %esp
+push (intrptno)
+call kernel_handle_interrupt
+movl %eax, %esp
+
+/* restore previous data */
+pop %eax
+pop %ebx
+pop %ecx
+pop %edx
+pop %esi
+pop %edi
+pop %ebp
+
+irqign:
+/* continue */
+iret
+
+.data
+intrptno: .byte 0