annotate cos/kernel/kernel.c @ 28:47b7df514243

Moved Makefiles
author windel
date Wed, 28 Dec 2011 13:38:43 +0100
parents 7f74363f4c82
children 7e3bdcb391dc
rev   line source
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
1 #include "kernel.h"
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
2
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
3 void testMalloc()
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
4 {
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
5 char *a, *b;
23
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
6
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
7 printf("Testing malloc\n");
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
8 a = kmalloc(100);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
9 printf("Got a at %x\n", a);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
10 a[0] = 'A';
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
11 b = kmalloc(22);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
12 printf("Got b at %x\n", b);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
13 b[0] = 'B';
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
14 kfree(a);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
15 }
b1fed2171e1a Now working with 2 MB pages
windel
parents: 19
diff changeset
16
26
dcce92b1efbc Added mm.c
windel
parents: 24
diff changeset
17 // A test program that prints 'Hoi' to the screen:
dcce92b1efbc Added mm.c
windel
parents: 24
diff changeset
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};
24
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
19
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
20 void kmain()
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
21 {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
22 init_screen();
26
dcce92b1efbc Added mm.c
windel
parents: 24
diff changeset
23 setupIDT();
23
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
24 init_heap();
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents: 9
diff changeset
25
28
47b7df514243 Moved Makefiles
windel
parents: 27
diff changeset
26 //new_task(hello_program);
47b7df514243 Moved Makefiles
windel
parents: 27
diff changeset
27
47b7df514243 Moved Makefiles
windel
parents: 27
diff changeset
28 // TODO: make below a user space program!
23
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
29 printf("Welcome!\n");
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
30
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
31 while (1==1)
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
32 {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
33 char buffer[70];
27
7f74363f4c82 Added some files for the python port
windel
parents: 26
diff changeset
34 printf(">");
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
35 getline(buffer, 70);
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
36 // TODO: interpret this line with python :)
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
37 printf("\n");
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
38 if (buffer[0] == 'x')
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
39 {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
40 printf("System time in ms: %d\n", getTimeMS());
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
41 }
23
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
42 if (buffer[0] == 't')
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
43 {
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
44 testMalloc();
5dd47d6eebac Added ubersimple malloc algorithm
windel
parents: 22
diff changeset
45 }
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
46 if ( strncmp(buffer, "help", 4))
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
47 {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
48 printf("Help\n Try one of these commands:\n");
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
49 printf(" x: print system time in ms\n");
28
47b7df514243 Moved Makefiles
windel
parents: 27
diff changeset
50 printf(" r: reboot\n");
47b7df514243 Moved Makefiles
windel
parents: 27
diff changeset
51 printf(" t: test\n");
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
52 }
24
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
53 if (strncmp(buffer, "r", 1))
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
54 {
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
55 reboot();
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
56 }
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
57 }
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
58 }
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
59
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
60