Mercurial > lcfOS
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 | 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 global halt | |
9 halt: | |
10 cli | |
11 hlt | |
12 | |
25 | 13 ; Function to read the current instruction pointer value: |
14 global read_rip | |
15 read_rip: | |
16 pop rax | |
17 jmp rax | |
18 | |
17 | 19 global magicBochsBreak |
20 magicBochsBreak: | |
21 | 21 xchg bx, bx |
17 | 22 ret |
23 | |
14 | 24 global loadIDT |
25 loadIDT: | |
17 | 26 extern idtP |
27 ; TODO: make this pointer thing more insightfull: | |
28 ;xchg bx, bx ; For debugging with bochs | |
29 lidt [idtP] | |
14 | 30 ret |
31 | |
17 | 32 %macro pushAll 0 |
33 push rax | |
34 push rcx | |
35 push rdx | |
36 push rbx | |
37 push rbp | |
38 push rsi | |
39 push rdi | |
40 %endmacro | |
41 | |
42 %macro popAll 0 | |
43 pop rdi | |
44 pop rsi | |
45 pop rbp | |
46 pop rbx | |
47 pop rdx | |
48 pop rcx | |
49 pop rax | |
50 %endmacro | |
51 | |
14 | 52 ; Define macro with two arguments: |
53 %macro INTX 2 | |
54 global %1 | |
55 %1: | |
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 | 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 | 61 extern %2 |
62 call %2 | |
14 | 63 ; Do restoration |
17 | 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 | 67 iretq |
14 | 68 |
69 %endmacro | |
70 | |
71 ; Exception handlers: | |
72 INTX INTDEF, INTDEF_handler | |
73 INTX INT0, INT0handler | |
74 INTX INT1, INT1handler | |
75 INTX INT2, INT2handler | |
76 INTX INT3, INT3handler | |
77 INTX INT4, INT4handler | |
78 INTX INT5, INT5handler | |
79 INTX INT6, INT6handler | |
80 INTX INT7, INT7handler | |
81 INTX INT8, INT8handler | |
82 INTX INT9, INT9handler | |
83 INTX INT10, INT10handler | |
84 INTX INT11, INT11handler | |
85 INTX INT12, INT12handler | |
86 INTX INT13, INT13handler | |
87 INTX INT14, INT14handler | |
88 INTX INT15, INT15handler | |
89 INTX INT16, INT16handler | |
90 INTX INT17, INT17handler | |
91 INTX INT18, INT18handler | |
92 INTX INT19, INT19handler | |
93 | |
94 INTX INT32, INT32handler | |
95 INTX INT33, INT33handler | |
96 INTX INT34, INT34handler | |
97 |