diff cos/kernel/kernel.c @ 29:7e3bdcb391dc

Added get_page function to mm
author windel
date Thu, 29 Dec 2011 19:34:01 +0100
parents 47b7df514243
children 88590c42320f
line wrap: on
line diff
--- a/cos/kernel/kernel.c	Wed Dec 28 13:38:43 2011 +0100
+++ b/cos/kernel/kernel.c	Thu Dec 29 19:34:01 2011 +0100
@@ -1,6 +1,6 @@
 #include "kernel.h"
 
-void testMalloc()
+static void testMalloc()
 {
    char *a, *b;
 
@@ -17,11 +17,18 @@
 // A test program that prints 'Hoi' to the screen:
 unsigned char hello_program[] = {0x55, 0x48, 0x89, 0xe5, 0x48, 0x83, 0xec, 0x10, 0x48, 0xc7, 0x45, 0xf8, 0x0, 0x80, 0xb, 0x0, 0x48, 0x8b, 0x45, 0xf8, 0xc6, 0x0, 0x48, 0x48, 0x8b, 0x45, 0xf8, 0x48, 0x83, 0xc0, 0x2, 0xc6, 0x0, 0x6f, 0x48, 0x8b, 0x45, 0xf8, 0x48, 0x83, 0xc0, 0x4, 0xc6, 0x0, 0x69, 0xeb, 0xfe, 0x0, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x7a, 0x52, 0x0, 0x1, 0x78, 0x10, 0x1, 0x1b, 0xc, 0x7, 0x8, 0x90, 0x1, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0xb0, 0xff, 0xff, 0xff, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x41, 0xe, 0x10, 0x86, 0x2, 0x43, 0xd, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
 
+/* This routine initializes the kernel.
+ * We are left here in 64-bit long mode with the first 6 MB identity mapped.
+ * */
 void kmain()
 {
-  init_screen();
-  setupIDT(); 
-  init_heap();
+   init_screen();
+   setupIDT();
+   // init_heap();
+
+   // Assume first 16MB:
+   // TODO: get size from grub
+   init_memory(0x1000000);
 
   //new_task(hello_program);
 
@@ -49,11 +56,16 @@
       printf(" x: print system time in ms\n");
       printf(" r: reboot\n");
       printf(" t: test\n");
+      printf(" b: break\n");
     }
     if (strncmp(buffer, "r", 1))
     {
        reboot();
     }
+    if (strncmp(buffer, "b", 1))
+    {
+       magicBochsBreak();
+    }
   }
 }