course 6 - interrupts
[lunaix-os.git] / lunaix-os / arch / x86 / interrupt.S
1 .macro isr_template vector, no_error_code=1
2     .global _asm_isr\vector
3     .type _asm_isr\vector, @function
4     _asm_isr\vector:
5         .if \no_error_code
6             pushl $0x0
7         .endif
8         pushl $\vector
9         jmp interrupt_wrapper
10 .endm
11
12 .section .text
13     isr_template 0
14
15     interrupt_wrapper:
16
17         movl %esp, %eax
18         andl $0xfffffff0, %esp
19         subl $16, %esp
20         movl %eax, (%esp)
21
22         call interrupt_handler
23         pop %eax
24         movl %eax, %esp
25         addl $8, %esp
26
27         iret