132 lines
1.9 KiB
ArmAsm
132 lines
1.9 KiB
ArmAsm
.code64
|
|
|
|
.extern printk
|
|
.extern apic_ack
|
|
|
|
.macro CALL_PRINTK msg
|
|
mov \msg, %rdi
|
|
mov $0, %eax # Required for variadic functions
|
|
mov $printk,%rcx
|
|
call *(%rcx)
|
|
.endm
|
|
|
|
.macro SAVE_REGS
|
|
push %r8
|
|
push %r9
|
|
push %r10
|
|
push %r11
|
|
push %r12
|
|
push %r13
|
|
push %r14
|
|
push %r15
|
|
push %rax
|
|
push %rbx
|
|
push %rcx
|
|
push %rdx
|
|
push %rbp
|
|
push %rsi
|
|
push %rdi
|
|
xor %rax,%rax # Because I am picky
|
|
mov %gs, %rax
|
|
push %rax
|
|
mov %es, %rax
|
|
push %rax
|
|
mov %fs, %rax
|
|
push %rax
|
|
mov %ds, %rax
|
|
push %rax
|
|
mov $0x10, %ax
|
|
mov %ax, %ds
|
|
mov 80(%rsp), %rax
|
|
.endm
|
|
|
|
.macro RESTORE_REGS
|
|
pop %rax
|
|
mov %ax, %ds
|
|
pop %rax
|
|
mov %ax, %fs
|
|
pop %rax
|
|
mov %ax, %es
|
|
pop %rax
|
|
mov %ax, %gs
|
|
pop %rdi
|
|
pop %rsi
|
|
pop %rbp
|
|
pop %rdx
|
|
pop %rcx
|
|
pop %rbx
|
|
pop %rax
|
|
pop %r15
|
|
pop %r14
|
|
pop %r13
|
|
pop %r12
|
|
pop %r11
|
|
pop %r10
|
|
pop %r9
|
|
pop %r8
|
|
.endm
|
|
|
|
.globl INT_DEFAULT
|
|
INT_DEFAULT:
|
|
SAVE_REGS
|
|
RESTORE_REGS
|
|
iretq
|
|
|
|
.globl INT_0
|
|
INT_0:
|
|
CALL_PRINTK $MSG_INT_0
|
|
INT_0_INFINITE:
|
|
jmp INT_0_INFINITE
|
|
iretq
|
|
|
|
.globl INT_10
|
|
INT_10:
|
|
CALL_PRINTK $MSG_INT_10
|
|
INT_10_INFINITE:
|
|
jmp INT_10_INFINITE
|
|
iretq
|
|
|
|
.globl INT_14
|
|
INT_14:
|
|
pop %rsi
|
|
CALL_PRINTK $MSG_INT_14
|
|
INT_14_INFINITE:
|
|
jmp INT_14_INFINITE
|
|
iretq
|
|
|
|
.globl INT_KBD
|
|
INT_KBD:
|
|
SAVE_REGS
|
|
CALL_PRINTK $MSG_INT_KBD
|
|
call apic_ack
|
|
RESTORE_REGS
|
|
iretq
|
|
|
|
.globl INT_CLK
|
|
.extern clock
|
|
INT_CLK:
|
|
SAVE_REGS
|
|
call clock
|
|
call apic_ack
|
|
RESTORE_REGS
|
|
iretq
|
|
|
|
.globl INT_SYSCALL
|
|
.extern syscall
|
|
INT_SYSCALL:
|
|
SAVE_REGS
|
|
call syscall
|
|
RESTORE_REGS
|
|
iretq
|
|
|
|
|
|
MSG_INT_0:
|
|
.asciz "Zero Division error!"
|
|
MSG_INT_10:
|
|
.asciz "Invalid TSS!"
|
|
MSG_INT_14:
|
|
.asciz "Page fault: error %x !"
|
|
MSG_INT_KBD:
|
|
.asciz "Key press!"
|
|
MSG:
|
|
.asciz "Called :)\n"
|