diff cos/kernel/handlers.c @ 24:d8627924d40d

Split up in more files and reboot command
author windel
date Fri, 02 Dec 2011 14:00:02 +0100
parents 5dd47d6eebac
children dcce92b1efbc
line wrap: on
line diff
--- a/cos/kernel/handlers.c	Thu Dec 01 21:42:59 2011 +0100
+++ b/cos/kernel/handlers.c	Fri Dec 02 14:00:02 2011 +0100
@@ -1,12 +1,5 @@
 #include "kernel.h"
 
-void panic(char *msg) {
-  printf("Kernel panic: ");
-  printf(msg);
-  magicBochsBreak();
-  halt();
-}
-
 // Assembler wrapper prototypes:
 void INTDEF(void);
 void INT0(void);
@@ -35,7 +28,7 @@
 void INT34(void);
 
 // THE interrupt descriptor table:
-IDT_entry *idt = (IDT_entry*)0x0;
+IDT_entry *idt = (IDT_entry*)0x5000;
 volatile idtPointer idtP;
 
 void setIDTentry(int num, void (*handler)(), uint16_t selector, uint8_t flags)
@@ -46,6 +39,8 @@
   // Typecast the function pointer to a number:
   offset = (uint64_t)handler;
 
+  //panic("Almost setting an IDT entry");
+
   // Set offset:
   idt[num].baseLow = offset & 0xFFFF;
   idt[num].baseMid = (offset >> 16) & 0xFFFF;
@@ -62,10 +57,13 @@
 
 void setupIDT(void) {
   int i;
+  //panic("Just before filling IDT");
+  // After this line a crash occurs!
   // Fill all vectors with the default handler:
   for (i=0; i<256; i++) {
-    setIDTentry(i, &INTDEF, 0x08, 0x8E);
+    setIDTentry(i, INTDEF, 0x08, 0x8E);
   }
+  //panic("Just after setting defhandlers in IDT");
 
   // Now set other then default handler:
   setIDTentry(0, INT0, 0x08, 0x8E);
@@ -98,9 +96,11 @@
   idtP.base = (uint64_t)idt;
   idtP.limit = (sizeof(IDT_entry) * 256) - 1;
   // call load IDT asm function:
+  //panic("Just before LIDT");
   loadIDT();
 
   PICremap();
+  //panic("Just before sti");
   asm("sti");
 }