boucane/src/core/int.S

133 lines
1.9 KiB
ArmAsm
Raw Normal View History

2021-04-27 19:02:17 +02:00
.code64
2021-04-21 18:54:50 +02:00
.extern printk
2021-05-02 14:46:18 +02:00
.extern apic_ack
2021-04-21 18:54:50 +02:00
2021-05-02 14:46:18 +02:00
.macro CALL_PRINTK msg
2021-04-21 18:54:50 +02:00
mov \msg, %rdi
mov $0, %eax # Required for variadic functions
mov $printk,%rcx
call *(%rcx)
2021-04-21 18:54:50 +02:00
.endm
2021-05-02 14:46:18 +02:00
.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
2021-05-02 14:46:18 +02:00
push %rax
mov $0x10, %ax
mov %ax, %ds
mov 80(%rsp), %rax
2021-05-02 14:46:18 +02:00
.endm
.macro RESTORE_REGS
pop %rax
mov %ax, %ds
pop %rax
mov %ax, %fs
pop %rax
mov %ax, %es
pop %rax
mov %ax, %gs
2021-05-02 14:46:18 +02:00
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
2021-04-21 18:54:50 +02:00
.globl INT_DEFAULT
INT_DEFAULT:
2021-05-02 14:46:18 +02:00
SAVE_REGS
RESTORE_REGS
2021-04-21 18:54:50 +02:00
iretq
.globl INT_0
INT_0:
2021-05-02 14:46:18 +02:00
CALL_PRINTK $MSG_INT_0
2021-04-21 18:54:50 +02:00
INT_0_INFINITE:
jmp INT_0_INFINITE
iretq
2021-05-02 14:46:18 +02:00
.globl INT_10
INT_10:
CALL_PRINTK $MSG_INT_10
INT_10_INFINITE:
jmp INT_10_INFINITE
iretq
2021-04-21 18:54:50 +02:00
.globl INT_14
INT_14:
pop %rsi
2021-05-02 14:46:18 +02:00
CALL_PRINTK $MSG_INT_14
2021-04-21 18:54:50 +02:00
INT_14_INFINITE:
jmp INT_14_INFINITE
iretq
.globl INT_KBD
INT_KBD:
2021-05-02 14:46:18 +02:00
SAVE_REGS
CALL_PRINTK $MSG_INT_KBD
call apic_ack
RESTORE_REGS
2021-05-01 11:37:52 +02:00
iretq
.globl INT_CLK
.extern clock
INT_CLK:
2021-05-02 14:46:18 +02:00
SAVE_REGS
2021-05-01 11:37:52 +02:00
call clock
2021-05-02 14:46:18 +02:00
call apic_ack
RESTORE_REGS
iretq
.globl INT_SYSCALL
.extern syscall
INT_SYSCALL:
SAVE_REGS
call syscall
RESTORE_REGS
iretq
2021-05-02 14:46:18 +02:00
2021-04-21 18:54:50 +02:00
MSG_INT_0:
.asciz "Zero Division error!"
2021-05-02 14:46:18 +02:00
MSG_INT_10:
.asciz "Invalid TSS!"
2021-04-21 18:54:50 +02:00
MSG_INT_14:
.asciz "Page fault: error %x !"
MSG_INT_KBD:
.asciz "Key press!"
MSG:
2021-04-27 19:02:17 +02:00
.asciz "Called :)\n"