update project structures
[lunaix-os.git] / lunaix-os / kernel / asm / x86 / interrupt.S
1 #define __ASM__
2 #include <arch/x86/interrupts.h>
3
4 .macro isr_template vector, no_error_code=1
5     .global _asm_isr\vector
6     .type _asm_isr\vector, @function
7     _asm_isr\vector:
8         .if \no_error_code
9             pushl $0x0
10         .endif
11         pushl $\vector
12         jmp interrupt_wrapper
13 .endm
14
15 .section .text
16     isr_template FAULT_DIVISION_ERROR
17     isr_template FAULT_GENERAL_PROTECTION, no_error_code=0
18     isr_template FAULT_PAGE_FAULT, no_error_code=0
19
20     isr_template LUNAIX_SYS_PANIC
21
22     interrupt_wrapper:
23         pushl %esp
24         pushl %esi
25         pushl %ebp
26         pushl %edi
27         pushl %edx
28         pushl %ecx
29         pushl %ebx
30         pushl %eax
31
32         movl %esp, %eax
33         andl $0xfffffff0, %esp
34         subl $16, %esp
35         movl %eax, (%esp)
36
37         call interrupt_handler
38         popl %eax
39         movl %eax, %esp
40
41         popl %eax
42         popl %ebx
43         popl %ecx
44         popl %edx
45         popl %edi
46         popl %ebp
47         popl %esi
48         popl %esp
49
50         addl $8, %esp
51
52         iret