9
|
1 #include "kernel.h"
|
|
2
|
19
|
3 void startPython()
|
|
4 {
|
|
5 // TODO: connect to Py_Main
|
23
|
6 //PyRun_SimpleString("print('hello world')");
|
19
|
7 }
|
|
8
|
20
|
9 void testMalloc()
|
|
10 {
|
|
11 char *a, *b;
|
23
|
12
|
|
13 printf("Testing malloc\n");
|
20
|
14 a = kmalloc(100);
|
|
15 printf("Got a at %x\n", a);
|
|
16 a[0] = 'A';
|
|
17 b = kmalloc(22);
|
|
18 printf("Got b at %x\n", b);
|
|
19 b[0] = 'B';
|
|
20 kfree(a);
|
|
21 }
|
|
22
|
24
|
23 void reboot()
|
|
24 {
|
|
25 while ( (inb(0x64) & 0x02) == 0x02)
|
|
26 {
|
|
27 ;
|
|
28 }
|
|
29 outb(0x64, 0xFE);
|
|
30 }
|
|
31
|
9
|
32 void kmain()
|
|
33 {
|
|
34 init_screen();
|
24
|
35 setupIDT(); // This causes error on real hardware
|
23
|
36 init_heap();
|
14
|
37
|
23
|
38 printf("Welcome!\n");
|
9
|
39
|
|
40 while (1==1)
|
|
41 {
|
|
42 char buffer[70];
|
|
43 printf(">>>");
|
|
44 getline(buffer, 70);
|
|
45 // TODO: interpret this line with python :)
|
|
46 printf("\n");
|
|
47 if (buffer[0] == 'x')
|
|
48 {
|
|
49 printf("System time in ms: %d\n", getTimeMS());
|
|
50 }
|
23
|
51 if (buffer[0] == 't')
|
|
52 {
|
|
53 testMalloc();
|
|
54 }
|
9
|
55 if ( strncmp(buffer, "help", 4))
|
|
56 {
|
|
57 printf("Help\n Try one of these commands:\n");
|
|
58 printf(" x: print system time in ms\n");
|
|
59 }
|
24
|
60 if (strncmp(buffer, "r", 1))
|
|
61 {
|
|
62 reboot();
|
|
63 }
|
9
|
64 }
|
|
65 }
|
|
66
|
|
67
|