diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-11-20 23:28:17 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-11-20 23:28:17 +0100 |
| commit | a822afc278e7855dea55bcd0de2e402d5bf43508 (patch) | |
| tree | 3ce639618b5548389096e5e340a36025e0371af7 /kernel | |
| parent | b9af856ae4a65e09b401cdbc7858c6cd4b1b0b5f (diff) | |
fixed loading and runnnng progs (clear bss)
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/config.h | 2 | ||||
| -rw-r--r-- | kernel/syscalls.c | 46 | ||||
| -rw-r--r-- | kernel/syscalls.h | 1 |
3 files changed, 40 insertions, 9 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/syscalls.c b/kernel/syscalls.c index b0a4ba1..d2efbc8 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -9,8 +9,6 @@ #include <sys/stat.h> -static int preread; -static int alloc=0xa00000; // TODO: implement properly sbrk!!! int syscall_write(int file, char *buf, int len) { @@ -74,6 +72,13 @@ int syscall_execve(char *name, char **argv, char **env) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"execve (name=0x%08X, argvs=0x%08X, env=0x%08X)", name,argv,env); #endif + // lets first clean some area for loading our prog! + // we need this to zero-initalize bss + for(uint32_t *addr=0x800000; addr<=0xb00000; addr++) + { + *addr=0; + } + ext2_inode_content(EXT2_RAM_ADDRESS,name,0x800000,0x100000); @@ -84,10 +89,10 @@ int syscall_execve(char *name, char **argv, char **env) asm("ret"); } -int syscall_open(char *name, int flags, int len) +int syscall_open(char *name, int flags, int mode) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"open (name=0x%08X(\"%s\"), flags=%d, len=%d)",name, name,flags,len); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"open (name=0x%08X(\"%s\"), flags=%d, mode=%d)",name, name,flags,mode); #endif return 99; @@ -130,17 +135,35 @@ int syscall_lseek(int file,int ptr,int dir) #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); #endif - +/* if(dir==0)preread=ptr; else{ while(1);} - return preread; +*/ + return 0; + } uint32_t syscall_sbrk(int incr, int none1, int none2) { - if(incr==0)alloc=0xa00000; // TODO: implement properly sbrk!!! + static uint32_t alloc; + + // fool-os-convention to set bss_end: + if(incr==0) + { + alloc=0; + return 0; + } + if(alloc==0) + { + #ifdef LOG_SYSCALLS + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk RESET to 0x%08X", incr); + #endif + + alloc=incr; + return alloc; + } - int oldalloc=alloc; + uint32_t oldalloc=alloc; alloc+=incr; #ifdef LOG_SYSCALLS @@ -171,3 +194,10 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) */ } +int syscall_exit(int ret, int none1, int none2) +{ + #ifdef LOG_SYSCALLS + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d)", ret); + #endif + syscall_execve(15,0,0); // start shell +} diff --git a/kernel/syscalls.h b/kernel/syscalls.h index 63aafc4..5fb62db 100644 --- a/kernel/syscalls.h +++ b/kernel/syscalls.h @@ -1,5 +1,6 @@ #include "fs/fs.h" +#define SYSCALL_EXIT 60 #define SYSCALL_WRITE 61 #define SYSCALL_READ 62 #define SYSCALL_READDIR 63 |
