diff --git a/sys/SConscript b/sys/SConscript index b2eca15..f7d9ec6 100644 --- a/sys/SConscript +++ b/sys/SConscript @@ -11,6 +11,7 @@ src_amd64 = [ "amd64/multiboot.S", "amd64/mbentry.c", # AMD64 + "amd64/debug.c", "amd64/trap.c", "amd64/trapentry.S", "amd64/machine.c", diff --git a/sys/amd64/debug.c b/sys/amd64/debug.c index bbba551..b560df3 100644 --- a/sys/amd64/debug.c +++ b/sys/amd64/debug.c @@ -3,7 +3,7 @@ #include #include -//#include +#include #include #include "trap.h" diff --git a/sys/dev/console.c b/sys/dev/console.c index f66b34d..6b82e23 100644 --- a/sys/dev/console.c +++ b/sys/dev/console.c @@ -29,9 +29,31 @@ Console_LateInit() Serial_LateInit(); } -void -Console_Getc(char ch) +char +Console_Getc() { + return Serial_Getc(); +} + +void +Console_Gets(char *str, size_t n) +{ + int i; + + for (i = 0; i < (n - 1); i++) + { + char ch = Console_Getc(); + if (ch == '\r') + { + Console_Putc('\n'); + str[i] = '\0'; + return; + } + Console_Putc(ch); + str[i] = ch; + } + + str[i+1] = '\0'; } void diff --git a/sys/dev/console.h b/sys/dev/console.h index b7511ca..174eba6 100644 --- a/sys/dev/console.h +++ b/sys/dev/console.h @@ -3,6 +3,8 @@ #define __CONSOLE_H__ void Console_Init(); +char Console_Getc(); +void Console_Gets(char *str, size_t n); void Console_Putc(char ch); void Console_Puts(const char *str); diff --git a/sys/include/kdebug.h b/sys/include/kdebug.h new file mode 100644 index 0000000..854e4a4 --- /dev/null +++ b/sys/include/kdebug.h @@ -0,0 +1,13 @@ + +#ifndef __KDEBUG_H__ +#define __KDEBUG_H__ + +// Platform Functions +void Debug_Registers(int argc, const char *argv[]); + +// Generic Functions +void Debug_Dump(int argc, const char *argv[]); +void Debug_Prompt(); + +#endif /* __KDEBUG_H__ */ + diff --git a/sys/kern/debug.c b/sys/kern/debug.c index d1f32c6..9832754 100644 --- a/sys/kern/debug.c +++ b/sys/kern/debug.c @@ -18,6 +18,9 @@ #include #include +#include + +#include "../dev/console.h" void Debug_PrintHex(const char *data, size_t length, off_t off, size_t limit) @@ -75,16 +78,23 @@ Debug_Dump(int argc, const char *argv[]) { } +#define DEBUG_MAX_LINE 128 + void Debug_Prompt() { + char buf[DEBUG_MAX_LINE]; kprintf("Entered Debugger!\n"); - kprintf("> "); - // read input + while (1) { + kprintf("> "); - // parse input + // read input + Console_Gets(&buf, DEBUG_MAX_LINE); - // execute command + // parse input + + // execute command + } }