forked from yhzhang0128/egos-2000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
egos.h
64 lines (52 loc) · 2.18 KB
/
egos.h
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
#pragma once
#define PAGE_SIZE 4096
/* memory layout */
#define FRAME_CACHE_END 0x80020000
#define FRAME_CACHE_START 0x80004000 /* 112KB frame cache */
/* earth interface */
#define GRASS_STACK_TOP 0x80003f80 /* ~8KB earth/grass stack */
/* grass interface */
#define APPS_STACK_TOP 0x80002000 /* ~6KB app stack */
#define SYSCALL_ARG 0x80000400 /* ~1KB syscall args */
#define APPS_ARG 0x80000000 /* ~1KB argc, argv */
#define APPS_SIZE 0x00003000
#define APPS_ENTRY 0x08005000 /* 12KB app code+data */
#define GRASS_SIZE 0x00002000
#define GRASS_ENTRY 0x08003000 /* 8KB grass code+data */
/* 12KB earth data */
/* earth code is in QSPI flash */
struct earth {
/* CPU interface */
int (*intr_enable)();
int (*intr_register)(void (*handler)(int));
int (*excp_register)(void (*handler)(int));
int (*mmu_alloc)(int* frame_no, int* cached_addr);
int (*mmu_free)(int pid);
int (*mmu_map)(int pid, int page_no, int frame_no);
int (*mmu_switch)(int pid);
/* Devices interface */
int (*disk_read)(int block_no, int nblocks, char* dst);
int (*disk_write)(int block_no, int nblocks, char* src);
int (*tty_intr)();
int (*tty_read)(char* buf, int len);
int (*tty_write)(char* buf, int len);
int (*tty_printf)(const char *format, ...);
int (*tty_info)(const char *format, ...);
int (*tty_fatal)(const char *format, ...);
int (*tty_success)(const char *format, ...);
int (*tty_critical)(const char *format, ...);
};
struct grass {
/* Process interface */
int (*proc_alloc)();
void (*proc_free)(int);
void (*proc_set_ready)(int);
int work_dir_ino;
char work_dir_name[32];
};
extern struct earth *earth;
#define printf earth->tty_printf
#define INFO earth->tty_info
#define FATAL earth->tty_fatal
#define SUCCESS earth->tty_success
#define CRITICAL earth->tty_critical