/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas             */
/*                                                                             */

.section .text

.macro  exception num
.global wrapper_exception\num
wrapper_exception\num:
pushl %ss
pushl %esp
pushf 
pushl %cs
pushl $\num
jmp exception_suite
.endm

.macro  semidumpcpu
cli
pushl %ds
pushl %es
pushl %fs
pushl %gs
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
pushl %ebp
mov %cr0, %eax 
pushl %eax
mov %cr2, %eax 
pushl %eax
mov %cr3, %eax 
pushl %eax
mov %cr4, %eax 
pushl %eax 
mov %dr0, %eax 
pushl %eax
mov %dr1, %eax 
pushl %eax
mov %dr2, %eax 
pushl %eax
mov %dr3, %eax 
pushl %eax
mov %dr6, %eax 
pushl %eax
mov %dr7, %eax 
pushl %eax
mov $0xC0000080, %ecx 
rdmsr 
pushl %edx 
pushl %eax
pushl %esp
.endm

exception 0
exception 1
exception 2
exception 3
exception 4
exception 5
exception 6
exception 7
exception 8
exception 9
exception 10
exception 11
exception 12
exception 13
exception 14
exception 15
exception 16
exception 17
exception 18

exception_suite:
semidumpcpu
call exception_handler

.global wrapper_sysenter
wrapper_sysenter:
pushl %ss
pushl %esp
pushf 
pushl %cs
pushl $0x00
semidumpcpu
call sysenter_handler

.global wrapper_interruption20
wrapper_interruption20:
pushl %ss
pushl %esp
pushf 
pushl %cs
pushl $0x14
semidumpcpu
call interruption_handler

.global wrapper_interruption
wrapper_interruption:
pushl %ss
pushl %esp
pushf 
pushl %cs
pushl $0x00
semidumpcpu
call interruption_handler

.global wrapper_timer
wrapper_timer:
pushl %ss
pushl %esp
pushf 
pushl %cs
pushl $0x00
semidumpcpu
call timer_handler
