summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-20 20:37:43 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-20 20:37:43 +0100
commitb9af856ae4a65e09b401cdbc7858c6cd4b1b0b5f (patch)
treef4e4cc549570f42d9e6701b0db702bc9f81157e1 /kernel/syscalls.c
parente500989866e365027e3071cc82ddffa2fbb38288 (diff)
working on syscalls
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index 1de5d3a..b0a4ba1 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -10,7 +10,7 @@
static int preread;
-static int alloc=0x600000; // TODO: implement properly sbrk!!!
+static int alloc=0xa00000; // TODO: implement properly sbrk!!!
int syscall_write(int file, char *buf, int len)
{
@@ -35,8 +35,8 @@ int syscall_read(int file, char *buf, int len)
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"read(file=%d, buf=0x%08X, len=%d)", file,buf,len);
#endif
- // stdin
- if(file==1)
+ // stdin TODO: other descroptiors!
+ if(file==1||file!=1)
{
char c;
@@ -74,9 +74,12 @@ 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
+
ext2_inode_content(EXT2_RAM_ADDRESS,name,0x800000,0x100000);
// autorun "user-space" prog
+ asm("push $10");//argv TODO: addresse
+ asm("push $20"); //argc TODO: real number of params!
asm("push $0x800000");
asm("ret");
}
@@ -84,10 +87,10 @@ int syscall_execve(char *name, char **argv, char **env)
int syscall_open(char *name, int flags, int len)
{
#ifdef LOG_SYSCALLS
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"open (name=0x%08X, flags=%d, len=%d)", name,flags,len);
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"open (name=0x%08X(\"%s\"), flags=%d, len=%d)",name, name,flags,len);
#endif
- return 1;
+ return 99;
}
@@ -133,14 +136,17 @@ int syscall_lseek(int file,int ptr,int dir)
return preread;
}
-caddr_t syscall_sbrk(int incr, int none1, int none2)
+uint32_t syscall_sbrk(int incr, int none1, int none2)
{
- #ifdef LOG_SYSCALLS
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk (incr=%d)", incr);
- #endif
+ if(incr==0)alloc=0xa00000; // TODO: implement properly sbrk!!!
int oldalloc=alloc;
alloc+=incr;
+
+ #ifdef LOG_SYSCALLS
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk (incr=%d) = 0x%08X", incr,oldalloc);
+ #endif
+
return oldalloc;
/*