Mercurial > lcfOS
comparison cos/kernel/asmcode.asm @ 31:88590c42320f
Changed interrupt handler
author | windel |
---|---|
date | Tue, 10 Jan 2012 20:40:35 +0100 |
parents | 7e3bdcb391dc |
children | 3a6a9b929db0 |
comparison
equal
deleted
inserted
replaced
30:0148f55bfe24 | 31:88590c42320f |
---|---|
16 extern idtP | 16 extern idtP |
17 ; TODO: make this pointer thing more insightfull: | 17 ; TODO: make this pointer thing more insightfull: |
18 lidt [idtP] | 18 lidt [idtP] |
19 ret | 19 ret |
20 | 20 |
21 %macro pushAll 0 | 21 ; ISR related assembler wrappers: |
22 | |
23 %macro ISR_NOERRCODE 1 | |
24 global INT%1 | |
25 INT%1: | |
26 cli | |
27 push strict qword 0 ; push dummy error code | |
28 push strict qword %1 ; push interrupt number | |
29 jmp isr_common_stub | |
30 %endmacro | |
31 | |
32 %macro ISR_ERRCODE 1 | |
33 global INT%1 | |
34 INT%1: | |
35 cli | |
36 push strict qword %1 ; push interrupt number | |
37 jmp isr_common_stub | |
38 %endmacro | |
39 | |
40 isr_common_stub: | |
41 ; Do some saving: | |
22 push rax | 42 push rax |
23 push rcx | 43 push rcx |
24 push rdx | 44 push rdx |
25 push rbx | 45 push rbx |
26 push rbp | 46 push rbp |
27 push rsi | 47 push rsi |
28 push rdi | 48 push rdi |
29 %endmacro | |
30 | 49 |
31 %macro popAll 0 | 50 ; AMD64 calling convention, first parameter is in rdi: |
51 mov rdi, rsp ; Load stack pointer into rdi to indicate where the registers on the stack are (so that we can change them!) | |
52 | |
53 extern isr_handler | |
54 call isr_handler | |
55 | |
32 pop rdi | 56 pop rdi |
33 pop rsi | 57 pop rsi |
34 pop rbp | 58 pop rbp |
35 pop rbx | 59 pop rbx |
36 pop rdx | 60 pop rdx |
37 pop rcx | 61 pop rcx |
38 pop rax | 62 pop rax |
39 %endmacro | |
40 | 63 |
41 ; Define macro with two arguments: | 64 add rsp, 16 ; cleanup error code and isr number |
42 %macro INTX 2 | 65 sti |
43 global %1 | 66 iretq |
44 %1: | |
45 ; Do some saving: | |
46 cli | |
47 pushAll | |
48 ;xchg bx,bx | |
49 | |
50 extern %2 | |
51 call %2 | |
52 ; Do restoration | |
53 popAll | |
54 ;xchg bx, bx | |
55 sti | |
56 iretq | |
57 | |
58 %endmacro | |
59 | 67 |
60 ; Exception handlers: | 68 ; Exception handlers: |
61 INTX INTDEF, INTDEF_handler | 69 ISR_NOERRCODE 0 |
62 INTX INT0, INT0handler | 70 ISR_NOERRCODE 1 |
63 INTX INT1, INT1handler | 71 ISR_NOERRCODE 2 |
64 INTX INT2, INT2handler | 72 ISR_NOERRCODE 3 |
65 INTX INT3, INT3handler | 73 ISR_NOERRCODE 4 |
66 INTX INT4, INT4handler | 74 ISR_NOERRCODE 5 |
67 INTX INT5, INT5handler | 75 ISR_NOERRCODE 6 |
68 INTX INT6, INT6handler | 76 ISR_NOERRCODE 7 |
69 INTX INT7, INT7handler | 77 ISR_ERRCODE 8 |
70 INTX INT8, INT8handler | 78 ISR_NOERRCODE 9 |
71 INTX INT9, INT9handler | 79 ISR_ERRCODE 10 |
72 INTX INT10, INT10handler | 80 ISR_ERRCODE 11 |
73 INTX INT11, INT11handler | 81 ISR_ERRCODE 12 |
74 INTX INT12, INT12handler | 82 ISR_ERRCODE 13 |
75 INTX INT13, INT13handler | 83 ISR_ERRCODE 14 |
76 INTX INT14, INT14handler | 84 ; 15 is reserved |
77 INTX INT15, INT15handler | 85 ISR_NOERRCODE 16 |
78 INTX INT16, INT16handler | 86 ISR_ERRCODE 17 |
79 INTX INT17, INT17handler | 87 ISR_NOERRCODE 18 |
80 INTX INT18, INT18handler | 88 ISR_NOERRCODE 19 |
81 INTX INT19, INT19handler | |
82 | 89 |
83 INTX INT32, INT32handler | 90 ISR_NOERRCODE 32 |
84 INTX INT33, INT33handler | 91 ISR_NOERRCODE 33 |
85 INTX INT34, INT34handler | 92 ISR_NOERRCODE 34 |
86 | 93 |
94 ; default handler: | |
95 ISR_NOERRCODE 255 | |
96 | |
97 |