From 7393db6692c861bc66164c0dd9b83f23a554775b Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 26 Nov 2014 23:17:55 +0100 Subject: changes, improvements and cleanup --- kernel/syscalls.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'kernel/syscalls.c') diff --git a/kernel/syscalls.c b/kernel/syscalls.c index e4d31b5..5939cff 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -114,29 +114,55 @@ int syscall_write(int file, char *buf, int len) int syscall_read(int file, char *buf, int len) { + static bool eof=false; #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"read(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif - if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); - // stdin TODO: other descroptiors! + if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); { + if(eof) + { + eof=false; + return 0; + } char c; + int l=0; while(1) { - asm("cli"); bool ret=ringbuffer_get(&c); - asm("sti"); if(ret) { - *buf=c; - if(c=='X')return 0; - return 1; + if(c==0x08) + { + if(l>0) + { + console_del_char(); + buf--; + l--; + } + } + else{ + + *buf=c; + buf++; + l++; + if(c!=0x04)console_put_char_red(c); + if(c=='\n')return l; + if(c==0x04) + { + l--; + buf--; + eof=true; + return l; + } + } + } } -- cgit v1.2.3