forked from yhzhang0128/egos-2000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grass.c
52 lines (39 loc) · 1.13 KB
/
grass.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
/*
* (C) 2022, Cornell University
* All rights reserved.
*/
/* Author: Yunhao Zhang
* Description: initialize the process control block and
* spawns some kernel processes, including file system and shell
*/
#include "egos.h"
#include "grass.h"
struct earth *earth = (void*)EARTH_ADDR;
static void fs_init();
static void timer_handler(int id, void* arg);
int main() {
SUCCESS("Enter the grass layer");
fs_init();
earth->mmu_switch(PID_FS);
earth->intr_register(TIMER_INTR_ID, timer_handler);
earth->intr_enable();
/* call the shell application entry and never return */
void (*app_entry)() = (void*)VADDR_START;
app_entry();
return 0;
}
static int read_fs_elf(int block_no, char* dst) {
return earth->disk_read(FS_EXEC_START + block_no, 1, dst);
}
static void fs_init() {
INFO("Load the file system as process #%d", PID_FS);
struct block_store bs;
bs.read = read_fs_elf;
elf_load(PID_FS, &bs, earth);
}
static int timer_cnt;
static void timer_handler(int id, void* arg) {
timer_cnt++;
if (timer_cnt % 20 == 0)
INFO("Timer interrupt count: %d", timer_cnt);
}