summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-10-22 10:39:56 +0200
committerMichal Idziorek <m.i@gmx.at>2014-10-22 10:39:56 +0200
commitbedf6a20ba49d7da460de862a58f8eb04bad1514 (patch)
treeca9721c76c847137de2b518cbb8f7230de697019 /userspace
parent430112c8d7224bf9d1e192adfc9fb55e7a044f83 (diff)
migrating shell to "userspace"
Diffstat (limited to 'userspace')
-rw-r--r--userspace/foolshell.c87
1 files changed, 86 insertions, 1 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c
index bc02102..7a029ef 100644
--- a/userspace/foolshell.c
+++ b/userspace/foolshell.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include "syscalls.c"
void hello() {
@@ -12,6 +13,7 @@ void prompt() {
"$ "
);
}
+
int main(int argc, char **argv)
{
syscalls_init();
@@ -26,9 +28,92 @@ int main(int argc, char **argv)
prompt();
fgets(buf,255,input);
buf[strlen(buf)-1]=0;
- puts(buf);
+// puts(buf);
+ process(buf);
+
}
return 0;
}
+
+int process(char *command)
+{
+ // copied from trottelshell
+
+ if(!strcmp(command,"HELP"))
+ {
+ puts("foolshell: supported built-in commands: HELP, ECHO, TIME, MEM, PROC, TASKS, ALLOC, READ, 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<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,"ECHO"))
+ {
+
+ printf("%s\n",command);
+
+ }
+ else
+ {
+ puts("foolshell: command not found");
+ }
+
+ //
+}
+
+
+
+
+