summaryrefslogtreecommitdiff
path: root/src/arch/amd64/idt.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/amd64/idt.S')
-rw-r--r--src/arch/amd64/idt.S92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/arch/amd64/idt.S b/src/arch/amd64/idt.S
new file mode 100644
index 0000000..43f4fd2
--- /dev/null
+++ b/src/arch/amd64/idt.S
@@ -0,0 +1,92 @@
+extern idt_exception_handler
+global isr_stub_table
+
+; call the exception handler with the interrupt number
+; args: interrupt number
+%macro ISRException 1
+align 8
+isr_stub_%+%1:
+ cld
+ mov rdi, %1
+ mov rsi, 0
+ call idt_exception_handler
+ iretq
+%endmacro
+
+; call the exception handler with the interrupt number
+; these exceptions also put an error code on the stack
+; args: interrupt number
+%macro ISRExceptionCode 1
+align 8
+isr_stub_%+%1:
+ cld
+ mov rdi, %1
+ pop rsi
+ call idt_exception_handler
+ iretq
+%endmacro
+
+; do nothing
+; args: interrupt number
+%macro ISRIgnore 1
+align 8
+isr_stub_%+%1:
+ iretq
+%endmacro
+
+; isr stubs
+section .text
+bits 64
+
+ISRException 0
+ISRException 1
+ISRException 2
+ISRException 3
+ISRException 4
+ISRException 5
+ISRException 6
+ISRException 7
+ISRExceptionCode 8
+ISRException 9
+ISRExceptionCode 10
+ISRExceptionCode 11
+ISRExceptionCode 12
+ISRExceptionCode 13
+ISRExceptionCode 14
+ISRException 15
+ISRException 16
+ISRExceptionCode 17
+ISRException 18
+ISRException 19
+ISRException 20
+ISRExceptionCode 21
+ISRException 22
+ISRException 23
+ISRException 24
+ISRException 25
+ISRException 26
+ISRException 27
+ISRException 28
+ISRExceptionCode 29
+ISRExceptionCode 30
+ISRException 31
+
+%assign i 32
+
+; ignore other interrupts
+%rep 0x100 - i
+ ISRIgnore i
+ %assign i i+1
+%endrep
+
+; isr stub table
+section .rodata
+bits 64
+align 16
+
+isr_stub_table:
+%assign i 0
+%rep 256
+ dq isr_stub_%+i
+%assign i i+1
+%endrep