From 8e3411139b27a3421e9ac75c13f14f99f6dd3137 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 2 Sep 2018 00:08:42 +0200 Subject: syscalls --- kernel/syscalls.c | 80 +++++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 52 deletions(-) (limited to 'kernel/syscalls.c') diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 56c4ae8..7a0dc50 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -22,6 +22,8 @@ static uint32_t next_fd=0; static fifo fifos[MAX_FIFOS]; static uint32_t next_fifo=0; +extern uint32_t fb_addr; + // screen / terminal term_out screen; terminal_tty tty1; @@ -54,9 +56,6 @@ int syscall_gettimeofday(struct timeval *tv, struct timezone *tz) int syscall_lseek(int file,int ptr,int dir) { - #ifdef LOG_SYSCALLS - klog("lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); - #endif kpanic("unhandled syscall: lseek"); @@ -66,9 +65,6 @@ int syscall_lseek(int file,int ptr,int dir) // TODO: /dev/console or /dev/tty1 - /dev/ttyN int syscall_write(int file, char *buf, int len) { - #ifdef LOG_SYSCALLS - klog("[%d] write(file=%d, buf=0x%08X, len=%d)", task_get_current_pid(),file,buf,len); - #endif for(int i=0;i=MAX_FIFOS || next_fd>=MAX_FD)kpanic("we ran out of fd's or fifo's"); @@ -258,13 +240,20 @@ int syscall_open(char *name, int flags, int mode) } else { - // FIRST TIME WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...) + + // HERE WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...) + + if (fb_addr<0x100000) + { screen.put_char=console_put_char; screen.update_cursor=update_cursor; - - // FIRST TIME WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...) + } + else + { screen.put_char=vesa_console_put_char; screen.update_cursor=vesa_update_cursor; + } + tty1=terminal_init(&screen,NULL); @@ -284,9 +273,6 @@ int syscall_open(char *name, int flags, int mode) // int syscall_close(int file,int none1,int none2) { - #ifdef LOG_SYSCALLS - klog("close (file=%d)", file); - #endif //if(file!=0&&file!=1&&file!=2) // kpanic("unhandled syscall: close"); @@ -297,9 +283,6 @@ int syscall_close(int file,int none1,int none2) // TODO: check if file is termminal! int syscall_isatty(int file,int none1,int none2) { - #ifdef LOG_SYSCALLS - klog("isatty (file=%d)", file); - #endif return 1; } @@ -315,9 +298,6 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) task_set_brk(alloc); - #ifdef LOG_SYSCALLS - klog("sbrk (incr=%d) = 0x%08X", incr,oldalloc); - #endif return oldalloc; } @@ -325,10 +305,6 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) // stat, fstat, lstat int syscall_stat(const char *path, struct stat *st,int none) { - #ifdef LOG_SYSCALLS - klog("stat (path=0x%08X,stat=0x%08X)", path,st); - #endif - st->st_mode = S_IFCHR; return 0; } @@ -336,7 +312,7 @@ int syscall_stat(const char *path, struct stat *st,int none) /// there also is task_fork, task_wait, task_exit.. which is in scheduler.c //////////////////////////////////////// -uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3) +uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid) { switch(nr){ @@ -345,9 +321,9 @@ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3) case SYSCALL_CLOSE : return syscall_close(p1,p2,p3); case SYSCALL_EXECVE : - return syscall_execve(p1,p2,p3); + return syscall_execve(p1,p2,p3,pid); case SYSCALL_FORK : - return task_fork(p1,p2,p3); + return task_fork(pid); case SYSCALL_GETPID : // return syscall_getpid(p1,p2,p3); return -1; -- cgit v1.2.3