summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/debug/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/debug/console.c')
-rw-r--r--arch/x86_64/debug/console.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86_64/debug/console.c b/arch/x86_64/debug/console.c
new file mode 100644
index 0000000..b73e980
--- /dev/null
+++ b/arch/x86_64/debug/console.c
@@ -0,0 +1,39 @@
+#ifdef DEBUG_CONSOLE
+#include "debug/console.h"
+#include "lib/printf.h"
+#include "../hal/serial_com.h"
+
+static char
+s_console_getc(void)
+{
+#ifdef DEBUG_SERIAL
+ char c = serial_com_getc(SERIAL_COM1);
+#endif
+ serial_com_putc(SERIAL_COM1, c);
+ return c;
+}
+
+int
+debug_console_readinput(char *buf, size_t len)
+{
+ serial_com_putc(SERIAL_COM1, '>');
+ char readc;
+ int readw = 0;
+ while((readc = s_console_getc()) != 0xD) {
+ if(readw > len) break;
+ buf[readw++] = readc;
+ }
+ buf[readw] = 0;
+ return readw;
+}
+
+void debug_console_start(void)
+{
+ char input_buffer[128];
+ while(1) {
+ debug_console_readinput(input_buffer, 128);
+ debug_console_parsecmd(input_buffer);
+ }
+}
+
+#endif