174 lines
2.6 KiB
ArmAsm

// vi: ft=asm :
.macro EXC_SAVE_STATE
push %edi
push %esi
push %ebp
push %ebx
push %edx
push %ecx
push %eax
.endm
.macro EXC_RESTORE_STATE
pop %eax
pop %ecx
pop %edx
pop %ebx
pop %ebp
pop %esi
pop %edi
.endm
.macro ISR_NERR, n
__i686_exc_\n:
cli
pushl $0
pushl $\n
jmp __i686_exc_common
.endm
.macro ISR_YERR, n
__i686_exc_\n:
cli
pushl $\n
jmp __i686_exc_common
.endm
.global __i686_dummy_vector
.global __i686_syscall_vector
.section .text
__i686_exc_common:
// %esp + 0: error number
// %esp + 4: error code (or 0)
// %esp + 8: %eip
// %esp + 12: %cs
// %esp + 16: %eflags
// If %cs != 0x08
// %esp + 20: %esp
// %esp + 24: %ss
EXC_SAVE_STATE
mov %esp, %ebp
push %ebp
call {exception_handler}
mov %ebp, %esp
EXC_RESTORE_STATE
// Remove error code/number from the stack
add $8, %esp
iret
__i686_dummy_vector:
jmp .
__i686_syscall_vector:
// %esp + 0: %eip
// %esp + 4: %cs
// %esp + 8: %eflags
// %esp + 12: %esp
// %esp + 16: %ss
pushl %ebp
pushl %edi
pushl %esi
pushl %edx
pushl %ecx
pushl %ebx
pushl %eax
mov %esp, %ebp
push %ebp
call {syscall_handler}
mov %ebp, %esp
pop %eax
pop %ebx
pop %ecx
pop %edx
pop %esi
pop %edi
pop %ebp
iret
ISR_NERR 0
ISR_NERR 1
ISR_NERR 2
ISR_NERR 3
ISR_NERR 4
ISR_NERR 5
ISR_NERR 6
ISR_NERR 7
ISR_YERR 8
ISR_NERR 9
ISR_YERR 10
ISR_YERR 11
ISR_YERR 12
ISR_YERR 13
ISR_YERR 14
ISR_NERR 15
ISR_NERR 16
ISR_YERR 17
ISR_NERR 18
ISR_NERR 19
ISR_NERR 20
ISR_NERR 21
ISR_NERR 22
ISR_NERR 23
ISR_NERR 24
ISR_NERR 25
ISR_NERR 26
ISR_NERR 27
ISR_NERR 28
ISR_NERR 29
ISR_YERR 30
ISR_NERR 31
.section .rodata
.global __i686_exception_vectors
.p2align 4
__i686_exception_vectors:
.long __i686_exc_0
.long __i686_exc_1
.long __i686_exc_2
.long __i686_exc_3
.long __i686_exc_4
.long __i686_exc_5
.long __i686_exc_6
.long __i686_exc_7
.long __i686_exc_8
.long __i686_exc_9
.long __i686_exc_10
.long __i686_exc_11
.long __i686_exc_12
.long __i686_exc_13
.long __i686_exc_14
.long __i686_exc_15
.long __i686_exc_16
.long __i686_exc_17
.long __i686_exc_18
.long __i686_exc_19
.long __i686_exc_20
.long __i686_exc_21
.long __i686_exc_22
.long __i686_exc_23
.long __i686_exc_24
.long __i686_exc_25
.long __i686_exc_26
.long __i686_exc_27
.long __i686_exc_28
.long __i686_exc_29
.long __i686_exc_30
.long __i686_exc_31
.section .text