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

Changed interrupt handler
author windel
date Tue, 10 Jan 2012 20:40:35 +0100
parents 7e3bdcb391dc
children 3a6a9b929db0
line wrap: on
line diff
--- a/cos/kernel/asmcode.asm	Thu Dec 29 23:51:35 2011 +0100
+++ b/cos/kernel/asmcode.asm	Tue Jan 10 20:40:35 2012 +0100
@@ -18,7 +18,27 @@
   lidt [idtP]
   ret
 
-%macro pushAll 0
+; ISR related assembler wrappers:
+
+%macro ISR_NOERRCODE 1
+global INT%1
+INT%1:
+  cli
+  push strict qword 0 ; push dummy error code
+  push strict qword %1 ; push interrupt number
+  jmp isr_common_stub
+%endmacro
+
+%macro ISR_ERRCODE 1
+global INT%1
+INT%1:
+  cli
+  push strict qword %1 ; push interrupt number
+  jmp isr_common_stub
+%endmacro
+
+isr_common_stub:
+  ; Do some saving:
   push rax
   push rcx
   push rdx
@@ -26,9 +46,13 @@
   push rbp
   push rsi
   push rdi
-%endmacro
+
+  ; AMD64 calling convention, first parameter is in rdi:
+  mov rdi, rsp ; Load stack pointer into rdi to indicate where the registers on the stack are (so that we can change them!)
 
-%macro popAll 0
+  extern isr_handler
+  call isr_handler
+
   pop rdi
   pop rsi
   pop rbp
@@ -36,51 +60,38 @@
   pop rdx
   pop rcx
   pop rax
-%endmacro
 
-; Define macro with two arguments:
-%macro INTX 2
-global %1
-%1:
- ; Do some saving:
- cli
- pushAll
- ;xchg bx,bx
-
- extern %2
- call %2
- ; Do restoration
- popAll
- ;xchg bx, bx
- sti
- iretq
-
-%endmacro
+  add rsp, 16 ; cleanup error code and isr number
+  sti
+  iretq
 
 ; Exception handlers:
-INTX INTDEF, INTDEF_handler
-INTX INT0, INT0handler
-INTX INT1, INT1handler
-INTX INT2, INT2handler
-INTX INT3, INT3handler
-INTX INT4, INT4handler
-INTX INT5, INT5handler
-INTX INT6, INT6handler
-INTX INT7, INT7handler
-INTX INT8, INT8handler
-INTX INT9, INT9handler
-INTX INT10, INT10handler
-INTX INT11, INT11handler
-INTX INT12, INT12handler
-INTX INT13, INT13handler
-INTX INT14, INT14handler
-INTX INT15, INT15handler
-INTX INT16, INT16handler
-INTX INT17, INT17handler
-INTX INT18, INT18handler
-INTX INT19, INT19handler
+ISR_NOERRCODE 0
+ISR_NOERRCODE 1
+ISR_NOERRCODE 2
+ISR_NOERRCODE 3
+ISR_NOERRCODE 4
+ISR_NOERRCODE 5
+ISR_NOERRCODE 6
+ISR_NOERRCODE 7
+ISR_ERRCODE   8
+ISR_NOERRCODE 9
+ISR_ERRCODE 10
+ISR_ERRCODE 11
+ISR_ERRCODE 12
+ISR_ERRCODE 13
+ISR_ERRCODE 14
+; 15 is reserved
+ISR_NOERRCODE 16
+ISR_ERRCODE 17
+ISR_NOERRCODE 18
+ISR_NOERRCODE 19
 
-INTX INT32, INT32handler
-INTX INT33, INT33handler
-INTX INT34, INT34handler
+ISR_NOERRCODE 32
+ISR_NOERRCODE 33
+ISR_NOERRCODE 34
 
+; default handler:
+ISR_NOERRCODE 255
+
+