diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-11-27 01:44:25 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-11-27 01:44:25 +0100 |
| commit | e7b9569041521da7e0b67c30af7179c0af1e3738 (patch) | |
| tree | 4b7d596414afd96df0826f24e750c1defa14167b /kernel/syscalls.c | |
| parent | 0e402637492f34a4d0e1302fbe34344e19bc4813 (diff) | |
struggling with new multitasking
Diffstat (limited to 'kernel/syscalls.c')
| -rw-r--r-- | kernel/syscalls.c | 88 |
1 files changed, 11 insertions, 77 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 765316b..585950d 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -72,7 +72,7 @@ typedef struct { } Elf32_Phdr; -static uint32_t alloc=0x900000; +static uint32_t alloc; int syscall_unhandled(int nr) { @@ -102,10 +102,9 @@ int syscall_write(int file, char *buf, int len) if(file!=1&&file!=2) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); - // ALL output to stdout + //stderr and stdout go to console for(int i=0;i<len;i++) { - //PutConsoleChar(buf[i],0b1111111111000000); console_put_char_green(buf[i]); } return len; @@ -180,9 +179,14 @@ int syscall_readdir(const char *name,fs_dirent *dirs,int max) return fs_readdir(name,dirs,max); } +int syscall_fork() +{ +} int syscall_execve(char *name, char **argv, char **env) { + // watchout this is called with esp in virtual memory of running process! + #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 @@ -190,74 +194,6 @@ int syscall_execve(char *name, char **argv, char **env) int inode_nr=ext2_filename_to_inode(EXT2_RAM_ADDRESS,name); if(inode_nr<1)return -1; -/* - char arg1[100]; - char arg2[100]; - char arg3[100]; - char arg4[100]; - char arg5[100]; - char *argvcopy[]={arg1,arg2,arg3,arg4,arg5}; - - int argc=0; - - if(argv!=NULL) - { - while(argv[argc]!=NULL) - { - //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"arg at 0x%08X: %s", argv[argc],argv[argc]); - - int i=-1; - do{ - i++; - argvcopy[argc][i]=argv[argc][i]; - }while(argv[argc][i]!=0); - - argc++; - } - } - argvcopy[argc]=NULL; - - // - char *env1="PS1=$ "; - char *env2="PATH=/bin"; - char *env3="PWD=/home/miguel"; - char environstr[256]; - - char **oldenviron=env; - char **environ=0xf00001; - - if(oldenviron==0) - { - environ[0]=env1; - environ[1]=env2; - environ[2]=env3; - environ[3]=NULL; - } - else - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"environ: (0x%08X)",oldenviron); - int i=0; - int k=-1; - while(oldenviron[i]!=NULL) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"copy env: %s (0x%08X)",oldenviron[i],oldenviron[i]); - int start=k+1; - int j=-1; - do{ - j++; - k++; - environstr[k]=oldenviron[i][j]; - }while(oldenviron[i][j]!=0); - - environ[i]=&environstr[start]; - i++; - } - - environ[i]=NULL; - } - - -*/ //TODO: load ELF binary and move this to own compilation unit //load binary @@ -300,7 +236,6 @@ int syscall_execve(char *name, char **argv, char **env) */ - // iterate over section headers for(int phidx=0;phidx<elf->e_phnum;phidx++) { @@ -372,7 +307,6 @@ int syscall_execve(char *name, char **argv, char **env) asm("ret"); // this is never reached! - } @@ -413,16 +347,13 @@ int syscall_isatty(int file,int none1,int none2) uint32_t syscall_sbrk(int incr, int none1, int none2) { - uint32_t oldalloc=alloc; alloc+=incr; #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk (incr=%d) = 0x%08X", incr,oldalloc); #endif - return oldalloc; - } @@ -432,6 +363,9 @@ int syscall_exit(int ret, char **env, int none2) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d) (env=0x%08X)", ret, env); #endif + panic(FOOLOS_MODULE_NAME,"exit not supported yet" ); + + /* int i=0; while(env[i]!=NULL) { @@ -442,11 +376,11 @@ int syscall_exit(int ret, char **env, int none2) asm("mov $0x05bff,%esp"); // set stack pointer static char *argv[]={"shell","--silent",NULL}; syscall_execve("/bin/foolshell",argv,env); // start shell + */ } // stat, fstat, lstat - int syscall_stat(const char *path, struct stat *st,int none) { #ifdef LOG_SYSCALLS |
