summaryrefslogtreecommitdiff
path: root/src/library/grapes/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/grapes/syscall.c')
-rw-r--r--src/library/grapes/syscall.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/library/grapes/syscall.c b/src/library/grapes/syscall.c
new file mode 100644
index 0000000..5a1a26e
--- /dev/null
+++ b/src/library/grapes/syscall.c
@@ -0,0 +1,27 @@
+#include "syscall.h"
+
+static int call(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f) {
+ unsigned ret;
+ asm volatile("int $64" : "=a"(ret) : "a"(a), "b"(b), "c"(c), "d"(d), "S"(e), "D"(f));
+ return ret;
+}
+
+void thread_exit() {
+ call(0, 0, 0, 0, 0, 0);
+}
+
+void schedule() {
+ call(1, 0, 0,0, 0, 0);
+}
+
+void thread_sleep(int time) {
+ call(2, time, 0, 0, 0, 0);
+}
+
+void process_exit(int retval) {
+ call(3, retval, 0, 0, 0, 0);
+}
+
+void printk(char* str) {
+ call(4, (unsigned)str, 0, 0, 0, 0);
+}