Files
towos/kernel/arch/x86_64/isr.S
T

121 lines
1.6 KiB
ArmAsm

.altmacro
.section .text
.code64
.extern interrupt_handler
common_isr_stub:
push %rax
push %rbx
push %rcx
push %rdx
push %rsi
push %rdi
push %rbp
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
cld
mov %rsp, %rdi
mov %rsp, %r12
and $-16, %rsp
call interrupt_handler
mov %r12, %rsp
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rbp
pop %rdi
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %rax
add $16, %rsp
iretq
.macro isr_err_stub i=1
isr_stub_\i:
pushq $\i
jmp common_isr_stub
.endm
.macro isr_nerr_stub i
isr_stub_\i:
pushq $0
pushq $\i
jmp common_isr_stub
.endm
# From https://wiki.osdev.org/Interrupts_Tutorial
isr_nerr_stub 0
isr_nerr_stub 1
isr_nerr_stub 2
isr_nerr_stub 3
isr_nerr_stub 4
isr_nerr_stub 5
isr_nerr_stub 6
isr_nerr_stub 7
isr_err_stub 8
isr_nerr_stub 9
isr_err_stub 10
isr_err_stub 11
isr_err_stub 12
isr_err_stub 13
isr_err_stub 14
isr_nerr_stub 15
isr_nerr_stub 16
isr_err_stub 17
isr_nerr_stub 18
isr_nerr_stub 19
isr_nerr_stub 20
isr_err_stub 21
isr_nerr_stub 22
isr_nerr_stub 23
isr_nerr_stub 24
isr_nerr_stub 25
isr_nerr_stub 26
isr_nerr_stub 27
isr_nerr_stub 28
isr_err_stub 29
isr_err_stub 30
isr_nerr_stub 31
.set i, 32
.rept 256 - 32
isr_nerr_stub %i
.set i, i+1
.endr
.macro isr_label i
.quad isr_stub_\i
.endm
.global isrStubTable
isrStubTable:
.set i, 0
.rept 256
isr_label %i
.set i, i+1
.endr