-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyscall-add-xv6.diff
executable file
·94 lines (90 loc) · 1.82 KB
/
syscall-add-xv6.diff
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
diff --git a/Makefile b/Makefile
index 09d790c..906f9d3 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,7 @@ UPROGS=\
_usertests\
_wc\
_zombie\
+ _tryhello\
fs.img: mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS)
diff --git a/syscall.c b/syscall.c
index ee85261..1e5198e 100644
--- a/syscall.c
+++ b/syscall.c
@@ -103,6 +103,7 @@ extern int sys_unlink(void);
extern int sys_wait(void);
extern int sys_write(void);
extern int sys_uptime(void);
+extern int sys_hello(void);
static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
@@ -126,6 +127,7 @@ static int (*syscalls[])(void) = {
[SYS_link] sys_link,
[SYS_mkdir] sys_mkdir,
[SYS_close] sys_close,
+[SYS_hello] sys_hello,
};
void
diff --git a/syscall.h b/syscall.h
index bc5f356..5f48d9b 100644
--- a/syscall.h
+++ b/syscall.h
@@ -20,3 +20,4 @@
#define SYS_link 19
#define SYS_mkdir 20
#define SYS_close 21
+#define SYS_hello 22
diff --git a/sysfile.c b/sysfile.c
index bfe61b7..f60f0da 100644
--- a/sysfile.c
+++ b/sysfile.c
@@ -442,3 +442,9 @@ sys_pipe(void)
fd[1] = fd1;
return 0;
}
+
+int sys_hello(void)
+{
+ cprintf("hello\n");
+ return 0;
+}
diff --git a/tryhello.c b/tryhello.c
new file mode 100644
index 0000000..610d700
--- /dev/null
+++ b/tryhello.c
@@ -0,0 +1,12 @@
+#include "types.h"
+#include "stat.h"
+#include "user.h"
+#include "fs.h"
+
+
+int
+main(int argc, char *argv[])
+{
+ hello();
+ exit();
+}
diff --git a/user.h b/user.h
index 4f99c52..2f95ca5 100644
--- a/user.h
+++ b/user.h
@@ -23,6 +23,7 @@ int getpid(void);
char* sbrk(int);
int sleep(int);
int uptime(void);
+int hello(void);
// ulib.c
int stat(const char*, struct stat*);
diff --git a/usys.S b/usys.S
index 8bfd8a1..0072273 100644
--- a/usys.S
+++ b/usys.S
@@ -29,3 +29,4 @@ SYSCALL(getpid)
SYSCALL(sbrk)
SYSCALL(sleep)
SYSCALL(uptime)
+SYSCALL(hello)