-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.cpp
111 lines (100 loc) · 1.83 KB
/
kernel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "kernel.h"
#include "vga.h"
#include "printk.h"
#include "ps2.h"
#include "keyboard.h"
#include "interrupt.h"
#include "gdt.h"
#include "serial.h"
#include "multiboot2_tags.h"
#include "page_table.h"
#include "kmalloc.h"
#include "threading.h"
void wait_a_little() {
int i = 100000;
while (i--);
}
void wait_longer() {
int i = 50000000;
while (i--);
}
void test0(void *arg) {
int i = *(int *)arg;
while (1) {
printk("%d\n", i);
i += 4;
if (i > 400)
break;
yield();
}
kexit();
}
void test1(void *arg) {
int i = *(int *)arg;
while (1) {
printk("%d\n", i);
i += 4;
if (i > 400)
break;
yield();
}
kexit();
}
void test2(void *arg) {
int i = *(int *)arg;
while (1) {
printk("%d\n", i);
i += 4;
if (i > 400)
break;
yield();
}
kexit();
}
void test3(void *arg) {
int i = *(int *)arg;
while (1) {
printk("%d\n", i);
i += 4;
if (i > 400)
break;
yield();
}
kexit();
}
void kernel_main(void *multiboot2_tag) {
setup_gdt_tss();
init_VGA();
init_COM1();
init_interrupts();
if (init_ps2())
init_keyboard();
sti();
read_multiboot2_tags(multiboot2_tag);
MMU_pf_init();
init_heap();
init_threading();
wait_longer();
clear_screen();
splash_screen();
wait_longer();
wait_longer();
clear_screen();
printk("Success!\n");
sti();
int i = 0;
PROC_create_kthread(test0, &i);
int j = 1;
PROC_create_kthread(test1, &j);
int k = 2;
PROC_create_kthread(test2, &k);
int l = 3;
PROC_create_kthread(test3, &l);
kernel_loop(0x0);
}
void kernel_loop(void * args) {
while (1) {
PROC_run();
}
//halt;
}