diff cos/kernel/kernel.c @ 33:d8185ddb6c7b

Added more interrupt handlers
author windel
date Sun, 15 Jan 2012 13:39:49 +0100
parents 3a6a9b929db0
children 8012221dd740
line wrap: on
line diff
--- a/cos/kernel/kernel.c	Fri Jan 13 18:18:17 2012 +0100
+++ b/cos/kernel/kernel.c	Sun Jan 15 13:39:49 2012 +0100
@@ -1,4 +1,3 @@
-
 #include "kernel.h"
 
 static void testMalloc()
@@ -27,9 +26,20 @@
 
    uint64_t available_memory = 0;
 
+   printf("Running with %d MB ram\n", available_memory / 1000000);
+
+   printf("Detecting amount of memory\n");
+
+   printf("Grub multiboot header location: %x\n", multiboot_info);
+   // On real hardware, the retrieval of the flags fails into general protection fault??
+   
+   printf("Grub lower mem: %d\n", multiboot_info->mem_lower);
+   printf("Grub multiboot header flags: %x\n", multiboot_info->flags);
+
    /* Display memory information from multiboot header */
    if ((multiboot_info->flags & (1<<6)) == (1<<6))
    {
+      printf("Found GRUB memory map\n");
       multiboot_memory_map_t *mmap;
       for (mmap = (multiboot_memory_map_t*)(uint64_t)multiboot_info->mmap_addr; 
             (uint64_t)mmap < multiboot_info->mmap_addr + multiboot_info->mmap_length; 
@@ -43,6 +53,10 @@
          }
       }
    }
+   else
+   {
+      printf("Found no GRUB map\n");
+   }
 
    printf("Running with %d MB ram\n", available_memory / 1000000);
 
@@ -116,7 +130,15 @@
     {
        magicBochsBreak();
     }
-  }
+      if (strncmp(buffer, "pf", 2))
+      {
+      /* Test general protection exception */
+      uint64_t *x;
+      x = (uint64_t*)0x4000000; // Address that is not mapped
+      *x = 0x2; // trigger paging exception
+      }
+
+   }
 }