summaryrefslogtreecommitdiff
path: root/src/kernel/task/syscall.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-01 23:48:56 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-01 23:48:56 +0200
commit43d0bb8e3997022e5270f7f75f615a47819c929e (patch)
tree937992d286966edecf81b405e414230c85d19bad /src/kernel/task/syscall.c
parente9683297bf480f9590b0e5796f4520fb430e2e03 (diff)
downloadTCE-43d0bb8e3997022e5270f7f75f615a47819c929e.tar.gz
TCE-43d0bb8e3997022e5270f7f75f615a47819c929e.zip
Basic object system - THIS IS STILL A LONG WAY TO GO!!
Diffstat (limited to 'src/kernel/task/syscall.c')
-rw-r--r--src/kernel/task/syscall.c70
1 files changed, 57 insertions, 13 deletions
diff --git a/src/kernel/task/syscall.c b/src/kernel/task/syscall.c
index bd27eba..8e1005c 100644
--- a/src/kernel/task/syscall.c
+++ b/src/kernel/task/syscall.c
@@ -2,18 +2,22 @@
#include "task.h"
#include <core/sys.h>
+#include <Object/Object.h>
+
+#define NUMBER_OF_SYSCALLS 32
+
#define CALL0(name, scname) static void scname(struct registers* r) { r->eax = name(); }
#define CALL1(name, scname) static void scname(struct registers* r) { \
- r->eax = name(r->ebx); }
+ r->eax = name(r->ecx); }
#define CALL2(name, scname) static void scname(struct registers* r) { \
- r->eax = name(r->ebx, r->ecx); }
+ r->eax = name(r->ecx, r->edx); }
#define CALL3(name, scname) static void scname(struct registers* r) { \
- r->eax = name(r->ebx, r->ecx, r->edx); }
+ r->eax = name(r->ecx, r->edx, r->esi); }
#define CALL0V(name, scname) static void scname(struct registers* r) { name(); }
-#define CALL1V(name, scname) static void scname(struct registers* r) { name(r->ebx); }
-#define CALL2V(name, scname) static void scname(struct registers* r) { name(r->ebx, r->ecx); }
-#define CALL3V(name, scname) static void scname(struct registers* r) { name(r->ebx, r->ecx, r->edx); }
-#define CALL4V(name, scname) static void scname(struct registers* r) { name(r->ebx, r->ecx, r->edx, r->esi); }
+#define CALL1V(name, scname) static void scname(struct registers* r) { name(r->ecx); }
+#define CALL2V(name, scname) static void scname(struct registers* r) { name(r->ecx, r->edx); }
+#define CALL3V(name, scname) static void scname(struct registers* r) { name(r->ecx, r->edx, r->esi); }
+#define CALL4V(name, scname) static void scname(struct registers* r) { name(r->ecx, r->edx, r->esi, r->edi); }
CALL0V(thread_exit, thread_exit_sc);
CALL0V(schedule, schedule_sc);
@@ -25,21 +29,61 @@ CALL0(proc_priv, proc_priv_sc);
CALL1(process_sbrk, proc_sbrk_sc);
CALL1V(process_brk, proc_brk_sc);
+CALL1(open, open_sc);
+CALL2(open_relative, open_relative_sc);
+CALL1V(close, close_sc);
+CALL2(get_methods, get_methods_sc);
+
static void thread_new_sc(struct registers* r) {
cli();
- thread_new(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx, (void*)r->edx);
+ thread_new(current_thread->process, (thread_entry)r->ecx, (void*)r->edx, (void*)r->esi);
sti();
}
int_callback syscalls[NUMBER_OF_SYSCALLS] = {
- thread_exit_sc, //0
+ 0, //0
+ thread_exit_sc,
schedule_sc,
thread_sleep_sc,
process_exit_sc,
- printk_sc,
- thread_new_sc, //5
+ printk_sc, //5
+ thread_new_sc,
irq_wait_sc,
proc_priv_sc,
proc_sbrk_sc,
- proc_brk_sc,
- 0 };
+ proc_brk_sc, //10
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, //15
+ 0,
+ 0,
+ 0,
+ 0,
+ open_sc, //20
+ open_relative_sc,
+ close_sc,
+ get_methods_sc,
+ 0,
+ 0, //25
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, //30
+ 0, //31
+
+ };
+
+/* Called in idt_.asm on a system call (interrupt 64).
+ Calls the correct syscall handler (if any). */
+void idt_syscallHandler(struct registers regs) {
+ if (regs.eax == 0) {
+ if (regs.ebx < NUMBER_OF_SYSCALLS && syscalls[regs.ebx] != 0) {
+ syscalls[regs.ebx](&regs);
+ }
+ } else {
+ do_method_call(&regs);
+ }
+}