old-DasOS/prototypes/base/interrupts.S
2016-05-05 17:06:11 +02:00

56 lines
No EOL
789 B
ArmAsm

.macro isr_stub nr
.global isr_\nr
isr_\nr:
pushl $0
pushl $\nr
jmp isr_handler
.endm
.macro isr_stub_with_err nr
.global isr_\nr
isr_\nr:
pushl $\nr
jmp isr_handler
.endm
#define ISR(num) isr_stub num
#define ISR_ERR(num) isr_stub_with_err num
#include "interrupt-list.inc"
#undef ISR
#undef ISR_ERR
#if !defined(IDT_DISPATCH)
#error "IDT_DISPATCH must be defined!"
#endif
.extern IDT_DISPATCH
isr_handler:
// Store CPU State
push %ebp
push %edi
push %esi
push %edx
push %ecx
push %ebx
push %eax
// Calls interrupt handler with CPU state as argument
push %esp
call IDT_DISPATCH
add $4, %esp
// Restore CPU State
pop %eax
pop %ebx
pop %ecx
pop %edx
pop %esi
pop %edi
pop %ebp
// Remove error code and interrupt number
add $8, %esp
iret