diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | kernel/syscalls.c | 17 | ||||
| -rw-r--r-- | kernel/task.c | 3 | ||||
| -rw-r--r-- | kernel/usermode.c | 23 | ||||
| -rw-r--r-- | terminal/terminal.c | 34 | ||||
| -rw-r--r-- | userspace/Makefile | 3 | ||||
| -rw-r--r-- | userspace/foolshell.c | 21 | ||||
| -rw-r--r-- | userspace/init.c | 2 | ||||
| -rw-r--r-- | userspace/snake.c | 11 |
9 files changed, 64 insertions, 52 deletions
@@ -165,7 +165,7 @@ run-qemu: all run-qemu-debug: all # qemu -enable-kvm -s -S ~/temp/FoolOs/disk.img # qemu -enable-kvm -s -singlestep disk.img - qemu -enable-kvm -s -S -kernel foolos.img -smp 4 -initrd userspace/ext2.img + qemu-system-i386 -enable-kvm -s -S -kernel foolos.img -smp 4 -initrd userspace/ext2.img stop: killall qemu-system-i386 diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 642f04a..c025b06 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -151,12 +151,23 @@ int copy_args(char **in, char **out) } -int syscall_execve(char *name, char **argv1, char **env1) +int syscall_execve(char *name, char **argv, char **env) { + #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"execve (name=0x%08X(%s), argvs=0x%08X, env=0x%08X)", name,name,argv1,env1); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"execve (name=0x%08X(%s), argvs=0x%08X, env=0x%08X)", name,name,argv,env); #endif + int arg_count=0; + while(argv[arg_count]!=NULL)arg_count++; + + char **argv1=kballoc(1); + char **env1=kballoc(1); + + copy_args(argv,argv1); + copy_args(env,env1); + + uint32_t alloc; uint32_t entry_global=load_elf(name,&alloc); task_set_brk(alloc); @@ -172,7 +183,6 @@ int syscall_execve(char *name, char **argv1, char **env1) /* try to move this to asm */ //asm volatile("jmp ."); asm volatile("mov $0x8fff000,%esp"); // set stack at high end of process image - int arg_count=0; asm volatile ("push %0" :: "r" (argv1)); asm volatile ("push %0" :: "r" (arg_count)); @@ -184,7 +194,6 @@ int syscall_execve(char *name, char **argv1, char **env1) asm volatile ("sti"); asm volatile ("ret"); - // this is never reached! } diff --git a/kernel/task.c b/kernel/task.c index 91a2c83..5373133 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -159,9 +159,6 @@ volatile void task_init(pdirectory *dir) current_task=0; switch_to_user_mode(); - - //syscall_execve("/bin/foolshell",argv_init,env_init); - //syscall_execve("/bin/tput",argv,env); } diff --git a/kernel/usermode.c b/kernel/usermode.c index 745cef1..1c7a726 100644 --- a/kernel/usermode.c +++ b/kernel/usermode.c @@ -56,34 +56,15 @@ void install_tss(int cpu_no){ void switch_to_user_mode() { -// char text[]="[internal] "; - asm_usermode(); -// write(1,text,11); - - while(1); // will not be reached? -// write(1,text,11); } char *argv_init[]={"/bin/init",NULL}; -char *env_init[]={NULL}; +char *env_init[]={"var1=dupa","var2=mundl",NULL}; // THIS WILL BE RUN IN RING 3! void userfunc() { - execve("/bin/init",argv_init,env_init); - - for(int i=0;i<3;i++) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"we are usermode!"); - } - - - char text[]="syscalling!"; - write(1,text,10); - - while(1) - { - } + while(1); // we should never get here. } diff --git a/terminal/terminal.c b/terminal/terminal.c index 4d3a1a0..7fc6f93 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -9,7 +9,7 @@ #include "driver/screen.h" #define SET_LFNL true -#define SET_BUFF true +#define SET_BUFF false #define SET_ECHO true @@ -262,22 +262,30 @@ terminal_tty terminal_init(term_out *screen,term_in *input) void terminal_kb(terminal_tty *tty, uint8_t c) { - terminal_put(tty,c); - tty->command[tty->command_l]=c; - (tty->command_l)++; + if(SET_ECHO)terminal_put(tty,c); - if(c==0x08) + if(SET_BUFF) { - tty->command_l-=2; - if(tty->command_l<0)tty->command_l=0; + tty->command[tty->command_l]=c; + (tty->command_l)++; + + if(c==0x08) + { + tty->command_l-=2; + if(tty->command_l<0)tty->command_l=0; + } + else if(c=='\n') + { + // write command to ringbuff + for(int i=0;i<tty->command_l;i++) + tty->input->put_char(tty->command[i]); + + tty->command_l=0; + } } - else if(c=='\n') + else { - // write command to ringbuff - for(int i=0;i<tty->command_l;i++) - tty->input->put_char(tty->command[i]); - - tty->command_l=0; + tty->input->put_char(c); } } diff --git a/userspace/Makefile b/userspace/Makefile index 48d9b1f..801326b 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -13,7 +13,7 @@ LDFLAGS=-lfool #CFLAGS+=$(SYSROOT)/usr/lib/crt0.o -PROGS=foolshell ls simple brainfuck add checker clear task1 task2 init cat +PROGS=foolshell ls simple brainfuck add checker clear task1 task2 init cat snake include ../Makefile.common @@ -40,6 +40,7 @@ ext2.img: $(PROGS) ../mp/mp.bin rm mnt -rf brainfuck: brainfuck.o +snake: snake.o foolshell: foolshell.o simple: simple.o add: add.o diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 2abb549..0ec7e88 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -4,6 +4,7 @@ #include <string.h> extern char **environ; + // void hello() { @@ -13,7 +14,7 @@ void hello() puts( "\033c" - "\033[37;44m" + "\033[36m" " ______ __ ____ _____ \n" " / ____/___ ____ / / / __ \\/ ___/ \n" @@ -21,10 +22,11 @@ void hello() " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" " /_/ \\____/\\____/_/ \\____//____/ \n" " \n" - "\033[37;43m" + + "\033[37;44m" " \n" - " Welcome to FoolShell v0.7 (Compiled on " __DATE__ " at " __TIME__ "\n" + " Welcome to FoolShell v0.8 (Compiled on " __DATE__ " at " __TIME__")\n" " ------------------------------------------------------------------\n\n" " Please type 'help' anytime, to show shell \"built-ins\". You can execute \n" " user programms that are in your $PATH directory by simply typing \n" @@ -41,15 +43,20 @@ void hello() void prompt() { - printf("%s%s",getenv("PWD"),getenv("PS1")); + printf("\033[36mfool\033[37m@\033[32mhill\033[33m:%s%s\033[37m",getenv("PWD"),getenv("PS1")); } + int main(int argc, char **argv) { - +/* + printf("argv= 0x%08x \n",argv); + printf("environ= 0x%08x \n",environ); +*/ bool silent=false; for(int i=0;i<argc;i++) { +// printf("%i:%s\n",i+1,argv[i]); if(!strcmp(argv[i],"--silent"))silent=true; } @@ -57,8 +64,6 @@ int main(int argc, char **argv) char *buf=malloc(256); - - while(1) { prompt(); @@ -227,7 +232,7 @@ int process(char *buf) int pid=fork(); if(pid!=0) { - printf("new task pid: %i \n",pid); + // printf("new task pid: %i \n",pid); } if(pid==0) { diff --git a/userspace/init.c b/userspace/init.c index 5d3658c..73848f5 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -13,7 +13,7 @@ int main(int argc, char **argv) if(pid==0) { char *argv[]={"/bin/foolshell",0}; - char *env[]={"PS1=$","PWD=/home/miguel","PATH=/bin","TERM=xterm",0}; + char *env[]={"PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=linux",0}; execve("/bin/foolshell",argv,env); // replace process with our foolshell :) puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!"); while(1);// hang diff --git a/userspace/snake.c b/userspace/snake.c new file mode 100644 index 0000000..afc6bf8 --- /dev/null +++ b/userspace/snake.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main() +{ + printf("Hello I am FoolSnake 0.1\n"); + + while(1) + { + printf("%c",getc(stdin)); + } +} |
