From cbadacbb881200b601c7b53b29aa0c1b78747692 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Tue, 23 Mar 2010 16:34:36 +0100 Subject: More work on IPC --- src/library/Makefile | 4 ++-- src/library/gc/syscall.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ src/library/grapes/syscall.c | 35 --------------------------------- src/library/grapes/syscall.h | 12 ----------- src/library/start.c | 2 +- 5 files changed, 50 insertions(+), 50 deletions(-) create mode 100644 src/library/gc/syscall.c delete mode 100644 src/library/grapes/syscall.c delete mode 100644 src/library/grapes/syscall.h (limited to 'src/library') diff --git a/src/library/Makefile b/src/library/Makefile index c562dec..74eb525 100644 --- a/src/library/Makefile +++ b/src/library/Makefile @@ -1,13 +1,13 @@ .PHONY: clean, mrproper CC = gcc -CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra +CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I../include LD = ld LDFLAGS = -r Library = grapes.o -Objects = grapes/syscall.o \ +Objects = gc/syscall.o \ start.o all: $(Library) diff --git a/src/library/gc/syscall.c b/src/library/gc/syscall.c new file mode 100644 index 0000000..e1ef3cd --- /dev/null +++ b/src/library/gc/syscall.c @@ -0,0 +1,47 @@ +#include + +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); +} + +void thread_new(void (*entry)(void*), void *data) { + call(5, (unsigned)entry, (unsigned)data, 0, 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 shm_create(size_t offset, size_t length) { + return call(8, offset, length, 0, 0, 0); +} + +int shm_delete(size_t offset) { + return call(9, offset, 0, 0, 0, 0); +} diff --git a/src/library/grapes/syscall.c b/src/library/grapes/syscall.c deleted file mode 100644 index 38adc01..0000000 --- a/src/library/grapes/syscall.c +++ /dev/null @@ -1,35 +0,0 @@ -#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); -} - -void thread_new(void (*entry)(void*), void *data) { - call(5, (unsigned)entry, (unsigned)data, 0, 0, 0); -} - -void irq_wait(int number) { - call(6, number, 0, 0, 0, 0); -} diff --git a/src/library/grapes/syscall.h b/src/library/grapes/syscall.h deleted file mode 100644 index d2f80e5..0000000 --- a/src/library/grapes/syscall.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DEF_SYSCALL_H -#define DEF_SYSCALL_H - -void thread_exit(); -void schedule(); -void thread_sleep(int time); -void process_exit(int retval); -void printk(char* str); -void thread_new(void (*entry)(void*), void *data); -void irq_wait(int number); - -#endif diff --git a/src/library/start.c b/src/library/start.c index 8f83a23..b3c5541 100644 --- a/src/library/start.c +++ b/src/library/start.c @@ -1,4 +1,4 @@ -#include "grapes/syscall.h" +#include extern int main(); -- cgit v1.2.3