diff options
Diffstat (limited to 'src/kernel/task/syscall.cpp')
-rw-r--r-- | src/kernel/task/syscall.cpp | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/src/kernel/task/syscall.cpp b/src/kernel/task/syscall.cpp index 678677d..797c5db 100644 --- a/src/kernel/task/syscall.cpp +++ b/src/kernel/task/syscall.cpp @@ -3,6 +3,7 @@ #include "timer.h" #include <core/monitor.h> #include <core/sys.h> +#include <vfs/node.h> #define CALL0(name, scname) static void scname(registers* r) { r->eax = name(); } #define CALL1(name, scname) static void scname(registers* r) { \ @@ -11,6 +12,8 @@ r->eax = name(r->ebx, r->ecx); } #define CALL3(name, scname) static void scname(registers* r) { \ r->eax = name(r->ebx, r->ecx, r->edx); } +#define CALL4(name, scname) static void scname(registers* r) { \ + r->eax = name(r->ebx, r->ecx, r->edx, r->esi); } #define CALL0V(name, scname) static void scname(registers* r) { name(); } #define CALL1V(name, scname) static void scname(registers* r) { name(r->ebx); } #define CALL2V(name, scname) static void scname(registers* r) { name(r->ebx, r->ecx); } @@ -26,29 +29,83 @@ CALL0(proc_priv, proc_priv_sc); CALL1(process_sbrk, proc_sbrk_sc); CALL1V(process_brk, proc_brk_sc); +CALL1V(close, close_sc); + static void printk_sc(registers *r) { monitor_write((char*)r->ebx); } static void thread_new_sc(registers* r) { cli(); - new thread(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx, (void*)r->edx); + new thread(current_process, (thread_entry)r->ebx, (void*)r->ecx, (void*)r->edx); sti(); } +static void open_sc(registers *r) { + r->eax = open((char*)r->ebx, r->ecx); +} + +static void open_relative_sc(registers *r) { + r->eax = open_relative(r->ebx, (char*)r->ecx, r->edx); +} + +static void stat_sc(registers *r) { + r->eax = stat((char*)r->ebx, (file_info*)r->ecx); +} + +static void stat_relative_sc(registers *r) { + r->eax = stat_relative(r->ebx, (char*)r->ecx, (file_info*)r->edx); +} + +static void statf_sc(registers *r) { + r->eax = statf(r->ebx, (file_info*)r->ecx); +} + +static void read_sc(registers *r) { + r->eax = read(r->ebx, r->ecx, r->edx, (char*)r->esi); +} + +static void write_sc(registers *r) { + r->eax = write(r->ebx, r->ecx, r->edx, (char*)r->esi); +} + +static void link_sc(registers *r) { + r->eax = link((char*)r->ebx, (char*)r->ecx, r->edx); +} + + int_callback syscalls[NUMBER_OF_SYSCALLS] = { // This must correspond to common/include/tce/syscalls.h - 0, - 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, + 0, + proc_sbrk_sc, //10 proc_brk_sc, - 0 }; + 0, + 0, + 0, + 0, //15 + 0, + 0, + 0, + 0, + open_sc, //20 + open_relative_sc, + stat_sc, + stat_relative_sc, + statf_sc, + close_sc, //25 + read_sc, + write_sc, + link_sc, + 0 + }; /* Called in idt_.asm on a system call (interrupt 64). |