diff 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
line wrap: on
line diff
--- a/cos/kernel/asmcode.asm	Fri Nov 18 14:41:53 2011 +0100
+++ b/cos/kernel/asmcode.asm	Sat Nov 19 20:01:28 2011 +0100
@@ -6,44 +6,69 @@
 align 4
 
 ; Port helpers:
-global outb
-outb:
-  mov eax, [esp + 8]
-  mov edx, [esp + 4]
-  out dx, al
-  ret
+;global outb
+;outb:
+;  mov eax, [esp + 8]
+;  mov edx, [esp + 4]
+;  out dx, al
+;  ret
 
-global inb
-inb:
-  xor eax, eax
-  mov edx, [esp + 4]
-  in al, dx
-  ret
-
-; Helper functions:
-global enableinterrupts
-enableinterrupts:
-  sti
-  ret
+;global inb
+;inb:
+;  xor eax, eax
+;  mov edx, [esp + 4]
+;  in al, dx
+;  ret
 
 global halt
 halt:
   cli
   hlt
 
+global magicBochsBreak
+magicBochsBreak:
+  xchg bx,bx
+  ret
+
 global loadIDT
 loadIDT:
+  extern idtP
+  ; TODO: make this pointer thing more insightfull:
+  ;xchg bx, bx ; For debugging with bochs
+  lidt [idtP]
   ret
 
+%macro pushAll 0
+  push rax
+  push rcx
+  push rdx
+  push rbx
+  push rbp
+  push rsi
+  push rdi
+%endmacro
+
+%macro popAll 0
+  pop rdi
+  pop rsi
+  pop rbp
+  pop rbx
+  pop rdx
+  pop rcx
+  pop rax
+%endmacro
+
 ; Define macro with two arguments:
 %macro INTX 2
 global %1
 %1:
  ; Do some saving:
-extern %2
-     call %2
+ pushAll
+ extern %2
+ call %2
  ; Do restoration
-     iret
+ popAll
+ iretq
 
 %endmacro