diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/config.h | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 5 | ||||
| -rw-r--r-- | kernel/syscalls.c | 67 |
3 files changed, 39 insertions, 35 deletions
diff --git a/kernel/config.h b/kernel/config.h index ef0fa71..e48c63c 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -6,7 +6,7 @@ //#define FOOLOS_COMPILE_FLOPPY // compile floppy drivers #define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line -//#define FOOLOS_LOG_OFF // do not log anything +#define FOOLOS_LOG_OFF // do not log anything #define FOOLOS_CONSOLE // otherwise VESA will be used! #define MEM_PRINT_MEMORYMAP #define LOG_BUF_SIZE 4069 diff --git a/kernel/kernel.c b/kernel/kernel.c index 45c8fbb..6daa625 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -9,11 +9,13 @@ #endif #define FOOLOS_MODULE_NAME "kernel" + +#include <stdint.h> + #include "config.h" #include "asm/asm.h" #include "lib/logger/log.h" -#include "lib/int/stdint.h" #include "lib/bool/bool.h" #include "lib/buffer/ringbuffer.h" @@ -34,7 +36,6 @@ #include "task.h" - #ifdef FOOLOS_COMPILE_FLOPPY #include "floppy.h" #endif diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 06caf2d..9f29750 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -140,9 +140,36 @@ int syscall_readdir(const char *name,fs_dirent *dirs,int max) int syscall_execve(char *name, char **argv, char **env) { -#ifdef LOG_SYSCALLS + #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"execve (name=0x%08X, argvs=0x%08X, env=0x%08X)", name,argv,env); -#endif + #endif + + + 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+1]!=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+1][i]; + }while(argv[argc+1][i]!=0); + + argc++; + } + } + argvcopy[argc]=NULL; //TODO: load ELF binary and move this to own compilation unit @@ -151,7 +178,6 @@ int syscall_execve(char *name, char **argv, char **env) ext2_check(EXT2_RAM_ADDRESS); ext2_inode_content(EXT2_RAM_ADDRESS,name,0x800000,0x100000); - Elf32_Ehdr *elf; elf=0x800000; @@ -226,39 +252,16 @@ int syscall_execve(char *name, char **argv, char **env) } + // argv / argc + asm("push %0" :: "r" (argvcopy)); + asm("push %0" :: "r" (argc)); - /* - // iterate over section headers - for(int shidx=0;shidx<elf->e_shnum;shidx++) - { - Elf32_Shdr *shdr=0x800000+elf->e_shoff;//+shidx*elf->e_shentsize; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"-- SECTION HEADER %d --",shidx); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sh-name idx: %d",shdr->sh_name); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sh-type: %d",shdr->sh_type); - while(1); - } - */ - - static char arg1[]="x";; - static char arg2[]="blah"; - static char arg3[]="foo"; - static char *args[]={arg1,arg2,arg3}; - - asm("push %0" :: "r" (args)); //argv - asm("push $3");//argc - - asm("push $0x800080"); + // push addr and return to it + asm("push %0"::"r"(elf->e_entry)); asm("ret"); - while(1); - /* + // this is never reached! - // autorun "user-space" prog - asm("push $10");//argv TODO: addresse - asm("push $20"); //argc TODO: real number of params! - asm("push $0x800000"); - asm("ret"); - */ } |
