From c742be9c738c91703a7be787639cad167de3a6b1 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 17 Aug 2018 02:28:02 +0200 Subject: started reviving my fool os --- kernel/syscalls.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'kernel/syscalls.c') diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 38cac63..31579e1 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -6,8 +6,8 @@ #include "kernel/kernel.h" #include "kernel/config.h" #include -#include -#include +#include +#include int syscall_unhandled(int nr) { @@ -29,7 +29,6 @@ int syscall_lseek(int file,int ptr,int dir) panic(FOOLOS_MODULE_NAME,"unhandled syscall: lseek"); return 0; - } // TODO: /dev/console or /dev/tty1 - /dev/ttyN @@ -77,14 +76,11 @@ int syscall_read(int file, char *buf, int len) if(l==len)return l; if(c=='\n')return l; } - - } //TODO: replace with dirent! int syscall_readdir(const char *name,fs_dirent *dirs,int max) { - #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"readdir(name=0x%08X, dirs=0x%08X, %d)", name,dirs,max); #endif @@ -95,7 +91,6 @@ int syscall_readdir(const char *name,fs_dirent *dirs,int max) // for non blocking io? int syscall_has_data_waiting(int file) { - #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"has data waiting?"); #endif @@ -105,13 +100,10 @@ int syscall_has_data_waiting(int file) int syscall_tune(int v1,int v2, int v3) { - - #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"tuning request"); #endif - if(v1==0) // regular tty mode { get_fool()->tty->set_buff=true; @@ -127,10 +119,6 @@ int syscall_tune(int v1,int v2, int v3) return 0; } - - - - int copy_args(char **in, char **out) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"copy_args(0x%08x, 0x%08X)",in,out); @@ -160,10 +148,8 @@ int copy_args(char **in, char **out) return count; } - int syscall_execve(char *name, char **argv, char **env) { - #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"execve (name=0x%08X(%s), argvs=0x%08X, env=0x%08X)", name,name,argv,env); #endif @@ -177,9 +163,9 @@ int syscall_execve(char *name, char **argv, char **env) copy_args(argv,argv1); copy_args(env,env1); - uint32_t alloc; uint32_t entry_global=load_elf(name,&alloc); + task_set_brk(alloc); if(!entry_global) @@ -191,7 +177,9 @@ int syscall_execve(char *name, char **argv, char **env) } /* try to move this to asm */ - //asm volatile("jmp ."); + // asm volatile("jmp ."); // loop forever + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"returning to jump addy (0x%08X)", entry_global); + asm volatile("mov $0x8fff000,%esp"); // set stack at high end of process image asm volatile ("push %0" :: "r" (argv1)); @@ -201,7 +189,7 @@ int syscall_execve(char *name, char **argv, char **env) // push addr and return to it asm volatile ("pushl %0"::"r"(entry_global)); - + asm volatile ("sti"); asm volatile ("ret"); -- cgit v1.2.3