comparison 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
comparison
equal deleted inserted replaced
28:47b7df514243 29:7e3bdcb391dc
1 #include "kernel.h" 1 #include "kernel.h"
2 2
3 void testMalloc() 3 static void testMalloc()
4 { 4 {
5 char *a, *b; 5 char *a, *b;
6 6
7 printf("Testing malloc\n"); 7 printf("Testing malloc\n");
8 a = kmalloc(100); 8 a = kmalloc(100);
15 } 15 }
16 16
17 // A test program that prints 'Hoi' to the screen: 17 // A test program that prints 'Hoi' to the screen:
18 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}; 18 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};
19 19
20 /* This routine initializes the kernel.
21 * We are left here in 64-bit long mode with the first 6 MB identity mapped.
22 * */
20 void kmain() 23 void kmain()
21 { 24 {
22 init_screen(); 25 init_screen();
23 setupIDT(); 26 setupIDT();
24 init_heap(); 27 // init_heap();
28
29 // Assume first 16MB:
30 // TODO: get size from grub
31 init_memory(0x1000000);
25 32
26 //new_task(hello_program); 33 //new_task(hello_program);
27 34
28 // TODO: make below a user space program! 35 // TODO: make below a user space program!
29 printf("Welcome!\n"); 36 printf("Welcome!\n");
47 { 54 {
48 printf("Help\n Try one of these commands:\n"); 55 printf("Help\n Try one of these commands:\n");
49 printf(" x: print system time in ms\n"); 56 printf(" x: print system time in ms\n");
50 printf(" r: reboot\n"); 57 printf(" r: reboot\n");
51 printf(" t: test\n"); 58 printf(" t: test\n");
59 printf(" b: break\n");
52 } 60 }
53 if (strncmp(buffer, "r", 1)) 61 if (strncmp(buffer, "r", 1))
54 { 62 {
55 reboot(); 63 reboot();
56 } 64 }
65 if (strncmp(buffer, "b", 1))
66 {
67 magicBochsBreak();
68 }
57 } 69 }
58 } 70 }
59 71
60 72