From d00e64542cb58b25cd67e8c3b682d0e07312f441 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Tue, 8 Jul 2014 23:19:51 +0200 Subject: added basic shell with one command. --- kernel/shell.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 kernel/shell.c (limited to 'kernel/shell.c') diff --git a/kernel/shell.c b/kernel/shell.c new file mode 100644 index 0000000..837a4c3 --- /dev/null +++ b/kernel/shell.c @@ -0,0 +1,82 @@ +#include "kernel.h" + +#define COMMAND_LENGTH 255 + +static char command[COMMAND_LENGTH]; +static int pos=0; + +// in timer: +uint16_t timer16; + +void shell_init() +{ + pos=0; + command[0]=0; + + scr_nextline(); + scr_put_string_nl("***********************"); + scr_put_string_nl("Fools Shell v 0.0.0.1 *"); + scr_put_string_nl("***********************"); + scr_nextline(); + scr_put_string("Command> "); +} + +void shell_put(char x) +{ + if(pos0); + pos--; + command[pos]=0; + +} + + +int strcmp(char *b1, char *b2) +{ + int i=0; + while(b1[i]==b2[i]&&b1[i]!=0&&b2[i]!=0) i++; + + if(b1[i]==0&&b2[i]==0)return 1; + + return 0; +} + +// TODO: EXECUTE LATER not inside INTERRUPT !!! + +void shell_execute() +{ + scr_nextline(); + scr_put_string(" processing command: "); + scr_put_string_nl(command); + + if(1==strcmp(command,"TIME")) + { + scr_put_string_nl(" getting sys time from kernel"); + scr_put_string(" "); + scr_put_hex(timer16); + scr_put_string_nl(" seconds passed since system start."); + } + else + { + scr_put_string_nl(" unsupported command, sorry!"); + } + + pos=0; + + scr_nextline(); + scr_put_string("Command> "); + +} + + + -- cgit v1.2.3