annotate cos/kernel/asmcode.asm @ 31:88590c42320f

Changed interrupt handler
author windel
date Tue, 10 Jan 2012 20:40:35 +0100
parents 7e3bdcb391dc
children 3a6a9b929db0
rev   line source
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
1 ; The default interrupt handlers.
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
2 ; from 20 - 31 are reserved vectors.
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
3 ; below are the custom ones!
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
4
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
5 section .text
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
6 align 4
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
7
25
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
8 ; Function to read the current instruction pointer value:
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
9 global read_rip
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
10 read_rip:
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
11 pop rax
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
12 jmp rax
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
13
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
14 global loadIDT
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
15 loadIDT:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
16 extern idtP
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
17 ; TODO: make this pointer thing more insightfull:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
18 lidt [idtP]
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
19 ret
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
20
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
21 ; ISR related assembler wrappers:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
22
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
23 %macro ISR_NOERRCODE 1
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
24 global INT%1
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
25 INT%1:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
26 cli
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
27 push strict qword 0 ; push dummy error code
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
28 push strict qword %1 ; push interrupt number
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
29 jmp isr_common_stub
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
30 %endmacro
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
32 %macro ISR_ERRCODE 1
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
33 global INT%1
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
34 INT%1:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
35 cli
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
36 push strict qword %1 ; push interrupt number
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
37 jmp isr_common_stub
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
38 %endmacro
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
39
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
40 isr_common_stub:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
41 ; Do some saving:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
42 push rax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
43 push rcx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
44 push rdx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
45 push rbx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
46 push rbp
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
47 push rsi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
48 push rdi
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
49
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
50 ; AMD64 calling convention, first parameter is in rdi:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
51 mov rdi, rsp ; Load stack pointer into rdi to indicate where the registers on the stack are (so that we can change them!)
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
52
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
53 extern isr_handler
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
54 call isr_handler
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
55
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
56 pop rdi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
57 pop rsi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58 pop rbp
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
59 pop rbx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
60 pop rdx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
61 pop rcx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
62 pop rax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
63
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
64 add rsp, 16 ; cleanup error code and isr number
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
65 sti
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
66 iretq
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
67
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
68 ; Exception handlers:
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
69 ISR_NOERRCODE 0
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
70 ISR_NOERRCODE 1
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
71 ISR_NOERRCODE 2
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
72 ISR_NOERRCODE 3
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
73 ISR_NOERRCODE 4
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
74 ISR_NOERRCODE 5
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
75 ISR_NOERRCODE 6
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
76 ISR_NOERRCODE 7
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
77 ISR_ERRCODE 8
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
78 ISR_NOERRCODE 9
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
79 ISR_ERRCODE 10
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
80 ISR_ERRCODE 11
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
81 ISR_ERRCODE 12
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
82 ISR_ERRCODE 13
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
83 ISR_ERRCODE 14
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
84 ; 15 is reserved
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
85 ISR_NOERRCODE 16
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
86 ISR_ERRCODE 17
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
87 ISR_NOERRCODE 18
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
88 ISR_NOERRCODE 19
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
89
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
90 ISR_NOERRCODE 32
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
91 ISR_NOERRCODE 33
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
92 ISR_NOERRCODE 34
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
93
31
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
94 ; default handler:
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
95 ISR_NOERRCODE 255
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
96
88590c42320f Changed interrupt handler
windel
parents: 29
diff changeset
97