-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.c
92 lines (77 loc) · 2.7 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
#include "kernel/kernel.h"
#include "servers/vfs.h"
#include "servers/ts.h"
#include "servers/pm.h"
#include "servers/ex.h"
#include "drivers/drv.h"
#include "usr/init.h"
#include "usr/apps.h"
#include "usr/sh.h"
/*
* The main purpose of this task is to start all the servers and set
* up the environment for the operating system. It exits at the end.
*/
void
startup (void* args UNUSED) {
pid_t pid;
char** initc;
/* starting time server */
pid = createtask(TASK_PRIO_RT, PAGE_INVALID);
allocatestack(pid, DEFAULT_STACK_SIZE);
setuptask(pid, ts, NULL, NULL);
starttask(pid);
settspid(pid);
/* starting virtual filesystem server */
pid = createtask(TASK_PRIO_HIGH, PAGE_INVALID);
allocatestack(pid, DEFAULT_STACK_SIZE * 2);
setuptask(pid, vfs, NULL, NULL);
starttask(pid);
setvfspid(pid);
/* setting up devices and special files */
/* pipe: 0 */
mkdev(memfile, NULL); /* 1 */
mkdev(tty_usart0, NULL); /* 2 */
/* starting executable store server */
pid = createtask(TASK_PRIO_HIGH, PAGE_INVALID);
allocatestack(pid, DEFAULT_STACK_SIZE);
setuptask(pid, ex, NULL, NULL);
starttask(pid);
setexpid(pid);
/* registering user programs */
ex_regprg("getty", getty, DEFAULT_STACK_SIZE);
ex_regprg("login", login, DEFAULT_STACK_SIZE);
ex_regprg("sh", sh, DEFAULT_STACK_SIZE+64);
ex_regprg("echo", echo, DEFAULT_STACK_SIZE);
ex_regprg("cat", cat, DEFAULT_STACK_SIZE);
ex_regprg("cap", cap, DEFAULT_STACK_SIZE);
ex_regprg("sleep", sleep, DEFAULT_STACK_SIZE);
ex_regprg("xargs", xargs, DEFAULT_STACK_SIZE);
ex_regprg("repeat", repeat, DEFAULT_STACK_SIZE);
ex_regprg("uptime", pr_uptime, DEFAULT_STACK_SIZE);
ex_regprg("stat", f_stat, DEFAULT_STACK_SIZE);
ex_regprg("mknod", f_mknod, DEFAULT_STACK_SIZE);
ex_regprg("grep", grep, DEFAULT_STACK_SIZE);
ex_regprg("fsdebug", fs_debug, DEFAULT_STACK_SIZE);
ex_regprg("init", init, DEFAULT_STACK_SIZE);
/* starting process manager server */
initc = (char**)kmalloc(sizeof(char*[2])); /* Freed in PM */
initc[0] = "init";
initc[1] = NULL;
pid = createtask(TASK_PRIO_HIGH, PAGE_INVALID);
allocatestack(pid, DEFAULT_STACK_SIZE * 2);
setuptask(pid, pm, initc, NULL);
starttask(pid);
setpmpid(pid);
/* done, exiting */
return;
}
/*
* Main entry point of the kernel. Parameter is the first task
*/
int main (void) {
kernel(startup, NULL, DEFAULT_STACK_SIZE, TASK_PRIO_DFLT);
return 0;
}
/*
*
*/