caos-with-snake/cpu/vectors.S

56 lines
811 B
ArmAsm
Raw Normal View History

2022-12-14 09:00:32 +03:00
.global trapret
2022-11-20 18:59:53 +03:00
alltraps:
# Build trap frame.
pushl %ds
pushl %es
pushl %fs
pushl %gs
pushal
2022-11-21 00:05:59 +03:00
//mov $10, %ax
//mov %ax, %ds
2022-11-20 18:59:53 +03:00
# Call trap(tf), where tf=%esp
pushl %esp
call trap
add $4, %esp
2022-12-14 09:00:32 +03:00
// execution falls through to trapret
2022-11-20 18:59:53 +03:00
2022-12-14 09:00:32 +03:00
trapret:
2022-11-20 18:59:53 +03:00
popal
popl %gs
popl %fs
popl %es
popl %ds
addl $0x8, %esp # trapno and errcode
iret
.macro handler i
vector\i :
.if (!(\i == 8 || (\i >= 10 && \i <= 14) || \i == 17))
pushl $0
.endif
pushl $\i
jmp alltraps
.endm
.altmacro
.macro irq_insertX number
.section .text
handler \number
2022-11-20 23:40:45 +03:00
.section .rodata
2022-11-20 18:59:53 +03:00
.long vector\number
.endm
2022-11-20 23:40:45 +03:00
.section .rodata
2022-11-20 18:59:53 +03:00
.global default_handlers
default_handlers:
.set i,0
2022-11-20 22:17:13 +03:00
.rept 256
2022-11-20 18:59:53 +03:00
irq_insertX %i
.set i, i+1
.endr