summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-26 23:17:55 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-26 23:17:55 +0100
commit7393db6692c861bc66164c0dd9b83f23a554775b (patch)
treed60c9deb33630d5fb6117c7c1bbc098e62a66f28 /kernel/syscalls.c
parent9c8cfc2e52b0446f7cab14325028075760869b45 (diff)
changes, improvements and cleanup
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c40
1 files changed, 33 insertions, 7 deletions
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;
+ }
+ }
+
}
}