view 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 source

; The default interrupt handlers.
; from 20 - 31 are reserved vectors.
; below are the custom ones!

section .text
align 4

; Port helpers:
;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

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:
 pushAll
 extern %2
 call %2
 ; Do restoration
 popAll
 iretq

%endmacro

; 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

INTX INT32, INT32handler
INTX INT33, INT33handler
INTX INT34, INT34handler