-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirqhack.inc
80 lines (68 loc) · 1.8 KB
/
irqhack.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
assembler; nostackframe;
const
HANDLER_VEC: pointer = @irq_handler[HANDLER_NUM].handler;
STACK_PTR: pointer = @irq_stack[HANDLER_NUM];
asm
pushw %ds {* save registers *}
pushw %es
pushw %fs
pushw %gs
pushal
movw %cs:___v2prt0_ds_alias, %ax {* cs: override *}
movw %ax, %ds {* set up selectors *}
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movl %esp, %ecx {* old stack in ecx + dx *}
movw %ss, %dx
movl STACK_PTR, %ebx
movl (%ebx), %esp {* set up our stack *}
movw %ax, %ss
pushl %edx {* push old stack onto new *}
pushl %ecx
pushl %ebx
cld {* clear the direction flag *}
movl HANDLER_VEC, %eax
movl (%eax),%eax
call *%eax {* call the C handler *}
cli
popl %ebx {* restore the old stack *}
popl %ecx
popl %edx
movw %dx, %ss
movl %ecx, %esp
orl %eax, %eax {* check return value *}
jz .Lget_out
popal {* chain to old handler *}
popw %gs
popw %fs
popw %es
popw %ds
{$IF HANDLER_NUM=0}
ljmp %cs:_old_vector_0
{$ELSEIF HANDLER_NUM=1}
ljmp %cs:_old_vector_1
{$ELSEIF HANDLER_NUM=2}
ljmp %cs:_old_vector_2
{$ELSEIF HANDLER_NUM=3}
ljmp %cs:_old_vector_3
{$ELSEIF HANDLER_NUM=4}
ljmp %cs:_old_vector_4
{$ELSEIF HANDLER_NUM=5}
ljmp %cs:_old_vector_5
{$ELSEIF HANDLER_NUM=6}
ljmp %cs:_old_vector_6
{$ELSEIF HANDLER_NUM=7}
ljmp %cs:_old_vector_7
{$ELSE}
{$ERROR Unknown handler number.}
{$ENDIF}
.Lget_out:
popal {* iret *}
popw %gs
popw %fs
popw %es
popw %ds
sti
iret
end;