annotate cos/kernel/asmcode.asm @ 17:f3e3e0e9c4bc

First attempt IDT loader 64 bits. INT13 occurs
author windel
date Sat, 19 Nov 2011 20:01:28 +0100
parents a58904747019
children 6129643f5c34
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 ; Port helpers:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
9 ;global outb
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
10 ;outb:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
11 ; mov eax, [esp + 8]
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
12 ; mov edx, [esp + 4]
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
13 ; out dx, al
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
14 ; ret
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
15
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
16 ;global inb
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
17 ;inb:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
18 ; xor eax, eax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
19 ; mov edx, [esp + 4]
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
20 ; in al, dx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
21 ; ret
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
22
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
23 global halt
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
24 halt:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
25 cli
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
26 hlt
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
27
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
28 global magicBochsBreak
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
29 magicBochsBreak:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
30 xchg bx,bx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
31 ret
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
32
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
33 global loadIDT
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
34 loadIDT:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
35 extern idtP
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
36 ; TODO: make this pointer thing more insightfull:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
37 ;xchg bx, bx ; For debugging with bochs
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
38 lidt [idtP]
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
39 ret
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
40
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
41 %macro pushAll 0
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
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
49 %endmacro
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
50
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
51 %macro popAll 0
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
52 pop rdi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
53 pop rsi
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
54 pop rbp
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
55 pop rbx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
56 pop rdx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
57 pop rcx
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58 pop rax
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
59 %endmacro
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
60
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
61 ; Define macro with two arguments:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
62 %macro INTX 2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
63 global %1
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
64 %1:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
65 ; Do some saving:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
66 pushAll
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
67 extern %2
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
68 call %2
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
69 ; Do restoration
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
70 popAll
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
71 iretq
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
72
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
73 %endmacro
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
74
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
75 ; Exception handlers:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
76 INTX INTDEF, INTDEF_handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
77 INTX INT0, INT0handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
78 INTX INT1, INT1handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
79 INTX INT2, INT2handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
80 INTX INT3, INT3handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
81 INTX INT4, INT4handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
82 INTX INT5, INT5handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
83 INTX INT6, INT6handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
84 INTX INT7, INT7handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
85 INTX INT8, INT8handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
86 INTX INT9, INT9handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
87 INTX INT10, INT10handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
88 INTX INT11, INT11handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
89 INTX INT12, INT12handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
90 INTX INT13, INT13handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
91 INTX INT14, INT14handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
92 INTX INT15, INT15handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
93 INTX INT16, INT16handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
94 INTX INT17, INT17handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
95 INTX INT18, INT18handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
96 INTX INT19, INT19handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
97
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
98 INTX INT32, INT32handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
99 INTX INT33, INT33handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
100 INTX INT34, INT34handler
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
101