-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
107 lines (85 loc) · 1.88 KB
/
main.c
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
#include "screen.h"
#include "scheduler.h"
#include "heap.h"
#include "paging.h"
#include "fs.h"
void processA();
void processB();
void processC();
void processD();
void print_fs()
{
char** files = list_files();
for (int curr_idx = 0; curr_idx < get_files_number(); curr_idx++) {
print("File: ");
print(files[curr_idx]);
println();
}
print("==");
println();
}
void kernel_main()
{
heap_init();
paging_init();
screen_init();
process_init();
scheduler_init();
filesystem_init();
print("Welcome to 539kernel!");
println();
print("We are now in Protected-mode");
println();
printi(539);
println();
process_create(&processA);
process_create(&processB);
process_create(&processC);
process_create(&processD);
char* data = kalloc(512);
strcpy(data, "The contents of the first file on 539filesystem");
create_file("first_file", data);
char* data2 = kalloc(512);
strcpy(data2, "SECOND FILE in 539filesystem");
create_file("second_file", data2);
char* data3 = kalloc(512);
strcpy(data3, "THIRD FILE in 539filesystem");
create_file("third_file", data3);
print(read_file("first_file")); println();
print(read_file("second_file")); println();
print(read_file("third_file")); println();
print_fs();
delete_file("first_file");
print_fs();
while (1);
}
void interrupt_handler(int interrupt_number)
{
println();
print("Interrupt Received ");
printi(interrupt_number);
}
void processA()
{
print("Process A,");
while(1)
asm("mov $5390, %eax");
}
void processB()
{
print("Process B,");
while(1)
asm("mov $5391, %eax");
}
void processC()
{
print("Process C,");
while(1)
asm("mov $5392, %eax");
}
void processD()
{
print("Process D,");
while(1)
asm("mov $5393, %eax");
}