14
|
1 ; The default interrupt handlers.
|
|
2 ; from 20 - 31 are reserved vectors.
|
|
3 ; below are the custom ones!
|
|
4
|
|
5 section .text
|
|
6 align 4
|
|
7
|
|
8 ; Port helpers:
|
17
|
9 ;global outb
|
|
10 ;outb:
|
|
11 ; mov eax, [esp + 8]
|
|
12 ; mov edx, [esp + 4]
|
|
13 ; out dx, al
|
|
14 ; ret
|
14
|
15
|
17
|
16 ;global inb
|
|
17 ;inb:
|
|
18 ; xor eax, eax
|
|
19 ; mov edx, [esp + 4]
|
|
20 ; in al, dx
|
|
21 ; ret
|
14
|
22
|
|
23 global halt
|
|
24 halt:
|
|
25 cli
|
|
26 hlt
|
|
27
|
17
|
28 global magicBochsBreak
|
|
29 magicBochsBreak:
|
|
30 xchg bx,bx
|
|
31 ret
|
|
32
|
14
|
33 global loadIDT
|
|
34 loadIDT:
|
17
|
35 extern idtP
|
|
36 ; TODO: make this pointer thing more insightfull:
|
|
37 ;xchg bx, bx ; For debugging with bochs
|
|
38 lidt [idtP]
|
14
|
39 ret
|
|
40
|
17
|
41 %macro pushAll 0
|
|
42 push rax
|
|
43 push rcx
|
|
44 push rdx
|
|
45 push rbx
|
|
46 push rbp
|
|
47 push rsi
|
|
48 push rdi
|
|
49 %endmacro
|
|
50
|
|
51 %macro popAll 0
|
|
52 pop rdi
|
|
53 pop rsi
|
|
54 pop rbp
|
|
55 pop rbx
|
|
56 pop rdx
|
|
57 pop rcx
|
|
58 pop rax
|
|
59 %endmacro
|
|
60
|
14
|
61 ; Define macro with two arguments:
|
|
62 %macro INTX 2
|
|
63 global %1
|
|
64 %1:
|
|
65 ; Do some saving:
|
17
|
66 pushAll
|
|
67 extern %2
|
|
68 call %2
|
14
|
69 ; Do restoration
|
17
|
70 popAll
|
|
71 iretq
|
14
|
72
|
|
73 %endmacro
|
|
74
|
|
75 ; Exception handlers:
|
|
76 INTX INTDEF, INTDEF_handler
|
|
77 INTX INT0, INT0handler
|
|
78 INTX INT1, INT1handler
|
|
79 INTX INT2, INT2handler
|
|
80 INTX INT3, INT3handler
|
|
81 INTX INT4, INT4handler
|
|
82 INTX INT5, INT5handler
|
|
83 INTX INT6, INT6handler
|
|
84 INTX INT7, INT7handler
|
|
85 INTX INT8, INT8handler
|
|
86 INTX INT9, INT9handler
|
|
87 INTX INT10, INT10handler
|
|
88 INTX INT11, INT11handler
|
|
89 INTX INT12, INT12handler
|
|
90 INTX INT13, INT13handler
|
|
91 INTX INT14, INT14handler
|
|
92 INTX INT15, INT15handler
|
|
93 INTX INT16, INT16handler
|
|
94 INTX INT17, INT17handler
|
|
95 INTX INT18, INT18handler
|
|
96 INTX INT19, INT19handler
|
|
97
|
|
98 INTX INT32, INT32handler
|
|
99 INTX INT33, INT33handler
|
|
100 INTX INT34, INT34handler
|
|
101
|