annotate cos/kernel/asmcode.asm @ 25:d3c4bf3720a3

Beginning of multitasking
author windel
date Tue, 27 Dec 2011 13:31:38 +0100
parents 66e9c332c845
children 47b7df514243
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
8 global halt
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
9 halt:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
10 cli
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
11 hlt
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
12
25
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
13 ; Function to read the current instruction pointer value:
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
14 global read_rip
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
15 read_rip:
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
16 pop rax
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
17 jmp rax
d3c4bf3720a3 Beginning of multitasking
windel
parents: 21
diff changeset
18
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
19 global magicBochsBreak
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
20 magicBochsBreak:
21
66e9c332c845 Forgot crucial adjustment to idt pointer
windel
parents: 18
diff changeset
21 xchg bx, bx
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
22 ret
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
23
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
24 global loadIDT
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
25 loadIDT:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
26 extern idtP
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
27 ; TODO: make this pointer thing more insightfull:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
28 ;xchg bx, bx ; For debugging with bochs
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
29 lidt [idtP]
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
30 ret
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
31
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
32 %macro pushAll 0
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
33 push rax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
34 push rcx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
35 push rdx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
36 push rbx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
37 push rbp
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
38 push rsi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
39 push rdi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
40 %endmacro
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
41
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
42 %macro popAll 0
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
43 pop rdi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
44 pop rsi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
45 pop rbp
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
46 pop rbx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
47 pop rdx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
48 pop rcx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
49 pop rax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
50 %endmacro
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
51
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
52 ; Define macro with two arguments:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
53 %macro INTX 2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
54 global %1
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
55 %1:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
56 ; Do some saving:
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
57 cli
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58 pushAll
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
59 ;xchg bx,bx
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
60
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
61 extern %2
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
62 call %2
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
63 ; Do restoration
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
64 popAll
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
65 ;xchg bx, bx
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
66 sti
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
67 iretq
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
68
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
69 %endmacro
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
70
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
71 ; Exception handlers:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
72 INTX INTDEF, INTDEF_handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
73 INTX INT0, INT0handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
74 INTX INT1, INT1handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
75 INTX INT2, INT2handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
76 INTX INT3, INT3handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
77 INTX INT4, INT4handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
78 INTX INT5, INT5handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
79 INTX INT6, INT6handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
80 INTX INT7, INT7handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
81 INTX INT8, INT8handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
82 INTX INT9, INT9handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
83 INTX INT10, INT10handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
84 INTX INT11, INT11handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
85 INTX INT12, INT12handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
86 INTX INT13, INT13handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
87 INTX INT14, INT14handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
88 INTX INT15, INT15handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
89 INTX INT16, INT16handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
90 INTX INT17, INT17handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
91 INTX INT18, INT18handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
92 INTX INT19, INT19handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
93
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
94 INTX INT32, INT32handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
95 INTX INT33, INT33handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
96 INTX INT34, INT34handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
97