From fde24d20cd6a7d5fd1f1df71515e377586b91e24 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 22 Oct 2014 23:52:02 +0200 Subject: improved shell --- userspace/foolshell.c | 82 +++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 64 deletions(-) (limited to 'userspace/foolshell.c') diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 6baeb87..8bf8288 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -84,83 +84,37 @@ int process(char *buf) // puts(command); // copied from trottelshell - if(!strcmp(command,"HELP")) + if(!strcmp(command,"help")) { - puts("foolshell: supported built-in commands: HELP, ECHO, TIME, MEM, PROC, TASKS, ALLOC, LS, SYSCALL."); + puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'ls [inode_nr]', 'malloc [bytes]', 'free [address]', "); } - else if(!strcmp(command,"TIME")) + else if(!strcmp(command,"ls")) { -// uint32_t time=task_system_clock; -// log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d seconds passed since system start.",(time/25)); - puts("foolshell: TIME not supported now."); - } - else if(!strcmp(command,"MEM")) - { - //mmap_show_free(); - puts("foolshell: MEM not supported now."); - } - else if(!strcmp(command,"PROC")) - { - /* - for(int i=0;i %d.",i,cpu_counter[i]); - } - */ - puts("foolshell: PROC not supported now."); - } - else if(!strcmp(command,"TASKS")) - { - //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d %d %d",c1,c2,c2); - puts("foolshell: TASKS not supported now."); - } - else if(!strcmp(command,"ALLOC")) - { - /* - uint32_t *malloc= pmmngr_alloc_block(); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"allocated 4KB block at: %08x.",malloc); - */ - puts("foolshell: ALLOC not supported now."); - } - else if(!strcmp(command,"SYSCALL")) - { - - puts("system call 10"); - unsigned int ebx; // will hold return value; - - // system call - asm("pusha"); - asm("mov $10,%eax"); // select syscall 10 (example_syscall) - asm("mov $666,%edx"); - asm("mov $333,%ecx"); - asm("int $0x80"); // actual syscall ! interrupt - asm("mov %%ebx, %0": "=b" (ebx)); - asm("popa"); - // - - printf("system call returned %i\n",ebx); - - } - else if(!strcmp(command,"LS")) - { - //fs_dirent dirs[25]; - fs_dirent *dirs=malloc(sizeof(fs_dirent)*25); - int ls=readdir("/dupa",dirs,25); + int ls=readdir(atoi(token[1]),dirs,25); + int i; for(i=0;i