summaryrefslogtreecommitdiff
path: root/src/user/lib/tce/syscall.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-01 12:20:45 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-01 12:20:45 +0200
commit5cac9acd3aedc8043d4272d93c56805c46ff6214 (patch)
treeba9eb5ef86f7cf7afd4f7ab02de1d6bb86715632 /src/user/lib/tce/syscall.c
parent66b32658d2e5aa99493dcb3abcb73cdb2cc6f0b5 (diff)
downloadTCE-5cac9acd3aedc8043d4272d93c56805c46ff6214.tar.gz
TCE-5cac9acd3aedc8043d4272d93c56805c46ff6214.zip
Some cleanup ; relocated the kernel at 0xC0000000
Diffstat (limited to 'src/user/lib/tce/syscall.c')
-rw-r--r--src/user/lib/tce/syscall.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/user/lib/tce/syscall.c b/src/user/lib/tce/syscall.c
new file mode 100644
index 0000000..ae58e73
--- /dev/null
+++ b/src/user/lib/tce/syscall.c
@@ -0,0 +1,68 @@
+#include <tce/syscall.h>
+#include <tce/mem.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);
+}
+
+//THREAD CREATION
+struct thread_start_data {
+ void (*entry)(void*);
+ void *data;
+ void *stack;
+};
+void thread_start(void *data) {
+ struct thread_start_data *tsd = data;
+ tsd->entry(tsd->data);
+ free(tsd->stack);
+ thread_exit();
+}
+void thread_new(void (*entry)(void*), void *data) {
+ struct thread_start_data *tsd = malloc(sizeof(struct thread_start_data));
+ tsd->entry = entry;
+ tsd->data = data;
+ tsd->stack = malloc(NEW_STACK_SIZE);
+ call(5, (unsigned)thread_start, (unsigned)tsd, (unsigned)(tsd->stack + NEW_STACK_SIZE), 0, 0);
+}
+
+void irq_wait(int number) {
+ call(6, number, 0, 0, 0, 0);
+}
+
+int proc_priv() {
+ return call(7, 0, 0, 0, 0, 0);
+}
+
+int proc_setheap(size_t start, size_t end) {
+ return call(8, start, end, 0, 0, 0);
+}
+
+int shm_create(size_t offset, size_t length) {
+ return call(9, offset, length, 0, 0, 0);
+}
+
+int shm_delete(size_t offset) {
+ return call(10, offset, 0, 0, 0, 0);
+}