diff options
Diffstat (limited to 'userspace/foolshell.c')
| -rw-r--r-- | userspace/foolshell.c | 82 |
1 files changed, 18 insertions, 64 deletions
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<SMP_MAX_PROC;i++) - { - if(cpu_counter[i]!=0) - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"cpu: %d => %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<ls;i++) { - printf("%i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==FS_FILE_TYPE_DIR)?'/':' ')); + printf("foolshell: %i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==FS_FILE_TYPE_DIR)?'/':' ')); } } - else if(!strcmp(command,"ECHO")) + else if(!strcmp(command,"echo")) { + printf("foolshell: \"%s\"\n",token[1]); - printf("%s\n",token[1]); - + } + else if(!strcmp(command,"malloc")) + { + uint8_t *mall=malloc(atoi(token[1])); + printf("foolshell: allocated %d bytes at 0x%8x (%i).\n",atoi(token[1]),mall,mall); + } + else if(!strcmp(command,"free")) + { + free(atoi(token[1])); + printf("foolshell: called free(%08x).\n",atoi(token[1])); } else { |
