summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c46
1 files changed, 38 insertions, 8 deletions
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
+}