#include #include #include "syscalls.c" #include "../fs/fs.h" void hello() { puts( "Welcome to FoolShell v0.1" ); } void prompt() { printf( "$ " ); } int main(int argc, char **argv) { syscalls_init(); hello(); FILE *input; input=fopen(1,"r"); char *buf=malloc(256); while(1) { prompt(); fgets(buf,255,input); buf[strlen(buf)-1]=0; // remove \n process(buf); } return 0; } char **tokenize(char *buf) { char **token; token=malloc(10*sizeof(char*)); int l=strlen(buf); int i; int c=0; for(i=0;i\n",c, token[c]); c++; } return token; } int process(char *buf) { char **token=tokenize(buf); char *command=token[0]; // puts(command); // copied from trottelshell if(!strcmp(command,"HELP")) { puts("foolshell: supported built-in commands: HELP, ECHO, TIME, MEM, PROC, TASKS, ALLOC, LS, SYSCALL."); } else if(!strcmp(command,"TIME")) { // 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[5]; int ls=readdir("/dupa",&dirs,5); int i; for(i=0;i